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@167867 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Luca Frosini 2018-06-04 13:31:13 +00:00
parent 4796e807ef
commit 8571ea190e
14 changed files with 84 additions and 84 deletions

View File

@ -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<Context> {
}
@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<Context> {
}
@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<Context> {
}
@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<Context> {
}
@Override
protected boolean reallyDelete() throws ERNotFoundException, ResourceRegistryException {
protected boolean reallyDelete() throws NotFoundException, ResourceRegistryException {
Iterable<Edge> iterable = getElement().getEdges(Direction.OUT);
Iterator<Edge> iterator = iterable.iterator();
while(iterator.hasNext()) {

View File

@ -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<IsParentOf,ContextM
}
@Override
protected IsParentOfNotFoundException getSpecificElementNotFoundException(ERNotFoundException e) {
protected IsParentOfNotFoundException getSpecificElementNotFoundException(NotFoundException e) {
return new IsParentOfNotFoundException(e.getMessage(), e.getCause());
}
@ -140,12 +140,12 @@ public class IsParentOfManagement extends RelationManagement<IsParentOf,ContextM
}
@Override
public boolean addToContext() throws ERNotFoundException, ContextException {
public boolean addToContext() throws NotFoundException, ContextException {
throw new UnsupportedOperationException();
}
@Override
public boolean removeFromContext() throws ERNotFoundException, ContextException {
public boolean removeFromContext() throws NotFoundException, ContextException {
throw new UnsupportedOperationException();
}

View File

@ -22,11 +22,11 @@ import org.gcube.informationsystem.model.ISManageable;
import org.gcube.informationsystem.model.embedded.Header;
import org.gcube.informationsystem.model.entity.Context;
import org.gcube.informationsystem.model.entity.Entity;
import org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException;
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.er.ERAlreadyPresentException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERAvailableInAnotherContextException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException;
import org.gcube.informationsystem.resourceregistry.context.ContextUtility;
import org.gcube.informationsystem.resourceregistry.context.security.SecurityContext;
@ -234,9 +234,9 @@ public abstract class ERManagement<ERType extends ER, El extends Element> {
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<ERType extends ER, El extends Element> {
}
}
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<ERType extends ER, El extends Element> {
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<ERType extends ER, El extends Element> {
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<ERType extends ER, El extends Element> {
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<ERType extends ER, El extends Element> {
}
}
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<ERType extends ER, El extends Element> {
}
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<ERType extends ER, El extends Element> {
}
}
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<ERType extends ER, El extends Element> {
}
}
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<ERType extends ER, El extends Element> {
}
}
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<ERType extends ER, El extends Element> {
}
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<ERType extends ER, El extends Element> {
}
}
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<ERType extends ER, El extends Element> {
}
}
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 {

View File

@ -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;

View File

@ -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<E extends Entity> extends ERManagement<E,
}
}
} catch(ERNotFoundException e) {
} catch(NotFoundException e) {
try {
Element el = ERManagementUtility.getAnyElementByUUID(uuid);
String error = String.format("UUID %s is already used by another %s. This is not allowed.",
uuid.toString(), (el instanceof Vertex) ? Entity.NAME : Relation.NAME);
throw getSpecificERAvailableInAnotherContextException(error);
} catch(ERNotFoundException e1) {
} catch(NotFoundException e1) {
// OK the UUID is not already used.
}
} catch(ERAvailableInAnotherContextException e) {
} catch(AvailableInAnotherContextException e) {
throw e;
}

View File

