From 275d9bf758b307aa41e5515eb637a6336e9b8827 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Thu, 7 Dec 2017 16:27:00 +0000 Subject: [PATCH] Exposed get all context through access port type git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry-client@160193 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/ResourceRegistryClient.java | 2 ++ .../client/ResourceRegistryClientImpl.java | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClient.java b/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClient.java index 459accb..08be8aa 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClient.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClient.java @@ -64,5 +64,7 @@ public interface ResourceRegistryClient { throws SchemaNotFoundException, ResourceRegistryException; public Context getContext(UUID uuid) throws ContextNotFoundException, ResourceRegistryException; + + public List getAllContext() throws ResourceRegistryException; } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java b/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java index 92c1280..16d47c7 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java @@ -22,6 +22,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERNotFound import org.gcube.informationsystem.resourceregistry.api.exceptions.query.InvalidQueryException; import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException; import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath; +import org.gcube.informationsystem.resourceregistry.api.rest.ContextPath; import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPCall; import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPCall.HTTPMETHOD; import org.gcube.informationsystem.resourceregistry.api.utils.Utility; @@ -343,6 +344,36 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { throw new RuntimeException(e); } } + + @Override + public List getAllContext() throws ContextNotFoundException, ResourceRegistryException { + try { + logger.info("Going to read all {}s", Context.NAME); + StringWriter stringWriter = new StringWriter(); + stringWriter.append(PATH_SEPARATOR); + stringWriter.append(AccessPath.ACCESS_PATH_PART); + stringWriter.append(PATH_SEPARATOR); + stringWriter.append(AccessPath.CONTEXT_PATH_PART); + stringWriter.append(PATH_SEPARATOR); + stringWriter.append(ContextPath.ALL_PATH_PART); + + HTTPCall httpCall = getHTTPCall(); + String ret = httpCall.call(String.class, stringWriter.toString(), HTTPMETHOD.GET); + + logger.debug("Got Contexts are {}", ret); + return ISMapper.unmarshalList(Context.class, ret); + } catch (ResourceRegistryException e) { + // logger.trace("Error while getting {} schema for {}", polymorphic ? + // AccessPath.POLYMORPHIC_PARAM + " " : "", + // type, e); + throw e; + } catch (Exception e) { + // logger.trace("Error while getting {}schema for {}", polymorphic ? + // AccessPath.POLYMORPHIC_PARAM + " " : "", + // type, e); + throw new RuntimeException(e); + } + } @Override public List getSchema(Class clazz, Boolean polymorphic)