60 lines
1.6 KiB
Java
60 lines
1.6 KiB
Java
package org.gcube.resourcemanagement.manager.webapp.rs;
|
|
|
|
import static org.gcube.resourcemanagement.manager.io.rs.RMContextPath.GXREST_ROOT;
|
|
import static org.gcube.resourcemanagement.manager.io.rs.RMContextPath.UUID_PARAM;
|
|
|
|
import javax.ws.rs.DELETE;
|
|
import javax.ws.rs.Path;
|
|
import javax.ws.rs.PathParam;
|
|
import javax.ws.rs.Produces;
|
|
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
|
|
*
|
|
* @author Manuele Simi (ISTI CNR)
|
|
*
|
|
*/
|
|
@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
|
|
*/
|
|
@DELETE
|
|
@Path("{" + UUID_PARAM + "}")
|
|
@Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8)
|
|
public Response delete(@PathParam(UUID_PARAM) String uuid) {
|
|
methodOne();
|
|
return null;
|
|
}
|
|
|
|
private void methodOne() {
|
|
methodTwo();
|
|
}
|
|
|
|
private void methodTwo() {
|
|
|
|
//something fails here
|
|
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 methodThree"));
|
|
}
|
|
}
|