Different instantiations for RRContextClient according to the forceURL parameter.

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/resource-management/resource-manager@160619 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Manuele Simi 2017-12-17 03:42:14 +00:00
parent d6bdcd615f
commit 6db70871b8
2 changed files with 17 additions and 7 deletions

View File

@ -3,6 +3,7 @@ package org.gcube.resourcemanagement.manager.webapp.context;
import java.util.Objects;
import org.gcube.informationsystem.model.entity.Context;
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
/**
* Actions that can be performed on the context.
@ -40,7 +41,15 @@ public final class CreateRequest extends RequestToResourceRegistry {
*/
@Override
protected ResponseFromResourceRegistry send() {
//TODO: to implement
try {
Context created = resourceRegistryContextClient.create(context);
if (Objects.nonNull(created)) {
}
} catch (ResourceRegistryException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return ResponseFromResourceRegistry.newSuccessResponseWithMessage("Context successfully created.");
}

View File

@ -1,7 +1,10 @@
package org.gcube.resourcemanagement.manager.webapp.context;
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;
/**
* Base request to an operation exposed by the Resource Registry.
@ -11,10 +14,7 @@ import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryCont
*/
public abstract class RequestToResourceRegistry {
protected String forceURL = "";
protected ResourceRegistryContextClient resourceRegistryContextClient =
ResourceRegistryContextClientFactory.create();
protected ResourceRegistryContextClient resourceRegistryContextClient;
/**
* Forces to use a RR instance at the given url.
@ -22,8 +22,7 @@ public abstract class RequestToResourceRegistry {
* @param forceURL
*/
public RequestToResourceRegistry forceURL(String forceURL) {
if (!forceURL.isEmpty())
this.forceURL = forceURL;
this.resourceRegistryContextClient = new ResourceRegistryContextClientImpl(forceURL);
return this;
}
@ -42,6 +41,8 @@ public abstract class RequestToResourceRegistry {
"Failed to validate the request. The request was not submitted to the Resource Registry.");
return response;
}
if (Objects.isNull(this.resourceRegistryContextClient))
this.resourceRegistryContextClient = ResourceRegistryContextClientFactory.create();
return this.send();
}