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)
|
||||
Map<String, String> roleForVre = UserUtil.getVreRoleForUser(
|
||||
SessionUtil.getCurrentUser(getThreadLocalRequest()).getEmail(),
|
||||
scopePerCurrentUrl,
|
||||
getCatalogue(scopePerCurrentUrl), isViewPerVREEnabled() != null);
|
||||
SessionUtil.getCurrentUser(
|
||||
getThreadLocalRequest()).getEmail(),
|
||||
scopePerCurrentUrl,
|
||||
getCatalogue(scopePerCurrentUrl),
|
||||
isViewPerVREEnabled() != null,
|
||||
getThreadLocalRequest().getSession());
|
||||
ckan.addListOfVREs(roleForVre);
|
||||
|
||||
return ckan;
|
||||
|
|
|
@ -7,6 +7,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.gcube.datacatalogue.ckanutillibrary.server.DataCatalogue;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.shared.RolesCkanGroupOrOrg;
|
||||
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 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.
|
||||
* retrieve the groups to whom a given user belongs (given the user EMail)
|
||||
* @param userEMail the user e mail
|
||||
* @param httpSession
|
||||
* @param pathVre
|
||||
* @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();
|
||||
UserManager userManager = new LiferayUserManager();
|
||||
|
@ -70,17 +76,22 @@ public class UserUtil {
|
|||
|
||||
// perform further checks
|
||||
if(!isViewPerVREEnabled){
|
||||
List<GCubeGroup> listOfGroups = groupManager.listGroupsByUser(user.getUserId());
|
||||
new AddUserToOrganizationThread(
|
||||
instance,
|
||||
user,
|
||||
listOfGroups,
|
||||
isViewPerVREEnabled,
|
||||
groupIdContext,
|
||||
roleManager,
|
||||
groupManager,
|
||||
localRoleInThisVre).
|
||||
start();
|
||||
String keyPerScope = context + ADD_USER_TO_OTHER_ORG_KEY;
|
||||
Boolean alreadyAdded = (Boolean)httpSession.getAttribute(keyPerScope);
|
||||
|
||||
if(alreadyAdded == null || !alreadyAdded){
|
||||
new AddUserToOrganizationThread(
|
||||
instance,
|
||||
user,
|
||||
groupManager.listGroupsByUser(user.getUserId()),
|
||||
isViewPerVREEnabled,
|
||||
groupIdContext,
|
||||
roleManager,
|
||||
groupManager,
|
||||
localRoleInThisVre).
|
||||
start();
|
||||
httpSession.setAttribute(keyPerScope, true);
|
||||
}
|
||||
}
|
||||
logger.debug("Returning Map to the ckan connector : " + mapRoleByGroupSingleVre);
|
||||
return mapRoleByGroupSingleVre;
|
||||
|
|
Loading…
Reference in New Issue