Added method for checking Organization custom attributes
git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portal/custom-portal-handler@117017 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
91fab6df3d
commit
258fe23bb4
|
@ -1,7 +1,20 @@
|
||||||
<ReleaseNotes>
|
<ReleaseNotes>
|
||||||
<Changeset component="org.gcube.portal.custom-portal-handler.1-1-0"
|
<Changeset component="org.gcube.portal.custom-portal-handler.1-7-0"
|
||||||
date="2012-05-04">
|
date="2015-07-06">
|
||||||
<Change>Fixed invalidate session bug</Change>
|
<Change>Added method for checking Organization custom attributes</Change>
|
||||||
|
</Changeset>
|
||||||
|
<Changeset component="org.gcube.portal.custom-portal-handler.1-6-0"
|
||||||
|
date="2014-06-03">
|
||||||
|
<Change>Added getBaseLayout method for Organizations</Change>
|
||||||
|
</Changeset>
|
||||||
|
<Changeset component="org.gcube.portal.custom-portal-handler.1-5-0"
|
||||||
|
date="2014-04-02">
|
||||||
|
<Change>Added getAdministratorUsername method in ScopeHelper</Change>
|
||||||
|
</Changeset>
|
||||||
|
<Changeset component="org.gcube.portal.custom-portal-handler.1-4-0"
|
||||||
|
date="2014-03-4">
|
||||||
|
<Change>Added possibility to create programmatically layouts with
|
||||||
|
framed portlets</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portal.custom-portal-handler.1-3-0"
|
<Changeset component="org.gcube.portal.custom-portal-handler.1-3-0"
|
||||||
date="2013-10-21">
|
date="2013-10-21">
|
||||||
|
@ -9,17 +22,8 @@
|
||||||
<Change>Removed GCF Dependency</Change>
|
<Change>Removed GCF Dependency</Change>
|
||||||
<Change>Logging with sl4j Enabled</Change>
|
<Change>Logging with sl4j Enabled</Change>
|
||||||
</Changeset>
|
</Changeset>
|
||||||
<Changeset component="org.gcube.portal.custom-portal-handler.1-4-0"
|
<Changeset component="org.gcube.portal.custom-portal-handler.1-1-0"
|
||||||
date="2014-03-4">
|
date="2012-05-04">
|
||||||
<Change>Added possibility to create programmatically layouts with
|
<Change>Fixed invalidate session bug</Change>
|
||||||
framed portlets</Change>
|
|
||||||
</Changeset>
|
|
||||||
<Changeset component="org.gcube.portal.custom-portal-handler.1-5-0"
|
|
||||||
date="2014-04-02">
|
|
||||||
<Change>Added getAdministratorUsername method in ScopeHelper</Change>
|
|
||||||
</Changeset>
|
|
||||||
<Changeset component="org.gcube.portal.custom-portal-handler.1-6-0"
|
|
||||||
date="2014-06-03">
|
|
||||||
<Change>Added getBaseLayout method for Organizations</Change>
|
|
||||||
</Changeset>
|
</Changeset>
|
||||||
</ReleaseNotes>
|
</ReleaseNotes>
|
2
pom.xml
2
pom.xml
|
@ -10,7 +10,7 @@
|
||||||
|
|
||||||
<groupId>org.gcube.portal</groupId>
|
<groupId>org.gcube.portal</groupId>
|
||||||
<artifactId>custom-portal-handler</artifactId>
|
<artifactId>custom-portal-handler</artifactId>
|
||||||
<version>1.6.0-SNAPSHOT</version>
|
<version>1.7.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>Custom Portal Handler</name>
|
<name>Custom Portal Handler</name>
|
||||||
<description>
|
<description>
|
||||||
|
|
|
@ -2,11 +2,12 @@ package org.gcube.portal.custom.communitymanager;
|
||||||
|
|
||||||
import org.gcube.portal.custom.communitymanager.components.GCUBESiteLayout;
|
import org.gcube.portal.custom.communitymanager.components.GCUBESiteLayout;
|
||||||
|
|
||||||
|
import com.liferay.portal.model.Organization;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Massimiliano Assante, massimiliano.assante@isti.cnr.it
|
* @author Massimiliano Assante, massimiliano.assante@isti.cnr.it
|
||||||
* @version 1.0 - Jan 4 2012
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface OrganizationManager {
|
public interface OrganizationManager {
|
||||||
|
@ -33,5 +34,13 @@ public interface OrganizationManager {
|
||||||
* @return the organizationid of the created VO
|
* @return the organizationid of the created VO
|
||||||
*/
|
*/
|
||||||
long createVRE(String voName, String voDesc, long parentid, GCUBESiteLayout siteLayout, String themeid);
|
long createVRE(String voName, String voDesc, long parentid, GCUBESiteLayout siteLayout, String themeid);
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param username the screenname of the current user
|
||||||
|
* @param currOrg the organization in which to check the custom attribute
|
||||||
|
* @param attrToCheck the key to check
|
||||||
|
* @return true or false
|
||||||
|
*/
|
||||||
|
Boolean readOrganizationCustomAttribute(String username, Organization currOrg, String attrToCheck);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import org.gcube.portal.custom.communitymanager.components.GCUBELayoutTab;
|
||||||
import org.gcube.portal.custom.communitymanager.components.GCUBEPortlet;
|
import org.gcube.portal.custom.communitymanager.components.GCUBEPortlet;
|
||||||
import org.gcube.portal.custom.communitymanager.components.GCUBESiteLayout;
|
import org.gcube.portal.custom.communitymanager.components.GCUBESiteLayout;
|
||||||
import org.gcube.portal.custom.communitymanager.types.GCUBELayoutType;
|
import org.gcube.portal.custom.communitymanager.types.GCUBELayoutType;
|
||||||
|
import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
||||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||||
import org.gcube.vomanagement.usermanagement.RoleManager;
|
import org.gcube.vomanagement.usermanagement.RoleManager;
|
||||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||||
|
@ -23,21 +24,26 @@ import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayRoleManager;
|
||||||
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager;
|
import org.gcube.vomanagement.usermanagement.impl.liferay.LiferayUserManager;
|
||||||
import org.gcube.vomanagement.usermanagement.model.GroupModel;
|
import org.gcube.vomanagement.usermanagement.model.GroupModel;
|
||||||
|
|
||||||
|
import com.liferay.portal.kernel.bean.BeanLocatorException;
|
||||||
import com.liferay.portal.kernel.exception.PortalException;
|
import com.liferay.portal.kernel.exception.PortalException;
|
||||||
import com.liferay.portal.kernel.exception.SystemException;
|
import com.liferay.portal.kernel.exception.SystemException;
|
||||||
import com.liferay.portal.kernel.log.Log;
|
import com.liferay.portal.kernel.log.Log;
|
||||||
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
import com.liferay.portal.kernel.log.LogFactoryUtil;
|
||||||
import com.liferay.portal.model.Group;
|
import com.liferay.portal.model.Group;
|
||||||
|
import com.liferay.portal.model.Organization;
|
||||||
import com.liferay.portal.model.Role;
|
import com.liferay.portal.model.Role;
|
||||||
import com.liferay.portal.model.Theme;
|
import com.liferay.portal.model.Theme;
|
||||||
import com.liferay.portal.model.User;
|
import com.liferay.portal.model.User;
|
||||||
|
import com.liferay.portal.security.permission.PermissionChecker;
|
||||||
|
import com.liferay.portal.security.permission.PermissionCheckerFactoryUtil;
|
||||||
|
import com.liferay.portal.security.permission.PermissionThreadLocal;
|
||||||
import com.liferay.portal.service.LayoutSetLocalServiceUtil;
|
import com.liferay.portal.service.LayoutSetLocalServiceUtil;
|
||||||
import com.liferay.portal.service.OrganizationLocalServiceUtil;
|
import com.liferay.portal.service.OrganizationLocalServiceUtil;
|
||||||
import com.liferay.portal.service.ThemeLocalServiceUtil;
|
import com.liferay.portal.service.ThemeLocalServiceUtil;
|
||||||
|
import com.liferay.portal.service.UserLocalServiceUtil;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Massimiliano Assante, massimiliano.assante@isti.cnr.it
|
* @author Massimiliano Assante, massimiliano.assante@isti.cnr.it
|
||||||
* @version 1.0 - Jan 4 2012
|
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class OrganizationManagerImpl extends OrganizationsUtil implements OrganizationManager {
|
public class OrganizationManagerImpl extends OrganizationsUtil implements OrganizationManager {
|
||||||
|
@ -266,4 +272,41 @@ public class OrganizationManagerImpl extends OrganizationsUtil implements Organi
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
public Boolean readOrganizationCustomAttribute(String username, Organization currOrg, String attrToCheck) {
|
||||||
|
Boolean isEnabled = false;
|
||||||
|
if (username.compareTo("test.user") == 0) {
|
||||||
|
_log.warn("Found test.user maybe you are in dev mode, returning ... ");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
long companyId = OrganizationsUtil.getCompany().getCompanyId();
|
||||||
|
_log.trace("Setting Thread Permission");
|
||||||
|
User user = UserLocalServiceUtil.getUserByScreenName(companyId, ScopeHelper.getAdministratorUsername());
|
||||||
|
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(user, false);
|
||||||
|
PermissionThreadLocal.setPermissionChecker(permissionChecker);
|
||||||
|
_log.trace("Setting Permission ok!");
|
||||||
|
|
||||||
|
String currVal = (String) currOrg.getExpandoBridge().getAttribute(attrToCheck);
|
||||||
|
isEnabled = (currVal.compareTo("true") == 0);
|
||||||
|
|
||||||
|
_log.trace("Setting Thread Permission back to regular");
|
||||||
|
User currentUser = OrganizationsUtil.validateUser(username);
|
||||||
|
permissionChecker = PermissionCheckerFactoryUtil.create(currentUser, false);
|
||||||
|
PermissionThreadLocal.setPermissionChecker(permissionChecker);
|
||||||
|
_log.trace("Setting Permission ok! returning ...");
|
||||||
|
System.out.println(" returning *********** isEnabled=" + isEnabled);
|
||||||
|
return isEnabled;
|
||||||
|
} catch (BeanLocatorException ex) {
|
||||||
|
ex.printStackTrace();
|
||||||
|
_log.warn("Could not read the property " + attrToCheck + " from LR DB, maybe you are in dev mode, returning true");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue