diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisher.java b/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisher.java index 2c775f6..b63b447 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisher.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisher.java @@ -51,9 +51,20 @@ public interface ResourceRegistryPublisher extends RequestInfo { public void addHeader(String name, String value); - + /** + * Use {@link #getContexts()} instead + * @return an array containing all contexts definition + * @throws ResourceRegistryException if fails + */ + @Deprecated public List getAllContext() throws ResourceRegistryException; + /** + * @return an array containing all contexts definition + * @throws ResourceRegistryException if fails + */ + public List getContexts() throws ResourceRegistryException; + public Context getContext(UUID uuid) throws ContextNotFoundException, ResourceRegistryException; public Context getCurrentContext() throws ContextNotFoundException, ResourceRegistryException; diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisherImpl.java b/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisherImpl.java index 4b3e086..e5374c4 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisherImpl.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisherImpl.java @@ -10,12 +10,10 @@ import java.util.UUID; import org.gcube.common.gxhttp.reference.GXConnection; import org.gcube.common.gxhttp.request.GXHTTPStringRequest; import org.gcube.common.http.GXHTTPUtility; -import org.gcube.informationsystem.base.reference.IdentifiableElement; import org.gcube.informationsystem.contexts.reference.entities.Context; import org.gcube.informationsystem.model.reference.ERElement; import org.gcube.informationsystem.model.reference.entities.Facet; import org.gcube.informationsystem.model.reference.entities.Resource; -import org.gcube.informationsystem.model.reference.properties.Metadata; import org.gcube.informationsystem.model.reference.relations.ConsistsOf; import org.gcube.informationsystem.model.reference.relations.IsRelatedTo; import org.gcube.informationsystem.resourceregistry.api.contexts.ContextCache; @@ -39,6 +37,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.isr import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.isrelatedto.IsRelatedToAvailableInAnotherContextException; import org.gcube.informationsystem.resourceregistry.api.exceptions.relations.isrelatedto.IsRelatedToNotFoundException; import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaViolationException; +import org.gcube.informationsystem.resourceregistry.api.request.BaseRequestInfo; import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath; import org.gcube.informationsystem.resourceregistry.api.rest.InstancePath; import org.gcube.informationsystem.resourceregistry.api.rest.SharingPath; @@ -51,7 +50,7 @@ import org.gcube.informationsystem.utils.UUIDUtility; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher { +public class ResourceRegistryPublisherImpl extends BaseRequestInfo implements ResourceRegistryPublisher { private static final Logger logger = LoggerFactory.getLogger(ResourceRegistryPublisherImpl.class); @@ -61,27 +60,6 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher protected final String address; protected Map headers; - - /** - * Track if the client must request the hierarchicalMode - */ - protected boolean hierarchicalMode; - - /** - * Track if the client must request to include contexts - */ - protected boolean includeContexts; - - /** - * Track if the client must request to include {@link Metadata} - */ - protected boolean includeMeta; - - /** - * Track if the client must request to include {@link Metadata} in all - * {@link IdentifiableElement} or just in the root instance - */ - protected boolean allMeta; protected ContextCache contextCache; @@ -107,32 +85,6 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher setIncludeContexts(includeContexts); } - @Override - public boolean includeContexts() { - return includeContexts; - } - - @Override - public void setIncludeContexts(boolean includeContexts) { - this.includeContexts = includeContexts; - } - - public boolean includeMeta() { - return includeMeta; - } - - public void setIncludeMeta(boolean includeMeta) { - this.includeMeta = includeMeta; - } - - public boolean allMeta() { - return allMeta; - } - - public void setAllMeta(boolean allMeta) { - this.allMeta = allMeta; - } - private void addOptionalQueryParameters(Map queryParams) throws UnsupportedEncodingException { addHierarchicalMode(queryParams); addIncludeContexts(queryParams); @@ -181,7 +133,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher @Override public List renew() throws ResourceRegistryException { - return getAllContextFromServer(); + return getContextsFromServer(); } }; @@ -205,12 +157,9 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher } public ResourceRegistryPublisherImpl(String address, boolean sharedContextCache) { + super(); this.address = address; this.headers = new HashMap<>(); - this.hierarchicalMode = false; - this.includeContexts = false; - this.includeMeta = false; - this.allMeta = false; if(sharedContextCache) { contextCache = ContextCache.getInstance(); }else { @@ -225,7 +174,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher * @return All Contexts read from server * @throws ResourceRegistryException */ - public List getAllContextFromServer() throws ResourceRegistryException { + public List getContextsFromServer() throws ResourceRegistryException { try { logger.info("Going to read all {}s", Context.NAME); GXHTTPStringRequest gxHTTPStringRequest = getGXHTTPStringRequest(); @@ -255,9 +204,15 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher throw new RuntimeException(e); } } - + + @Deprecated @Override public List getAllContext() throws ResourceRegistryException { + return getContexts(); + } + + @Override + public List getContexts() throws ResourceRegistryException { return contextCache.getContexts(); } diff --git a/src/test/java/org/gcube/informationsystem/resourceregistry/publisher/old/MultiContextTest.java b/src/test/java/org/gcube/informationsystem/resourceregistry/publisher/old/MultiContextTest.java index 8166932..3b3f30e 100644 --- a/src/test/java/org/gcube/informationsystem/resourceregistry/publisher/old/MultiContextTest.java +++ b/src/test/java/org/gcube/informationsystem/resourceregistry/publisher/old/MultiContextTest.java @@ -224,8 +224,8 @@ public class MultiContextTest extends ContextTest { } @Test - public void testGetAllContexts() throws Exception { - List contexts = resourceRegistryPublisher.getAllContext(); + public void testGetContexts() throws Exception { + List contexts = resourceRegistryPublisher.getContexts(); logger.debug("{}", contexts); ContextCache contextCache = ContextCache.getInstance();