From 4e6d0a1192945a2308daa86e4a6038bd14f406fd Mon Sep 17 00:00:00 2001 From: "manuele.simi" Date: Wed, 10 Jan 2018 04:12:00 +0000 Subject: [PATCH] Rename package exceptions to codeexceptions. git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/resource-management/resource-manager@162028 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../io/{exceptions => codeexceptions}/CodeEntity.java | 2 +- .../io/{exceptions => codeexceptions}/CodeFinder.java | 2 +- .../io/{exceptions => codeexceptions}/ErrorCode.java | 2 +- .../LocalCodeException.java | 2 +- .../SerializableErrorCode.java | 2 +- .../{exceptions => codeexceptions}/WebCodeException.java | 2 +- .../manager/io/codeexceptions/package-info.java | 8 ++++++++ .../manager/io/exceptions/package-info.java | 6 ------ .../gcube/resourcemanagement/manager/io/rs/RMCode.java | 2 +- .../LocalCodeExceptionTest.java | 5 +++-- .../WebCodeExceptionTest.java | 6 +++--- .../manager/webapp/context/CreateRequest.java | 2 +- .../manager/webapp/context/RequestToResourceRegistry.java | 4 ++-- .../webapp/context/ResponseFromResourceRegistry.java | 2 +- .../resourcemanagement/manager/webapp/rs/RMContext.java | 6 ++---- .../manager/webapp/context/RMContextTest.java | 4 ++-- 16 files changed, 29 insertions(+), 28 deletions(-) rename io/src/main/java/org/gcube/resourcemanagement/manager/io/{exceptions => codeexceptions}/CodeEntity.java (84%) rename io/src/main/java/org/gcube/resourcemanagement/manager/io/{exceptions => codeexceptions}/CodeFinder.java (90%) rename io/src/main/java/org/gcube/resourcemanagement/manager/io/{exceptions => codeexceptions}/ErrorCode.java (81%) rename io/src/main/java/org/gcube/resourcemanagement/manager/io/{exceptions => codeexceptions}/LocalCodeException.java (88%) rename io/src/main/java/org/gcube/resourcemanagement/manager/io/{exceptions => codeexceptions}/SerializableErrorCode.java (92%) rename io/src/main/java/org/gcube/resourcemanagement/manager/io/{exceptions => codeexceptions}/WebCodeException.java (91%) create mode 100644 io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/package-info.java delete mode 100644 io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/package-info.java rename io/src/test/java/org/gcube/resourcemanagement/manager/io/{exceptions => codeexceptions}/LocalCodeExceptionTest.java (67%) rename io/src/test/java/org/gcube/resourcemanagement/manager/io/{exceptions => codeexceptions}/WebCodeExceptionTest.java (71%) diff --git a/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/CodeEntity.java b/io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/CodeEntity.java similarity index 84% rename from io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/CodeEntity.java rename to io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/CodeEntity.java index 175bd3c..a4d408a 100644 --- a/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/CodeEntity.java +++ b/io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/CodeEntity.java @@ -1,4 +1,4 @@ -package org.gcube.resourcemanagement.manager.io.exceptions; +package org.gcube.resourcemanagement.manager.io.codeexceptions; import javax.ws.rs.core.GenericEntity; diff --git a/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/CodeFinder.java b/io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/CodeFinder.java similarity index 90% rename from io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/CodeFinder.java rename to io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/CodeFinder.java index ad8aeea..572402c 100644 --- a/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/CodeFinder.java +++ b/io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/CodeFinder.java @@ -1,4 +1,4 @@ -package org.gcube.resourcemanagement.manager.io.exceptions; +package org.gcube.resourcemanagement.manager.io.codeexceptions; import java.util.stream.Stream; diff --git a/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/ErrorCode.java b/io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/ErrorCode.java similarity index 81% rename from io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/ErrorCode.java rename to io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/ErrorCode.java index 9a1a194..4e9c18b 100644 --- a/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/ErrorCode.java +++ b/io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/ErrorCode.java @@ -1,4 +1,4 @@ -package org.gcube.resourcemanagement.manager.io.exceptions; +package org.gcube.resourcemanagement.manager.io.codeexceptions; /** * Interface for error codes. diff --git a/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/LocalCodeException.java b/io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/LocalCodeException.java similarity index 88% rename from io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/LocalCodeException.java rename to io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/LocalCodeException.java index 979ce81..d418b58 100644 --- a/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/LocalCodeException.java +++ b/io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/LocalCodeException.java @@ -1,5 +1,5 @@ -package org.gcube.resourcemanagement.manager.io.exceptions; +package org.gcube.resourcemanagement.manager.io.codeexceptions; /** * A local exception wrapping an {@link ErrorCode}. diff --git a/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/SerializableErrorCode.java b/io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/SerializableErrorCode.java similarity index 92% rename from io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/SerializableErrorCode.java rename to io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/SerializableErrorCode.java index b0a114b..facf9a7 100644 --- a/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/SerializableErrorCode.java +++ b/io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/SerializableErrorCode.java @@ -1,4 +1,4 @@ -package org.gcube.resourcemanagement.manager.io.exceptions; +package org.gcube.resourcemanagement.manager.io.codeexceptions; /** * An {@link ErrorCode} that can be serialized in a {@link WebCodeException}. diff --git a/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/WebCodeException.java b/io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/WebCodeException.java similarity index 91% rename from io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/WebCodeException.java rename to io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/WebCodeException.java index 65d545d..eef72a9 100644 --- a/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/WebCodeException.java +++ b/io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/WebCodeException.java @@ -1,4 +1,4 @@ -package org.gcube.resourcemanagement.manager.io.exceptions; +package org.gcube.resourcemanagement.manager.io.codeexceptions; import javax.ws.rs.WebApplicationException; import javax.ws.rs.core.Response; diff --git a/io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/package-info.java b/io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/package-info.java new file mode 100644 index 0000000..a405f84 --- /dev/null +++ b/io/src/main/java/org/gcube/resourcemanagement/manager/io/codeexceptions/package-info.java @@ -0,0 +1,8 @@ +/** + * Code Exception is capable to hold an error code + * and an associated message, wrap them into a REST response and return them to the caller. + * + * @author Manuele Simi (ISTI - CNR) + * + */ +package org.gcube.resourcemanagement.manager.io.codeexceptions; \ No newline at end of file diff --git a/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/package-info.java b/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/package-info.java deleted file mode 100644 index fb4958e..0000000 --- a/io/src/main/java/org/gcube/resourcemanagement/manager/io/exceptions/package-info.java +++ /dev/null @@ -1,6 +0,0 @@ -/** - * Exception handling in the Resource Management. - * @author Manuele Simi (ISTI - CNR) - * - */ -package org.gcube.resourcemanagement.manager.io.exceptions; \ No newline at end of file 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 6652d42..bb2efe2 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,6 +1,6 @@ package org.gcube.resourcemanagement.manager.io.rs; -import org.gcube.resourcemanagement.manager.io.exceptions.ErrorCode; +import org.gcube.resourcemanagement.manager.io.codeexceptions.ErrorCode; /** * Error codes returned by the context resource. diff --git a/io/src/test/java/org/gcube/resourcemanagement/manager/io/exceptions/LocalCodeExceptionTest.java b/io/src/test/java/org/gcube/resourcemanagement/manager/io/codeexceptions/LocalCodeExceptionTest.java similarity index 67% rename from io/src/test/java/org/gcube/resourcemanagement/manager/io/exceptions/LocalCodeExceptionTest.java rename to io/src/test/java/org/gcube/resourcemanagement/manager/io/codeexceptions/LocalCodeExceptionTest.java index d4c457a..4eec33d 100644 --- a/io/src/test/java/org/gcube/resourcemanagement/manager/io/exceptions/LocalCodeExceptionTest.java +++ b/io/src/test/java/org/gcube/resourcemanagement/manager/io/codeexceptions/LocalCodeExceptionTest.java @@ -1,10 +1,11 @@ /** * */ -package org.gcube.resourcemanagement.manager.io.exceptions; +package org.gcube.resourcemanagement.manager.io.codeexceptions; import static org.junit.Assert.*; +import org.gcube.resourcemanagement.manager.io.codeexceptions.LocalCodeException; import org.gcube.resourcemanagement.manager.io.rs.RMCode; import org.junit.Test; @@ -17,7 +18,7 @@ import org.junit.Test; public class LocalCodeExceptionTest { /** - * Test method for {@link org.gcube.resourcemanagement.manager.io.exceptions.LocalCodeException#CodeException(org.gcube.resourcemanagement.manager.io.exceptions.ErrorCode)}. + * Test method for {@link org.gcube.resourcemanagement.manager.io.codeexceptions.LocalCodeException#CodeException(org.gcube.resourcemanagement.manager.io.codeexceptions.ErrorCode)}. */ @Test public void testCodeException() { diff --git a/io/src/test/java/org/gcube/resourcemanagement/manager/io/exceptions/WebCodeExceptionTest.java b/io/src/test/java/org/gcube/resourcemanagement/manager/io/codeexceptions/WebCodeExceptionTest.java similarity index 71% rename from io/src/test/java/org/gcube/resourcemanagement/manager/io/exceptions/WebCodeExceptionTest.java rename to io/src/test/java/org/gcube/resourcemanagement/manager/io/codeexceptions/WebCodeExceptionTest.java index 1102623..fe225d8 100644 --- a/io/src/test/java/org/gcube/resourcemanagement/manager/io/exceptions/WebCodeExceptionTest.java +++ b/io/src/test/java/org/gcube/resourcemanagement/manager/io/codeexceptions/WebCodeExceptionTest.java @@ -1,10 +1,10 @@ -package org.gcube.resourcemanagement.manager.io.exceptions; +package org.gcube.resourcemanagement.manager.io.codeexceptions; import static org.junit.Assert.*; import java.util.Objects; -import org.gcube.resourcemanagement.manager.io.exceptions.WebCodeException; +import org.gcube.resourcemanagement.manager.io.codeexceptions.WebCodeException; import org.gcube.resourcemanagement.manager.io.rs.RMCode; import org.junit.Test; import org.junit.runner.RunWith; @@ -21,7 +21,7 @@ public class WebCodeExceptionTest { /** * Test method for - * {@link org.gcube.resourcemanagement.manager.io.exceptions.WebCodeException#CodeException(org.gcube.resourcemanagement.manager.io.rs.RMCode)}. + * {@link org.gcube.resourcemanagement.manager.io.codeexceptions.WebCodeException#CodeException(org.gcube.resourcemanagement.manager.io.rs.RMCode)}. */ @Test public void testWebCodeException() { 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 cadf64a..30c060e 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.WebCodeException; +import org.gcube.resourcemanagement.manager.io.codeexceptions.WebCodeException; import org.gcube.resourcemanagement.manager.io.rs.RMCode; /** 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 7f01091..66e6ead 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.WebCodeException; +import org.gcube.resourcemanagement.manager.io.codeexceptions.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 WebCodeException(RMCode.INVALID_REQUEST)); + fromException(new WebCodeException(RMCode.INVALID_REQUEST_FOR_RR)); 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 1f631f8..70d78e3 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.WebCodeException; +import org.gcube.resourcemanagement.manager.io.codeexceptions.WebCodeException; /** * The response to a {@link RequestToResourceRegistry}. diff --git a/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/rs/RMContext.java b/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/rs/RMContext.java index e1726a3..4d9a145 100644 --- a/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/rs/RMContext.java +++ b/webapp/src/main/java/org/gcube/resourcemanagement/manager/webapp/rs/RMContext.java @@ -12,8 +12,8 @@ import org.gcube.common.authorization.library.provider.CalledMethodProvider; import org.gcube.informationsystem.model.entity.Context; import static org.gcube.resourcemanagement.manager.io.rs.RMContextPath.*; -import org.gcube.resourcemanagement.manager.io.exceptions.LocalCodeException; -import org.gcube.resourcemanagement.manager.io.exceptions.WebCodeException; +import org.gcube.resourcemanagement.manager.io.codeexceptions.LocalCodeException; +import org.gcube.resourcemanagement.manager.io.codeexceptions.WebCodeException; import org.gcube.resourcemanagement.manager.io.rs.RMCode; import org.gcube.resourcemanagement.manager.webapp.ResourceInitializer; import org.gcube.resourcemanagement.manager.webapp.context.CreateRequest; @@ -56,8 +56,6 @@ public class RMContext { response = Response.status(Status.BAD_REQUEST) .entity(returned.getMessage().map(m -> m).orElse("Failed to create the context.")).build(); } - LocalCodeException lce = null - throw new WebCodeException(lce); return response; } @DELETE diff --git a/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/context/RMContextTest.java b/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/context/RMContextTest.java index ad1dd41..04e30f2 100644 --- a/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/context/RMContextTest.java +++ b/webapp/src/test/java/org/gcube/resourcemanagement/manager/webapp/context/RMContextTest.java @@ -18,8 +18,8 @@ import org.gcube.common.scope.api.ScopeProvider; import org.gcube.informationsystem.impl.entity.ContextImpl; import org.gcube.informationsystem.impl.utils.ISMapper; import org.gcube.informationsystem.model.entity.Context; -import org.gcube.resourcemanagement.manager.io.exceptions.CodeFinder; -import org.gcube.resourcemanagement.manager.io.exceptions.SerializableErrorCode; +import org.gcube.resourcemanagement.manager.io.codeexceptions.CodeFinder; +import org.gcube.resourcemanagement.manager.io.codeexceptions.SerializableErrorCode; import org.gcube.resourcemanagement.manager.io.rs.RMCode; import org.gcube.resourcemanagement.manager.io.rs.RMContextPath; import org.gcube.resourcemanagement.manager.webapp.rs.RMContext;