added getResource method
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@162550 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
8cf12d1593
commit
749f67101d
|
@ -644,4 +644,9 @@ public interface DataCatalogue {
|
||||||
* @return an email address for sending email to this catalogue
|
* @return an email address for sending email to this catalogue
|
||||||
*/
|
*/
|
||||||
String getCatalogueEmail();
|
String getCatalogueEmail();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve a resource by id
|
||||||
|
*/
|
||||||
|
CkanResource getResource(String id, String apiKey);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1886,6 +1886,26 @@ public class DataCatalogueImpl implements DataCatalogue{
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CkanResource getResource(String id, String apiKey) {
|
||||||
|
logger.info("Request ckan resource with id " + id);
|
||||||
|
|
||||||
|
// checks
|
||||||
|
checkNotNull(id);
|
||||||
|
checkArgument(!id.isEmpty());
|
||||||
|
checkNotNull(apiKey);
|
||||||
|
checkArgument(!apiKey.isEmpty());
|
||||||
|
|
||||||
|
try{
|
||||||
|
CheckedCkanClient client = new CheckedCkanClient(CKAN_CATALOGUE_URL, apiKey);
|
||||||
|
return client.getResource(id);
|
||||||
|
}catch(Exception e){
|
||||||
|
logger.error("Unable to retrieve such resource, returning null ...", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CkanDataset getDataset(String datasetId, String apiKey) {
|
public CkanDataset getDataset(String datasetId, String apiKey) {
|
||||||
|
|
Loading…
Reference in New Issue