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 5f08f35..2e12e77 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/Access.java @@ -13,6 +13,7 @@ import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; import javax.ws.rs.core.Response.Status; +import org.gcube.common.authorization.library.provider.CalledMethodProvider; import org.gcube.informationsystem.resourceregistry.ResourceInitializer; import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException; import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERAvailableInAnotherContextException; @@ -20,6 +21,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.httputils.HTTPCall.HTTPMETHOD; import org.gcube.informationsystem.resourceregistry.er.ERManagement; import org.gcube.informationsystem.resourceregistry.er.entity.EntityManagement; import org.gcube.informationsystem.resourceregistry.er.relation.RelationManagement; @@ -86,6 +88,10 @@ public class Access { public Response exists(@PathParam(TYPE_PATH_PARAM) String type, @PathParam(ID_PATH_PARAM) String id) throws ERNotFoundException, ERAvailableInAnotherContextException, ResourceRegistryException { + CalledMethodProvider.instance.set( + HTTPMETHOD.HEAD.name() + " /" + AccessPath.ACCESS_PATH_PART + + "/" + AccessPath.INSTANCE_PATH_PART + "/" + type + "/{" + ID_PATH_PARAM + "}"); + logger.info("Requested to check if {} with id {} exists", type, id); @SuppressWarnings("rawtypes") ERManagement erManagement = ERManagement.getERManagement(type); @@ -126,6 +132,11 @@ public class Access { public String getInstance(@PathParam(TYPE_PATH_PARAM) String type, @PathParam(ID_PATH_PARAM) String id) throws ERNotFoundException, ResourceRegistryException { + + CalledMethodProvider.instance.set( + HTTPMETHOD.GET.name() + " /" + AccessPath.ACCESS_PATH_PART + + "/" + AccessPath.INSTANCE_PATH_PART + "/" + type + "/{" + ID_PATH_PARAM + "}"); + logger.info("Requested {} with id {}", type, id); @SuppressWarnings("rawtypes") diff --git a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/ERManager.java b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/ERManager.java index 88aaeab..537f41d 100644 --- a/src/main/java/org/gcube/informationsystem/resourceregistry/rest/ERManager.java +++ b/src/main/java/org/gcube/informationsystem/resourceregistry/rest/ERManager.java @@ -47,11 +47,6 @@ public class ERManager { public static final String ID_PATH_PARAM = "id"; public static final String TYPE_PATH_PARAM = "type"; - /* - public static final String SOURCE_ID_PATH_PARAM = "sourceId"; - public static final String TARGET_ID_PATH_PARAM = "targetId"; - */ - /** * e.g. PUT /resource-registry/er/facet/ContactFacet * @@ -65,7 +60,7 @@ public class ERManager { public Response createFacet(@PathParam(TYPE_PATH_PARAM) String type, String json) throws FacetAlreadyPresentException, ResourceRegistryException { CalledMethodProvider.instance.set( - HTTPMETHOD.PUT.name() + "/" + ERPath.ER_PATH_PART + + HTTPMETHOD.PUT.name() + " /" + ERPath.ER_PATH_PART + "/" + ERPath.FACET_PATH_PART + "/" + type); logger.info("requested facet creation for type {}", type); logger.trace("requested facet creation for type {} defined by {} ", type, json); @@ -90,7 +85,7 @@ public class ERManager { public String updateFacet(@PathParam(ID_PATH_PARAM) String uuid, String json) throws FacetNotFoundException, ResourceRegistryException { CalledMethodProvider.instance.set( - HTTPMETHOD.POST.name() + "/" + ERPath.ER_PATH_PART + + HTTPMETHOD.POST.name() + " /" + ERPath.ER_PATH_PART + "/" + ERPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}"); logger.info("requested facet update for id {}", uuid); logger.trace("requested facet update for id {} with {}", uuid, json); @@ -109,7 +104,7 @@ public class ERManager { public boolean deleteFacet(@PathParam(ID_PATH_PARAM) String uuid) throws FacetNotFoundException, ResourceRegistryException { CalledMethodProvider.instance.set( - HTTPMETHOD.DELETE.name() + "/" + ERPath.ER_PATH_PART + + HTTPMETHOD.DELETE.name() + " /" + ERPath.ER_PATH_PART + "/" + ERPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}"); logger.info("Requested to delete Facet with id {}", uuid); FacetManagement facetManagement = new FacetManagement(); @@ -132,7 +127,7 @@ public class ERManager { public Response createResource(@PathParam(TYPE_PATH_PARAM) String type, String json) throws ResourceAlreadyPresentException, ResourceRegistryException { CalledMethodProvider.instance.set( - HTTPMETHOD.PUT.name() + "/" + ERPath.ER_PATH_PART + + HTTPMETHOD.PUT.name() + " /" + ERPath.ER_PATH_PART + "/" + ERPath.RESOURCE_PATH_PART + "/" + type); logger.info("requested resource creation for type {}", type); logger.trace("requested resource creation for type {} with json {}", type, json); @@ -157,7 +152,7 @@ public class ERManager { public String updateResource(@PathParam(ID_PATH_PARAM) String uuid, String json) throws ResourceNotFoundException, ResourceRegistryException { CalledMethodProvider.instance.set( - HTTPMETHOD.POST.name() + "/" + ERPath.ER_PATH_PART + + HTTPMETHOD.POST.name() + " /" + ERPath.ER_PATH_PART + "/" + ERPath.RESOURCE_PATH_PART + "/{" + ID_PATH_PARAM + "}"); logger.info("requested resource update for id {}", uuid); logger.trace("requested resource update for id {} with {}", uuid, json); @@ -175,7 +170,7 @@ public class ERManager { @Path(ERPath.RESOURCE_PATH_PART + "/{" + ID_PATH_PARAM + "}") public boolean deleteResource(@PathParam(ID_PATH_PARAM) String uuid) throws ResourceNotFoundException, Exception { CalledMethodProvider.instance.set( - HTTPMETHOD.DELETE.name() + "/" + ERPath.ER_PATH_PART + + HTTPMETHOD.DELETE.name() + " /" + ERPath.ER_PATH_PART + "/" + ERPath.RESOURCE_PATH_PART + "/{" + ID_PATH_PARAM + "}"); logger.info("requested resource deletion for id {}", uuid); ResourceManagement resourceManagement = new ResourceManagement(); @@ -197,7 +192,7 @@ public class ERManager { public Response createConsistsOf(@PathParam(TYPE_PATH_PARAM) String type, String json) throws ResourceAlreadyPresentException, ResourceRegistryException { CalledMethodProvider.instance.set( - HTTPMETHOD.PUT.name() + "/" + ERPath.ER_PATH_PART + + HTTPMETHOD.PUT.name() + " /" + ERPath.ER_PATH_PART + "/" + ERPath.CONSISTS_OF_PATH_PART + "/" + type); logger.info("Requested to create {} {} of type {}", ConsistsOf.NAME, Relation.NAME, type); logger.trace("Requested to create {} {} of type {} : {}", ConsistsOf.NAME, Relation.NAME, type, json); @@ -217,7 +212,7 @@ public class ERManager { @Path(ERPath.CONSISTS_OF_PATH_PART + "/{" + ID_PATH_PARAM + "}") public boolean detachFacet(@PathParam(ID_PATH_PARAM) String consistOfUUID) throws ResourceRegistryException { CalledMethodProvider.instance.set( - HTTPMETHOD.DELETE.name() + "/" + ERPath.ER_PATH_PART + + HTTPMETHOD.DELETE.name() + " /" + ERPath.ER_PATH_PART + "/" + ERPath.CONSISTS_OF_PATH_PART + "/{" + ID_PATH_PARAM + "}"); logger.info("requested to detach {}", consistOfUUID); ConsistsOfManagement consistsOfManagement = new ConsistsOfManagement(); @@ -238,7 +233,7 @@ public class ERManager { public Response createIsRelatedTo(@PathParam(TYPE_PATH_PARAM) String type, String json) throws ResourceAlreadyPresentException, ResourceRegistryException { CalledMethodProvider.instance.set( - HTTPMETHOD.PUT.name() + "/" + ERPath.ER_PATH_PART + + HTTPMETHOD.PUT.name() + " /" + ERPath.ER_PATH_PART + "/" + ERPath.IS_RELATED_TO_PATH_PART + "/" + type); logger.info("Requested to create {} {} of type {} : {}", IsRelatedTo.NAME, Relation.NAME, type, json); IsRelatedToManagement isRelatedToManagement = new IsRelatedToManagement(); @@ -257,7 +252,7 @@ public class ERManager { @Path(ERPath.IS_RELATED_TO_PATH_PART + "/{" + ID_PATH_PARAM + "}") public boolean detachResource(@PathParam(ID_PATH_PARAM) String relatedToUUID) throws ResourceRegistryException { CalledMethodProvider.instance.set( - HTTPMETHOD.DELETE.name() + "/" + ERPath.ER_PATH_PART + + HTTPMETHOD.DELETE.name() + " /" + ERPath.ER_PATH_PART + "/" + ERPath.IS_RELATED_TO_PATH_PART + "/{" + ID_PATH_PARAM + "}"); logger.info("requested to detach {}", relatedToUUID); IsRelatedToManagement isRelatedToManagement = new IsRelatedToManagement(); @@ -274,7 +269,7 @@ public class ERManager { public boolean addResourceToContext(@PathParam(ID_PATH_PARAM) String uuid) throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException { CalledMethodProvider.instance.set( - HTTPMETHOD.POST.name() + "/" + ERPath.ER_PATH_PART + + HTTPMETHOD.POST.name() + " /" + ERPath.ER_PATH_PART + "/" + ERPath.ADD_PATH_PART + "/" + ERPath.RESOURCE_PATH_PART + "/{" + ID_PATH_PARAM + "}"); logger.info("requested to add {} with UUID {} to current context {}", Resource.NAME, uuid, ContextUtility.getCurrentContext()); @@ -292,7 +287,7 @@ public class ERManager { public boolean addFacetToContext(@PathParam(ID_PATH_PARAM) String uuid) throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException { CalledMethodProvider.instance.set( - HTTPMETHOD.POST.name() + "/" + ERPath.ER_PATH_PART + + HTTPMETHOD.POST.name() + " /" + ERPath.ER_PATH_PART + "/" + ERPath.ADD_PATH_PART + "/" + ERPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}"); logger.info("requested to add {} with UUID {} to current context {}", Facet.NAME, uuid, ContextUtility.getCurrentContext()); @@ -310,7 +305,7 @@ public class ERManager { public boolean removeResourceFromContext(@PathParam(ID_PATH_PARAM) String uuid) throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException { CalledMethodProvider.instance.set( - HTTPMETHOD.POST.name() + "/" + ERPath.ER_PATH_PART + + HTTPMETHOD.POST.name() + " /" + ERPath.ER_PATH_PART + "/" + ERPath.REMOVE_PATH_PART + "/" + ERPath.RESOURCE_PATH_PART + "/{" + ID_PATH_PARAM + "}"); logger.info("requested to remove {} with UUID {} from current context {}", Resource.NAME, uuid, ContextUtility.getCurrentContext()); @@ -328,7 +323,7 @@ public class ERManager { public boolean removeFacetFromContext(@PathParam(ID_PATH_PARAM) String uuid) throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException { CalledMethodProvider.instance.set( - HTTPMETHOD.POST.name() + "/" + ERPath.ER_PATH_PART + + HTTPMETHOD.POST.name() + " /" + ERPath.ER_PATH_PART + "/" + ERPath.REMOVE_PATH_PART + "/" + ERPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}"); logger.info("requested to remove {} with UUID {} from current context {}", Facet.NAME, uuid, ContextUtility.getCurrentContext());