From f4b358be2c282d26f26aec52628be6a144a88e99 Mon Sep 17 00:00:00 2001 From: "luca.frosini" Date: Tue, 12 Jun 2018 15:13:29 +0000 Subject: [PATCH] Refs #11288: Made resource-registry more RESTful Task-Url: https://support.d4science.org/issues/11288 git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@169078 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../resourceregistry/er/ERManagement.java | 10 ++++++++-- .../resourceregistry/rest/Access.java | 2 +- .../resourceregistry/rest/InstancesManager.java | 4 ++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/er/ERManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/er/ERManagement.java index b49a3b6..3917bc0 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/er/ERManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/er/ERManagement.java @@ -429,10 +429,16 @@ public abstract class ERManagement { } } - public boolean exists() + public boolean exists(boolean writer) throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException { try { - orientGraph = getWorkingContext().getGraph(PermissionMode.READER); + if(writer) { + // Exists is used to understand if it is a create or update. + // In any case the we need writing right on this instance + orientGraph = getWorkingContext().getGraph(PermissionMode.WRITER); + }else { + orientGraph = getWorkingContext().getGraph(PermissionMode.READER); + } getElement(); diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java index 639b1a2..2ae3d99 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java @@ -209,7 +209,7 @@ public class Access { try { erManagement.setUUID(UUID.fromString(uuid)); - boolean found = erManagement.exists(); + boolean found = erManagement.exists(false); if(found) { return Response.status(Status.NO_CONTENT).build(); } else { diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/InstancesManager.java b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/InstancesManager.java index 364c0da..6177cc3 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/InstancesManager.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/InstancesManager.java @@ -99,7 +99,7 @@ public class InstancesManager { try { erManagement.setUUID(UUID.fromString(uuid)); - boolean found = erManagement.exists(); + boolean found = erManagement.exists(false); if(found) { return Response.status(Status.NO_CONTENT).build(); } else { @@ -162,7 +162,7 @@ public class InstancesManager { boolean create = false; try { - erManagement.exists(); + erManagement.exists(true); } catch(NotFoundException e) { create = true; }