Added support for context names included in header among UUIDs refs

#22090
This commit is contained in:
Luca Frosini 2021-10-28 11:19:50 +02:00
parent 57d0a5dbc4
commit e907c029f9
3 changed files with 8 additions and 9 deletions

View File

@ -6,6 +6,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
- Aligned APIs to other clients [#22011] - Aligned APIs to other clients [#22011]
- Moved Direction class in information-system-model - Moved Direction class in information-system-model
- Added support for context names included in header among UUIDs [#22090]
## [v4.1.0] ## [v4.1.0]

View File

@ -2,7 +2,6 @@ package org.gcube.informationsystem.resourceregistry.client;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import org.gcube.informationsystem.base.reference.Direction; import org.gcube.informationsystem.base.reference.Direction;
@ -97,10 +96,10 @@ public interface ResourceRegistryClient {
public List<Context> getAllContext() throws ResourceRegistryException; public List<Context> getAllContext() throws ResourceRegistryException;
public <ERElem extends ERElement> Set<UUID> getInstanceContexts(Class<ERElem> clazz, UUID uuid) public <ERElem extends ERElement> Map<UUID, String> getInstanceContexts(Class<ERElem> clazz, UUID uuid)
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException; throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException;
public Set<UUID> getInstanceContexts(String type, UUID uuid) public Map<UUID, String> getInstanceContexts(String type, UUID uuid)
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException; throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException;
} }

View File

@ -5,7 +5,6 @@ import java.net.HttpURLConnection;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set;
import java.util.UUID; import java.util.UUID;
import org.gcube.common.gxhttp.reference.GXConnection; import org.gcube.common.gxhttp.reference.GXConnection;
@ -609,14 +608,14 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
} }
@Override @Override
public <ERElem extends ERElement> Set<UUID> getInstanceContexts(Class<ERElem> clazz, UUID uuid) public <ERElem extends ERElement> Map<UUID, String> getInstanceContexts(Class<ERElem> clazz, UUID uuid)
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException { throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
String typeName = Utility.getTypeName(clazz); String typeName = Utility.getTypeName(clazz);
return getInstanceContexts(typeName, uuid); return getInstanceContexts(typeName, uuid);
} }
@Override @Override
public Set<UUID> getInstanceContexts(String type, UUID uuid) public Map<UUID, String> getInstanceContexts(String type, UUID uuid)
throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException { throws NotFoundException, AvailableInAnotherContextException, ResourceRegistryException {
try { try {
logger.trace("Going to get contexts of {} with UUID {}", type, uuid); logger.trace("Going to get contexts of {} with UUID {}", type, uuid);
@ -630,11 +629,11 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient {
gxHTTPStringRequest.path(AccessPath.CONTEXTS_PATH_PART); gxHTTPStringRequest.path(AccessPath.CONTEXTS_PATH_PART);
HttpURLConnection httpURLConnection = gxHTTPStringRequest.get(); HttpURLConnection httpURLConnection = gxHTTPStringRequest.get();
String jsonArray = HTTPUtility.getResponse(String.class, httpURLConnection); String objectNode = HTTPUtility.getResponse(String.class, httpURLConnection);
logger.info("Contexts of {} with UUID {} are {}", type, uuid, jsonArray); logger.info("Contexts of {} with UUID {} are {}", type, uuid, objectNode);
Set<UUID> contexts = ContextUtility.getContextUUIDSet(jsonArray); Map<UUID, String> contexts = ContextUtility.getContextMap(objectNode);
return contexts; return contexts;
} catch(ResourceRegistryException e) { } catch(ResourceRegistryException e) {
// logger.trace("Error while getting {} with UUID {}", type, uuid, e); // logger.trace("Error while getting {} with UUID {}", type, uuid, e);