From 2b5bd8e3bc548e0222033b0a8969f9a7761ec3c8 Mon Sep 17 00:00:00 2001 From: Massimiliano Assante Date: Sun, 22 Jan 2017 11:11:03 +0000 Subject: [PATCH] Bug fix for Bug #6237, Users added to VRE when loggedin could not enter the VRE unless they logout first git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/admin/register-vre-users@141694 82a268e6-3cf1-43bd-a215-b396298e98cf --- distro/changelog.xml | 4 ++++ pom.xml | 2 +- .../server/ManageUsersServiceImpl.java | 16 ++++++++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/distro/changelog.xml b/distro/changelog.xml index aca7706..3505a3c 100644 --- a/distro/changelog.xml +++ b/distro/changelog.xml @@ -1,4 +1,8 @@ + + Bug fix for Bug #6237, Users added to VRE when loggedin could not enter the VRE unless they logout first + Removed ASL Session diff --git a/pom.xml b/pom.xml index dc557b0..c1c8932 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ org.gcube.portlets.admin register-vre-users war - 2.2.0-SNAPSHOT + 2.2.1-SNAPSHOT Register VRE Users Register VRE Users Portlet allow to select a user from the portal and add her to the VRE. diff --git a/src/main/java/org/gcube/portlets/admin/manageusers/server/ManageUsersServiceImpl.java b/src/main/java/org/gcube/portlets/admin/manageusers/server/ManageUsersServiceImpl.java index 6ba9d1f..596ce73 100644 --- a/src/main/java/org/gcube/portlets/admin/manageusers/server/ManageUsersServiceImpl.java +++ b/src/main/java/org/gcube/portlets/admin/manageusers/server/ManageUsersServiceImpl.java @@ -1,6 +1,7 @@ package org.gcube.portlets.admin.manageusers.server; import java.util.ArrayList; +import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletRequest; @@ -139,7 +140,7 @@ public class ManageUsersServiceImpl extends RemoteServiceServlet implements Mana long currSiteGroupId = getSiteFromServletRequest(getThreadLocalRequest()).getGroupId(); UserManager userM = new LiferayUserManager(); List nonBelongingUsers = userM.listUsersByGroup(currSiteGroupId, false); //the users of i-marine or services etc - nonBelongingUsers.removeAll(userM.listUsersByGroup(pContext.getCurrentGroupId(getThreadLocalRequest()))); + nonBelongingUsers.removeAll(userM.listUsersByGroup(pContext.getCurrentGroupId(getThreadLocalRequest()), false)); for (GCubeUser u : nonBelongingUsers) { String id = u.getUsername(); @@ -179,6 +180,7 @@ public class ManageUsersServiceImpl extends RemoteServiceServlet implements Mana } /** * register the user to the VRE and in the HL Group, plus send notifications to the users + * it is needed to issue a fake membership request otherwise if the user is loggedIn it is not able to access the VRE unless she logout and login */ @Override public boolean registerUsers(List users2Register) { @@ -186,8 +188,18 @@ public class ManageUsersServiceImpl extends RemoteServiceServlet implements Mana UserManager userM = new LiferayUserManager(); for (PortalUserDTO user : users2Register) { try { + GCubeUser currUser = userM.getUserByUsername(user.getId()); + _log.debug("registerUser " + currUser.getUsername() + " to groupId: "+ vreGroupId); + userM.requestMembership(currUser.getUserId(), vreGroupId, "Automatic Request at " + new Date()); + _log.debug("fakeRequest sent"); + String replierUsername = LiferayUserManager.getAdmin().getScreenName(); + _log.trace("Sleep 1 second ..."); + Thread.sleep(1000); + userM.acceptMembershipRequest(currUser.getUserId(), vreGroupId, true, replierUsername, "Automatic acceptance request at " + new Date()); + _log.info("fakeRequest accepted"); + //add the user to the VRE - userM.assignUserToGroup(vreGroupId, userM.getUserId(user.getId())); + userM.assignUserToGroup(vreGroupId, currUser.getUserId()); //send notification sendNotificationToUser(vreGroupId, user); }