java.lang.Object
org.gcube.informationsystem.resourceregistry.rest.base.BaseRest
Direct Known Subclasses:
Access, AdminQueryManager, AdminSystemManager, ContextManager, InstancesManager, QueryTemplateManager, StatisticsManager, TypeManager

public class BaseRest extends Object
Base class for JAX-RS REST resources, providing common logger, context injection, and response-building utility methods.
Author:
Luca Frosini (ISTI - CNR)
  • Field Details

    • logger

      protected org.slf4j.Logger logger
      The logger instance for REST operation auditing and diagnostics.
    • uriInfo

      @Context protected jakarta.ws.rs.core.UriInfo uriInfo
      Injected JAX-RS URI metadata helper for the current request.
  • Constructor Details

    • BaseRest

      public BaseRest()
      Default constructor for JAX-RS sub-classes.
  • Method Details

    • setAccountingMethod

      protected void setAccountingMethod(String method)
      Sets the raw accounting method name for request tracking.
      Parameters:
      method - the method string to set
    • setAccountingMethod

      protected void setAccountingMethod(Method method, String type)
      Sets the accounting method name by formatting the prefix and suffix for a given type.
      Parameters:
      method - the Method enum value defining prefix and suffix
      type - the type name to interpolate
    • buildResponse

      protected jakarta.ws.rs.core.Response buildResponse(String json, PolicyEnforcementPoint pep)
      Builds a 200 OK JSON Response from the given entity string. The X-Warning/X-Result-Scope/Preference-Applied/Link/ Content-Location response headers are not set here: they are finalized on the response by the corresponding global ContainerResponseFilters, reading from what pep already accumulated on the current request (e.g. PolicyEnforcementPoint.addQueryParameterWarning(org.gcube.informationsystem.resourceregistry.http.headers.warning.QueryParameterWarning)). The pep parameter exists so callers pass it through uniformly at every call site, keeping the PEP accumulation + filter pattern consistent across every response-building method.
      Parameters:
      json - the serialized JSON entity
      pep - the Policy Enforcement Point for the current request
      Returns:
      a JAX-RS Response ready to be returned from a resource method
    • buildResponse

      protected jakarta.ws.rs.core.Response buildResponse(PageResult page, PolicyEnforcementPoint pep)
      Builds a paginated 200 OK JSON Response. RFC 8288 pagination Link headers (relations first/prev/next) are emitted separately via PolicyEnforcementPoint.addPaginationLinks(PageResult), called by the PEP itself while it still holds the PageResult, and finalized on the response by LinkResponseFilter.
      Parameters:
      page - paginated payload and pagination parameters
      pep - the Policy Enforcement Point for the current request
      Returns:
      a JAX-RS Response ready to be returned from a resource method