@ -3,11 +3,11 @@ package org.gcube.informationsystem.resourceregistry.er.entity;
import org.codehaus.jettison.json.JSONObject;
import org.gcube.informationsystem.model.AccessType;
import org.gcube.informationsystem.model.entity.Facet;
import org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetAlreadyPresentException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetAvailableInAnotherContextException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.entity.facet.FacetNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERNotFoundException;
import org.gcube.informationsystem.resourceregistry.context.security.SecurityContext;
import org.gcube.informationsystem.resourceregistry.er.ERManagement;
@ -28,7 +28,7 @@ public class FacetManagement extends EntityManagement<Facet> {
}
@Override
protected FacetNotFoundException getSpecificElementNotFoundException(ERNotFoundException e) {
protected FacetNotFoundException getSpecificElementNotFoundException(NotFoundException e) {
return new FacetNotFoundException(e.getMessage(), e.getCause());
}

View File

@ -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<Resource> {
}
@Override
protected ResourceNotFoundException getSpecificElementNotFoundException(ERNotFoundException e) {
protected ResourceNotFoundException getSpecificElementNotFoundException(NotFoundException e) {
return new ResourceNotFoundException(e.getMessage(), e.getCause());
}

View File

@ -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<ConsistsOf,Resource
}
@Override
protected ConsistsOfNotFoundException getSpecificElementNotFoundException(ERNotFoundException e) {
protected ConsistsOfNotFoundException getSpecificElementNotFoundException(NotFoundException e) {
return new ConsistsOfNotFoundException(e.getMessage(), e.getCause());
}

View File

@ -2,8 +2,8 @@ package org.gcube.informationsystem.resourceregistry.er.relation;
import org.gcube.informationsystem.model.AccessType;
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.er.ERNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.isrelatedto.IsRelatedToAlreadyPresentException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.isrelatedto.IsRelatedToAvailableInAnotherContextException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.relation.isrelatedto.IsRelatedToNotFoundException;
@ -27,7 +27,7 @@ public class IsRelatedToManagement extends RelationManagement<IsRelatedTo,Resour
}
@Override
protected IsRelatedToNotFoundException getSpecificElementNotFoundException(ERNotFoundException e) {
protected IsRelatedToNotFoundException getSpecificElementNotFoundException(NotFoundException e) {
return new IsRelatedToNotFoundException(e.getMessage(), e.getCause());
}

View File

@ -18,9 +18,9 @@ import org.gcube.informationsystem.model.entity.Entity;
import org.gcube.informationsystem.model.entity.Facet;
import org.gcube.informationsystem.model.entity.Resource;
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.RelationNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaException;
import org.gcube.informationsystem.resourceregistry.context.ContextUtility;
@ -552,7 +552,7 @@ public abstract class RelationManagement<R extends Relation, S extends EntityMan
}
@Override
public boolean addToContext() throws ERNotFoundException, ContextException {
public boolean addToContext() throws NotFoundException, ContextException {
logger.debug("Going to add {} with UUID {} to actual Context", accessType.getName(), uuid);
try {

View File

@ -22,10 +22,10 @@ import org.gcube.common.authorization.library.provider.CalledMethodProvider;
import org.gcube.informationsystem.model.entity.Facet;
import org.gcube.informationsystem.model.relation.ConsistsOf;
import org.gcube.informationsystem.resourceregistry.ResourceInitializer;
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.ContextNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERAvailableInAnotherContextException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.query.InvalidQueryException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath;
@ -94,7 +94,7 @@ public class Access {
@HEAD
@Path(AccessPath.INSTANCE_PATH_PART + "/" + "{" + TYPE_PATH_PARAM + "}" + "/{" + ID_PATH_PARAM + "}")
public Response exists(@PathParam(TYPE_PATH_PARAM) String type, @PathParam(ID_PATH_PARAM) String id)
throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException {
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
CalledMethodProvider.instance.set(HTTPMETHOD.HEAD.name() + " /" + AccessPath.ACCESS_PATH_PART + "/"
+ AccessPath.INSTANCE_PATH_PART + "/" + type + "/{" + ID_PATH_PARAM + "}");
@ -117,9 +117,9 @@ public class Access {
// anyway adding it for safety reason
return Response.status(Status.NOT_FOUND).build();
}
} catch(ERNotFoundException e) {
} catch(NotFoundException e) {
return Response.status(Status.NOT_FOUND).build();
} catch(ERAvailableInAnotherContextException e) {
} catch(AvailableInAnotherContextException e) {
return Response.status(Status.FORBIDDEN).build();
} catch(ResourceRegistryException e) {
throw e;
@ -134,7 +134,7 @@ public class Access {
@Path(AccessPath.INSTANCE_PATH_PART + "/" + "{" + TYPE_PATH_PARAM + "}" + "/{" + ID_PATH_PARAM + "}")
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
public String getInstance(@PathParam(TYPE_PATH_PARAM) String type, @PathParam(ID_PATH_PARAM) String id)
throws ERNotFoundException, ResourceRegistryException {
throws NotFoundException, ResourceRegistryException {
CalledMethodProvider.instance.set(HTTPMETHOD.GET.name() + " /" + AccessPath.ACCESS_PATH_PART + "/"
+ AccessPath.INSTANCE_PATH_PART + "/" + type + "/{" + ID_PATH_PARAM + "}");

View File

@ -53,13 +53,13 @@ public class ERManager {
*
*/
@PUT
@Path(ERPath.FACET_PATH_PART + "/{" + TYPE_PATH_PARAM + "}")
@Path(ERPath.FACETS_PATH_PART + "/{" + TYPE_PATH_PARAM + "}")
@Consumes({MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8})
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
public Response createFacet(@PathParam(TYPE_PATH_PARAM) String type, String json)
throws FacetAlreadyPresentException, ResourceRegistryException {
CalledMethodProvider.instance
.set(HTTPMETHOD.PUT.name() + " /" + ERPath.ER_PATH_PART + "/" + ERPath.FACET_PATH_PART + "/" + type);
.set(HTTPMETHOD.PUT.name() + " /" + ERPath.ER_PATH_PART + "/" + ERPath.FACETS_PATH_PART + "/" + type);
logger.info("Requested to create {} of type {}", Facet.NAME, type);
logger.trace("Requested to create {} of type {} defined by {} ", Facet.NAME, type, json);
FacetManagement facetManagement = new FacetManagement();
@ -77,13 +77,13 @@ public class ERManager {
*
*/
@POST
@Path(ERPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}")
@Path(ERPath.FACETS_PATH_PART + "/{" + ID_PATH_PARAM + "}")
@Consumes({MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8})
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
public String updateFacet(@PathParam(ID_PATH_PARAM) String uuid, String json)
throws FacetNotFoundException, ResourceRegistryException {
CalledMethodProvider.instance.set(HTTPMETHOD.POST.name() + " /" + ERPath.ER_PATH_PART + "/"
+ ERPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}");
+ ERPath.FACETS_PATH_PART + "/{" + ID_PATH_PARAM + "}");
logger.info("Requested to update {} with id {}", Facet.NAME, uuid);
logger.trace("Requested to update {} with id {} with json {}", Facet.NAME, uuid, json);
FacetManagement facetManagement = new FacetManagement();
@ -97,11 +97,11 @@ public class ERManager {
*
*/
@DELETE
@Path(ERPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}")
@Path(ERPath.FACETS_PATH_PART + "/{" + ID_PATH_PARAM + "}")
public boolean deleteFacet(@PathParam(ID_PATH_PARAM) String uuid)
throws FacetNotFoundException, ResourceRegistryException {
CalledMethodProvider.instance.set(HTTPMETHOD.DELETE.name() + " /" + ERPath.ER_PATH_PART + "/"
+ ERPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}");
+ ERPath.FACETS_PATH_PART + "/{" + ID_PATH_PARAM + "}");
logger.info("Requested to delete {} with id {}", Facet.NAME, uuid);
FacetManagement facetManagement = new FacetManagement();
facetManagement.setUUID(UUID.fromString(uuid));
@ -273,11 +273,11 @@ public class ERManager {
*
*/
@POST
@Path(ERPath.ADD_PATH_PART + "/" + ERPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}")
@Path(ERPath.ADD_PATH_PART + "/" + ERPath.FACETS_PATH_PART + "/{" + ID_PATH_PARAM + "}")
public boolean addFacetToContext(@PathParam(ID_PATH_PARAM) String uuid)
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
CalledMethodProvider.instance.set(HTTPMETHOD.POST.name() + " /" + ERPath.ER_PATH_PART + "/"
+ ERPath.ADD_PATH_PART + "/" + ERPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}");
+ ERPath.ADD_PATH_PART + "/" + ERPath.FACETS_PATH_PART + "/{" + ID_PATH_PARAM + "}");
logger.info("Requested to add {} with UUID {} to current {}", Facet.NAME, uuid, Context.NAME);
FacetManagement facetManagement = new FacetManagement();
facetManagement.setUUID(UUID.fromString(uuid));
@ -307,11 +307,11 @@ public class ERManager {
*
*/
@POST
@Path(ERPath.REMOVE_PATH_PART + "/" + ERPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}")
@Path(ERPath.REMOVE_PATH_PART + "/" + ERPath.FACETS_PATH_PART + "/{" + ID_PATH_PARAM + "}")
public boolean removeFacetFromContext(@PathParam(ID_PATH_PARAM) String uuid)
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
CalledMethodProvider.instance.set(HTTPMETHOD.POST.name() + " /" + ERPath.ER_PATH_PART + "/"
+ ERPath.REMOVE_PATH_PART + "/" + ERPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}");
+ ERPath.REMOVE_PATH_PART + "/" + ERPath.FACETS_PATH_PART + "/{" + ID_PATH_PARAM + "}");
logger.info("Requested to remove {} with UUID {} from current {}", Facet.NAME, uuid, Context.NAME);
FacetManagement facetManagement = new FacetManagement();
facetManagement.setUUID(UUID.fromString(uuid));

View File

@ -6,10 +6,10 @@ import javax.ws.rs.core.Response.Status;
import javax.ws.rs.ext.ExceptionMapper;
import javax.ws.rs.ext.Provider;
import org.gcube.informationsystem.resourceregistry.api.exceptions.AlreadyPresentException;
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.er.ERAlreadyPresentException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERAvailableInAnotherContextException;
import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERNotFoundException;
/**
* @author Luca Frosini (ISTI - CNR)
@ -22,11 +22,11 @@ public class ResourceRegistryExceptionMapper implements ExceptionMapper<Resource
Status status = Status.BAD_REQUEST;
if(ERNotFoundException.class.isAssignableFrom(exception.getClass())) {
if(NotFoundException.class.isAssignableFrom(exception.getClass())) {
status = Status.NOT_FOUND;
} else if(ERAlreadyPresentException.class.isAssignableFrom(exception.getClass())) {
} else if(AlreadyPresentException.class.isAssignableFrom(exception.getClass())) {
status = Status.CONFLICT;
} else if(ERAvailableInAnotherContextException.class.isAssignableFrom(exception.getClass())) {
} else if(AvailableInAnotherContextException.class.isAssignableFrom(exception.getClass())) {
status = Status.FORBIDDEN;
} else if(exception.getClass() == ResourceRegistryException.class) {
status = Status.INTERNAL_SERVER_ERROR;

View File

@ -12,8 +12,8 @@ import org.gcube.informationsystem.model.embedded.Embedded;
import org.gcube.informationsystem.model.embedded.Header;
import org.gcube.informationsystem.model.entity.Entity;
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.ContextUtility;
import org.gcube.informationsystem.resourceregistry.context.security.AdminSecurityContext;
import org.gcube.informationsystem.resourceregistry.context.security.SecurityContext.PermissionMode;
@ -85,7 +85,7 @@ public class Utility {
}
public static <El extends Element> El getElementByUUIDAsAdmin(String elementType, UUID uuid,
Class<? extends El> clz) throws ERNotFoundException, ResourceRegistryException {
Class<? extends El> clz) throws NotFoundException, ResourceRegistryException {
OrientGraphNoTx orientGraphNoTx = null;
try {
AdminSecurityContext adminSecurityContext = ContextUtility.getAdminSecurityContext();
@ -99,7 +99,7 @@ public class Utility {
}
public static <El extends Element> El getElementByUUID(Graph graph, String elementType, UUID uuid,
Class<? extends El> clz) throws ERNotFoundException, ResourceRegistryException {
Class<? extends El> 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<El> iterator = elements.iterator();