minor fix for session attribute

git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@131392 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-09-15 13:59:13 +00:00
parent a625555295
commit e71ddc9b6c
1 changed files with 7 additions and 6 deletions

View File

@ -290,12 +290,13 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
String scopePerCurrentUrl = (String)this.getThreadLocalRequest().getSession().getAttribute(SCOPE_CLIENT_PORTLET_URL);
// get key per scope
String keyPerScope = UtilMethods.concatenateSessionKeyScope(CKAN_HIGHEST_ROLE, scopePerCurrentUrl);
String keyPerScopeRole = UtilMethods.concatenateSessionKeyScope(CKAN_HIGHEST_ROLE, scopePerCurrentUrl);
String keyPerScopeOrganizations = UtilMethods.concatenateSessionKeyScope(CKAN_ORGANIZATIONS_PUBLISH_KEY, scopePerCurrentUrl);
// check into session
if(httpSession.getAttribute(keyPerScope) != null){
if(httpSession.getAttribute(keyPerScopeRole) != null){
toReturn = (CkanRole)httpSession.getAttribute(keyPerScope);
toReturn = (CkanRole)httpSession.getAttribute(keyPerScopeRole);
logger.info("Found user role into session " + toReturn + " and it is going to be returned for user " + username);
}else{
@ -309,13 +310,13 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
toReturn = UserUtil.getHighestRole(scopePerCurrentUrl, username, groupName, this, orgsInWhichAtLeastEditorRole);
// put role in session
httpSession.setAttribute(keyPerScope, toReturn);
httpSession.setAttribute(keyPerScopeRole, toReturn);
logger.info("Set role " + toReturn + " into session for user " + username);
// if he is an admin/editor preload:
// 1) organizations in which he can publish (the widget will find these info in session)
if(toReturn.equals(CkanRole.ADMIN) || toReturn.equals(CkanRole.EDITOR)){
httpSession.setAttribute(keyPerScope, orgsInWhichAtLeastEditorRole);
httpSession.setAttribute(keyPerScopeOrganizations, orgsInWhichAtLeastEditorRole);
logger.info("Set organizations in which he can publish to " + orgsInWhichAtLeastEditorRole + " into session for user " + username);
}
}catch(Exception e){