Class BaseRest
java.lang.Object
org.gcube.informationsystem.resourceregistry.rest.base.BaseRest
- Direct Known Subclasses:
Access,AdminInstancesManager,AdminQueryManager,AdminSystemManager,ContextManager,InstancesManager,QueryTemplateManager,SharingManager,TypeManager
Base class for JAX-RS REST resources, providing common logger, context injection,
and response-building utility methods.
- Author:
- Luca Frosini (ISTI - CNR)
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected jakarta.ws.rs.core.ResponsebuildResponse(String json, PolicyEnforcementPoint pep) Builds a200 OKJSONResponsefrom the given entity string.protected jakarta.ws.rs.core.ResponsebuildResponse(PageResult page, PolicyEnforcementPoint pep) Builds a paginated200 OKJSONResponse.protected voidsetAccountingMethod(String method) Sets the raw accounting method name for request tracking.protected voidsetAccountingMethod(Method method, String type) Sets the accounting method name by formatting the prefix and suffix for a given type.
-
Field Details
-
logger
protected org.slf4j.Logger loggerThe logger instance for REST operation auditing and diagnostics. -
uriInfo
@Context protected jakarta.ws.rs.core.UriInfo uriInfoInjected JAX-RS URI metadata helper for the current request.
-
-
Constructor Details
-
BaseRest
public BaseRest()Default constructor for JAX-RS sub-classes.
-
-
Method Details
-
setAccountingMethod
Sets the raw accounting method name for request tracking.- Parameters:
method- the method string to set
-
setAccountingMethod
Sets the accounting method name by formatting the prefix and suffix for a given type.- Parameters:
method- the Method enum value defining prefix and suffixtype- the type name to interpolate
-
buildResponse
Builds a200 OKJSONResponsefrom the given entity string. TheX-Warning/X-Result-Scope/Preference-Applied/Link/Content-Locationresponse headers are not set here: they are finalized on the response by the corresponding globalContainerResponseFilters, reading from whatpepalready accumulated on the current request (e.g.PolicyEnforcementPoint.addQueryParameterWarning(org.gcube.informationsystem.resourceregistry.http.headers.warning.QueryParameterWarning)). Thepepparameter 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 entitypep- the Policy Enforcement Point for the current request- Returns:
- a JAX-RS
Responseready to be returned from a resource method
-
buildResponse
Builds a paginated200 OKJSONResponse. RFC 8288 paginationLinkheaders (relationsfirst/prev/next) are emitted separately viaPolicyEnforcementPoint.addPaginationLinks(PageResult), called by the PEP itself while it still holds thePageResult, and finalized on the response byLinkResponseFilter.- Parameters:
page- paginated payload and pagination parameterspep- the Policy Enforcement Point for the current request- Returns:
- a JAX-RS
Responseready to be returned from a resource method
-