diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/client/proxy/ResourceRegistryClient.java b/src/main/java/org/gcube/informationsystem/resourceregistry/client/proxy/ResourceRegistryClient.java index 580aa35..5dd97f1 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/client/proxy/ResourceRegistryClient.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/client/proxy/ResourceRegistryClient.java @@ -18,6 +18,10 @@ import org.gcube.informationsystem.types.TypeBinder.TypeDefinition; */ public interface ResourceRegistryClient { + public void exists( + Class clazz, UUID uuid) throws ERNotFoundException, + ResourceRegistryException; + public ERType getInstance( Class clazz, UUID uuid) throws ERNotFoundException, ResourceRegistryException; diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/client/proxy/ResourceRegistryClientCall.java b/src/main/java/org/gcube/informationsystem/resourceregistry/client/proxy/ResourceRegistryClientCall.java index 75c599a..a0fdda3 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/client/proxy/ResourceRegistryClientCall.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/client/proxy/ResourceRegistryClientCall.java @@ -20,8 +20,7 @@ public class ResourceRegistryClientCall implements Call protected String getURLStringFromEndpointReference( EndpointReference endpoint) throws IOException { - JaxRSEndpointReference jaxRSEndpointReference = new JaxRSEndpointReference( - endpoint); + JaxRSEndpointReference jaxRSEndpointReference = new JaxRSEndpointReference(endpoint); return jaxRSEndpointReference.toString(); } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/client/proxy/ResourceRegistryClientImpl.java b/src/main/java/org/gcube/informationsystem/resourceregistry/client/proxy/ResourceRegistryClientImpl.java index 3a589d3..93f3a3f 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/client/proxy/ResourceRegistryClientImpl.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/client/proxy/ResourceRegistryClientImpl.java @@ -47,6 +47,38 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { this.delegate = new AsyncProxyDelegate(config); } + + @Override + public void exists(Class clazz, UUID uuid) + throws ERNotFoundException, ResourceRegistryException { + String type = clazz.getSimpleName(); + try { + logger.info("Going to check if {} with UUID {} exists", type, uuid); + StringWriter stringWriter = new StringWriter(); + stringWriter.append(PATH_SEPARATOR); + stringWriter.append(AccessPath.ACCESS_PATH_PART); + stringWriter.append(PATH_SEPARATOR); + stringWriter.append(AccessPath.INSTANCE_PATH_PART); + stringWriter.append(PATH_SEPARATOR); + stringWriter.append(type); + stringWriter.append(PATH_SEPARATOR); + stringWriter.append(uuid.toString()); + + HTTPCall httpCall = new HTTPCall<>(stringWriter.toString(), + HTTPMETHOD.HEAD, null); + + ResourceRegistryClientCall call = new ResourceRegistryClientCall<>( + clazz, httpCall); + + delegate.make(call); + logger.info("{} with UUID {} exists", type, uuid); + } catch (ResourceRegistryException e) { + throw e; + } catch (Exception e) { + throw new ServiceException(e); + } + } + @Override public ERType getInstance(Class clazz, UUID uuid) throws ERNotFoundException, ResourceRegistryException {