Class IgnoredFieldsWarning
java.lang.Object
org.gcube.informationsystem.resourceregistry.http.headers.warning.IgnoredFieldsWarning
- All Implemented Interfaces:
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 Summary
Modifier and TypeMethodDescriptionstatic Optional<IgnoredFieldsWarning>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.static IgnoredFieldsWarningCreates a warning for fields explicitly ignored by an endpoint's write contract.getId()The specific entity instance identifier.The set of top-level JSON field names that were ignored.getType()The entity's collection/type name.Returns the formatted value to emit as anX-Warningresponse header.Returns a human-readable diagnostic message suitable for log output.
-
Method Details
-
forFields
Creates a warning for fields explicitly ignored by an endpoint's write contract.- Parameters:
type- the entity's collection/type nameid- the specific entity identifierignoredFields- the non-empty set of ignored top-level fields- Returns:
- the structured ignored-fields warning
- Throws:
IllegalArgumentException- ifignoredFieldsis 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 bodyresolvedClass- 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
Returns the formatted value to emit as anX-Warningresponse header. The value follows the normative format defined in the API reference:<warn-code> <warn-agent> "<warn-text>".- Specified by:
toHeaderValuein interfaceServiceWarning- Returns:
- the header value string, never
null
-
toLogMessage
Returns a human-readable diagnostic message suitable for log output.- Specified by:
toLogMessagein interfaceServiceWarning- Returns:
- the log message string, never
null
-
getType
The entity's collection/type name.- Returns:
- the type name
-
getId
The specific entity instance identifier.- Returns:
- the id
-
getIgnoredFields
The set of top-level JSON field names that were ignored.- Returns:
- the ignored field names
-