The list of organizations in which a sysadmin can publish has every ckan organization
git-svn-id: http://svn.d4science-ii.research-infrastructures.eu/gcube/trunk/portlets/widgets/ckan-metadata-publisher-widget@129156 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
96147b6e65
commit
445d2d364a
|
@ -124,19 +124,27 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve the list of organizations in which the user can publish (roles ADMIN, EDITOR)
|
* Retrieve the list of organizations in which the user can publish (roles ADMIN, EDITOR)
|
||||||
|
* If he is a SYSADMIN, he can publish everywhere
|
||||||
* @param username
|
* @param username
|
||||||
* @return the list of organizations
|
* @return the list of organizations
|
||||||
*/
|
*/
|
||||||
private List<String> getUserOrganizationsList(String username) {
|
private List<String> getUserOrganizationsList(String username) {
|
||||||
|
|
||||||
logger.debug("Request for user " + username + " organizations list");
|
logger.debug("Request for user " + username + " organizations list");
|
||||||
|
List<String> orgsName = new ArrayList<String>();
|
||||||
|
|
||||||
|
if(instance.isSysAdmin(username, getUserCKanTokenFromSession())){
|
||||||
|
|
||||||
|
logger.debug("The user " + username + " is a sysadmin. He can publish everywhere");
|
||||||
|
orgsName = instance.getOrganizationsNames();
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
// We need to retrieve orgs in which the user has the roles ADMIN, EDITOR
|
// We need to retrieve orgs in which the user has the roles ADMIN, EDITOR
|
||||||
List<RolesIntoOrganization> rolesToMatch = new ArrayList<RolesIntoOrganization>();
|
List<RolesIntoOrganization> rolesToMatch = new ArrayList<RolesIntoOrganization>();
|
||||||
rolesToMatch.add(RolesIntoOrganization.EDITOR);
|
rolesToMatch.add(RolesIntoOrganization.EDITOR);
|
||||||
rolesToMatch.add(RolesIntoOrganization.ADMIN);
|
rolesToMatch.add(RolesIntoOrganization.ADMIN);
|
||||||
|
|
||||||
List<String> orgsName = new ArrayList<String>();
|
|
||||||
Map<String, List<RolesIntoOrganization>> orgsAndRoles = instance.getGroupsAndRolesByUser(username, rolesToMatch);
|
Map<String, List<RolesIntoOrganization>> orgsAndRoles = instance.getGroupsAndRolesByUser(username, rolesToMatch);
|
||||||
Iterator<Entry<String, List<RolesIntoOrganization>>> iterator = orgsAndRoles.entrySet().iterator();
|
Iterator<Entry<String, List<RolesIntoOrganization>>> iterator = orgsAndRoles.entrySet().iterator();
|
||||||
|
|
||||||
|
@ -146,7 +154,7 @@ public class CKANPublisherServicesImpl extends RemoteServiceServlet implements C
|
||||||
.next();
|
.next();
|
||||||
orgsName.add(entry.getKey());
|
orgsName.add(entry.getKey());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return orgsName;
|
return orgsName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue