Adapt outbound responses to the latest changes in gxRest.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/resource-management/resource-manager@165682 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
7aee1a7989
commit
91821885d0
|
@ -6,6 +6,7 @@ import javax.ws.rs.Path;
|
|||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
||||
|
@ -54,8 +55,8 @@ public class RMContext {
|
|||
else
|
||||
GXOutboundErrorResponse.throwException(new Exception("Failed to create the context."));
|
||||
}
|
||||
return GXOutboundSuccessResponse.newCREATEResponse(null).withMessage("Context successfully created.")
|
||||
.ofType(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8).build();
|
||||
return GXOutboundSuccessResponse.newCREATEResponse(null).withContent("Context successfully created.")
|
||||
.ofType(MediaType.TEXT_PLAIN).build();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -79,7 +80,7 @@ public class RMContext {
|
|||
else
|
||||
GXOutboundErrorResponse.throwException(new Exception("Failed to delete the context."));
|
||||
}
|
||||
return GXOutboundSuccessResponse.newOKResponse().withMessage("Context successfully deleted.")
|
||||
.ofType(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8).build();
|
||||
return GXOutboundSuccessResponse.newOKResponse().withContent("Context successfully deleted.")
|
||||
.ofType(MediaType.TEXT_PLAIN).build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ import javax.ws.rs.core.Response;
|
|||
import org.gcube.common.gxrest.response.outbound.GXOutboundErrorResponse;
|
||||
import org.gcube.resourcemanagement.manager.io.rs.RMContextDoesNotExistException;
|
||||
import org.gcube.resourcemanagement.manager.webapp.ResourceInitializer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Tests for gxrest
|
||||
|
@ -22,6 +24,8 @@ import org.gcube.resourcemanagement.manager.webapp.ResourceInitializer;
|
|||
@Path(GXREST_ROOT)
|
||||
public class RMTestForGXRest {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(RMTestForGXRest.class);
|
||||
|
||||
/** e.g. DELETE
|
||||
* /resource-manager/gxrest/UUID?rrURL=http://registry:port//resource-
|
||||
* registry
|
||||
|
@ -30,7 +34,7 @@ public class RMTestForGXRest {
|
|||
@Path("{" + UUID_PARAM + "}")
|
||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||
public Response delete(@PathParam(UUID_PARAM) String uuid) {
|
||||
methodThree();
|
||||
methodOne();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -41,14 +45,15 @@ public class RMTestForGXRest {
|
|||
private void methodTwo() {
|
||||
|
||||
//something fails here
|
||||
|
||||
GXOutboundErrorResponse.throwExceptionWithTrace(new RMContextDoesNotExistException("Error in methodTwo"),3);
|
||||
logger.error("method 2 failed");
|
||||
GXOutboundErrorResponse.throwExceptionWithTrace(new RMContextDoesNotExistException("Error in methodTwo"),3,Response.Status.BAD_REQUEST);
|
||||
}
|
||||
|
||||
private void methodThree() {
|
||||
|
||||
//something fails here
|
||||
logger.error("method 3 failed");
|
||||
|
||||
GXOutboundErrorResponse.throwException(new RMContextDoesNotExistException("Error in methodTwo"));
|
||||
GXOutboundErrorResponse.throwException(new RMContextDoesNotExistException("Error in methodThree"));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -139,7 +139,7 @@ public class GXRestTest extends JerseyTest {
|
|||
|
||||
} else {
|
||||
assertEquals("Unexpected returned code. Reason: " + response.getHTTPCode(),
|
||||
Status.NOT_ACCEPTABLE.getStatusCode(), delete.getStatus());
|
||||
Status.BAD_REQUEST.getStatusCode(), delete.getStatus());
|
||||
if (response.hasException()) {
|
||||
try {
|
||||
response.getException().printStackTrace();
|
||||
|
|
Loading…
Reference in New Issue