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

public final class IgnoredFieldsWarning extends Object implements ServiceWarning
Structured representation of an X-Warning header entry reporting JSON fields present in a write request body that were ignored by the target write operation, either because they are not recognized by the model or because they are system-managed.

At most MAX_LISTED_FIELDS field names are listed, sorted lexicographically; if more were ignored, the list is truncated with TRUNCATION_TOKEN while ignored-count keeps reporting the true, untruncated count. Each field name is percent-encoded (WarningHeaderValue.encodeToken(String)) to preserve the header's structural integrity.

Header format:

199 resource-registry "type=EntityTypeName; id=entityIdentifier; ignored-fields=field1,field2;
 ignored-count=2"
Author:
Luca Frosini (ISTI - CNR)
  • Method Details

    • forFields

      public static IgnoredFieldsWarning forFields(String type, String id, Set<String> ignoredFields)
      Creates a warning for fields explicitly ignored by an endpoint's write contract.
      Parameters:
      type - the entity's collection/type name
      id - the specific entity identifier
      ignoredFields - the non-empty set of ignored top-level fields
      Returns:
      the structured ignored-fields warning
      Throws:
      IllegalArgumentException - if ignoredFields is null or empty
    • detect

      public static Optional<IgnoredFieldsWarning> detect(String type, String id, String json, Class<?> resolvedClass)
      Compares the top-level field names present in a write request body against the properties actually recognized by the entity's resolved model class, and returns a warning if one or more fields would be silently dropped.
      Parameters:
      type - the entity's collection/type name (e.g. Context.NAME, Type.NAME)
      id - an identifier for the specific entity instance (name or UUID)
      json - the raw request body
      resolvedClass - the concrete class the body was (or would be) deserialized into
      Returns:
      a warning listing the ignored fields, or empty if every field was recognized or the body could not be parsed as a JSON object
    • 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>".
      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
    • getType

      public String getType()
      The entity's collection/type name.
      Returns:
      the type name
    • getId

      public String getId()
      The specific entity instance identifier.
      Returns:
      the id
    • getIgnoredFields

      public Set<String> getIgnoredFields()
      The set of top-level JSON field names that were ignored.
      Returns:
      the ignored field names