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
This commit is contained in:
Luca Frosini 2017-04-18 09:49:34 +00:00
parent fcd12e945b
commit e4229c4c07
2 changed files with 21 additions and 8 deletions

View File

@ -25,6 +25,7 @@ public interface ResourceRegistryPublisher {
public <F extends Facet> boolean deleteFacet(F facet) throws FacetNotFoundException, ResourceRegistryException;
public boolean deleteFacet(UUID uuid) throws FacetNotFoundException, ResourceRegistryException;
public <R extends Resource> R createResource(Class<R> resourceClass,
R resource) throws ResourceAlreadyPresentException, ResourceRegistryException;
@ -33,6 +34,8 @@ public interface ResourceRegistryPublisher {
public <R extends Resource> boolean deleteResource(R resource) throws ResourceNotFoundException, ResourceRegistryException;
public boolean deleteResource(UUID uuid) throws ResourceNotFoundException, ResourceRegistryException;
public <C extends ConsistsOf<? extends Resource, ? extends Facet>> C createConsistsOf(
Class<C> consistsOfClass, C consistsOf) throws FacetNotFoundException, ResourceNotFoundException, ResourceRegistryException;

View File

@ -126,21 +126,27 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
@Override
public <F extends Facet> 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 extends Resource> R createResource(Class<R> resourceClass,
@ -219,21 +224,27 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher
@Override
public <R extends Resource> 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 extends ConsistsOf<? extends Resource, ? extends Facet>> C createConsistsOf(