|
|
|
@ -5,6 +5,7 @@ import java.util.Objects;
|
|
|
|
|
import org.gcube.informationsystem.model.entity.Context;
|
|
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
|
|
|
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.context.ContextAlreadyPresentException;
|
|
|
|
|
import org.gcube.resourcemanagement.manager.io.codeexceptions.LocalCodeException;
|
|
|
|
|
import org.gcube.resourcemanagement.manager.io.codeexceptions.WebCodeException;
|
|
|
|
|
import org.gcube.resourcemanagement.manager.io.rs.RMCreateContextCode;
|
|
|
|
|
|
|
|
|
@ -31,12 +32,13 @@ public final class CreateRequest extends RequestToResourceRegistry {
|
|
|
|
|
* @see org.gcube.resourcemanagement.manager.webapp.context.RequestToResourceRegistry#validate()
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public CreateRequest validate() throws Exception {
|
|
|
|
|
//TODO: to implement
|
|
|
|
|
public void validate() throws LocalCodeException {
|
|
|
|
|
if (Objects.nonNull(this.context.getParent())) {
|
|
|
|
|
throw new Exception("Unable to manage a context with parent.");
|
|
|
|
|
Context parent = new Queries().fetchContext(this.context.getParent().getHeader().getUUID(), this.getContextClient());
|
|
|
|
|
if (Objects.isNull(parent)) {
|
|
|
|
|
throw new LocalCodeException(RMCreateContextCode.CONTEXT_PARENT_DOES_NOT_EXIST);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* (non-Javadoc)
|
|
|
|
@ -45,7 +47,7 @@ public final class CreateRequest extends RequestToResourceRegistry {
|
|
|
|
|
@Override
|
|
|
|
|
protected ResponseFromResourceRegistry send() {
|
|
|
|
|
try {
|
|
|
|
|
Context created = resourceRegistryContextClient.create(context);
|
|
|
|
|
Context created = this.getContextClient().create(context);
|
|
|
|
|
if (Objects.nonNull(created)) {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|