minor fixes
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@163124 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
611d3ab580
commit
f9710ffbb5
|
@ -167,9 +167,12 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
||||||
|
|
||||||
// retrieve the list of VREs to whom the user belongs (actually one vre at most is sent)
|
// retrieve the list of VREs to whom the user belongs (actually one vre at most is sent)
|
||||||
Map<String, String> roleForVre = UserUtil.getVreRoleForUser(
|
Map<String, String> roleForVre = UserUtil.getVreRoleForUser(
|
||||||
SessionUtil.getCurrentUser(getThreadLocalRequest()).getEmail(),
|
SessionUtil.getCurrentUser(
|
||||||
scopePerCurrentUrl,
|
getThreadLocalRequest()).getEmail(),
|
||||||
getCatalogue(scopePerCurrentUrl), isViewPerVREEnabled() != null);
|
scopePerCurrentUrl,
|
||||||
|
getCatalogue(scopePerCurrentUrl),
|
||||||
|
isViewPerVREEnabled() != null,
|
||||||
|
getThreadLocalRequest().getSession());
|
||||||
ckan.addListOfVREs(roleForVre);
|
ckan.addListOfVREs(roleForVre);
|
||||||
|
|
||||||
return ckan;
|
return ckan;
|
||||||
|
|
|
@ -7,6 +7,8 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||||
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
||||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.server.thread.AddUserToOrganizationThread;
|
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.server.thread.AddUserToOrganizationThread;
|
||||||
|
@ -42,14 +44,18 @@ public class UserUtil {
|
||||||
//private static Logger logger = LoggerFactory.getLogger(UserUtil.class);
|
//private static Logger logger = LoggerFactory.getLogger(UserUtil.class);
|
||||||
private static final Log logger = LogFactoryUtil.getLog(UserUtil.class);
|
private static final Log logger = LogFactoryUtil.getLog(UserUtil.class);
|
||||||
|
|
||||||
|
private static final String ADD_USER_TO_OTHER_ORG_KEY = "ADD_USER_TO_OTHER_ORG_KEY";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the list vre for user and the role the user has in them.
|
* Gets the list vre for user and the role the user has in them.
|
||||||
* retrieve the groups to whom a given user belongs (given the user EMail)
|
* retrieve the groups to whom a given user belongs (given the user EMail)
|
||||||
* @param userEMail the user e mail
|
* @param userEMail the user e mail
|
||||||
|
* @param httpSession
|
||||||
* @param pathVre
|
* @param pathVre
|
||||||
* @return the list vre for user
|
* @return the list vre for user
|
||||||
*/
|
*/
|
||||||
public static Map<String, String> getVreRoleForUser(String userEMail, String context, DataCatalogue instance, boolean isViewPerVREEnabled){
|
public static Map<String, String> getVreRoleForUser(String userEMail, String context, DataCatalogue instance, boolean isViewPerVREEnabled,
|
||||||
|
HttpSession httpSession){
|
||||||
|
|
||||||
GroupManager groupManager = new LiferayGroupManager();
|
GroupManager groupManager = new LiferayGroupManager();
|
||||||
UserManager userManager = new LiferayUserManager();
|
UserManager userManager = new LiferayUserManager();
|
||||||
|
@ -70,17 +76,22 @@ public class UserUtil {
|
||||||
|
|
||||||
// perform further checks
|
// perform further checks
|
||||||
if(!isViewPerVREEnabled){
|
if(!isViewPerVREEnabled){
|
||||||
List<GCubeGroup> listOfGroups = groupManager.listGroupsByUser(user.getUserId());
|
String keyPerScope = context + ADD_USER_TO_OTHER_ORG_KEY;
|
||||||
new AddUserToOrganizationThread(
|
Boolean alreadyAdded = (Boolean)httpSession.getAttribute(keyPerScope);
|
||||||
instance,
|
|
||||||
user,
|
if(alreadyAdded == null || !alreadyAdded){
|
||||||
listOfGroups,
|
new AddUserToOrganizationThread(
|
||||||
isViewPerVREEnabled,
|
instance,
|
||||||
groupIdContext,
|
user,
|
||||||
roleManager,
|
groupManager.listGroupsByUser(user.getUserId()),
|
||||||
groupManager,
|
isViewPerVREEnabled,
|
||||||
localRoleInThisVre).
|
groupIdContext,
|
||||||
start();
|
roleManager,
|
||||||
|
groupManager,
|
||||||
|
localRoleInThisVre).
|
||||||
|
start();
|
||||||
|
httpSession.setAttribute(keyPerScope, true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
logger.debug("Returning Map to the ckan connector : " + mapRoleByGroupSingleVre);
|
logger.debug("Returning Map to the ckan connector : " + mapRoleByGroupSingleVre);
|
||||||
return mapRoleByGroupSingleVre;
|
return mapRoleByGroupSingleVre;
|
||||||
|
|
Loading…
Reference in New Issue