Class QueryTemplatePolicyEnforcementPoint

java.lang.Object
org.gcube.informationsystem.resourceregistry.pep.PolicyEnforcementPoint
org.gcube.informationsystem.resourceregistry.queries.templates.QueryTemplatePolicyEnforcementPoint

public class QueryTemplatePolicyEnforcementPoint extends PolicyEnforcementPoint
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)
  • Constructor Details

    • QueryTemplatePolicyEnforcementPoint

      public QueryTemplatePolicyEnforcementPoint(jakarta.ws.rs.container.ContainerRequestContext requestContext)
      Creates a new QueryTemplatePolicyEnforcementPoint instance 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.ResourceRegistryException
      Lists 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 invalid
      org.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 exist
      org.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 execute
      params - 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 exist
      org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException - if the query execution fails
      org.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 update
      json - 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 found
      org.gcube.informationsystem.resourceregistry.api.exceptions.instances.AvailableInAnotherContextException - if the Query Template is available in another context
      org.gcube.informationsystem.resourceregistry.api.exceptions.queries.InvalidQueryException - if the stored query or its default substitutions are invalid
      org.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 exist
      org.gcube.informationsystem.resourceregistry.api.exceptions.ResourceRegistryException - if deletion fails