minor improvements
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@134267 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
3f06966b7f
commit
71cefc4b77
|
@ -280,10 +280,10 @@ public interface DataCatalogue {
|
|||
Map<String, List<String>> getRolesAndUsersOrganization(String organizationName);
|
||||
|
||||
/**
|
||||
* Returns a Map with key 'capacity' and as value a list of users with that capacity into the group groupName.
|
||||
* Returns a Map with key 'capacity' and as value a list of users with that capacity into the group groupNameOrTitle.
|
||||
* @return
|
||||
*/
|
||||
Map<String, List<String>> getRolesAndUsersGroup(String groupName);
|
||||
Map<RolesCkanGroupOrOrg, List<String>> getRolesAndUsersGroup(String groupNameOrTitle);
|
||||
|
||||
/**
|
||||
* Given the username and the organization name the method retrieves the role of the user (i.e. his/her 'capacity')
|
||||
|
|
|
@ -1430,14 +1430,16 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
}
|
||||
|
||||
@Override
|
||||
public Map<String, List<String>> getRolesAndUsersGroup(String groupName) {
|
||||
public Map<RolesCkanGroupOrOrg, List<String>> getRolesAndUsersGroup(String groupName) {
|
||||
|
||||
// checks
|
||||
checkNotNull(groupName);
|
||||
checkArgument(!groupName.isEmpty());
|
||||
|
||||
String groupNameToCheck = UtilMethods.fromGroupTitleToName(groupName);
|
||||
|
||||
Map<String, List<String>> capacityAndUsers = new HashMap<String, List<String>>();
|
||||
CkanGroup org = client.getGroup(groupName);
|
||||
Map<RolesCkanGroupOrOrg, List<String>> capacityAndUsers = new HashMap<RolesCkanGroupOrOrg, List<String>>();
|
||||
CkanGroup org = client.getGroup(groupNameToCheck);
|
||||
List<CkanUser> users = org.getUsers();
|
||||
for (CkanUser ckanUser : users) {
|
||||
|
||||
|
@ -1450,7 +1452,7 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
listUsers = new ArrayList<String>();
|
||||
|
||||
listUsers.add(ckanUser.getName());
|
||||
capacityAndUsers.put(ckanUser.getCapacity(), listUsers);
|
||||
capacityAndUsers.put(RolesCkanGroupOrOrg.valueOf(ckanUser.getCapacity().toUpperCase()), listUsers);
|
||||
|
||||
}
|
||||
|
||||
|
@ -1628,5 +1630,4 @@ public class DataCatalogueImpl implements DataCatalogue{
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,6 +27,18 @@ public class UtilMethods {
|
|||
|
||||
return username.trim().replaceAll("\\.", "_");
|
||||
}
|
||||
|
||||
/**
|
||||
* Liferay username has . instead of _ (that is, costantino_perciante -> costantino.perciante)
|
||||
* @param owner
|
||||
* @return
|
||||
*/
|
||||
public static String fromCKanUsernameToUsername(String ckanUsername){
|
||||
if(ckanUsername == null)
|
||||
return null;
|
||||
|
||||
return ckanUsername.trim().replaceAll("_", ".");
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the catalogue's dataset name from its title
|
||||
|
|
|
@ -378,4 +378,11 @@ public class TestDataCatalogueLib {
|
|||
logger.debug("Searchability set? " + setSearchability);
|
||||
}
|
||||
|
||||
//@Test
|
||||
public void testNameConversion(){
|
||||
|
||||
logger.debug(UtilMethods.fromCKanUsernameToUsername("costantino_perciante"));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue