Creating missing ConsistsOf when updating a Resource

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@150850 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2017-07-06 15:45:22 +00:00
parent 939392a5b9
commit e4ad9c6d09
2 changed files with 12 additions and 1 deletions

View File

@ -331,6 +331,14 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
public abstract El reallyUpdate() throws ERNotFoundException, public abstract El reallyUpdate() throws ERNotFoundException,
ResourceRegistryException; ResourceRegistryException;
public El reallyCreateOrUdate() throws ResourceRegistryException {
try {
return reallyUpdate();
}catch (ERNotFoundException e) {
return reallyCreate();
}
}
public abstract boolean reallyDelete() throws ERNotFoundException, public abstract boolean reallyDelete() throws ERNotFoundException,
ResourceRegistryException; ResourceRegistryException;
@ -420,6 +428,9 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
public El retrieveElement() throws ERNotFoundException, ResourceRegistryException { public El retrieveElement() throws ERNotFoundException, ResourceRegistryException {
try { try {
if(uuid==null){
throw new ERNotFoundException("null UUID does not allow to retrieve the Element");
}
return Utility.getElementByUUID(orientGraph, return Utility.getElementByUUID(orientGraph,
erType == null ? accessType.getName() : erType, uuid, elementClass); erType == null ? accessType.getName() : erType, uuid, elementClass);
} catch (ERNotFoundException e) { } catch (ERNotFoundException e) {

View File

@ -170,7 +170,7 @@ public class ResourceManagement extends EntityManagement<Resource> {
for (JsonNode relationJsonNode : jsonNodeArray) { for (JsonNode relationJsonNode : jsonNodeArray) {
ConsistsOfManagement com = new ConsistsOfManagement(orientGraph); ConsistsOfManagement com = new ConsistsOfManagement(orientGraph);
com.setJSON(relationJsonNode); com.setJSON(relationJsonNode);
com.reallyUpdate(); com.reallyCreateOrUdate();
} }
} }