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

public final class ContentWarning extends Object implements ServiceWarning
Structured representation of a single X-Warning header entry related to one content field in the response body.

Two flavours are supported:

  • Unavailable — a field or sub-resource could not be populated (e.g. the backing service was unreachable, or the data simply does not exist). Header format:
    199 resource-registry "content-field=fieldPath; reason=..."
  • Modified — a field value was accepted but altered by business rules before being included in the response (e.g. a list was truncated, a value was rewritten). Header format:
    199 resource-registry "content-field=fieldPath; 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

    • unavailable

      public static ContentWarning unavailable(String field, String reason)
      Creates a warning for a content field that could not be populated.
      Parameters:
      field - dot-notation path to the field (e.g. "metadata.creator")
      reason - human-readable explanation (no trailing period; sentence-case)
      Returns:
      the populated ContentWarning instance
    • modified

      public static ContentWarning modified(String field, String requestedValue, String appliedValue, String reason)
      Creates a warning for a content field whose value was altered by the system.
      Parameters:
      field - dot-notation path to the field
      requestedValue - the value that was requested or expected by the client
      appliedValue - the value actually included in the response
      reason - human-readable explanation (no trailing period; sentence-case)
      Returns:
      the populated ContentWarning 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>".
      • Unavailable: 199 resource-registry "content-field=fieldPath; reason=..."
      • Modified: 199 resource-registry "content-field=fieldPath; 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 ContentWarning.Kind getKind()
      The warning flavour.
      Returns:
      the warning kind
    • getField

      public String getField()
      The dot-notation path of the affected field.
      Returns:
      the field path
    • getReason

      public String getReason()
      Human-readable reason.
      Returns:
      the reason string
    • getRequestedValue

      public String getRequestedValue()
      The expected value; null for ContentWarning.Kind.UNAVAILABLE warnings.
      Returns:
      the requested value, or null
    • getAppliedValue

      public String getAppliedValue()
      The value actually included in the response; null for ContentWarning.Kind.UNAVAILABLE warnings.
      Returns:
      the applied value, or null