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.PathParam;
|
||||||
import javax.ws.rs.Produces;
|
import javax.ws.rs.Produces;
|
||||||
import javax.ws.rs.QueryParam;
|
import javax.ws.rs.QueryParam;
|
||||||
|
import javax.ws.rs.core.MediaType;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
|
|
||||||
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
||||||
|
@ -54,8 +55,8 @@ public class RMContext {
|
||||||
else
|
else
|
||||||
GXOutboundErrorResponse.throwException(new Exception("Failed to create the context."));
|
GXOutboundErrorResponse.throwException(new Exception("Failed to create the context."));
|
||||||
}
|
}
|
||||||
return GXOutboundSuccessResponse.newCREATEResponse(null).withMessage("Context successfully created.")
|
return GXOutboundSuccessResponse.newCREATEResponse(null).withContent("Context successfully created.")
|
||||||
.ofType(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8).build();
|
.ofType(MediaType.TEXT_PLAIN).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -79,7 +80,7 @@ public class RMContext {
|
||||||
else
|
else
|
||||||
GXOutboundErrorResponse.throwException(new Exception("Failed to delete the context."));
|
GXOutboundErrorResponse.throwException(new Exception("Failed to delete the context."));
|
||||||
}
|
}
|
||||||
return GXOutboundSuccessResponse.newOKResponse().withMessage("Context successfully deleted.")
|
return GXOutboundSuccessResponse.newOKResponse().withContent("Context successfully deleted.")
|
||||||
.ofType(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8).build();
|
.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.common.gxrest.response.outbound.GXOutboundErrorResponse;
|
||||||
import org.gcube.resourcemanagement.manager.io.rs.RMContextDoesNotExistException;
|
import org.gcube.resourcemanagement.manager.io.rs.RMContextDoesNotExistException;
|
||||||
import org.gcube.resourcemanagement.manager.webapp.ResourceInitializer;
|
import org.gcube.resourcemanagement.manager.webapp.ResourceInitializer;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests for gxrest
|
* Tests for gxrest
|
||||||
|
@ -22,6 +24,8 @@ import org.gcube.resourcemanagement.manager.webapp.ResourceInitializer;
|
||||||
@Path(GXREST_ROOT)
|
@Path(GXREST_ROOT)
|
||||||
public class RMTestForGXRest {
|
public class RMTestForGXRest {
|
||||||
|
|
||||||
|
private static Logger logger = LoggerFactory.getLogger(RMTestForGXRest.class);
|
||||||
|
|
||||||
/** e.g. DELETE
|
/** e.g. DELETE
|
||||||
* /resource-manager/gxrest/UUID?rrURL=http://registry:port//resource-
|
* /resource-manager/gxrest/UUID?rrURL=http://registry:port//resource-
|
||||||
* registry
|
* registry
|
||||||
|
@ -30,7 +34,7 @@ public class RMTestForGXRest {
|
||||||
@Path("{" + UUID_PARAM + "}")
|
@Path("{" + UUID_PARAM + "}")
|
||||||
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
||||||
public Response delete(@PathParam(UUID_PARAM) String uuid) {
|
public Response delete(@PathParam(UUID_PARAM) String uuid) {
|
||||||
methodThree();
|
methodOne();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,14 +45,15 @@ public class RMTestForGXRest {
|
||||||
private void methodTwo() {
|
private void methodTwo() {
|
||||||
|
|
||||||
//something fails here
|
//something fails here
|
||||||
|
logger.error("method 2 failed");
|
||||||
GXOutboundErrorResponse.throwExceptionWithTrace(new RMContextDoesNotExistException("Error in methodTwo"),3);
|
GXOutboundErrorResponse.throwExceptionWithTrace(new RMContextDoesNotExistException("Error in methodTwo"),3,Response.Status.BAD_REQUEST);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void methodThree() {
|
private void methodThree() {
|
||||||
|
|
||||||
//something fails here
|
//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 {
|
} else {
|
||||||
assertEquals("Unexpected returned code. Reason: " + response.getHTTPCode(),
|
assertEquals("Unexpected returned code. Reason: " + response.getHTTPCode(),
|
||||||
Status.NOT_ACCEPTABLE.getStatusCode(), delete.getStatus());
|
Status.BAD_REQUEST.getStatusCode(), delete.getStatus());
|
||||||
if (response.hasException()) {
|
if (response.hasException()) {
|
||||||
try {
|
try {
|
||||||
response.getException().printStackTrace();
|
response.getException().printStackTrace();
|
||||||
|
|
Loading…
Reference in New Issue