From e4229c4c0790f786d67fd6db8150d81c1421e64a Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Tue, 18 Apr 2017 09:49:34 +0000 Subject: [PATCH] Added deleteResource and deleteFacet by UUID git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-publisher@146919 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../publisher/ResourceRegistryPublisher.java | 3 +++ .../ResourceRegistryPublisherImpl.java | 26 +++++++++++++------ 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisher.java b/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisher.java index c0382d5..781a005 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisher.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisher.java @@ -25,6 +25,7 @@ public interface ResourceRegistryPublisher { public boolean deleteFacet(F facet) throws FacetNotFoundException, ResourceRegistryException; + public boolean deleteFacet(UUID uuid) throws FacetNotFoundException, ResourceRegistryException; public R createResource(Class resourceClass, R resource) throws ResourceAlreadyPresentException, ResourceRegistryException; @@ -33,6 +34,8 @@ public interface ResourceRegistryPublisher { public boolean deleteResource(R resource) throws ResourceNotFoundException, ResourceRegistryException; + public boolean deleteResource(UUID uuid) throws ResourceNotFoundException, ResourceRegistryException; + public > C createConsistsOf( Class consistsOfClass, C consistsOf) throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException; diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisherImpl.java b/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisherImpl.java index dd904eb..a693fdd 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisherImpl.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisherImpl.java @@ -126,21 +126,27 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher @Override public boolean deleteFacet(F facet) throws FacetNotFoundException, ResourceRegistryException { + logger.info("Going to delete : {}", facet); + return deleteFacet(facet.getHeader().getUUID()); + } + + @Override + public boolean deleteFacet(UUID uuid) throws FacetNotFoundException, ResourceRegistryException { try { - logger.info("Going to delete: {}", facet); + logger.info("Going to delete {} with UUID {}", Facet.NAME, uuid.toString()); StringWriter stringWriter = new StringWriter(); stringWriter.append(PATH_SEPARATOR); stringWriter.append(ERPath.ER_PATH_PART); stringWriter.append(PATH_SEPARATOR); stringWriter.append(ERPath.FACET_PATH_PART); stringWriter.append(PATH_SEPARATOR); - stringWriter.append(facet.getHeader().getUUID().toString()); + stringWriter.append(uuid.toString()); HTTPCall httpCall = getHTTPCall(); boolean deleted = httpCall.call(Boolean.class, stringWriter.toString(), HTTPMETHOD.DELETE); - logger.info("{} {}", facet, deleted ? " successfully deleted" + logger.info("{} with UUID {} {}", Facet.NAME, uuid.toString(), deleted ? " successfully deleted" : "was NOT deleted"); return deleted; @@ -152,7 +158,6 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher throw new RuntimeException(e); } } - @Override public R createResource(Class resourceClass, @@ -219,21 +224,27 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher @Override public boolean deleteResource(R resource) throws ResourceNotFoundException, ResourceRegistryException { + logger.info("Going to delete {}", resource); + return deleteResource(resource.getHeader().getUUID()); + } + + @Override + public boolean deleteResource(UUID uuid) throws ResourceNotFoundException, ResourceRegistryException { try { - logger.info("Going to delete: {}", resource); + logger.info("Going to delete {} with UUID {}", Resource.NAME, uuid.toString()); StringWriter stringWriter = new StringWriter(); stringWriter.append(PATH_SEPARATOR); stringWriter.append(ERPath.ER_PATH_PART); stringWriter.append(PATH_SEPARATOR); stringWriter.append(ERPath.RESOURCE_PATH_PART); stringWriter.append(PATH_SEPARATOR); - stringWriter.append(resource.getHeader().getUUID().toString()); + stringWriter.append(uuid.toString()); HTTPCall httpCall = getHTTPCall(); boolean deleted = httpCall.call(Boolean.class, stringWriter.toString(), HTTPMETHOD.DELETE); - logger.info("{} {}", resource, deleted ? " successfully deleted" + logger.info("{} with UUID {} {}", Resource.NAME, uuid.toString(), deleted ? " successfully deleted" : "was NOT deleted"); return deleted; @@ -245,7 +256,6 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher throw new RuntimeException(e); } } - @Override public > C createConsistsOf(