diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java index fb7d87d..60f89b9 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java @@ -34,6 +34,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.Schema import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath; import org.gcube.informationsystem.resourceregistry.api.rest.httputils.HTTPCall.HTTPMETHOD; import org.gcube.informationsystem.resourceregistry.context.ContextManagement; +import org.gcube.informationsystem.resourceregistry.context.ContextUtility; import org.gcube.informationsystem.resourceregistry.er.ERManagement; import org.gcube.informationsystem.resourceregistry.er.ERManagementUtility; import org.gcube.informationsystem.resourceregistry.er.entity.ResourceManagement; @@ -114,17 +115,22 @@ public class Access { * e.g. GET /access/contexts/c0f314e7-2807-4241-a792-2a6c79ed4fd0 */ @GET - @Path(AccessPath.CONTEXTS_PATH_PART + "{" + AccessPath.UUID_PATH_PARAM + "}") + @Path(AccessPath.CONTEXTS_PATH_PART + "/{" + AccessPath.UUID_PATH_PARAM + "}") @Consumes({MediaType.TEXT_PLAIN, ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8}) @Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8) public String getContext(@PathParam(AccessPath.UUID_PATH_PARAM) String uuid) throws ContextNotFoundException, ResourceRegistryException { - ContextManagement contextManagement = new ContextManagement(); + if(uuid.compareTo(AccessPath.CURRENT_CONTEXT)==0){ + uuid = ContextUtility.getCurrentSecurityContext().getUUID().toString(); + } logger.info("Requested to read {} with id {} ", org.gcube.informationsystem.model.entity.Context.NAME, uuid); + List pathValues = new ArrayList<>(); pathValues.add(AccessPath.CONTEXTS_PATH_PART); pathValues.add(uuid); setCalledMethodLocal(HTTPMETHOD.GET, pathValues); + + ContextManagement contextManagement = new ContextManagement(); contextManagement.setUUID(UUID.fromString(uuid)); return contextManagement.read(); } diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/ContextManager.java b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/ContextManager.java index 353ea25..24e2a66 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/ContextManager.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/ContextManager.java @@ -76,15 +76,13 @@ public class ContextManager { @Produces(ResourceInitializer.APPLICATION_JSON_CHARSET_UTF_8) public String read(@PathParam(AccessPath.CONTEXT_UUID_PATH_PARAM) String uuid) throws ContextNotFoundException, ResourceRegistryException { - logger.info("Requested to read {} with id {} ", Context.NAME, uuid); - setCalledMethod(HTTPMETHOD.GET, uuid); - - - ContextManagement contextManagement = new ContextManagement(); if(uuid.compareTo(AccessPath.CURRENT_CONTEXT)==0){ uuid = ContextUtility.getCurrentSecurityContext().getUUID().toString(); } + logger.info("Requested to read {} with id {} ", Context.NAME, uuid); + setCalledMethod(HTTPMETHOD.GET, uuid); + ContextManagement contextManagement = new ContextManagement(); contextManagement.setUUID(UUID.fromString(uuid)); return contextManagement.read(); }