REST methods override default ServiceUsageRecord 'calledMethod' field to improve accounting performaces refs #9020
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/information-system/resource-registry@150605 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
31901d5ce3
commit
965954622f
|
@ -13,6 +13,7 @@ import javax.ws.rs.QueryParam;
|
||||||
import javax.ws.rs.core.Response;
|
import javax.ws.rs.core.Response;
|
||||||
import javax.ws.rs.core.Response.Status;
|
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.ResourceInitializer;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.er.ERAvailableInAnotherContextException;
|
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.query.InvalidQueryException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
import org.gcube.informationsystem.resourceregistry.api.exceptions.schema.SchemaNotFoundException;
|
||||||
import org.gcube.informationsystem.resourceregistry.api.rest.AccessPath;
|
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.ERManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.er.entity.EntityManagement;
|
import org.gcube.informationsystem.resourceregistry.er.entity.EntityManagement;
|
||||||
import org.gcube.informationsystem.resourceregistry.er.relation.RelationManagement;
|
import org.gcube.informationsystem.resourceregistry.er.relation.RelationManagement;
|
||||||
|
@ -86,6 +88,10 @@ public class Access {
|
||||||
public Response exists(@PathParam(TYPE_PATH_PARAM) String type,
|
public Response exists(@PathParam(TYPE_PATH_PARAM) String type,
|
||||||
@PathParam(ID_PATH_PARAM) String id) throws ERNotFoundException,
|
@PathParam(ID_PATH_PARAM) String id) throws ERNotFoundException,
|
||||||
ERAvailableInAnotherContextException, ResourceRegistryException {
|
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);
|
logger.info("Requested to check if {} with id {} exists", type, id);
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
ERManagement erManagement = ERManagement.getERManagement(type);
|
ERManagement erManagement = ERManagement.getERManagement(type);
|
||||||
|
@ -126,6 +132,11 @@ public class Access {
|
||||||
public String getInstance(@PathParam(TYPE_PATH_PARAM) String type,
|
public String getInstance(@PathParam(TYPE_PATH_PARAM) String type,
|
||||||
@PathParam(ID_PATH_PARAM) String id)
|
@PathParam(ID_PATH_PARAM) String id)
|
||||||
throws ERNotFoundException, ResourceRegistryException {
|
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);
|
logger.info("Requested {} with id {}", type, id);
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
|
|
|
@ -47,11 +47,6 @@ public class ERManager {
|
||||||
public static final String ID_PATH_PARAM = "id";
|
public static final String ID_PATH_PARAM = "id";
|
||||||
public static final String TYPE_PATH_PARAM = "type";
|
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
|
* 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)
|
public Response createFacet(@PathParam(TYPE_PATH_PARAM) String type, String json)
|
||||||
throws FacetAlreadyPresentException, ResourceRegistryException {
|
throws FacetAlreadyPresentException, ResourceRegistryException {
|
||||||
CalledMethodProvider.instance.set(
|
CalledMethodProvider.instance.set(
|
||||||
HTTPMETHOD.PUT.name() + "/" + ERPath.ER_PATH_PART +
|
HTTPMETHOD.PUT.name() + " /" + ERPath.ER_PATH_PART +
|
||||||
"/" + ERPath.FACET_PATH_PART + "/" + type);
|
"/" + ERPath.FACET_PATH_PART + "/" + type);
|
||||||
logger.info("requested facet creation for type {}", type);
|
logger.info("requested facet creation for type {}", type);
|
||||||
logger.trace("requested facet creation for type {} defined by {} ", type, json);
|
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)
|
public String updateFacet(@PathParam(ID_PATH_PARAM) String uuid, String json)
|
||||||
throws FacetNotFoundException, ResourceRegistryException {
|
throws FacetNotFoundException, ResourceRegistryException {
|
||||||
CalledMethodProvider.instance.set(
|
CalledMethodProvider.instance.set(
|
||||||
HTTPMETHOD.POST.name() + "/" + ERPath.ER_PATH_PART +
|
HTTPMETHOD.POST.name() + " /" + ERPath.ER_PATH_PART +
|
||||||
"/" + ERPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}");
|
"/" + ERPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}");
|
||||||
logger.info("requested facet update for id {}", uuid);
|
logger.info("requested facet update for id {}", uuid);
|
||||||
logger.trace("requested facet update for id {} with {}", uuid, json);
|
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)
|
public boolean deleteFacet(@PathParam(ID_PATH_PARAM) String uuid)
|
||||||
throws FacetNotFoundException, ResourceRegistryException {
|
throws FacetNotFoundException, ResourceRegistryException {
|
||||||
CalledMethodProvider.instance.set(
|
CalledMethodProvider.instance.set(
|
||||||
HTTPMETHOD.DELETE.name() + "/" + ERPath.ER_PATH_PART +
|
HTTPMETHOD.DELETE.name() + " /" + ERPath.ER_PATH_PART +
|
||||||
"/" + ERPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}");
|
"/" + ERPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}");
|
||||||
logger.info("Requested to delete Facet with id {}", uuid);
|
logger.info("Requested to delete Facet with id {}", uuid);
|
||||||
FacetManagement facetManagement = new FacetManagement();
|
FacetManagement facetManagement = new FacetManagement();
|
||||||
|
@ -132,7 +127,7 @@ public class ERManager {
|
||||||
public Response createResource(@PathParam(TYPE_PATH_PARAM) String type, String json)
|
public Response createResource(@PathParam(TYPE_PATH_PARAM) String type, String json)
|
||||||
throws ResourceAlreadyPresentException, ResourceRegistryException {
|
throws ResourceAlreadyPresentException, ResourceRegistryException {
|
||||||
CalledMethodProvider.instance.set(
|
CalledMethodProvider.instance.set(
|
||||||
HTTPMETHOD.PUT.name() + "/" + ERPath.ER_PATH_PART +
|
HTTPMETHOD.PUT.name() + " /" + ERPath.ER_PATH_PART +
|
||||||
"/" + ERPath.RESOURCE_PATH_PART + "/" + type);
|
"/" + ERPath.RESOURCE_PATH_PART + "/" + type);
|
||||||
logger.info("requested resource creation for type {}", type);
|
logger.info("requested resource creation for type {}", type);
|
||||||
logger.trace("requested resource creation for type {} with json {}", type, json);
|
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)
|
public String updateResource(@PathParam(ID_PATH_PARAM) String uuid, String json)
|
||||||
throws ResourceNotFoundException, ResourceRegistryException {
|
throws ResourceNotFoundException, ResourceRegistryException {
|
||||||
CalledMethodProvider.instance.set(
|
CalledMethodProvider.instance.set(
|
||||||
HTTPMETHOD.POST.name() + "/" + ERPath.ER_PATH_PART +
|
HTTPMETHOD.POST.name() + " /" + ERPath.ER_PATH_PART +
|
||||||
"/" + ERPath.RESOURCE_PATH_PART + "/{" + ID_PATH_PARAM + "}");
|
"/" + ERPath.RESOURCE_PATH_PART + "/{" + ID_PATH_PARAM + "}");
|
||||||
logger.info("requested resource update for id {}", uuid);
|
logger.info("requested resource update for id {}", uuid);
|
||||||
logger.trace("requested resource update for id {} with {}", uuid, json);
|
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 + "}")
|
@Path(ERPath.RESOURCE_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
||||||
public boolean deleteResource(@PathParam(ID_PATH_PARAM) String uuid) throws ResourceNotFoundException, Exception {
|
public boolean deleteResource(@PathParam(ID_PATH_PARAM) String uuid) throws ResourceNotFoundException, Exception {
|
||||||
CalledMethodProvider.instance.set(
|
CalledMethodProvider.instance.set(
|
||||||
HTTPMETHOD.DELETE.name() + "/" + ERPath.ER_PATH_PART +
|
HTTPMETHOD.DELETE.name() + " /" + ERPath.ER_PATH_PART +
|
||||||
"/" + ERPath.RESOURCE_PATH_PART + "/{" + ID_PATH_PARAM + "}");
|
"/" + ERPath.RESOURCE_PATH_PART + "/{" + ID_PATH_PARAM + "}");
|
||||||
logger.info("requested resource deletion for id {}", uuid);
|
logger.info("requested resource deletion for id {}", uuid);
|
||||||
ResourceManagement resourceManagement = new ResourceManagement();
|
ResourceManagement resourceManagement = new ResourceManagement();
|
||||||
|
@ -197,7 +192,7 @@ public class ERManager {
|
||||||
public Response createConsistsOf(@PathParam(TYPE_PATH_PARAM) String type, String json)
|
public Response createConsistsOf(@PathParam(TYPE_PATH_PARAM) String type, String json)
|
||||||
throws ResourceAlreadyPresentException, ResourceRegistryException {
|
throws ResourceAlreadyPresentException, ResourceRegistryException {
|
||||||
CalledMethodProvider.instance.set(
|
CalledMethodProvider.instance.set(
|
||||||
HTTPMETHOD.PUT.name() + "/" + ERPath.ER_PATH_PART +
|
HTTPMETHOD.PUT.name() + " /" + ERPath.ER_PATH_PART +
|
||||||
"/" + ERPath.CONSISTS_OF_PATH_PART + "/" + type);
|
"/" + ERPath.CONSISTS_OF_PATH_PART + "/" + type);
|
||||||
logger.info("Requested to create {} {} of type {}", ConsistsOf.NAME, Relation.NAME, 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);
|
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 + "}")
|
@Path(ERPath.CONSISTS_OF_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
||||||
public boolean detachFacet(@PathParam(ID_PATH_PARAM) String consistOfUUID) throws ResourceRegistryException {
|
public boolean detachFacet(@PathParam(ID_PATH_PARAM) String consistOfUUID) throws ResourceRegistryException {
|
||||||
CalledMethodProvider.instance.set(
|
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 + "}");
|
"/" + ERPath.CONSISTS_OF_PATH_PART + "/{" + ID_PATH_PARAM + "}");
|
||||||
logger.info("requested to detach {}", consistOfUUID);
|
logger.info("requested to detach {}", consistOfUUID);
|
||||||
ConsistsOfManagement consistsOfManagement = new ConsistsOfManagement();
|
ConsistsOfManagement consistsOfManagement = new ConsistsOfManagement();
|
||||||
|
@ -238,7 +233,7 @@ public class ERManager {
|
||||||
public Response createIsRelatedTo(@PathParam(TYPE_PATH_PARAM) String type, String json)
|
public Response createIsRelatedTo(@PathParam(TYPE_PATH_PARAM) String type, String json)
|
||||||
throws ResourceAlreadyPresentException, ResourceRegistryException {
|
throws ResourceAlreadyPresentException, ResourceRegistryException {
|
||||||
CalledMethodProvider.instance.set(
|
CalledMethodProvider.instance.set(
|
||||||
HTTPMETHOD.PUT.name() + "/" + ERPath.ER_PATH_PART +
|
HTTPMETHOD.PUT.name() + " /" + ERPath.ER_PATH_PART +
|
||||||
"/" + ERPath.IS_RELATED_TO_PATH_PART + "/" + type);
|
"/" + ERPath.IS_RELATED_TO_PATH_PART + "/" + type);
|
||||||
logger.info("Requested to create {} {} of type {} : {}", IsRelatedTo.NAME, Relation.NAME, type, json);
|
logger.info("Requested to create {} {} of type {} : {}", IsRelatedTo.NAME, Relation.NAME, type, json);
|
||||||
IsRelatedToManagement isRelatedToManagement = new IsRelatedToManagement();
|
IsRelatedToManagement isRelatedToManagement = new IsRelatedToManagement();
|
||||||
|
@ -257,7 +252,7 @@ public class ERManager {
|
||||||
@Path(ERPath.IS_RELATED_TO_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
@Path(ERPath.IS_RELATED_TO_PATH_PART + "/{" + ID_PATH_PARAM + "}")
|
||||||
public boolean detachResource(@PathParam(ID_PATH_PARAM) String relatedToUUID) throws ResourceRegistryException {
|
public boolean detachResource(@PathParam(ID_PATH_PARAM) String relatedToUUID) throws ResourceRegistryException {
|
||||||
CalledMethodProvider.instance.set(
|
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 + "}");
|
"/" + ERPath.IS_RELATED_TO_PATH_PART + "/{" + ID_PATH_PARAM + "}");
|
||||||
logger.info("requested to detach {}", relatedToUUID);
|
logger.info("requested to detach {}", relatedToUUID);
|
||||||
IsRelatedToManagement isRelatedToManagement = new IsRelatedToManagement();
|
IsRelatedToManagement isRelatedToManagement = new IsRelatedToManagement();
|
||||||
|
@ -274,7 +269,7 @@ public class ERManager {
|
||||||
public boolean addResourceToContext(@PathParam(ID_PATH_PARAM) String uuid)
|
public boolean addResourceToContext(@PathParam(ID_PATH_PARAM) String uuid)
|
||||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||||
CalledMethodProvider.instance.set(
|
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 + "}");
|
"/" + ERPath.ADD_PATH_PART + "/" + ERPath.RESOURCE_PATH_PART + "/{" + ID_PATH_PARAM + "}");
|
||||||
logger.info("requested to add {} with UUID {} to current context {}", Resource.NAME, uuid,
|
logger.info("requested to add {} with UUID {} to current context {}", Resource.NAME, uuid,
|
||||||
ContextUtility.getCurrentContext());
|
ContextUtility.getCurrentContext());
|
||||||
|
@ -292,7 +287,7 @@ public class ERManager {
|
||||||
public boolean addFacetToContext(@PathParam(ID_PATH_PARAM) String uuid)
|
public boolean addFacetToContext(@PathParam(ID_PATH_PARAM) String uuid)
|
||||||
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||||
CalledMethodProvider.instance.set(
|
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 + "}");
|
"/" + ERPath.ADD_PATH_PART + "/" + ERPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}");
|
||||||
logger.info("requested to add {} with UUID {} to current context {}", Facet.NAME, uuid,
|
logger.info("requested to add {} with UUID {} to current context {}", Facet.NAME, uuid,
|
||||||
ContextUtility.getCurrentContext());
|
ContextUtility.getCurrentContext());
|
||||||
|
@ -310,7 +305,7 @@ public class ERManager {
|
||||||
public boolean removeResourceFromContext(@PathParam(ID_PATH_PARAM) String uuid)
|
public boolean removeResourceFromContext(@PathParam(ID_PATH_PARAM) String uuid)
|
||||||
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
throws ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||||
CalledMethodProvider.instance.set(
|
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 + "}");
|
"/" + ERPath.REMOVE_PATH_PART + "/" + ERPath.RESOURCE_PATH_PART + "/{" + ID_PATH_PARAM + "}");
|
||||||
logger.info("requested to remove {} with UUID {} from current context {}", Resource.NAME, uuid,
|
logger.info("requested to remove {} with UUID {} from current context {}", Resource.NAME, uuid,
|
||||||
ContextUtility.getCurrentContext());
|
ContextUtility.getCurrentContext());
|
||||||
|
@ -328,7 +323,7 @@ public class ERManager {
|
||||||
public boolean removeFacetFromContext(@PathParam(ID_PATH_PARAM) String uuid)
|
public boolean removeFacetFromContext(@PathParam(ID_PATH_PARAM) String uuid)
|
||||||
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
throws FacetNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||||
CalledMethodProvider.instance.set(
|
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 + "}");
|
"/" + ERPath.REMOVE_PATH_PART + "/" + ERPath.FACET_PATH_PART + "/{" + ID_PATH_PARAM + "}");
|
||||||
logger.info("requested to remove {} with UUID {} from current context {}", Facet.NAME, uuid,
|
logger.info("requested to remove {} with UUID {} from current context {}", Facet.NAME, uuid,
|
||||||
ContextUtility.getCurrentContext());
|
ContextUtility.getCurrentContext());
|
||||||
|
|
Loading…
Reference in New Issue