diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/context/ContextManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/context/ContextManagement.java index 5956669..5091b7d 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/context/ContextManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/context/ContextManagement.java @@ -11,13 +11,13 @@ import org.gcube.informationsystem.model.embedded.Header; import org.gcube.informationsystem.model.entity.Context; import org.gcube.informationsystem.model.relation.IsParentOf; import org.gcube.informationsystem.model.relation.Relation; +import org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException; +import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextAlreadyPresentException; import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException; import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException; import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.EntityAvailableInAnotherContextException; -import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERAlreadyPresentException; -import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERNotFoundException; import org.gcube.informationsystem.resourceregistry.context.security.SecurityContext; import org.gcube.informationsystem.resourceregistry.dbinitialization.DatabaseEnvironment; import org.gcube.informationsystem.resourceregistry.er.ERManagement; @@ -86,7 +86,7 @@ public class ContextManagement extends EntityManagement { } @Override - protected ContextNotFoundException getSpecificElementNotFoundException(ERNotFoundException e) { + protected ContextNotFoundException getSpecificElementNotFoundException(NotFoundException e) { return new ContextNotFoundException(e.getMessage(), e.getCause()); } @@ -194,7 +194,7 @@ public class ContextManagement extends EntityManagement { } @Override - protected Vertex reallyCreate() throws ERAlreadyPresentException, ResourceRegistryException { + protected Vertex reallyCreate() throws AlreadyPresentException, ResourceRegistryException { SecurityContext securityContext = null; SecurityContext parentSecurityContext = null; @@ -250,7 +250,7 @@ public class ContextManagement extends EntityManagement { } @Override - protected Vertex reallyUpdate() throws ERNotFoundException, ResourceRegistryException { + protected Vertex reallyUpdate() throws NotFoundException, ResourceRegistryException { boolean parentChanged = false; boolean nameChanged = false; @@ -366,7 +366,7 @@ public class ContextManagement extends EntityManagement { } @Override - protected boolean reallyDelete() throws ERNotFoundException, ResourceRegistryException { + protected boolean reallyDelete() throws NotFoundException, ResourceRegistryException { Iterable iterable = getElement().getEdges(Direction.OUT); Iterator iterator = iterable.iterator(); while(iterator.hasNext()) { diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/context/IsParentOfManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/context/IsParentOfManagement.java index e929b98..968749d 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/context/IsParentOfManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/context/IsParentOfManagement.java @@ -7,9 +7,9 @@ import org.gcube.informationsystem.model.embedded.PropagationConstraint.AddConst import org.gcube.informationsystem.model.embedded.PropagationConstraint.RemoveConstraint; import org.gcube.informationsystem.model.relation.IsParentOf; import org.gcube.informationsystem.model.relation.Relation; +import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException; -import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERNotFoundException; import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.RelationAvailableInAnotherContextException; import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.isparentof.IsParentOfAlreadyPresentException; import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.isparentof.IsParentOfNotFoundException; @@ -90,7 +90,7 @@ public class IsParentOfManagement extends RelationManagement { public abstract JSONObject serializeAsJson() throws ResourceRegistryException; - protected abstract El reallyCreate() throws ERAlreadyPresentException, ResourceRegistryException; + protected abstract El reallyCreate() throws AlreadyPresentException, ResourceRegistryException; - public El internalCreate() throws ERAlreadyPresentException, ResourceRegistryException { + public El internalCreate() throws AlreadyPresentException, ResourceRegistryException { try { reallyCreate(); @@ -259,9 +259,9 @@ public abstract class ERManagement { } } - protected abstract El reallyUpdate() throws ERNotFoundException, ResourceRegistryException; + protected abstract El reallyUpdate() throws NotFoundException, ResourceRegistryException; - public El internalUpdate() throws ERNotFoundException, ResourceRegistryException { + public El internalUpdate() throws NotFoundException, ResourceRegistryException { try { reallyUpdate(); @@ -280,14 +280,14 @@ public abstract class ERManagement { public El internalCreateOrUdate() throws ResourceRegistryException { try { return internalUpdate(); - } catch(ERNotFoundException e) { + } catch(NotFoundException e) { return internalCreate(); } } - protected abstract boolean reallyDelete() throws ERNotFoundException, ResourceRegistryException; + protected abstract boolean reallyDelete() throws NotFoundException, ResourceRegistryException; - public boolean internalDelete() throws ERNotFoundException, ResourceRegistryException { + public boolean internalDelete() throws NotFoundException, ResourceRegistryException { // Added for consistency with create and update addToContext removeFromContext. return reallyDelete(); } @@ -330,24 +330,24 @@ public abstract class ERManagement { this.uuid = HeaderUtility.getHeader(element).getUUID(); } - protected abstract ERNotFoundException getSpecificElementNotFoundException(ERNotFoundException e); + protected abstract NotFoundException getSpecificElementNotFoundException(NotFoundException e); - protected abstract ERAvailableInAnotherContextException getSpecificERAvailableInAnotherContextException( + protected abstract AvailableInAnotherContextException getSpecificERAvailableInAnotherContextException( String message); - protected abstract ERAlreadyPresentException getSpecificERAlreadyPresentException(String message); + protected abstract AlreadyPresentException getSpecificERAlreadyPresentException(String message); - public El getElement() throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException { + public El getElement() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException { if(element == null) { try { element = retrieveElement(); - } catch(ERNotFoundException e) { + } catch(NotFoundException e) { try { retrieveElementFromAnyContext(); throw getSpecificERAvailableInAnotherContextException(erType == null ? accessType.getName() : erType + " with UUID " + uuid + " is available in another " + Context.class.getSimpleName()); - } catch(ERAvailableInAnotherContextException e1) { + } catch(AvailableInAnotherContextException e1) { throw e1; } catch(Exception e1) { throw e; @@ -366,14 +366,14 @@ public abstract class ERManagement { return element; } - public El retrieveElement() throws ERNotFoundException, ResourceRegistryException { + public El retrieveElement() throws NotFoundException, ResourceRegistryException { try { if(uuid == null) { - throw new ERNotFoundException("null UUID does not allow to retrieve the Element"); + throw new NotFoundException("null UUID does not allow to retrieve the Element"); } return Utility.getElementByUUID(orientGraph, erType == null ? accessType.getName() : erType, uuid, elementClass); - } catch(ERNotFoundException e) { + } catch(NotFoundException e) { throw getSpecificElementNotFoundException(e); } catch(ResourceRegistryException e) { throw e; @@ -382,10 +382,10 @@ public abstract class ERManagement { } } - public El retrieveElementFromAnyContext() throws ERNotFoundException, ResourceRegistryException { + public El retrieveElementFromAnyContext() throws NotFoundException, ResourceRegistryException { try { return Utility.getElementByUUIDAsAdmin(erType == null ? accessType.getName() : erType, uuid, elementClass); - } catch(ERNotFoundException e) { + } catch(NotFoundException e) { throw getSpecificElementNotFoundException(e); } catch(ResourceRegistryException e) { throw e; @@ -414,7 +414,7 @@ public abstract class ERManagement { } public boolean exists() - throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException { + throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException { try { orientGraph = getWorkingContext().getGraph(PermissionMode.READER); @@ -434,7 +434,7 @@ public abstract class ERManagement { } } - public String create() throws ERAlreadyPresentException, ResourceRegistryException { + public String create() throws AlreadyPresentException, ResourceRegistryException { try { orientGraph = getWorkingContext().getGraph(PermissionMode.WRITER); @@ -468,7 +468,7 @@ public abstract class ERManagement { } } - public String read() throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException { + public String read() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException { try { orientGraph = getWorkingContext().getGraph(PermissionMode.READER); @@ -488,7 +488,7 @@ public abstract class ERManagement { } } - public String update() throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException { + public String update() throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException { try { orientGraph = getWorkingContext().getGraph(PermissionMode.WRITER); orientGraph.setAutoStartTx(false); @@ -524,7 +524,7 @@ public abstract class ERManagement { } public boolean delete() - throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException { + throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException { logger.debug("Going to delete {} with UUID {}", accessType.getName(), uuid); try { @@ -564,7 +564,7 @@ public abstract class ERManagement { } } - public boolean addToContext() throws ERNotFoundException, ContextException, ResourceRegistryException { + public boolean addToContext() throws NotFoundException, ContextException, ResourceRegistryException { logger.info("Going to add {} with UUID {} to Context {}", accessType.getName(), uuid, getWorkingContext().toString()); @@ -598,7 +598,7 @@ public abstract class ERManagement { } } - public boolean removeFromContext() throws ERNotFoundException, ContextException, ResourceRegistryException { + public boolean removeFromContext() throws NotFoundException, ContextException, ResourceRegistryException { logger.debug("Going to remove {} with UUID {} from actual Context", accessType.getName(), uuid); try { diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/er/ERManagementUtility.java b/src/main/java/org/gcube/informationsystem/resourceregistry/er/ERManagementUtility.java index e69042a..f7f6c7b 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/er/ERManagementUtility.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/er/ERManagementUtility.java @@ -8,8 +8,8 @@ import org.gcube.informationsystem.model.entity.Resource; import org.gcube.informationsystem.model.relation.ConsistsOf; import org.gcube.informationsystem.model.relation.IsRelatedTo; import org.gcube.informationsystem.model.relation.Relation; +import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; -import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERNotFoundException; import org.gcube.informationsystem.resourceregistry.context.security.SecurityContext; import org.gcube.informationsystem.resourceregistry.er.entity.EntityManagement; import org.gcube.informationsystem.resourceregistry.er.entity.FacetManagement; @@ -75,10 +75,10 @@ public class ERManagementUtility { Entity.NAME, Relation.NAME)); } - public static Element getAnyElementByUUID(UUID uuid) throws ERNotFoundException, ResourceRegistryException { + public static Element getAnyElementByUUID(UUID uuid) throws NotFoundException, ResourceRegistryException { try { return Utility.getElementByUUIDAsAdmin(null, uuid, Vertex.class); - } catch(ERNotFoundException e) { + } catch(NotFoundException e) { return Utility.getElementByUUIDAsAdmin(null, uuid, Edge.class); } catch(ResourceRegistryException e) { throw e; @@ -88,10 +88,10 @@ public class ERManagementUtility { } private static Element getAnyElementByUUID(OrientGraph orientGraph, UUID uuid) - throws ERNotFoundException, ResourceRegistryException { + throws NotFoundException, ResourceRegistryException { try { return Utility.getElementByUUID(orientGraph, null, uuid, Vertex.class); - } catch(ERNotFoundException e) { + } catch(NotFoundException e) { return Utility.getElementByUUID(orientGraph, null, uuid, Edge.class); } catch(ResourceRegistryException e) { throw e; diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/er/entity/EntityManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/er/entity/EntityManagement.java index be30424..9406ef2 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/er/entity/EntityManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/er/entity/EntityManagement.java @@ -8,11 +8,11 @@ import org.codehaus.jettison.json.JSONObject; import org.gcube.informationsystem.model.AccessType; import org.gcube.informationsystem.model.entity.Entity; import org.gcube.informationsystem.model.relation.Relation; +import org.gcube.informationsystem.resourceregistry.api.exceptions.AvailableInAnotherContextException; +import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException; import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.EntityAlreadyPresentException; -import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERAvailableInAnotherContextException; -import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERNotFoundException; import org.gcube.informationsystem.resourceregistry.context.security.SecurityContext; import org.gcube.informationsystem.resourceregistry.er.ERManagement; import org.gcube.informationsystem.resourceregistry.er.ERManagementUtility; @@ -135,17 +135,17 @@ public abstract class EntityManagement extends ERManagement { } @Override - protected FacetNotFoundException getSpecificElementNotFoundException(ERNotFoundException e) { + protected FacetNotFoundException getSpecificElementNotFoundException(NotFoundException e) { return new FacetNotFoundException(e.getMessage(), e.getCause()); } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/er/entity/ResourceManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/er/entity/ResourceManagement.java index cd9525b..943cc0e 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/er/entity/ResourceManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/er/entity/ResourceManagement.java @@ -9,11 +9,11 @@ import org.gcube.informationsystem.model.AccessType; import org.gcube.informationsystem.model.entity.Resource; import org.gcube.informationsystem.model.relation.ConsistsOf; import org.gcube.informationsystem.model.relation.IsRelatedTo; +import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceAlreadyPresentException; import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceAvailableInAnotherContextException; import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.resource.ResourceNotFoundException; -import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERNotFoundException; import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath; import org.gcube.informationsystem.resourceregistry.context.security.SecurityContext; import org.gcube.informationsystem.resourceregistry.context.security.SecurityContext.PermissionMode; @@ -50,7 +50,7 @@ public class ResourceManagement extends EntityManagement { } @Override - protected ResourceNotFoundException getSpecificElementNotFoundException(ERNotFoundException e) { + protected ResourceNotFoundException getSpecificElementNotFoundException(NotFoundException e) { return new ResourceNotFoundException(e.getMessage(), e.getCause()); } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/er/relation/ConsistsOfManagement.java b/src/main/java/org/gcube/informationsystem/resourceregistry/er/relation/ConsistsOfManagement.java index 10a61dc..566753f 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/er/relation/ConsistsOfManagement.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/er/relation/ConsistsOfManagement.java @@ -2,8 +2,8 @@ package org.gcube.informationsystem.resourceregistry.er.relation; import org.gcube.informationsystem.model.AccessType; import org.gcube.informationsystem.model.relation.ConsistsOf; +import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; -import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERNotFoundException; import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.consistsOf.ConsistsOfAlreadyPresentException; import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.consistsOf.ConsistsOfAvailableInAnotherContextException; import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.consistsOf.ConsistsOfNotFoundException; @@ -28,7 +28,7 @@ public class ConsistsOfManagement extends RelationManagement El getElementByUUIDAsAdmin(String elementType, UUID uuid, - Class clz) throws ERNotFoundException, ResourceRegistryException { + Class clz) throws NotFoundException, ResourceRegistryException { OrientGraphNoTx orientGraphNoTx = null; try { AdminSecurityContext adminSecurityContext = ContextUtility.getAdminSecurityContext(); @@ -99,7 +99,7 @@ public class Utility { } public static El getElementByUUID(Graph graph, String elementType, UUID uuid, - Class clz) throws ERNotFoundException, ResourceRegistryException { + Class clz) throws NotFoundException, ResourceRegistryException { if(elementType == null || elementType.compareTo("") == 0) { if(Vertex.class.isAssignableFrom(clz)) { @@ -120,7 +120,7 @@ public class Utility { if(elements == null || !elements.iterator().hasNext()) { String error = String.format("No %s with UUID %s was found", elementType, uuid.toString()); logger.info(error); - throw new ERNotFoundException(error); + throw new NotFoundException(error); } Iterator iterator = elements.iterator();