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 837b3f0..33e12b9 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClient.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClient.java @@ -113,6 +113,8 @@ public interface ResourceRegistryClient { public Context getContext(UUID uuid) throws ContextNotFoundException, ResourceRegistryException; + public Context getCurrentContext() 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 907fcca..bfbcadb 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/client/ResourceRegistryClientImpl.java @@ -56,6 +56,37 @@ public class ResourceRegistryClientImpl implements ResourceRegistryClient { return httpCall; } + @Override + public Context getCurrentContext() throws ContextNotFoundException, ResourceRegistryException { + try { + logger.info("Going to get current {} ", Context.NAME); + StringWriter stringWriter = new StringWriter(); + stringWriter.append(PATH_SEPARATOR); + stringWriter.append(AccessPath.ACCESS_PATH_PART); + stringWriter.append(PATH_SEPARATOR); + stringWriter.append(AccessPath.CONTEXTS_PATH_PART); + stringWriter.append(PATH_SEPARATOR); + stringWriter.append(AccessPath.CURRENT_CONTEXT); + + HTTPCall httpCall = getHTTPCall(); + Context context = httpCall.call(Context.class, stringWriter.toString(), HTTPMETHOD.GET); + + logger.debug("Got Context is {}", ISMapper.marshal(context)); + return context; + } 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 Context getContext(UUID uuid) throws ContextNotFoundException, ResourceRegistryException { try {