Force to use the resource registry client when a FORCE_RRURL parameter is specified in the request.
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/resource-management/resource-manager@165589 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
fecaee352c
commit
17d9b96aa1
|
@ -37,7 +37,7 @@ public final class CreateRequest extends RequestToResourceRegistry {
|
|||
try {
|
||||
IsParentOf<Context, Context> relationship = this.context.getParent();
|
||||
logger.info("Fetching parent with UUID: " + relationship.getSource().getHeader().getUUID().toString());
|
||||
Context parent = new Queries(this.getContextClient()).fetchContext(relationship.getSource().getHeader().getUUID());
|
||||
Context parent = new Queries(this.getContextClient(), this.getRegistryClient()).fetchContext(relationship.getSource().getHeader().getUUID());
|
||||
if (Objects.isNull(parent)) {
|
||||
throw new LocalCodeException(RMCreateContextCode.CONTEXT_PARENT_DOES_NOT_EXIST);
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public final class DeleteRequest extends RequestToResourceRegistry {
|
|||
*/
|
||||
@Override
|
||||
public void validate() throws LocalCodeException {
|
||||
Queries queries = new Queries(this.getContextClient());
|
||||
Queries queries = new Queries(this.getContextClient(), this.getRegistryClient());
|
||||
if (!queries.contextExists(context)) {
|
||||
throw new LocalCodeException(RMDeleteContextCode.CONTEXT_DOES_NOT_EXIST);
|
||||
}
|
||||
|
|
|
@ -33,9 +33,9 @@ final class Queries {
|
|||
*
|
||||
* @param cclient
|
||||
*/
|
||||
protected Queries(ResourceRegistryContextClient cclient) {
|
||||
protected Queries(ResourceRegistryContextClient cclient, ResourceRegistryClient rclient) {
|
||||
this.cclient = cclient;
|
||||
this.rclient = ResourceRegistryClientFactory.create();
|
||||
this.rclient =rclient;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -3,6 +3,9 @@ package org.gcube.resourcemanagement.manager.webapp.context;
|
|||
import java.util.Objects;
|
||||
|
||||
import org.gcube.common.gxrest.response.outbound.LocalCodeException;
|
||||
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient;
|
||||
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientFactory;
|
||||
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientImpl;
|
||||
import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClient;
|
||||
import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClientFactory;
|
||||
import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClientImpl;
|
||||
|
@ -18,6 +21,7 @@ import org.slf4j.LoggerFactory;
|
|||
public abstract class RequestToResourceRegistry {
|
||||
|
||||
protected ResourceRegistryContextClient resourceRegistryContextClient;
|
||||
private ResourceRegistryClientImpl resourceResourceRegistryClient;
|
||||
protected static Logger logger = LoggerFactory.getLogger(RequestToResourceRegistry.class);
|
||||
|
||||
/**
|
||||
|
@ -27,6 +31,7 @@ public abstract class RequestToResourceRegistry {
|
|||
*/
|
||||
public RequestToResourceRegistry forceURL(String forceURL) {
|
||||
this.resourceRegistryContextClient = new ResourceRegistryContextClientImpl(forceURL);
|
||||
this.resourceResourceRegistryClient = new ResourceRegistryClientImpl(forceURL);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -71,6 +76,17 @@ public abstract class RequestToResourceRegistry {
|
|||
return ResourceRegistryContextClientFactory.create();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the registry client
|
||||
*/
|
||||
ResourceRegistryClient getRegistryClient() {
|
||||
if (Objects.nonNull(this.resourceResourceRegistryClient)) {
|
||||
return this.resourceResourceRegistryClient;
|
||||
} else {
|
||||
return ResourceRegistryClientFactory.create();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits the request to the RR.
|
||||
|
|
|
@ -16,6 +16,8 @@ import org.gcube.common.authorization.library.AuthorizationEntry;
|
|||
import org.gcube.common.authorization.library.provider.SecurityTokenProvider;
|
||||
import org.gcube.common.scope.api.ScopeProvider;
|
||||
import org.gcube.informationsystem.model.entity.Context;
|
||||
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClient;
|
||||
import org.gcube.informationsystem.resourceregistry.client.ResourceRegistryClientImpl;
|
||||
import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClient;
|
||||
import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClientImpl;
|
||||
import org.junit.AfterClass;
|
||||
|
@ -90,8 +92,9 @@ public class QueriesTest {
|
|||
public void testContextExists() {
|
||||
if (skipTest)
|
||||
return;
|
||||
ResourceRegistryContextClient client = new ResourceRegistryContextClientImpl(RR);
|
||||
Queries queries = new Queries(client);
|
||||
ResourceRegistryContextClient cclient = new ResourceRegistryContextClientImpl(RR);
|
||||
ResourceRegistryClient rclient = new ResourceRegistryClientImpl(RR);
|
||||
Queries queries = new Queries(cclient, rclient);
|
||||
assertFalse("Context does exist, but it should not", queries.contextExists(UUID.randomUUID()));
|
||||
}
|
||||
|
||||
|
@ -102,8 +105,9 @@ public class QueriesTest {
|
|||
public void testFetchContext() {
|
||||
if (skipTest)
|
||||
return;
|
||||
ResourceRegistryContextClient client = new ResourceRegistryContextClientImpl(RR);
|
||||
Queries queries = new Queries(client);
|
||||
ResourceRegistryContextClient cclient = new ResourceRegistryContextClientImpl(RR);
|
||||
ResourceRegistryClient rclient = new ResourceRegistryClientImpl(RR);
|
||||
Queries queries = new Queries(cclient, rclient);
|
||||
Context context = queries.fetchContext(context1UUID);
|
||||
assertNotNull("Context does not exist.", context);
|
||||
assertEquals("Unexpected uuid for context", context1UUID, context.getHeader().getUUID());
|
||||
|
|
|
@ -28,7 +28,6 @@ import org.gcube.informationsystem.model.entity.Context;
|
|||
import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClient;
|
||||
import org.gcube.informationsystem.resourceregistry.context.ResourceRegistryContextClientImpl;
|
||||
import org.gcube.resourcemanagement.manager.io.rs.RMCreateContextCode;
|
||||
import org.gcube.resourcemanagement.manager.io.rs.RMContextDoesNotExistException;
|
||||
import org.gcube.resourcemanagement.manager.io.rs.RMContextPath;
|
||||
import org.gcube.resourcemanagement.manager.webapp.rs.RMContext;
|
||||
import org.glassfish.jersey.server.ResourceConfig;
|
||||
|
|
Reference in New Issue