Added missing query parameter analisys

This commit is contained in:
Luca Frosini 2023-05-05 11:11:39 +02:00
parent 074935d3d2
commit 69bac7493d
6 changed files with 33 additions and 3 deletions

View File

@ -136,11 +136,15 @@ public class ServerRequestInfo implements RequestInfo {
}
public void checkIncludeQueryParameters() {
checkQueryParameter(InstancePath.INCLUDE_META_QUERY_PARAMETER);
checkQueryParameter(InstancePath.INCLUDE_META_IN_ALL_INSTANCES_QUERY_PARAMETER);
checkIncludeMetaQueryParameters();
checkQueryParameter(InstancePath.INCLUDE_CONTEXTS_QUERY_PARAMETER);
}
public void checkIncludeMetaQueryParameters() {
checkQueryParameter(InstancePath.INCLUDE_META_QUERY_PARAMETER);
checkQueryParameter(InstancePath.INCLUDE_META_IN_ALL_INSTANCES_QUERY_PARAMETER);
}
@Override
public boolean includeMeta() {
return includeMeta;

View File

@ -21,6 +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.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -52,6 +53,8 @@ public class ContextManager {
logger.info("Requested to read all {}s", Context.NAME);
CalledMethodProvider.instance.set("listContexts");
RequestUtility.getRequestInfo().get().checkIncludeMetaQueryParameters();
ContextManagement contextManagement = new ContextManagement();
return contextManagement.all(false);
}
@ -73,6 +76,8 @@ public class ContextManager {
logger.info("Requested to read {} with id {} ", Context.NAME, uuid);
CalledMethodProvider.instance.set("readContext");
RequestUtility.getRequestInfo().get().checkIncludeMetaQueryParameters();
ContextManagement contextManagement = new ContextManagement();
contextManagement.setUUID(UUID.fromString(uuid));
return contextManagement.readAsString();
@ -94,6 +99,8 @@ public class ContextManager {
logger.info("Requested to update/create {} with json {} ", Context.NAME, json);
CalledMethodProvider.instance.set("updateContext");
RequestUtility.getRequestInfo().get().checkIncludeMetaQueryParameters();
ContextManagement contextManagement = new ContextManagement();
contextManagement.setUUID(UUID.fromString(uuid));
contextManagement.setJson(json);

View File

@ -20,6 +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.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -43,6 +44,8 @@ public class QueryTemplateManager {
logger.info("Requested to read all {}s", QueryTemplate.NAME);
CalledMethodProvider.instance.set("listQueryTemplates");
RequestUtility.getRequestInfo().get().checkIncludeMetaQueryParameters();
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
return queryTemplateManagement.all(false);
}
@ -86,6 +89,8 @@ public class QueryTemplateManager {
logger.info("Requested {} creation with name {} and content {}", QueryTemplate.NAME, queryTemplateName, json);
CalledMethodProvider.instance.set("createQueryTemplate");
RequestUtility.getRequestInfo().get().checkIncludeMetaQueryParameters();
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
queryTemplateManagement.setName(queryTemplateName);
queryTemplateManagement.setJson(json);
@ -106,6 +111,8 @@ public class QueryTemplateManager {
logger.info("Requested {} with name", QueryTemplate.NAME, queryTemplateName);
CalledMethodProvider.instance.set("readQueryTemplate");
RequestUtility.getRequestInfo().get().checkIncludeMetaQueryParameters();
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
queryTemplateManagement.setName(queryTemplateName);
return queryTemplateManagement.read();
@ -127,6 +134,8 @@ public class QueryTemplateManager {
logger.info("Requested {} with name", QueryTemplate.NAME, queryTemplateName);
CalledMethodProvider.instance.set("readQueryTemplate");
RequestUtility.getRequestInfo().get().checkIncludeMetaQueryParameters();
QueryTemplateManagement queryTemplateManagement = new QueryTemplateManagement();
queryTemplateManagement.setName(queryTemplateName);
queryTemplateManagement.setParams(params);

View File

@ -27,6 +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.utils.UUIDUtility;
import org.gcube.informationsystem.utils.TypeUtility;
import org.slf4j.Logger;
@ -92,6 +93,8 @@ public class SharingManager {
String body)
throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
RequestUtility.getRequestInfo().get().checkIncludeQueryParameters();
try {
StringBuffer calledMethod = new StringBuffer();
if(dryRun==null) {
@ -171,6 +174,8 @@ public class SharingManager {
@QueryParam(SharingPath.FORCE_ADD_TO_CONTEXT_QUERY_PARAMETER) @DefaultValue("false") Boolean forceAddToContext)
throws SchemaViolationException, ResourceNotFoundException, ContextNotFoundException, ResourceRegistryException {
RequestUtility.getRequestInfo().get().checkIncludeQueryParameters();
StringBuffer calledMethod = new StringBuffer();
if(dryRun==null) {
dryRun = false;

View File

@ -20,6 +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.types.TypeManagement;
import org.gcube.informationsystem.types.TypeMapper;
import org.gcube.informationsystem.types.reference.Type;
@ -56,6 +57,8 @@ public class TypeManager {
logger.info("Requested {} creation with schema {}", typeName, json);
CalledMethodProvider.instance.set("createType");
RequestUtility.getRequestInfo().get().checkIncludeMetaQueryParameters();
TypeManagement schemaManagement = new TypeManagement();
schemaManagement.setTypeName(typeName);
schemaManagement.setJson(json);
@ -78,6 +81,8 @@ public class TypeManager {
logger.info("Requested Schema for type {}", type);
CalledMethodProvider.instance.set("readType");
RequestUtility.getRequestInfo().get().checkIncludeMetaQueryParameters();
TypeManagement schemaManagement = new TypeManagement();
schemaManagement.setTypeName(type);
List<Type> types = schemaManagement.read(polymorphic);

View File

@ -473,7 +473,7 @@ public class ContextManagementTest extends ContextTest {
List<Context> contexts = getAll();
contexts = ContextCache.getInstance().getContexts();
for(Context context : contexts) {
logger.trace(ElementMapper.marshal(context));
logger.info(ElementMapper.marshal(context));
List<IsParentOf> children = context.getChildren();
for(IsParentOf child : children) {
Assert.assertTrue(child.getSource() == context);