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 = "4620e6d0-2313-4f48-9d54-eb3efd01a810";
|
||||||
// private final static String TEST_SEC_TOKEN = "f539884c-8697-4ac0-9bbf-2f4d595281f5";
|
// 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)
|
/* (non-Javadoc)
|
||||||
* @see org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GcubeCkanDataCatalogService#getCKanConnector()
|
* @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 username = getASLSession(httpSession).getUsername();
|
||||||
String currentScope = getASLSession(httpSession).getScope();
|
String currentScope = getASLSession(httpSession).getScope();
|
||||||
String groupName = getASLSession(httpSession).getGroupName();
|
String groupName = getASLSession(httpSession).getGroupName();
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
|
||||||
// retrieve the liferay's roles for the user
|
// retrieve the liferay's roles for the user
|
||||||
UserManager userManager = new LiferayUserManager();
|
UserManager userManager = new LiferayUserManager();
|
||||||
RoleManager roleManager = new LiferayRoleManager();
|
RoleManager roleManager = new LiferayRoleManager();
|
||||||
GroupManager groupManager = new LiferayGroupManager();
|
GroupManager groupManager = new LiferayGroupManager();
|
||||||
List<RoleModel> roles = roleManager.listRolesByUserAndGroup(groupManager.getGroupId(groupName), userManager.getUserId(username));
|
List<RoleModel> roles = roleManager.listRolesByUserAndGroup(groupManager.getGroupId(groupName), userManager.getUserId(username));
|
||||||
|
|
||||||
// the default one
|
// the default one
|
||||||
CkanRolesIntoLiferay mainRole = CkanRolesIntoLiferay.CATALOG_MEMBER;
|
CkanRolesIntoLiferay mainRole = CkanRolesIntoLiferay.CATALOG_MEMBER;
|
||||||
RolesIntoOrganization correspondentRoleToCheck = RolesIntoOrganization.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
|
// NOTE: it is supposed that there is just one role for this person correspondent to the one in the catalog
|
||||||
for (RoleModel role : roles) {
|
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())){
|
if(role.getRoleName().contains(CkanRolesIntoLiferay.CATALOG_SYSADMIN.toString())){
|
||||||
mainRole = CkanRolesIntoLiferay.CATALOG_SYSADMIN;
|
mainRole = CkanRolesIntoLiferay.CATALOG_SYSADMIN;
|
||||||
correspondentRoleToCheck = RolesIntoOrganization.SYSADMIN;
|
correspondentRoleToCheck = RolesIntoOrganization.SYSADMIN;
|
||||||
break;
|
break;
|
||||||
}else if(role.getRoleName().contains(CkanRolesIntoLiferay.CATALOG_ADMIN.toString())){
|
}else if(role.getRoleName().contains(CkanRolesIntoLiferay.CATALOG_ADMIN.toString())){
|
||||||
mainRole = CkanRolesIntoLiferay.CATALOG_ADMIN;
|
mainRole = CkanRolesIntoLiferay.CATALOG_ADMIN;
|
||||||
correspondentRoleToCheck = RolesIntoOrganization.ADMIN;
|
correspondentRoleToCheck = RolesIntoOrganization.ADMIN;
|
||||||
break;
|
break;
|
||||||
}else if(role.getRoleName().contains(CkanRolesIntoLiferay.CATALOG_EDITOR.toString())){
|
}else if(role.getRoleName().contains(CkanRolesIntoLiferay.CATALOG_EDITOR.toString())){
|
||||||
mainRole = CkanRolesIntoLiferay.CATALOG_EDITOR;
|
mainRole = CkanRolesIntoLiferay.CATALOG_EDITOR;
|
||||||
correspondentRoleToCheck = RolesIntoOrganization.EDITOR;
|
correspondentRoleToCheck = RolesIntoOrganization.EDITOR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// with this invocation, we check if the role is present in ckan and if it is not it will be added
|
// 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);
|
boolean res = instance.checkRole(username, groupName, correspondentRoleToCheck);
|
||||||
|
|
||||||
|
if(res)
|
||||||
|
return reMapRole(mainRole);
|
||||||
|
|
||||||
return reMapRole(mainRole);
|
|
||||||
|
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
logger.error("Unable to retrieve the role information for this user. Returning member role", 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 the base role
|
||||||
return CkanRole.MEMBER;
|
return CkanRole.MEMBER;
|
||||||
|
|
Loading…
Reference in New Issue