added getVirtual group method

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vo-management/usermanagement-core@125710 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-03-18 10:51:18 +00:00
parent e928e212b6
commit 59a3786158
2 changed files with 30 additions and 0 deletions

View File

@ -84,6 +84,13 @@ public interface GroupManager {
* @throws GroupRetrievalFault
*/
GCubeGroup getGroup(long groupId) throws UserManagementSystemException, GroupRetrievalFault;
/**
* Virtual Groups are handled as Custom attributes in Liferay Sites table
* @param groupId the LR groupId
* @return the virtual group name associated to this group
* @throws GroupRetrievalFault
*/
String getVirtualGroupName(long groupId) throws GroupRetrievalFault;
/**
*
* @param scope the infrastructure scope e.g. /gcube/devsec

View File

@ -6,6 +6,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.gcube.common.portal.CustomAttributeKeys;
import org.gcube.common.portal.PortalContext;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
@ -109,6 +110,28 @@ public class LiferayGroupManager implements GroupManager {
return group;
}
public String getVirtualGroupName(long groupId) throws GroupRetrievalFault {
try {
_log.debug("Setting Thread Permission");
long userId = LiferayUserManager.getAdmin().getUserId();
PrincipalThreadLocal.setName(userId);
PermissionChecker permissionChecker = PermissionCheckerFactoryUtil.create(UserLocalServiceUtil.getUser(userId));
PermissionThreadLocal.setPermissionChecker(permissionChecker);
Group site = GroupLocalServiceUtil.getGroup(groupId);
if (site.getExpandoBridge().getAttribute(CustomAttributeKeys.VIRTUAL_GROUP.getKeyName()) == null || site.getExpandoBridge().getAttribute(CustomAttributeKeys.VIRTUAL_GROUP.getKeyName()).equals("")) {
_log.warn(String.format("Attribute %s not initialized.", CustomAttributeKeys.VIRTUAL_GROUP.getKeyName()));
return null;
} else {
String[] values = (String[]) site.getExpandoBridge().getAttribute(CustomAttributeKeys.VIRTUAL_GROUP.getKeyName());
if (values != null)
return values[0];
else return "";
}
} catch (Exception e) {
e.printStackTrace();
return "Exception ";
}
}
@Override
public GCubeGroup createRootVO(String rootVOName, String description) throws UserManagementNameException, UserManagementSystemException, UserRetrievalFault, GroupRetrievalFault, UserManagementPortalException {
Group group = null;