diff --git a/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/CodeException.java b/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/WebCodeException.java similarity index 77% rename from io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/CodeException.java rename to io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/WebCodeException.java index b9fd580..65d545d 100644 --- a/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/CodeException.java +++ b/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/WebCodeException.java @@ -9,16 +9,16 @@ import javax.ws.rs.core.Response; * @author Manuele Simi (ISTI CNR) * */ -public class CodeException extends WebApplicationException { +public class WebCodeException extends WebApplicationException { private static final long serialVersionUID = 333945715086602250L; - public CodeException(Response.Status status, ErrorCode code) { + public WebCodeException(Response.Status status, ErrorCode code) { super(Response.status(status).entity(new CodeEntity(new SerializableErrorCode(code.getId(), code.getMessage()))) .build()); } - public CodeException(ErrorCode code) { + public WebCodeException(ErrorCode code) { super(Response.status(Response.Status.NOT_ACCEPTABLE) .entity(new CodeEntity(new SerializableErrorCode(code.getId(), code.getMessage()))).build()); } diff --git a/io/src/main/java/org/gcube/resourcemanagement/manager/io/rs/RMCode.java b/io/src/main/java/org/gcube/resourcemanagement/manager/io/rs/RMCode.java index 101f649..e27cf6a 100644 --- a/io/src/main/java/org/gcube/resourcemanagement/manager/io/rs/RMCode.java +++ b/io/src/main/java/org/gcube/resourcemanagement/manager/io/rs/RMCode.java @@ -1,10 +1,9 @@ package org.gcube.resourcemanagement.manager.io.rs; -import org.gcube.resourcemanagement.manager.io.exceptions.CodeException; import org.gcube.resourcemanagement.manager.io.exceptions.ErrorCode; /** - * Exception codes handled with {@link CodeException}. + * Exception codes handled with {@link WebCodeException}. * * @author Manuele Simi (ISTI CNR) * diff --git a/io/src/test/java/org/gcube/resourcemanagement/manager/io/exceptions/CodeExceptionTest.java b/io/src/test/java/org/gcube/resourcemanagement/manager/io/exceptions/CodeExceptionTest.java index 058c96c..8bf6647 100644 --- a/io/src/test/java/org/gcube/resourcemanagement/manager/io/exceptions/CodeExceptionTest.java +++ b/io/src/test/java/org/gcube/resourcemanagement/manager/io/exceptions/CodeExceptionTest.java @@ -2,14 +2,14 @@ package org.gcube.resourcemanagement.manager.io.exceptions; import static org.junit.Assert.*; -import org.gcube.resourcemanagement.manager.io.exceptions.CodeException; +import org.gcube.resourcemanagement.manager.io.exceptions.WebCodeException; import org.gcube.resourcemanagement.manager.io.rs.RMCode; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.BlockJUnit4ClassRunner; /** - * Tests for {@link CodeException}s + * Tests for {@link WebCodeException}s * * @author Manuele Simi (ISTI CNR) * @@ -18,11 +18,11 @@ import org.junit.runners.BlockJUnit4ClassRunner; public class CodeExceptionTest { /** - * Test method for {@link org.gcube.resourcemanagement.manager.io.exceptions.CodeException#CodeException(org.gcube.resourcemanagement.manager.io.rs.RMCode)}. + * Test method for {@link org.gcube.resourcemanagement.manager.io.exceptions.WebCodeException#CodeException(org.gcube.resourcemanagement.manager.io.rs.RMCode)}. */ @Test public void testCodeException() { - CodeException exception = new CodeException(RMCode.CONTEXT_ALREADY_EXIST); + WebCodeException exception = new WebCodeException(RMCode.CONTEXT_ALREADY_EXIST); assertTrue("Unexpected id", exception.getErrorCode() == RMCode.CONTEXT_ALREADY_EXIST.getId()); assertTrue("Unexpected message", exception.getErrorMsg().equals(RMCode.CONTEXT_ALREADY_EXIST.getMessage())); diff --git a/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/context/CreateRequest.java b/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/context/CreateRequest.java index 3ffc673..46eb65d 100644 --- a/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/context/CreateRequest.java +++ b/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/context/CreateRequest.java @@ -5,7 +5,7 @@ import java.util.Objects; import org.gcube.informationsystem.model.entity.Context; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextAlreadyPresentException; -import org.gcube.resourcemanagement.manager.io.exceptions.CodeException; +import org.gcube.resourcemanagement.manager.io.exceptions.WebCodeException; import org.gcube.resourcemanagement.manager.io.rs.RMCode; /** @@ -52,9 +52,9 @@ public final class CreateRequest extends RequestToResourceRegistry { return ResponseFromResourceRegistry.newFailureResponse("Invalid response from the RR (null?)"); } } catch (ContextAlreadyPresentException cape) { - return ResponseFromResourceRegistry.fromException(new CodeException(RMCode.CONTEXT_ALREADY_EXIST)); + return ResponseFromResourceRegistry.fromException(new WebCodeException(RMCode.CONTEXT_ALREADY_EXIST)); } catch (ResourceRegistryException e) { - return ResponseFromResourceRegistry.fromException(new CodeException(RMCode.GENERIC_ERROR_FROM_RR)); + return ResponseFromResourceRegistry.fromException(new WebCodeException(RMCode.GENERIC_ERROR_FROM_RR)); } return ResponseFromResourceRegistry.newSuccessResponseWithMessage("Context successfully created."); } diff --git a/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/context/RequestToResourceRegistry.java b/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/context/RequestToResourceRegistry.java index 38be885..7f01091 100644 --- a/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/context/RequestToResourceRegistry.java +++ b/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/context/RequestToResourceRegistry.java @@ -5,7 +5,7 @@ import java.util.Objects; import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClient; import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClientFactory; import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClientImpl; -import org.gcube.resourcemanagement.manager.io.exceptions.CodeException; +import org.gcube.resourcemanagement.manager.io.exceptions.WebCodeException; import org.gcube.resourcemanagement.manager.io.rs.RMCode; /** @@ -40,7 +40,7 @@ public abstract class RequestToResourceRegistry { this.validate(); } catch (Exception e) { ResponseFromResourceRegistry response = ResponseFromResourceRegistry. - fromException(new CodeException(RMCode.INVALID_REQUEST)); + fromException(new WebCodeException(RMCode.INVALID_REQUEST)); return response; } if (Objects.isNull(this.resourceRegistryContextClient)) diff --git a/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/context/ResponseFromResourceRegistry.java b/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/context/ResponseFromResourceRegistry.java index bb9eeb9..1f631f8 100644 --- a/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/context/ResponseFromResourceRegistry.java +++ b/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/context/ResponseFromResourceRegistry.java @@ -2,7 +2,7 @@ package org.gcube.resourcemanagement.manager.webapp.context; import java.util.Optional; -import org.gcube.resourcemanagement.manager.io.exceptions.CodeException; +import org.gcube.resourcemanagement.manager.io.exceptions.WebCodeException; /** * The response to a {@link RequestToResourceRegistry}. @@ -16,7 +16,7 @@ public class ResponseFromResourceRegistry { private String message; - CodeException exception; + WebCodeException exception; protected ResponseFromResourceRegistry() {} @@ -43,7 +43,7 @@ public class ResponseFromResourceRegistry { * The {@link Exception} returned by the RR. * @return the exception */ - public Optional getException() { + public Optional getException() { return Optional.ofNullable(success? null: this.exception); } @@ -52,7 +52,7 @@ public class ResponseFromResourceRegistry { * @param e * @return the response */ - public static ResponseFromResourceRegistry fromException(CodeException e) { + public static ResponseFromResourceRegistry fromException(WebCodeException e) { ResponseFromResourceRegistry response = new ResponseFromResourceRegistry(); response.success = false; response.exception = e;