log added, method to check if a dataset already exists fixed
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/data-catalogue/ckan-util-library@131747 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
6295a91bae
commit
cb0c641ae4
|
@ -82,6 +82,7 @@ public class ApplicationProfileScopePerUrlReader {
|
|||
for (int i = 0; i < urls.size(); i++) {
|
||||
if (urls.get(i).trim().compareTo(url) == 0) { // url found
|
||||
scopeToReturn = helper.evaluate("/Resource/Profile/Body/EndPoint/Scope/text()").get(i);
|
||||
logger.debug("Found, returning " + scopeToReturn);
|
||||
foundScope = true;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -231,4 +231,12 @@ public interface CKanUtils {
|
|||
*/
|
||||
List<CkanDatasetRelationship> getRelationshipDatasets(String datasetIdSubject, String datasetIdObject, String apiKey);
|
||||
|
||||
/**
|
||||
* Checks if a product with such name already exists.
|
||||
* Please remember that the name is unique.
|
||||
* @param nameOrId the name or the id of the dataset to check
|
||||
* @return
|
||||
*/
|
||||
boolean existProductWithNameOrId(String nameOrId);
|
||||
|
||||
}
|
||||
|
|
|
@ -1054,4 +1054,21 @@ public class CKanUtilsImpl implements CKanUtils{
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean existProductWithNameOrId(String nameOrId) {
|
||||
|
||||
// checks
|
||||
checkNotNull(nameOrId);
|
||||
checkArgument(!nameOrId.isEmpty());
|
||||
|
||||
try{
|
||||
// check if exists
|
||||
CkanDataset product = client.getDataset(nameOrId);
|
||||
return product != null;
|
||||
}catch(Exception e){
|
||||
logger.error("Unable to retrieve dataset information", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue