Minor fixes
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@129158 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7d164c7566
commit
4490c079e5
|
@ -52,6 +52,21 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
private final static String TEST_SEC_TOKEN = "4620e6d0-2313-4f48-9d54-eb3efd01a810";
|
||||
// private final static String TEST_SEC_TOKEN = "f539884c-8697-4ac0-9bbf-2f4d595281f5";
|
||||
|
||||
// ckan utils methods
|
||||
private CKanUtilsImpl instance;
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
|
||||
// retrieve ckan information
|
||||
try{
|
||||
String currentScope = ScopeProvider.instance.get();
|
||||
instance = new CKanUtilsImpl(currentScope);
|
||||
}catch(Exception e){
|
||||
logger.error("Unable to retrieve ckan information");
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GcubeCkanDataCatalogService#getCKanConnector()
|
||||
*/
|
||||
|
@ -163,47 +178,50 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
String username = getASLSession(httpSession).getUsername();
|
||||
String currentScope = getASLSession(httpSession).getScope();
|
||||
String groupName = getASLSession(httpSession).getGroupName();
|
||||
|
||||
|
||||
try{
|
||||
|
||||
// retrieve the liferay's roles for the user
|
||||
UserManager userManager = new LiferayUserManager();
|
||||
RoleManager roleManager = new LiferayRoleManager();
|
||||
GroupManager groupManager = new LiferayGroupManager();
|
||||
List<RoleModel> roles = roleManager.listRolesByUserAndGroup(groupManager.getGroupId(groupName), userManager.getUserId(username));
|
||||
// retrieve the liferay's roles for the user
|
||||
UserManager userManager = new LiferayUserManager();
|
||||
RoleManager roleManager = new LiferayRoleManager();
|
||||
GroupManager groupManager = new LiferayGroupManager();
|
||||
List<RoleModel> roles = roleManager.listRolesByUserAndGroup(groupManager.getGroupId(groupName), userManager.getUserId(username));
|
||||
|
||||
// the default one
|
||||
CkanRolesIntoLiferay mainRole = CkanRolesIntoLiferay.CATALOG_MEMBER;
|
||||
RolesIntoOrganization correspondentRoleToCheck = RolesIntoOrganization.MEMBER;
|
||||
// the default one
|
||||
CkanRolesIntoLiferay mainRole = CkanRolesIntoLiferay.CATALOG_MEMBER;
|
||||
RolesIntoOrganization correspondentRoleToCheck = RolesIntoOrganization.MEMBER;
|
||||
|
||||
// NOTE: it is supposed that there is just one role for this person correspondent to the one in the catalog
|
||||
for (RoleModel role : roles) {
|
||||
// NOTE: it is supposed that there is just one role for this person correspondent to the one in the catalog
|
||||
for (RoleModel role : roles) {
|
||||
|
||||
logger.debug("User " + username + " has role " + role.getRoleName() + " in " + currentScope);
|
||||
logger.debug("User " + username + " has role " + role.getRoleName() + " in " + currentScope);
|
||||
|
||||
if(role.getRoleName().contains(CkanRolesIntoLiferay.CATALOG_SYSADMIN.toString())){
|
||||
mainRole = CkanRolesIntoLiferay.CATALOG_SYSADMIN;
|
||||
correspondentRoleToCheck = RolesIntoOrganization.SYSADMIN;
|
||||
break;
|
||||
}else if(role.getRoleName().contains(CkanRolesIntoLiferay.CATALOG_ADMIN.toString())){
|
||||
mainRole = CkanRolesIntoLiferay.CATALOG_ADMIN;
|
||||
correspondentRoleToCheck = RolesIntoOrganization.ADMIN;
|
||||
break;
|
||||
}else if(role.getRoleName().contains(CkanRolesIntoLiferay.CATALOG_EDITOR.toString())){
|
||||
mainRole = CkanRolesIntoLiferay.CATALOG_EDITOR;
|
||||
correspondentRoleToCheck = RolesIntoOrganization.EDITOR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(role.getRoleName().contains(CkanRolesIntoLiferay.CATALOG_SYSADMIN.toString())){
|
||||
mainRole = CkanRolesIntoLiferay.CATALOG_SYSADMIN;
|
||||
correspondentRoleToCheck = RolesIntoOrganization.SYSADMIN;
|
||||
break;
|
||||
}else if(role.getRoleName().contains(CkanRolesIntoLiferay.CATALOG_ADMIN.toString())){
|
||||
mainRole = CkanRolesIntoLiferay.CATALOG_ADMIN;
|
||||
correspondentRoleToCheck = RolesIntoOrganization.ADMIN;
|
||||
break;
|
||||
}else if(role.getRoleName().contains(CkanRolesIntoLiferay.CATALOG_EDITOR.toString())){
|
||||
mainRole = CkanRolesIntoLiferay.CATALOG_EDITOR;
|
||||
correspondentRoleToCheck = RolesIntoOrganization.EDITOR;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// with this invocation, we check if the role is present in ckan and if it is not it will be added
|
||||
new CKanUtilsImpl(currentScope).checkRole(username, groupName, correspondentRoleToCheck);
|
||||
// with this invocation, we check if the role is present in ckan and if it is not it will be added
|
||||
boolean res = instance.checkRole(username, groupName, correspondentRoleToCheck);
|
||||
|
||||
if(res)
|
||||
return reMapRole(mainRole);
|
||||
|
||||
return reMapRole(mainRole);
|
||||
|
||||
}catch(Exception e){
|
||||
logger.error("Unable to retrieve the role information for this user. Returning member role", e);
|
||||
}
|
||||
|
||||
logger.debug("Unable to check the role into ckan organization, returning MEMBER as role");
|
||||
|
||||
// return the base role
|
||||
return CkanRole.MEMBER;
|
||||
|
|
Loading…
Reference in New Issue