diff --git a/src/main/java/org/gcube/vomanagement/usermanagement/GroupManager.java b/src/main/java/org/gcube/vomanagement/usermanagement/GroupManager.java index 1ad1f09..9f68622 100644 --- a/src/main/java/org/gcube/vomanagement/usermanagement/GroupManager.java +++ b/src/main/java/org/gcube/vomanagement/usermanagement/GroupManager.java @@ -1,5 +1,6 @@ package org.gcube.vomanagement.usermanagement; +import java.io.Serializable; import java.util.List; import java.util.Map; @@ -159,5 +160,19 @@ public interface GroupManager { * @throws GroupRetrievalFault */ Boolean isVRE(long groupId) throws UserManagementSystemException, GroupRetrievalFault; - + /** + * + * @param groupId the LR groupId + * @param attributeKey the name of the attribute you want to read its value + * @return the attributeKey value if existing, null otherwise + */ + Serializable readCustomAttr(long groupId, String attributeKey) throws GroupRetrievalFault; + /** + * + * @param groupId + * @param attributeKey the name of the attribute you want to save + * @param value the value + * @throws GroupRetrievalFault + */ + void saveCustomAttr(long groupId, String attributeKey, Serializable value) throws GroupRetrievalFault; } diff --git a/src/main/java/org/gcube/vomanagement/usermanagement/impl/LiferayGroupManager.java b/src/main/java/org/gcube/vomanagement/usermanagement/impl/LiferayGroupManager.java index bd8cdbb..e4213d8 100644 --- a/src/main/java/org/gcube/vomanagement/usermanagement/impl/LiferayGroupManager.java +++ b/src/main/java/org/gcube/vomanagement/usermanagement/impl/LiferayGroupManager.java @@ -1,5 +1,6 @@ package org.gcube.vomanagement.usermanagement.impl; +import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -102,7 +103,7 @@ public class LiferayGroupManager implements GroupManager { } return group; } - + @Override public GCubeGroup createRootVO(String rootVOName, String description) throws UserManagementNameException, UserManagementSystemException, UserRetrievalFault, GroupRetrievalFault, UserManagementPortalException { Group group = null; @@ -120,8 +121,8 @@ public class LiferayGroupManager implements GroupManager { } @Override public GCubeGroup createVO(String virtualOrgName, long rootVOGroupId, String description) throws UserManagementNameException, - UserManagementSystemException, UserRetrievalFault, - GroupRetrievalFault, UserManagementPortalException { + UserManagementSystemException, UserRetrievalFault, + GroupRetrievalFault, UserManagementPortalException { Group group = null; try { group = createGroup(virtualOrgName, description, rootVOGroupId); @@ -136,8 +137,8 @@ public class LiferayGroupManager implements GroupManager { } @Override public GCubeGroup createVRE(String virtualResearchEnvName, long virtualOrgGroupId, String description) throws UserManagementNameException, - UserManagementSystemException, UserRetrievalFault, - GroupRetrievalFault, UserManagementPortalException { + UserManagementSystemException, UserRetrievalFault, + GroupRetrievalFault, UserManagementPortalException { Group group = null; try { group = createGroup(virtualResearchEnvName, description, virtualOrgGroupId); @@ -361,6 +362,37 @@ public class LiferayGroupManager implements GroupManager { public String getScope(long groupId) throws UserManagementSystemException, GroupRetrievalFault { return getInfrastructureScope(groupId); } + /** + * {@inheritDoc} + */ + @Override + public Serializable readCustomAttr(long groupId, String attributeKey) throws GroupRetrievalFault { + try { + Group g = GroupLocalServiceUtil.getGroup(groupId); + if (g.getExpandoBridge().hasAttribute(attributeKey)) { + g.getExpandoBridge().getAttribute(attributeKey); + } else + return null; + } catch (PortalException e1) { + throw new GroupRetrievalFault("Group not existing (I think you better check)", e1); + } catch (Exception e) { + e.printStackTrace(); + } + return null; + }/** + * {@inheritDoc} + */ + @Override + public void saveCustomAttr(long groupId, String attributeKey, Serializable value) throws GroupRetrievalFault { + try { + Group g = GroupLocalServiceUtil.getGroup(groupId); + g.getExpandoBridge().setAttribute(attributeKey, value); + } catch (PortalException e1) { + throw new GroupRetrievalFault("Group not existing (I think you better check)", e1); + } catch (Exception e) { + e.printStackTrace(); + } + } }