Fixed code to properly set UriInfo
This commit is contained in:
parent
992b9d23cc
commit
024af70188
|
@ -41,7 +41,6 @@ import org.gcube.informationsystem.resourceregistry.queries.Query;
|
|||
import org.gcube.informationsystem.resourceregistry.queries.QueryImpl;
|
||||
import org.gcube.informationsystem.resourceregistry.queries.json.JsonQuery;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.ServerRequestInfo;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.RequestUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.types.TypeManagement;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
|
@ -72,6 +71,9 @@ public class Access extends BaseRest {
|
|||
logger.info("Requested to read all {}s", org.gcube.informationsystem.contexts.reference.entities.Context.NAME);
|
||||
CalledMethodProvider.instance.set("listContexts");
|
||||
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
return contextManagement.all(false);
|
||||
}
|
||||
|
@ -91,6 +93,9 @@ public class Access extends BaseRest {
|
|||
logger.info("Requested to read {} with id {} ", org.gcube.informationsystem.contexts.reference.entities.Context.NAME, uuid);
|
||||
CalledMethodProvider.instance.set("readContext");
|
||||
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
contextManagement.setUUID(UUID.fromString(uuid));
|
||||
return contextManagement.readAsString();
|
||||
|
@ -109,6 +114,9 @@ public class Access extends BaseRest {
|
|||
logger.info("Requested Schema for type {}", type);
|
||||
CalledMethodProvider.instance.set("readType");
|
||||
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
|
||||
TypeManagement typeManagement = new TypeManagement();
|
||||
typeManagement.setTypeName(type);
|
||||
List<Type> types = typeManagement.read(polymorphic);
|
||||
|
@ -133,7 +141,8 @@ public class Access extends BaseRest {
|
|||
logger.info("Requested all {}instances of {}", polymorphic ? InstancePath.POLYMORPHIC_QUERY_PARAMETER + " " : "", type);
|
||||
CalledMethodProvider.instance.set("listInstances");
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkAllQueryParameters();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkAllQueryParameters();
|
||||
|
||||
ElementManagement<?,?> erManagement = ElementManagementUtility.getERManagement(type);
|
||||
return erManagement.all(polymorphic);
|
||||
|
@ -152,7 +161,8 @@ public class Access extends BaseRest {
|
|||
logger.info("Requested to check if {} with id {} exists", type, uuid);
|
||||
CalledMethodProvider.instance.set("existInstance");
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkQueryParameter(InstancePath.HIERARCHICAL_MODE_QUERY_PARAMETER);
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkQueryParameter(InstancePath.HIERARCHICAL_MODE_QUERY_PARAMETER);
|
||||
|
||||
ElementManagement<?,?> erManagement = ElementManagementUtility.getERManagement(type);
|
||||
|
||||
|
@ -188,7 +198,8 @@ public class Access extends BaseRest {
|
|||
logger.info("Requested to read {} with id {}", type, uuid);
|
||||
CalledMethodProvider.instance.set("readInstance");
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkAllQueryParameters();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkAllQueryParameters();
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
|
||||
|
@ -244,12 +255,12 @@ public class Access extends BaseRest {
|
|||
logger.info("Requested query (Raw {}):\n{}", raw, query);
|
||||
CalledMethodProvider.instance.set("graphQuery");
|
||||
|
||||
ServerRequestInfo requestInfo = RequestUtility.getRequestInfo().get();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
if(raw) {
|
||||
// TODO Check if the role allow to request raw data
|
||||
requestInfo.checkQueryParameter(InstancePath.HIERARCHICAL_MODE_QUERY_PARAMETER);
|
||||
serverRequestInfo.checkQueryParameter(InstancePath.HIERARCHICAL_MODE_QUERY_PARAMETER);
|
||||
}else {
|
||||
requestInfo.checkAllQueryParameters();
|
||||
serverRequestInfo.checkAllQueryParameters();
|
||||
}
|
||||
|
||||
Query queryManager = new QueryImpl();
|
||||
|
@ -303,7 +314,8 @@ public class Access extends BaseRest {
|
|||
logger.info("Requested json query \n{}", jsonQuery);
|
||||
CalledMethodProvider.instance.set("jsonQuery");
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkAllQueryParameters();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkAllQueryParameters();
|
||||
|
||||
JsonQuery jsonQueryManager = new JsonQuery();
|
||||
jsonQueryManager.setJsonQuery(jsonQuery);
|
||||
|
@ -353,7 +365,8 @@ public class Access extends BaseRest {
|
|||
|
||||
CalledMethodProvider.instance.set("query");
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkAllQueryParameters();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkAllQueryParameters();
|
||||
|
||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(resourcetype);
|
||||
|
||||
|
|
|
@ -3,8 +3,8 @@ package org.gcube.informationsystem.resourceregistry.rest;
|
|||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.UriInfo;
|
||||
|
||||
import org.gcube.informationsystem.resourceregistry.requests.ServerRequestInfo;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.RequestUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.ServerRequestInfo;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -19,12 +19,16 @@ public class BaseRest {
|
|||
protected UriInfo uriInfo;
|
||||
|
||||
public BaseRest() {
|
||||
|
||||
}
|
||||
|
||||
protected ServerRequestInfo initRequestInfo() {
|
||||
ServerRequestInfo requestInfo = new ServerRequestInfo();
|
||||
requestInfo.setUriInfo(uriInfo);
|
||||
|
||||
RequestUtility.getRequestInfo().set(requestInfo);
|
||||
|
||||
return requestInfo;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.contexts.Cont
|
|||
import org.gcube.informationsystem.resourceregistry.api.rest.ContextPath;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.ContextUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.contexts.entities.ContextManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.RequestUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.ServerRequestInfo;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
|
@ -46,7 +46,8 @@ public class ContextManager extends BaseRest {
|
|||
logger.info("Requested to read all {}s", Context.NAME);
|
||||
CalledMethodProvider.instance.set("listContexts");
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkIncludeMetaQueryParameters();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
return contextManagement.all(false);
|
||||
|
@ -69,7 +70,8 @@ public class ContextManager extends BaseRest {
|
|||
logger.info("Requested to read {} with id {} ", Context.NAME, uuid);
|
||||
CalledMethodProvider.instance.set("readContext");
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkIncludeMetaQueryParameters();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
contextManagement.setUUID(UUID.fromString(uuid));
|
||||
|
@ -92,7 +94,8 @@ public class ContextManager extends BaseRest {
|
|||
logger.info("Requested to update/create {} with json {} ", Context.NAME, json);
|
||||
CalledMethodProvider.instance.set("updateContext");
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkIncludeMetaQueryParameters();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
|
||||
ContextManagement contextManagement = new ContextManagement();
|
||||
contextManagement.setUUID(UUID.fromString(uuid));
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.gcube.informationsystem.resourceregistry.api.rest.InstancePath;
|
|||
import org.gcube.informationsystem.resourceregistry.api.rest.SharingPath;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.RequestUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.ServerRequestInfo;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
|
@ -56,7 +56,8 @@ public class InstancesManager extends BaseRest {
|
|||
logger.info("Requested all {}instances of {}", polymorphic ? InstancePath.POLYMORPHIC_QUERY_PARAMETER + " " : "", type);
|
||||
CalledMethodProvider.instance.set("listInstances");
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkAllQueryParameters();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkAllQueryParameters();
|
||||
|
||||
ElementManagement<?,?> erManagement = ElementManagementUtility.getERManagement(type);
|
||||
return erManagement.all(polymorphic);
|
||||
|
@ -76,7 +77,8 @@ public class InstancesManager extends BaseRest {
|
|||
logger.info("Requested to check if {} with id {} exists", type, uuid);
|
||||
CalledMethodProvider.instance.set("existInstance");
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkQueryParameter(InstancePath.HIERARCHICAL_MODE_QUERY_PARAMETER);
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkQueryParameter(InstancePath.HIERARCHICAL_MODE_QUERY_PARAMETER);
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
|
||||
|
@ -113,7 +115,8 @@ public class InstancesManager extends BaseRest {
|
|||
logger.info("Requested to read {} with id {}", type, uuid);
|
||||
CalledMethodProvider.instance.set("readInstance");
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkAllQueryParameters();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkAllQueryParameters();
|
||||
|
||||
ElementManagement<?,?> erManagement = ElementManagementUtility.getERManagement(type);
|
||||
erManagement.setElementType(type);
|
||||
|
@ -138,7 +141,8 @@ public class InstancesManager extends BaseRest {
|
|||
logger.trace("Requested to update/create {} with id {} with json {}", type, uuid, json);
|
||||
CalledMethodProvider.instance.set("updateInstance");
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkIncludeQueryParameters();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeQueryParameters();
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
ElementManagement erManagement = ElementManagementUtility.getERManagement(type);
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.QueryTemplatePath;
|
||||
import org.gcube.informationsystem.resourceregistry.queries.templates.QueryTemplateManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.RequestUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.ServerRequestInfo;
|
||||
|
||||
/**
|
||||
* @author Luca Frosini (ISTI - CNR)
|
||||
|
@ -44,7 +44,8 @@ public class QueryTemplateManager extends BaseRest {
|
|||
logger.info("Requested to read all {}s", QueryTemplate.NAME);
|
||||
CalledMethodProvider.instance.set("listQueryTemplates");
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkIncludeMetaQueryParameters();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
|
||||
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
|
||||
return queryTemplateManagement.all(false);
|
||||
|
@ -89,7 +90,8 @@ public class QueryTemplateManager extends BaseRest {
|
|||
logger.info("Requested {} creation with name {} and content {}", QueryTemplate.NAME, queryTemplateName, json);
|
||||
CalledMethodProvider.instance.set("createQueryTemplate");
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkIncludeMetaQueryParameters();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
|
||||
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
|
||||
queryTemplateManagement.setName(queryTemplateName);
|
||||
|
@ -111,7 +113,8 @@ public class QueryTemplateManager extends BaseRest {
|
|||
logger.info("Requested {} with name", QueryTemplate.NAME, queryTemplateName);
|
||||
CalledMethodProvider.instance.set("readQueryTemplate");
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkIncludeMetaQueryParameters();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
|
||||
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
|
||||
queryTemplateManagement.setName(queryTemplateName);
|
||||
|
@ -134,7 +137,8 @@ public class QueryTemplateManager extends BaseRest {
|
|||
logger.info("Requested {} with name", QueryTemplate.NAME, queryTemplateName);
|
||||
CalledMethodProvider.instance.set("readQueryTemplate");
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkIncludeMetaQueryParameters();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
|
||||
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
|
||||
queryTemplateManagement.setName(queryTemplateName);
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.gcube.informationsystem.resourceregistry.api.rest.SharingPath.Sharing
|
|||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.base.ElementManagementUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.instances.model.ERManagement;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.RequestUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.ServerRequestInfo;
|
||||
import org.gcube.informationsystem.resourceregistry.utils.UUIDUtility;
|
||||
import org.gcube.informationsystem.utils.TypeUtility;
|
||||
|
||||
|
@ -89,7 +89,8 @@ public class SharingManager extends BaseRest {
|
|||
String body)
|
||||
throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkIncludeQueryParameters();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeQueryParameters();
|
||||
|
||||
try {
|
||||
StringBuffer calledMethod = new StringBuffer();
|
||||
|
@ -170,7 +171,8 @@ public class SharingManager extends BaseRest {
|
|||
@QueryParam(SharingPath.FORCE_ADD_TO_CONTEXT_QUERY_PARAMETER) @DefaultValue("false") Boolean forceAddToContext)
|
||||
throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkIncludeQueryParameters();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeQueryParameters();
|
||||
|
||||
StringBuffer calledMethod = new StringBuffer();
|
||||
if(dryRun==null) {
|
||||
|
|
|
@ -20,7 +20,7 @@ import org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegis
|
|||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.exceptions.types.SchemaNotFoundException;
|
||||
import org.gcube.informationsystem.resourceregistry.api.rest.TypePath;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.RequestUtility;
|
||||
import org.gcube.informationsystem.resourceregistry.requests.ServerRequestInfo;
|
||||
import org.gcube.informationsystem.resourceregistry.types.TypeManagement;
|
||||
import org.gcube.informationsystem.types.TypeMapper;
|
||||
import org.gcube.informationsystem.types.reference.Type;
|
||||
|
@ -53,7 +53,8 @@ public class TypeManager extends BaseRest {
|
|||
logger.info("Requested {} creation with schema {}", typeName, json);
|
||||
CalledMethodProvider.instance.set("createType");
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkIncludeMetaQueryParameters();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
|
||||
TypeManagement schemaManagement = new TypeManagement();
|
||||
schemaManagement.setTypeName(typeName);
|
||||
|
@ -77,7 +78,8 @@ public class TypeManager extends BaseRest {
|
|||
logger.info("Requested Schema for type {}", type);
|
||||
CalledMethodProvider.instance.set("readType");
|
||||
|
||||
RequestUtility.getRequestInfo().get().checkIncludeMetaQueryParameters();
|
||||
ServerRequestInfo serverRequestInfo = initRequestInfo();
|
||||
serverRequestInfo.checkIncludeMetaQueryParameters();
|
||||
|
||||
TypeManagement schemaManagement = new TypeManagement();
|
||||
schemaManagement.setTypeName(type);
|
||||
|
|
Loading…
Reference in New Issue