From 4d2a519963ee114242e3413bd8692e7f03b350a5 Mon Sep 17 00:00:00 2001 From: "luca.frosini" Date: Fri, 2 Sep 2016 13:12:28 +0000 Subject: [PATCH] Fixing REST exception management git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@131088 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../resourceregistry/resources/ContextManager.java | 4 +++- .../resources/ResourceRegistryExceptionMapper.java | 5 +++++ .../resources/impl/ContextManagementImpl.java | 7 ++++--- .../resources/impl/ContextManagementImplTest.java | 13 +++++++------ 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/resources/ContextManager.java b/src/main/java/org/gcube/informationsystem/resourceregistry/resources/ContextManager.java index 0591d04..4cbd40b 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/resources/ContextManager.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/resources/ContextManager.java @@ -11,6 +11,7 @@ import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; import org.gcube.informationsystem.resourceregistry.api.ContextManagement; +import org.gcube.informationsystem.resourceregistry.api.exceptions.InternalException; import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextCreationException; import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextException; import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextNotFoundException; @@ -41,13 +42,14 @@ public class ContextManager { * @param parentUUID * @param name * @return + * @throws InternalException * @throws Exception */ @PUT public String create( @QueryParam(ContextPath.PARENT_CONTEXT_ID_PARAM) String parentUUID, @QueryParam(ContextPath.NAME_PARAM) String name) - throws ContextCreationException { + throws ContextCreationException, InternalException { logger.trace("requested to create context with name : {} ", name); return contextManager.create(parentUUID, name); } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/resources/ResourceRegistryExceptionMapper.java b/src/main/java/org/gcube/informationsystem/resourceregistry/resources/ResourceRegistryExceptionMapper.java index d48406d..5607927 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/resources/ResourceRegistryExceptionMapper.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/resources/ResourceRegistryExceptionMapper.java @@ -5,6 +5,7 @@ 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.InternalException; import org.gcube.informationsystem.resourceregistry.api.exceptions.NotAllowedException; import org.gcube.informationsystem.resourceregistry.api.exceptions.ObjectNotFound; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; @@ -23,6 +24,10 @@ public class ResourceRegistryExceptionMapper implements ExceptionMapper