java.lang.Object
org.gcube.informationsystem.resourceregistry.http.headers.warning.QueryParameterWarning
All Implemented Interfaces:
ServiceWarning

public final class QueryParameterWarning extends Object implements ServiceWarning
Structured representation of a single X-Warning header entry related to one or more query parameters.

Two flavours are supported, matching the normative warning formats defined in the API reference:

  • Ignored — one or more parameters were silently discarded (inapplicable, unknown, or overridden). Header format:
    199 resource-registry "ignored-query-parameters=p1,p2; ignored-count=N; reason=..."
  • Modified — a parameter value was accepted but clamped/altered by the system before being applied. Header format:
    199 resource-registry "modified-query-parameters=p; requested-value=...; applied-value=...;
     reason=..."

Instances are created exclusively via the static factory methods:

Use toHeaderValue() to obtain the value to emit as an X-Warning response header. Use toLogMessage() for diagnostic log output.

Author:
Luca Frosini (ISTI - CNR)
  • Method Details

    • ignored

      public static QueryParameterWarning ignored(String parameter, String reason)
      Creates a warning for a single ignored query parameter.
      Parameters:
      parameter - the parameter name
      reason - human-readable explanation (no trailing period; sentence-case)
      Returns:
      the created QueryParameterWarning instance
    • ignored

      public static QueryParameterWarning ignored(List<String> parameters, String reason)
      Creates a warning for a group of ignored query parameters that share the same reason. Emits a single header entry with comma-separated parameter names.
      Parameters:
      parameters - the parameter names (must not be empty)
      reason - human-readable explanation shared by all parameters
      Returns:
      the created QueryParameterWarning instance
    • modified

      public static QueryParameterWarning modified(String parameter, String requestedValue, String appliedValue, String reason)
      Creates a warning for a single query parameter whose value was altered by the system.
      Parameters:
      parameter - the parameter name
      requestedValue - the value supplied by the client
      appliedValue - the value actually used by the server
      reason - human-readable explanation (no trailing period; sentence-case)
      Returns:
      the created QueryParameterWarning instance
    • toHeaderValue

      public String toHeaderValue()
      Returns the formatted value to emit as an X-Warning response header. The value follows the normative format defined in the API reference: <warn-code> <warn-agent> "<warn-text>".
      • Ignored: 199 resource-registry "ignored-query-parameters=p1,p2; ignored-count=N; reason=..."}
      • Modified: 199 resource-registry "modified-query-parameters=p; requested-value=...; applied-value=...; reason=..."}
      Specified by:
      toHeaderValue in interface ServiceWarning
      Returns:
      the header value string, never null
    • toLogMessage

      public String toLogMessage()
      Returns a human-readable diagnostic message suitable for log output.
      Specified by:
      toLogMessage in interface ServiceWarning
      Returns:
      the log message string, never null
    • getKind

      public QueryParameterWarning.Kind getKind()
      Returns the warning flavour.
      Returns:
      the kind of warning
    • getParameters

      public List<String> getParameters()
      The parameter name(s) covered by this warning.
      Returns:
      the parameter names
    • getReason

      public String getReason()
      Human-readable reason, also used in log messages.
      Returns:
      the human-readable reason
    • getRequestedValue

      public String getRequestedValue()
      The value supplied by the client; null for QueryParameterWarning.Kind.IGNORED warnings.
      Returns:
      the requested value
    • getAppliedValue

      public String getAppliedValue()
      The value actually applied by the server; null for QueryParameterWarning.Kind.IGNORED warnings.
      Returns:
      the applied value