|
|
|
@ -9,13 +9,10 @@ import javax.ws.rs.QueryParam;
|
|
|
|
|
import javax.ws.rs.core.Response;
|
|
|
|
|
|
|
|
|
|
import org.gcube.common.authorization.library.provider.CalledMethodProvider;
|
|
|
|
|
import org.gcube.common.gxrest.response.error.GXErrorOutboundResponse;
|
|
|
|
|
import org.gcube.common.gxrest.response.success.GXOutboundSuccessResponse;
|
|
|
|
|
import org.gcube.common.gxrest.response.outbound.GXOutboundErrorResponse;
|
|
|
|
|
import org.gcube.common.gxrest.response.outbound.GXOutboundSuccessResponse;
|
|
|
|
|
import org.gcube.informationsystem.model.entity.Context;
|
|
|
|
|
import static org.gcube.resourcemanagement.manager.io.rs.RMContextPath.*;
|
|
|
|
|
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
import org.gcube.resourcemanagement.manager.webapp.ResourceInitializer;
|
|
|
|
|
import org.gcube.resourcemanagement.manager.webapp.context.CreateRequest;
|
|
|
|
|
import org.gcube.resourcemanagement.manager.webapp.context.DeleteRequest;
|
|
|
|
@ -23,6 +20,8 @@ import org.gcube.resourcemanagement.manager.webapp.context.ResponseFromResourceR
|
|
|
|
|
import org.gcube.resourcemanagement.manager.webapp.context.ContextHolder;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Resource methods for {@link Context}.
|
|
|
|
@ -49,11 +48,11 @@ public class RMContext {
|
|
|
|
|
ResponseFromResourceRegistry returned = CreateRequest.fromHolder(holder).forceURL(rrURL).submit();
|
|
|
|
|
if (!returned.wasSuccessful()) {
|
|
|
|
|
if (returned.getException().isPresent())
|
|
|
|
|
GXErrorOutboundResponse.throwException(returned.getException().get());
|
|
|
|
|
GXOutboundErrorResponse.throwException(returned.getException().get());
|
|
|
|
|
else if (returned.getErrorCode().isPresent())
|
|
|
|
|
GXErrorOutboundResponse.throwErrorCode(returned.getErrorCode().get());
|
|
|
|
|
GXOutboundErrorResponse.throwErrorCode(returned.getErrorCode().get());
|
|
|
|
|
else
|
|
|
|
|
GXErrorOutboundResponse.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.")
|
|
|
|
|
.ofType(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8).build();
|
|
|
|
@ -74,11 +73,11 @@ public class RMContext {
|
|
|
|
|
ResponseFromResourceRegistry returned = DeleteRequest.fromUUID(UUID.fromString(uuid)).forceURL(rrURL).submit();
|
|
|
|
|
if (!returned.wasSuccessful()) {
|
|
|
|
|
if (returned.getException().isPresent())
|
|
|
|
|
GXErrorOutboundResponse.throwException(returned.getException().get());
|
|
|
|
|
GXOutboundErrorResponse.throwException(returned.getException().get());
|
|
|
|
|
else if (returned.getErrorCode().isPresent())
|
|
|
|
|
GXErrorOutboundResponse.throwErrorCode(returned.getErrorCode().get());
|
|
|
|
|
GXOutboundErrorResponse.throwErrorCode(returned.getErrorCode().get());
|
|
|
|
|
else
|
|
|
|
|
GXErrorOutboundResponse.throwException(new Exception("Failed to delete the context."));
|
|
|
|
|
GXOutboundErrorResponse.throwException(new Exception("Failed to delete the context."));
|
|
|
|
|
}
|
|
|
|
|
return GXOutboundSuccessResponse.newOKResponse().withMessage("Context successfully deleted.")
|
|
|
|
|
.ofType(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8).build();
|
|
|
|
|