added method to retrieve user contacts depending on the current group

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/vo-management/usermanagement-core@141429 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Massimiliano Assante 2016-12-29 16:05:36 +00:00
parent d28f3ccea6
commit b072b22511
4 changed files with 62 additions and 1 deletions

View File

@ -163,6 +163,15 @@ public interface GroupManager {
* @throws GroupRetrievalFault
*/
Set<GCubeGroup> listGroupsByUserAndSite(long userId, final String serverName) throws UserRetrievalFault, UserManagementSystemException, GroupRetrievalFault, VirtualGroupNotExistingException;
/**
* @param userId the LR userId
* @param siteGroupId the LR groupId from which is sending the request
* @return a set of VREs where the user is registered as @see {@link GCubeGroup} on the current Site (e.g i-marine.d4science.org)
* @throws UserRetrievalFault
* @throws UserManagementSystemException
* @throws GroupRetrievalFault
*/
Set<GCubeGroup> listGroupsByUserAndSiteGroupId(long userId, long siteGroupId) throws UserRetrievalFault, UserManagementSystemException, GroupRetrievalFault, VirtualGroupNotExistingException;
/**
*
* @param userId the LR userId

View File

@ -3,6 +3,7 @@ package org.gcube.vomanagement.usermanagement;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.gcube.vomanagement.usermanagement.exception.GroupRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.RoleRetrievalFault;
@ -226,6 +227,16 @@ public interface UserManager {
* @throws UserRetrievalFault
*/
List<GCubeUser> listUsersByGroupName(String name) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
/**
* @param scopeGroupId the liferay groupid number of the current Site
* @param userId the LR userid for which you need to fetch the contacts
* @return a set containing all portal active users that the user can contact/see (depending on the scopeGroupId he/she can see the users a VRE, or the users of all the VREs he/she is subscribed)
*
* @throws UserManagementSystemException .
* @throws GroupRetrievalFault .
* @throws UserRetrievalFault .
*/
Set<GCubeUser> getUserContactsByGroup(long userId, long scopeGroupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault;
/**
*
* @param groupId the LR groupId

View File

@ -419,9 +419,21 @@ public class LiferayGroupManager implements GroupManager {
*/
@Override
public Set<GCubeGroup> listGroupsByUserAndSite(long userId, final String serverName) throws UserRetrievalFault, UserManagementSystemException, GroupRetrievalFault, VirtualGroupNotExistingException {
try {
return listGroupsByUserAndSiteGroupId(userId, ManagementUtils.getSiteGroupIdFromServletRequest(serverName));
} catch (SystemException | PortalException e) {
e.printStackTrace();
}
return null;
}
/**
* {@inheritDoc}
*/
@Override
public Set<GCubeGroup> listGroupsByUserAndSiteGroupId(long userId, long siteGroupId) throws UserRetrievalFault, UserManagementSystemException, GroupRetrievalFault, VirtualGroupNotExistingException {
Set<GCubeGroup> toReturn = new HashSet<>();
try {
List<VirtualGroup> currSiteVirtualGroups = getVirtualGroups(ManagementUtils.getSiteGroupIdFromServletRequest(serverName));
List<VirtualGroup> currSiteVirtualGroups = getVirtualGroups(siteGroupId);
for (GCubeGroup userGroup : listGroupsByUser(userId)) {
if (isVRE(userGroup.getGroupId())) {

View File

@ -3,10 +3,12 @@ package org.gcube.vomanagement.usermanagement.impl;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import org.gcube.vomanagement.usermanagement.GroupManager;
import org.gcube.vomanagement.usermanagement.UserManager;
@ -16,8 +18,10 @@ import org.gcube.vomanagement.usermanagement.exception.TeamRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.UserManagementPortalException;
import org.gcube.vomanagement.usermanagement.exception.UserManagementSystemException;
import org.gcube.vomanagement.usermanagement.exception.UserRetrievalFault;
import org.gcube.vomanagement.usermanagement.exception.VirtualGroupNotExistingException;
import org.gcube.vomanagement.usermanagement.model.CustomAttributeKeys;
import org.gcube.vomanagement.usermanagement.model.Email;
import org.gcube.vomanagement.usermanagement.model.GCubeGroup;
import org.gcube.vomanagement.usermanagement.model.GCubeMembershipRequest;
import org.gcube.vomanagement.usermanagement.model.GCubeRole;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
@ -707,10 +711,35 @@ public class LiferayUserManager implements UserManager {
}
return toReturn;
}
/**
* {@inheritDoc}
*/
@Override
public Set<GCubeUser> getUserContactsByGroup(long userId, long scopeGroupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault {
Set<GCubeUser> users = new HashSet<>();
GroupManager gm = new LiferayGroupManager();
try {
if (gm.isRootVO(scopeGroupId)) {
Set<GCubeGroup> userGroups = gm.listGroupsByUserAndSiteGroupId(userId, scopeGroupId);
for (GCubeGroup userGroup : userGroups) {
if (gm.isVRE(userGroup.getGroupId())) {
users.addAll(listUsersByGroup(userGroup.getGroupId()));
_log.debug("getUserContactsByGroup added users of group " + userGroup.getGroupId() + " for userid="+userId);
}
}
} else { //is a VRE
users.addAll(listUsersByGroup(scopeGroupId));
}
} catch (UserManagementSystemException | GroupRetrievalFault | UserRetrievalFault | VirtualGroupNotExistingException e) {
e.printStackTrace();
}
return users;
}
/*
* END LISTING ENTITIES
*/
/*
* MEMBERSHIP REQUESTS