added method to fetch dataset also without api key (only public datasets)

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@146751 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Costantino Perciante 2017-04-11 13:18:18 +00:00
parent ebadddd097
commit 440cc907e4
2 changed files with 23 additions and 0 deletions

View File

@ -382,6 +382,15 @@ public interface DataCatalogue {
*/
CkanDataset getDataset(String datasetId, String apiKey);
/**
* Retrieve a ckan dataset given its id. The CkanClient is used, without api key. The result
* is null also when the dataset is private.
* @param datasetId
* @return
* @throws Exception
*/
CkanDataset getDataset(String datasetId) throws Exception;
/**
* Set searchable field
* The field, if set to true, allows organization's users to view private products also in groups

View File

@ -1685,6 +1685,19 @@ public class DataCatalogueImpl implements DataCatalogue{
return null;
}
@Override
public CkanDataset getDataset(String datasetId) throws Exception{
logger.info("Request ckan dataset with id " + datasetId);
// checks
checkNotNull(datasetId);
checkArgument(!datasetId.isEmpty());
CkanClient client = new CkanClient(CKAN_CATALOGUE_URL);
return client.getDataset(datasetId);
}
@Override
public boolean setSearchableField(String datasetId, boolean searchable) {
@ -2569,4 +2582,5 @@ public class DataCatalogueImpl implements DataCatalogue{
}
return toReturn;
}
}