From 882f26ac12b845ff101d193ade58ed394b254a83 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Thu, 28 Oct 2021 13:26:14 +0200 Subject: [PATCH] Added support for context names included in header among UUIDs refs #22090 --- CHANGELOG.md | 1 + .../publisher/ResourceRegistryPublisher.java | 14 ++++++------ .../ResourceRegistryPublisherImpl.java | 22 +++++++++---------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb00319..4df32cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm - Aligned overrided APIs [#21979] - Getting all the relations of a type it is returned a list of relations and not the list of Resources sources of such relation [#22003] - Added check for reserved UUID +- Added support for context names included in header among UUIDs [#22090] ## [v4.1.0] 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 4f5e6c2..0b32b4b 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisher.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisher.java @@ -1,7 +1,7 @@ package org.gcube.informationsystem.resourceregistry.publisher; import java.util.List; -import java.util.Set; +import java.util.Map; import java.util.UUID; import org.gcube.informationsystem.contexts.reference.entities.Context; @@ -226,10 +226,10 @@ public interface ResourceRegistryPublisher { public List removeFromCurrentContext(ERElement er, Boolean dryRun) throws SchemaViolationException, NotFoundException, ContextNotFoundException, ResourceRegistryException; - public Set getElementContexts(String type, UUID instanceUUID) + public Map getElementContexts(String type, UUID instanceUUID) throws NotFoundException, ResourceRegistryException; - public Set getElementContexts(ERElem er) + public Map getElementContexts(ERElem er) throws NotFoundException, ResourceRegistryException; /* ----- */ @@ -258,10 +258,10 @@ public interface ResourceRegistryPublisher { public List removeResourceFromCurrentContext(R resource, Boolean dryRun) throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException; - public Set getResourceContexts(String resourceType, UUID resourceUUID) + public Map getResourceContexts(String resourceType, UUID resourceUUID) throws ResourceNotFoundException, ResourceRegistryException; - public Set getResourceContexts(R resource) + public Map getResourceContexts(R resource) throws ResourceNotFoundException, ResourceRegistryException; /* ----- */ @@ -290,10 +290,10 @@ public interface ResourceRegistryPublisher { public List removeFacetFromCurrentContext(F facet, Boolean dryRun) throws SchemaViolationException, FacetNotFoundException, ContextNotFoundException, ResourceRegistryException; - public Set getFacetContexts(String facetType, UUID facetUUID) + public Map getFacetContexts(String facetType, UUID facetUUID) throws FacetNotFoundException, ResourceRegistryException; - public Set getFacetContexts(F facet) + public Map getFacetContexts(F facet) throws FacetNotFoundException, 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 630480a..9a1ef07 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisherImpl.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/publisher/ResourceRegistryPublisherImpl.java @@ -5,7 +5,6 @@ import java.net.HttpURLConnection; import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Set; import java.util.UUID; import org.gcube.common.gxhttp.reference.GXConnection; @@ -906,7 +905,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher } @Override - public Set getElementContexts(String type, UUID instanceUUID) + public Map getElementContexts(String type, UUID instanceUUID) throws NotFoundException, ResourceRegistryException { try { logger.trace("Going to get contexts of {} with UUID {}", type, instanceUUID); @@ -918,10 +917,11 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher gxHTTPStringRequest.path(SharingPath.CONTEXTS_PATH_PART); HttpURLConnection httpURLConnection = gxHTTPStringRequest.get(); - String jsonArray = HTTPUtility.getResponse(String.class, httpURLConnection); - Set contexts = ContextUtility.getContextUUIDSet(jsonArray); - - logger.info("Contexts of {} with UUID {} are {}", type, instanceUUID, contexts); + String objectNode = HTTPUtility.getResponse(String.class, httpURLConnection); + + logger.info("Contexts of {} with UUID {} are {}", type, instanceUUID, objectNode); + + Map contexts = ContextUtility.getContextMap(objectNode); return contexts; @@ -935,7 +935,7 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher } @Override - public Set getElementContexts(ERElem er) + public Map getElementContexts(ERElem er) throws NotFoundException, ResourceRegistryException { String type = org.gcube.informationsystem.resourceregistry.api.utils.Utility.getTypeName(er); UUID instanceUUID = er.getHeader().getUUID(); @@ -991,13 +991,13 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher } @Override - public Set getResourceContexts(String resourceType, UUID resourceUUID) + public Map getResourceContexts(String resourceType, UUID resourceUUID) throws ResourceNotFoundException, ResourceRegistryException { return getElementContexts(resourceType, resourceUUID); } @Override - public Set getResourceContexts(R resource) + public Map getResourceContexts(R resource) throws ResourceNotFoundException, ResourceRegistryException { return getElementContexts(resource); } @@ -1051,13 +1051,13 @@ public class ResourceRegistryPublisherImpl implements ResourceRegistryPublisher } @Override - public Set getFacetContexts(String facetType, UUID facetUUID) + public Map getFacetContexts(String facetType, UUID facetUUID) throws FacetNotFoundException, ResourceRegistryException { return getElementContexts(facetType, facetUUID); } @Override - public Set getFacetContexts(F facet) + public Map getFacetContexts(F facet) throws FacetNotFoundException, ResourceRegistryException { return getElementContexts(facet); }