Rename CodeException to WebCodeException to make it clear that it is a subclass of WebAppException.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/resource-management/resource-manager@161930 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
5c9549160c
commit
a70350c9df
|
@ -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());
|
||||
}
|
|
@ -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)
|
||||
*
|
||||
|
|
|
@ -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()));
|
||||
|
||||
|
|
|
@ -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.");
|
||||
}
|
||||
|
|
|
@ -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))
|
||||
|
|
|
@ -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<CodeException> getException() {
|
||||
public Optional<WebCodeException> 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;
|
||||
|
|
Reference in New Issue