fixed possibility to add double join request
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/join-vre@130581 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c048f3276c
commit
70c456ab50
|
@ -168,13 +168,6 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
ASLSession session = getASLSession();
|
ASLSession session = getASLSession();
|
||||||
GroupManager gm = new LiferayGroupManager();
|
GroupManager gm = new LiferayGroupManager();
|
||||||
LinkedHashMap<VRECategory, ArrayList<VRE>> toReturn = new LinkedHashMap<VRECategory, ArrayList<VRE>>();
|
LinkedHashMap<VRECategory, ArrayList<VRE>> toReturn = new LinkedHashMap<VRECategory, ArrayList<VRE>>();
|
||||||
//before iterating the actual groups create the virtualGroups in the correct order
|
|
||||||
// List<VirtualGroup> virtualGroups = gm.getVirtualGroups();
|
|
||||||
// for (VirtualGroup vg : virtualGroups) {
|
|
||||||
// ArrayList<VRE> toCreate = new ArrayList<VRE>();
|
|
||||||
// VRECategory cat = new VRECategory(1L, vg.getName(), vg.getDescription());
|
|
||||||
// toReturn.put(cat, toCreate);
|
|
||||||
// }
|
|
||||||
|
|
||||||
long currentSiteGroupId = getSiteFromServletRequest(getThreadLocalRequest()).getGroupId();
|
long currentSiteGroupId = getSiteFromServletRequest(getThreadLocalRequest()).getGroupId();
|
||||||
List<VirtualGroup> currentSiteVGroups = getVirtualGroups(currentSiteGroupId);
|
List<VirtualGroup> currentSiteVGroups = getVirtualGroups(currentSiteGroupId);
|
||||||
|
@ -192,6 +185,13 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
_log.error("Cannot find root organziation, please check gcube-data.properties file in $CATALINA_HOME/conf folder, unless your installing the Bundle");
|
_log.error("Cannot find root organziation, please check gcube-data.properties file in $CATALINA_HOME/conf folder, unless your installing the Bundle");
|
||||||
return toReturn;
|
return toReturn;
|
||||||
}
|
}
|
||||||
|
CacheRegistryUtil.clear();
|
||||||
|
|
||||||
|
List<GCubeGroup> currUserGroups = new ArrayList<GCubeGroup>();
|
||||||
|
if (session.getUsername().compareTo(TEST_USER) != 0) {
|
||||||
|
GCubeUser currUser = new LiferayUserManager().getUserByUsername(session.getUsername());
|
||||||
|
currUserGroups = gm.listGroupsByUser(currUser.getUserId());
|
||||||
|
}
|
||||||
|
|
||||||
//for each root sub organizations (VO)
|
//for each root sub organizations (VO)
|
||||||
for (GCubeGroup vOrg : rootGroupVO.getChildren()) {
|
for (GCubeGroup vOrg : rootGroupVO.getChildren()) {
|
||||||
|
@ -226,8 +226,7 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
if (session.getUsername().compareTo(TEST_USER) != 0) {
|
if (session.getUsername().compareTo(TEST_USER) != 0) {
|
||||||
GCubeUser currUser = new LiferayUserManager().getUserByUsername(session.getUsername());
|
GCubeUser currUser = new LiferayUserManager().getUserByUsername(session.getUsername());
|
||||||
//check if the user belongs to it
|
//check if the user belongs to it
|
||||||
CacheRegistryUtil.clear();
|
if (currUserGroups.contains(vreOrganization)) {
|
||||||
if (gm.listGroupsByUser(currUser.getUserId()).contains(vreOrganization)) {
|
|
||||||
toAdd.setUserBelonging(UserBelonging.BELONGING);
|
toAdd.setUserBelonging(UserBelonging.BELONGING);
|
||||||
}
|
}
|
||||||
else if (checkPending(currUser.getUsername(), vreOrganization.getGroupId()))
|
else if (checkPending(currUser.getUsername(), vreOrganization.getGroupId()))
|
||||||
|
@ -353,7 +352,6 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
* @throws UserManagementSystemException
|
* @throws UserManagementSystemException
|
||||||
*/
|
*/
|
||||||
private static boolean checkPending(String screenName, long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault {
|
private static boolean checkPending(String screenName, long groupId) throws UserManagementSystemException, GroupRetrievalFault, UserRetrievalFault {
|
||||||
CacheRegistryUtil.clear();
|
|
||||||
UserManager um = new LiferayUserManager();
|
UserManager um = new LiferayUserManager();
|
||||||
List<GCubeMembershipRequest> requests = um.listMembershipRequestsByGroup(groupId);
|
List<GCubeMembershipRequest> requests = um.listMembershipRequestsByGroup(groupId);
|
||||||
for (GCubeMembershipRequest r : requests) {
|
for (GCubeMembershipRequest r : requests) {
|
||||||
|
@ -369,6 +367,23 @@ public class JoinServiceImpl extends RemoteServiceServlet implements JoinService
|
||||||
if (optionalMessage == null || optionalMessage.compareTo("") == 0)
|
if (optionalMessage == null || optionalMessage.compareTo("") == 0)
|
||||||
optionalMessage = "none";
|
optionalMessage = "none";
|
||||||
try {
|
try {
|
||||||
|
CacheRegistryUtil.clear();
|
||||||
|
GroupManager gm = new LiferayGroupManager();
|
||||||
|
long groupId = gm.getGroupIdFromInfrastructureScope(scope);
|
||||||
|
_log.debug("Look if a request exists already");
|
||||||
|
List<GCubeGroup> userGroups = gm.listGroupsByUser(new LiferayUserManager().getUserId(username));
|
||||||
|
for (GCubeGroup g : userGroups) {
|
||||||
|
if (g.getGroupId() == groupId) {
|
||||||
|
_log.warn("User already belongs to " + scope + " SKIP addMembershipRequest");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
CacheRegistryUtil.clear();
|
||||||
|
if (checkPending(username, groupId)) {
|
||||||
|
_log.warn("User already asked for " + scope + " REQUEST IS IN PENDING - SKIP addMembershipRequest");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_log.debug("Request does not exist, addMembershipRequest for user " + username);
|
||||||
LoginServiceUtil.addMembershipRequest(username, scope, optionalMessage, getThreadLocalRequest());
|
LoginServiceUtil.addMembershipRequest(username, scope, optionalMessage, getThreadLocalRequest());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
Loading…
Reference in New Issue