minor fixes to retrieve user's organizations names and titles
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/user/gcube-ckan-datacatalog@130608 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
224014aff7
commit
854578d2f7
|
@ -26,6 +26,7 @@ import org.gcube.portal.custom.scopemanager.scopehelper.ScopeHelper;
|
|||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.client.GcubeCkanDataCatalogService;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanConnectorAccessPoint;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -294,7 +295,7 @@ public class GcubeCkanDataCatalogServiceImpl extends RemoteServiceServlet implem
|
|||
}else{
|
||||
|
||||
// we build up also a list that keeps track of the scopes (orgs) in which the user has role ADMIN
|
||||
List<String> orgsInWhichAdminRole = new ArrayList<String>();
|
||||
List<OrganizationBean> orgsInWhichAdminRole = new ArrayList<OrganizationBean>();
|
||||
toReturn = UserUtil.getHighestRole(currentScope, username, groupName, this, orgsInWhichAdminRole);
|
||||
httpSession.setAttribute(keyPerScope, toReturn);
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import java.util.List;
|
|||
import org.gcube.datacatalogue.ckanutillibrary.CKanUtils;
|
||||
import org.gcube.datacatalogue.ckanutillibrary.models.RolesIntoOrganization;
|
||||
import org.gcube.portlets.gcubeckan.gcubeckandatacatalog.shared.CkanRole;
|
||||
import org.gcube.portlets.widgets.ckandatapublisherwidget.shared.OrganizationBean;
|
||||
import org.gcube.vomanagement.usermanagement.GroupManager;
|
||||
import org.gcube.vomanagement.usermanagement.RoleManager;
|
||||
import org.gcube.vomanagement.usermanagement.UserManager;
|
||||
|
@ -25,6 +26,8 @@ import org.gcube.vomanagement.usermanagement.model.GatewayRolesNames;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import eu.trentorise.opendata.jackan.model.CkanOrganization;
|
||||
|
||||
|
||||
/**
|
||||
* The Class UserUtil.
|
||||
|
@ -77,7 +80,7 @@ public class UserUtil {
|
|||
* @param orgsInWhichAdminRole
|
||||
* @param ckanUtils ckanUtils
|
||||
*/
|
||||
public static CkanRole getHighestRole(String currentScope, String username, String groupName, GcubeCkanDataCatalogServiceImpl gcubeCkanDataCatalogServiceImpl, List<String> orgsInWhichAdminRole){
|
||||
public static CkanRole getHighestRole(String currentScope, String username, String groupName, GcubeCkanDataCatalogServiceImpl gcubeCkanDataCatalogServiceImpl, List<OrganizationBean> orgsInWhichAdminRole){
|
||||
|
||||
// base role as default value
|
||||
CkanRole toReturn = CkanRole.MEMBER;
|
||||
|
@ -138,9 +141,14 @@ public class UserUtil {
|
|||
boolean res = ckanUtils.checkRole(username, gCubeGroupName, correspondentRoleToCheck);
|
||||
if(res){
|
||||
|
||||
orgsInWhichAdminRole.add(gCubeGroupName.toLowerCase());
|
||||
continue; // it is already the highest
|
||||
|
||||
// get the orgs of the user
|
||||
List<CkanOrganization> ckanOrgs = ckanUtils.getOrganizationsByUser(username);
|
||||
for (CkanOrganization ckanOrganization : ckanOrgs) {
|
||||
if(ckanOrganization.getName().equals(gCubeGroupName.toLowerCase())){
|
||||
orgsInWhichAdminRole.add(new OrganizationBean(ckanOrganization.getTitle(), ckanOrganization.getName()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else
|
||||
logger.error("It seems there is no ckan instance into scope " + groupManager.getInfrastructureScope(gCubeGroup.getGroupId()));
|
||||
|
@ -186,10 +194,14 @@ public class UserUtil {
|
|||
if(ckanUtils != null){
|
||||
boolean res = ckanUtils.checkRole(username, gCubeGroupName, correspondentRoleToCheck);
|
||||
if(res){
|
||||
|
||||
orgsInWhichAdminRole.add(gCubeGroupName.toLowerCase());
|
||||
continue; // it is already the highest
|
||||
|
||||
// get the orgs of the user
|
||||
List<CkanOrganization> ckanOrgs = ckanUtils.getOrganizationsByUser(username);
|
||||
for (CkanOrganization ckanOrganization : ckanOrgs) {
|
||||
if(ckanOrganization.getName().equals(gCubeGroupName.toLowerCase())){
|
||||
orgsInWhichAdminRole.add(new OrganizationBean(ckanOrganization.getTitle(), ckanOrganization.getName()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}else
|
||||
logger.error("It seems there is no ckan instance into scope " + groupManager.getInfrastructureScope(gCubeGroup.getGroupId()));
|
||||
|
@ -225,8 +237,15 @@ public class UserUtil {
|
|||
if(res){
|
||||
// set the role
|
||||
toReturn = mapLiferayRoleToCkan(mainRole);
|
||||
orgsInWhichAdminRole.add(groupName.toLowerCase());
|
||||
|
||||
// get the orgs of the user
|
||||
List<CkanOrganization> ckanOrgs = ckanUtils.getOrganizationsByUser(username);
|
||||
for (CkanOrganization ckanOrganization : ckanOrgs) {
|
||||
if(ckanOrganization.getName().equals(groupName.toLowerCase())){
|
||||
orgsInWhichAdminRole.add(new OrganizationBean(ckanOrganization.getTitle(), ckanOrganization.getName()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue