moved to Catalogue Manager team role (see #7393)

git-svn-id: http://svn.research-infrastructures.eu/public/d4science/gcube/trunk/portlets/widgets/grsf-manage-widget@144655 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2017-03-03 17:26:35 +00:00
parent 41413b80a6
commit c206010000
1 changed files with 6 additions and 7 deletions

View File

@ -31,6 +31,7 @@ import org.gcube.resources.discovery.client.queries.api.SimpleQuery;
import org.gcube.vomanagement.usermanagement.impl.LiferayRoleManager;
import org.gcube.vomanagement.usermanagement.impl.LiferayUserManager;
import org.gcube.vomanagement.usermanagement.model.GCubeRole;
import org.gcube.vomanagement.usermanagement.model.GCubeTeam;
import org.gcube.vomanagement.usermanagement.model.GCubeUser;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@ -95,7 +96,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
// session info for user
public static final String GRSF_ADMIN_SESSION_KEY = "IS_GRSF_ADMIN";
private static final String GRSF_ADMIN_ROLE = "GRSF-Admin";
private static final String GRSF_CATALOGUE_MANAGER_ROLE = "Catalogue Manager"; // managed as Team Role
/**
* Instanciate the ckan util library.
@ -533,12 +534,10 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
return inSession;
else{
PortalContext pContext = PortalContext.getConfiguration();
List<GCubeRole> userRoles = new LiferayRoleManager().listRolesByUserAndGroup(
pContext.getCurrentUser(getThreadLocalRequest()).getUserId(),
pContext.getCurrentGroupId(getThreadLocalRequest()));
List<GCubeTeam> teamRoles = new LiferayRoleManager().listTeamsByUserAndGroup(pContext.getCurrentUser(getThreadLocalRequest()).getUserId(), pContext.getCurrentGroupId(getThreadLocalRequest()));
boolean toSetInSession = false;
for (GCubeRole gCubeRole : userRoles) {
if(gCubeRole.getRoleName().equals(GRSF_ADMIN_ROLE)){
for (GCubeTeam team : teamRoles) {
if(team.getTeamName().equals(GRSF_CATALOGUE_MANAGER_ROLE)){
toSetInSession = true;
break;
}
@ -547,7 +546,7 @@ public class GRSFNotificationService extends RemoteServiceServlet implements GRS
return toSetInSession;
}
}catch(Exception e){
logger.error("Failed to check if the user has role " + GRSF_ADMIN_ROLE, e);
logger.error("Failed to check if the user has team " + GRSF_CATALOGUE_MANAGER_ROLE, e);
}
return false;
}