added method to get groups in the ckan instance

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@134140 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-11-14 17:07:47 +00:00
parent 5a2df65687
commit f146436ef5
2 changed files with 21 additions and 2 deletions

View File

@ -338,4 +338,10 @@ public interface DataCatalogue {
* @return true if the field is set, false otherwise
*/
boolean setSearchableField(String datasetId, boolean searchable);
/**
* Retrieve the list of groups in this instance
* @return a list of groups
*/
List<CkanGroup> getGroups();
}

View File

@ -669,12 +669,12 @@ public class DataCatalogueImpl implements DataCatalogue{
// create the base dataset and fill it
CkanDataset dataset = new CkanDataset();
// get the name from the title
String nameToUse = name;
if(nameToUse == null)
nameToUse = UtilMethods.fromProductTitleToName(title);
logger.debug("Name of the dataset is going to be " + nameToUse + ". Title is going to be " + title);
dataset.setName(nameToUse);
dataset.setTitle(title);
@ -1611,4 +1611,17 @@ public class DataCatalogueImpl implements DataCatalogue{
return false;
}
@Override
public List<CkanGroup> getGroups() {
try{
CkanClient client = new CkanClient(CKAN_CATALOGUE_URL);
return client.getGroupList();
}catch(Exception e){
logger.error("Failed to retrieve the list groups", e);
return null;
}
}
}