Class QueryTemplatePolicyEnforcementPoint
java.lang.Object
org.gcube.informationsystem.resourceregistry.pep.PolicyEnforcementPoint
org.gcube.informationsystem.resourceregistry.queries.templates.QueryTemplatePolicyEnforcementPoint
Policy Enforcement Point (PEP) for the
QueryTemplate collection.
Enforces role-based endpoint access control, executes declarative validation
of query parameters, and delegates database operations to QueryTemplateRepository.
Following the strict layered architecture applied to every other collection in this
service, this class acts as the single entry point for REST-facing Query Template
operations; it is entirely DB-agnostic and never instantiates the OrientDB-specific
QueryTemplateManagement class directly.
- Author:
- Luca Frosini (ISTI - CNR)
-
Nested Class Summary
Nested classes/interfaces inherited from class org.gcube.informationsystem.resourceregistry.pep.PolicyEnforcementPoint
PolicyEnforcementPoint.EndpointPolicySpec, PolicyEnforcementPoint.QueryParamSpec, PolicyEnforcementPoint.TokenScopeRule -
Field Summary
Fields inherited from class org.gcube.informationsystem.resourceregistry.pep.PolicyEnforcementPoint
ALL_ADMIN_ROLES, ALL_OPERATIONAL_ROLES, CONTEXT_MANAGER, DEPTH_DEFAULT, GLOBAL_PRIVILEGED_ROLES, INFRASTRUCTURE_MANAGER, IS_ADMIN, IS_CONTRIBUTOR, IS_EDITOR, IS_MANAGER, IS_MEMBER, LEGACY_ALL_META_QUERY_PARAMETER, LEGACY_INCLUDE_META_QUERY_PARAMETER, LIMIT_DEFAULT, LIMIT_MAX, OFFSET_DEFAULT, requestContext, SUBTREE_ADMIN_ROLES -
Constructor Summary
ConstructorsConstructorDescriptionQueryTemplatePolicyEnforcementPoint(jakarta.ws.rs.container.ContainerRequestContext requestContext) Creates a newQueryTemplatePolicyEnforcementPointinstance associated with the current JAX-RS request context. -
Method Summary
Modifier and TypeMethodDescriptioncreateOrUpdate(String queryTemplateName, String json) Creates or updates a Query Template under authorized constraints, restricted to globally-privileged roles.voidDeletes the Query Template with the specified name under authorized constraints, restricted to globally-privileged roles.list()Lists all Query Templates under authorized constraints.Executes a JSON query against the Query Template collection under authorized constraints.Reads a single Query Template by name under authorized constraints.Executes the Query Template with the specified name and parameters under authorized constraints.Methods inherited from class org.gcube.informationsystem.resourceregistry.pep.PolicyEnforcementPoint
addContentWarning, addIgnoredFieldsWarning, addLink, addPaginationLinks, addPreferenceApplied, addQueryParameterWarning, addResultScope, buildUri, enforcePolicy, enforceTargetContextWithinTokenSubtree, getAllWarnings, getContentLocation, getContentWarnings, getIgnoredFieldsWarnings, getLinks, getPreferenceApplied, getQueryParameterWarnings, getResolvedContextPath, getResultScopes, getUriInfo, hasNonActiveDescendant, isAdministrativeUser, isPrivilegedUser, isSiblingOfTokenContext, isUserAllowed, resolveAllMeta, resolveBoolean, resolveBypassHierarchyCheck, resolveDepth, resolveDepth, resolveDryRun, resolveHierarchical, resolveIncludeContexts, resolveIncludeMeta, resolveLimit, resolveMetadataPolicy, resolveOffset, resolvePolymorphic, resolvePropagationMode, resolveRawResult, resolveSyncExistingHierarchy, resolveTokenContextUuid, setContentLocation, validateQueryParameters, warnEnrichmentParametersIgnoredByEmitProjection
-
Constructor Details
-
QueryTemplatePolicyEnforcementPoint
public QueryTemplatePolicyEnforcementPoint(jakarta.ws.rs.container.ContainerRequestContext requestContext) Creates a newQueryTemplatePolicyEnforcementPointinstance associated with the current JAX-RS request context.- Parameters:
requestContext- the JAX-RS container request context
-
-
Method Details
-
list
public PageResult list() throws org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryExceptionLists all Query Templates under authorized constraints.- Returns:
- a paginated page of Query Template definitions
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database or read failure
-
query
public PageResult query(String jsonQuery) throws org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Executes a JSON query against the Query Template collection under authorized constraints.- Parameters:
jsonQuery- the JSON query payload describing the Query Template search criteria- Returns:
- a paginated page of matching Query Template definitions
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if the query syntax or structure is invalidorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database or processing failure
-
read
public String read(String queryTemplateName) throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Reads a single Query Template by name under authorized constraints.- Parameters:
queryTemplateName- the name of the Query Template to read- Returns:
- the serialized JSON representation of the Query Template
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the Query Template does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the lookup fails
-
run
public PageResult run(String queryTemplateName, String params) throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Executes the Query Template with the specified name and parameters under authorized constraints.- Parameters:
queryTemplateName- the name of the Query Template to executeparams- JSON object containing parameter values for template substitution- Returns:
- a paginated page of query results
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the Query Template does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if the query execution failsorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- on database or processing failure
-
createOrUpdate
public QueryTemplateCreationResult createOrUpdate(String queryTemplateName, String json) throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Creates or updates a Query Template under authorized constraints, restricted to globally-privileged roles.- Parameters:
queryTemplateName- the name of the Query Template to create or updatejson- the raw Query Template JSON definition- Returns:
- the outcome, carrying the serialized JSON representation of the created/updated Query Template and a created/updated flag
- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if referenced dependencies are not foundorg.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException- if the Query Template is available in another contextorg.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException- if the stored query or its default substitutions are invalidorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if the creation or update fails
-
delete
public void delete(String queryTemplateName) throws org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException, org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException Deletes the Query Template with the specified name under authorized constraints, restricted to globally-privileged roles.- Parameters:
queryTemplateName- the name of the Query Template to delete- Throws:
org.gcube.informationsystem.resourceregistry.api.exceptions.NotFoundException- if the Query Template does not existorg.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException- if deletion fails
-