Rename RMCode to RMCreateContextCode.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/resource-management/resource-manager@162299 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Manuele Simi 2018-01-18 05:05:35 +00:00
parent 60a49651a5
commit f08c550f1d
6 changed files with 16 additions and 16 deletions

View File

@ -8,7 +8,7 @@ import org.gcube.resourcemanagement.manager.io.codeexceptions.ErrorCode;
* @author Manuele Simi (ISTI CNR) * @author Manuele Simi (ISTI CNR)
* *
*/ */
public enum RMCode implements ErrorCode { public enum RMCreateContextCode implements ErrorCode {
INVALID_METHOD_REQUEST(0, "The request is invalid."), INVALID_METHOD_REQUEST(0, "The request is invalid."),
MISSING_PARAMETER(1,"Required query parameter is missing."), MISSING_PARAMETER(1,"Required query parameter is missing."),
@ -21,7 +21,7 @@ public enum RMCode implements ErrorCode {
private int id; private int id;
private String msg; private String msg;
private RMCode(int id, String msg) { private RMCreateContextCode(int id, String msg) {
this.id = id; this.id = id;
this.msg = msg; this.msg = msg;
} }

View File

@ -6,7 +6,7 @@ package org.gcube.resourcemanagement.manager.io.codeexceptions;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.gcube.resourcemanagement.manager.io.codeexceptions.LocalCodeException; import org.gcube.resourcemanagement.manager.io.codeexceptions.LocalCodeException;
import org.gcube.resourcemanagement.manager.io.rs.RMCode; import org.gcube.resourcemanagement.manager.io.rs.RMCreateContextCode;
import org.junit.Test; import org.junit.Test;
/** /**
@ -22,8 +22,8 @@ public class LocalCodeExceptionTest {
*/ */
@Test @Test
public void testCodeException() { public void testCodeException() {
LocalCodeException exception = new LocalCodeException(RMCode.GENERIC_ERROR_FROM_RR); LocalCodeException exception = new LocalCodeException(RMCreateContextCode.GENERIC_ERROR_FROM_RR);
assertTrue("Unexpected id", exception.getId() == RMCode.GENERIC_ERROR_FROM_RR.getId()); assertTrue("Unexpected id", exception.getId() == RMCreateContextCode.GENERIC_ERROR_FROM_RR.getId());
} }
} }

View File

@ -5,7 +5,7 @@ import static org.junit.Assert.*;
import java.util.Objects; import java.util.Objects;
import org.gcube.resourcemanagement.manager.io.codeexceptions.WebCodeException; import org.gcube.resourcemanagement.manager.io.codeexceptions.WebCodeException;
import org.gcube.resourcemanagement.manager.io.rs.RMCode; import org.gcube.resourcemanagement.manager.io.rs.RMCreateContextCode;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.junit.runners.BlockJUnit4ClassRunner; import org.junit.runners.BlockJUnit4ClassRunner;
@ -21,11 +21,11 @@ public class WebCodeExceptionTest {
/** /**
* Test method for * Test method for
* {@link org.gcube.resourcemanagement.manager.io.codeexceptions.WebCodeException#CodeException(org.gcube.resourcemanagement.manager.io.rs.RMCode)}. * {@link org.gcube.resourcemanagement.manager.io.codeexceptions.WebCodeException#CodeException(org.gcube.resourcemanagement.manager.io.rs.RMCreateContextCode)}.
*/ */
@Test @Test
public void testWebCodeException() { public void testWebCodeException() {
WebCodeException exception = new WebCodeException(RMCode.CONTEXT_ALREADY_EXISTS); WebCodeException exception = new WebCodeException(RMCreateContextCode.CONTEXT_ALREADY_EXISTS);
// unfortunately, we cannot test the response readEntity method on an // unfortunately, we cannot test the response readEntity method on an
// outbound response // outbound response
assertTrue("Unexpected code", Objects.nonNull(exception.getResponse())); assertTrue("Unexpected code", Objects.nonNull(exception.getResponse()));

View File

@ -6,7 +6,7 @@ import org.gcube.informationsystem.model.entity.Context;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; 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.ContextAlreadyPresentException;
import org.gcube.resourcemanagement.manager.io.codeexceptions.WebCodeException; import org.gcube.resourcemanagement.manager.io.codeexceptions.WebCodeException;
import org.gcube.resourcemanagement.manager.io.rs.RMCode; import org.gcube.resourcemanagement.manager.io.rs.RMCreateContextCode;
/** /**
* Create request for a new context. * Create request for a new context.
@ -52,9 +52,9 @@ public final class CreateRequest extends RequestToResourceRegistry {
return ResponseFromResourceRegistry.newFailureResponse("Invalid response from the RR (null?)"); return ResponseFromResourceRegistry.newFailureResponse("Invalid response from the RR (null?)");
} }
} catch (ContextAlreadyPresentException cape) { } catch (ContextAlreadyPresentException cape) {
return ResponseFromResourceRegistry.fromException(new WebCodeException(RMCode.CONTEXT_ALREADY_EXISTS)); return ResponseFromResourceRegistry.fromException(new WebCodeException(RMCreateContextCode.CONTEXT_ALREADY_EXISTS));
} catch (ResourceRegistryException e) { } catch (ResourceRegistryException e) {
return ResponseFromResourceRegistry.fromException(new WebCodeException(RMCode.GENERIC_ERROR_FROM_RR)); return ResponseFromResourceRegistry.fromException(new WebCodeException(RMCreateContextCode.GENERIC_ERROR_FROM_RR));
} }
return ResponseFromResourceRegistry.newSuccessResponseWithMessage("Context successfully created."); return ResponseFromResourceRegistry.newSuccessResponseWithMessage("Context successfully created.");
} }

View File

@ -6,7 +6,7 @@ import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryCont
import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClientFactory; import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClientFactory;
import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClientImpl; import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClientImpl;
import org.gcube.resourcemanagement.manager.io.codeexceptions.WebCodeException; import org.gcube.resourcemanagement.manager.io.codeexceptions.WebCodeException;
import org.gcube.resourcemanagement.manager.io.rs.RMCode; import org.gcube.resourcemanagement.manager.io.rs.RMCreateContextCode;
/** /**
* Base request to an operation exposed by the Resource Registry. * Base request to an operation exposed by the Resource Registry.
@ -40,7 +40,7 @@ public abstract class RequestToResourceRegistry {
this.validate(); this.validate();
} catch (Exception e) { } catch (Exception e) {
ResponseFromResourceRegistry response = ResponseFromResourceRegistry. ResponseFromResourceRegistry response = ResponseFromResourceRegistry.
fromException(new WebCodeException(RMCode.INVALID_REQUEST_FOR_RR)); fromException(new WebCodeException(RMCreateContextCode.INVALID_REQUEST_FOR_RR));
return response; return response;
} }
if (Objects.isNull(this.resourceRegistryContextClient)) if (Objects.isNull(this.resourceRegistryContextClient))

View File

@ -21,7 +21,7 @@ import org.gcube.informationsystem.impl.utils.ISMapper;
import org.gcube.informationsystem.model.entity.Context; import org.gcube.informationsystem.model.entity.Context;
import org.gcube.resourcemanagement.manager.io.codeexceptions.CodeFinder; import org.gcube.resourcemanagement.manager.io.codeexceptions.CodeFinder;
import org.gcube.resourcemanagement.manager.io.codeexceptions.SerializableErrorCode; import org.gcube.resourcemanagement.manager.io.codeexceptions.SerializableErrorCode;
import org.gcube.resourcemanagement.manager.io.rs.RMCode; import org.gcube.resourcemanagement.manager.io.rs.RMCreateContextCode;
import org.gcube.resourcemanagement.manager.io.rs.RMContextPath; import org.gcube.resourcemanagement.manager.io.rs.RMContextPath;
import org.gcube.resourcemanagement.manager.webapp.rs.RMContext; import org.gcube.resourcemanagement.manager.webapp.rs.RMContext;
import org.glassfish.jersey.server.ResourceConfig; import org.glassfish.jersey.server.ResourceConfig;
@ -124,8 +124,8 @@ public class RMContextTest extends JerseyTest {
assertEquals("Unexpected returned code. Reason: " + create.getStatusInfo().getReasonPhrase(), assertEquals("Unexpected returned code. Reason: " + create.getStatusInfo().getReasonPhrase(),
Status.NOT_ACCEPTABLE.getStatusCode(), create.getStatus()); Status.NOT_ACCEPTABLE.getStatusCode(), create.getStatus());
SerializableErrorCode code = create.readEntity(SerializableErrorCode.class); SerializableErrorCode code = create.readEntity(SerializableErrorCode.class);
RMCode realCode = CodeFinder.findAndConvert(code, RMCode.values()); RMCreateContextCode realCode = CodeFinder.findAndConvert(code, RMCreateContextCode.values());
assertEquals(RMCode.CONTEXT_ALREADY_EXISTS, realCode); assertEquals(RMCreateContextCode.CONTEXT_ALREADY_EXISTS, realCode);
} }
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {