added get parent groups method

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@135155 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2016-12-01 07:26:51 +00:00
parent 495c10958e
commit 610946dcf5
3 changed files with 32 additions and 3 deletions

View File

@ -328,7 +328,7 @@ public interface DataCatalogue {
*/
boolean assignDatasetToGroup(String groupNameOrId, String datasetNameOrId,
String apiKey);
/**
* Remove a dataset from a group.
* @param groupNameOrId the id or the name of the group.
@ -403,7 +403,7 @@ public interface DataCatalogue {
* @return true on success, false otherwise
*/
boolean patchProductCustomFields(String productId, String apiKey, Map<String, List<String>> customFieldsToChange);
/**
* Remove a tag from a product
* @param productId
@ -412,7 +412,7 @@ public interface DataCatalogue {
* @return true on success, false otherwise
*/
boolean removeTag(String productId, String apiKey, String tagToRemove);
/**
* Add a tag from a product
* @param productId
@ -421,4 +421,10 @@ public interface DataCatalogue {
* @return true on success, false otherwise
*/
boolean addTag(String productId, String apiKey, String tagToAdd);
/**
* Get the parent groups of this group
* @return the group parent, if any
*/
List<CkanGroup> getParentGroups(String groupName, String apiKey);
}

View File

@ -2079,4 +2079,20 @@ public class DataCatalogueImpl implements DataCatalogue{
return false;
}
@Override
public List<CkanGroup> getParentGroups(String groupName, String apiKey) {
// checks
checkNotNull(groupName);
checkNotNull(apiKey);
try{
CheckedCkanClient client = new CheckedCkanClient(CKAN_CATALOGUE_URL, apiKey);
return client.getGroup(groupName).getGroups();
}catch(Exception e){
logger.error("Something went wrong, returning null", e);
}
return null;
}
}

View File

@ -437,4 +437,11 @@ public class TestDataCatalogueLib {
}
//@Test
public void getGroups() throws Exception{
DataCatalogueImpl instance = factory.getUtilsPerScope(scope);
instance.getParentGroups("abundance-level", instance.getApiKeyFromUsername("costantino_perciante"));
}
}