added getGroupByName

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@148341 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2017-05-06 17:22:05 +00:00
parent be0ab0518a
commit 612dcf19a6
2 changed files with 17 additions and 0 deletions

View File

@ -51,6 +51,12 @@ public interface DataCatalogue {
* @return a list of groups
*/
List<CkanGroup> getGroupsByUser(String username);
/**
* Returns a group given its name
* @return return a {@link CkanGroup} or null if no group with this name exists
*/
CkanGroup getGroupByName(String nameOrId);
/**
* Returns the list of organizations' names to whom the user belongs (with any role)

View File

@ -2581,4 +2581,15 @@ public class DataCatalogueImpl implements DataCatalogue{
return toReturn;
}
@Override
public CkanGroup getGroupByName(String name) {
String ckanName = UtilMethods.fromGroupTitleToName(name);
try{
return client.getGroup(ckanName);
}catch(Exception e){
logger.error("Failed to retrieve the group with name" + name, e);
}
return null;
}
}