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:
Costantino Perciante 2016-09-23 12:37:32 +00:00
parent 6295a91bae
commit cb0c641ae4
3 changed files with 26 additions and 0 deletions

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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;
}
}
}