|
|
|
@ -5,8 +5,8 @@ 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.codeexceptions.LocalCodeException;
|
|
|
|
|
import org.gcube.resourcemanagement.manager.io.codeexceptions.WebCodeException;
|
|
|
|
|
import org.gcube.resourcemanagement.manager.io.rs.RMCreateContextCode;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Base request to an operation exposed by the Resource Registry.
|
|
|
|
@ -31,16 +31,16 @@ public abstract class RequestToResourceRegistry {
|
|
|
|
|
/**
|
|
|
|
|
* Validates the request.
|
|
|
|
|
*
|
|
|
|
|
* @return the response from the service.
|
|
|
|
|
* @throws LocalCodeException
|
|
|
|
|
*/
|
|
|
|
|
abstract public RequestToResourceRegistry validate() throws Exception;
|
|
|
|
|
abstract public void validate() throws LocalCodeException;
|
|
|
|
|
|
|
|
|
|
public ResponseFromResourceRegistry submit() {
|
|
|
|
|
try {
|
|
|
|
|
this.validate();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
} catch (LocalCodeException e) {
|
|
|
|
|
ResponseFromResourceRegistry response = ResponseFromResourceRegistry.
|
|
|
|
|
fromException(new WebCodeException(RMCreateContextCode.INVALID_REQUEST_FOR_RR));
|
|
|
|
|
fromException(new WebCodeException(e));
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
if (Objects.isNull(this.resourceRegistryContextClient))
|
|
|
|
@ -58,6 +58,13 @@ public abstract class RequestToResourceRegistry {
|
|
|
|
|
// by default, returns the response as it is
|
|
|
|
|
return response;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return the context client
|
|
|
|
|
*/
|
|
|
|
|
ResourceRegistryContextClient getContextClient() {
|
|
|
|
|
return resourceRegistryContextClient;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Submits the request to the RR.
|
|
|
|
|