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:
Luca Frosini 2017-06-28 14:26:47 +00:00
parent 31901d5ce3
commit 965954622f
2 changed files with 25 additions and 19 deletions

View File

@ -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")

View File

@ -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
*