Class QueryParameterWarning
java.lang.Object
org.gcube.informationsystem.resourceregistry.http.headers.warning.QueryParameterWarning
- All Implemented Interfaces:
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:
ignored(String, String)— single ignored parameterignored(List, String)— group of ignored parameters sharing the same reasonmodified(String, String, String, String)— single modified parameter
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)
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionThe value actually applied by the server;nullforQueryParameterWarning.Kind.IGNOREDwarnings.getKind()Returns the warning flavour.The parameter name(s) covered by this warning.Human-readable reason, also used in log messages.The value supplied by the client;nullforQueryParameterWarning.Kind.IGNOREDwarnings.static QueryParameterWarningCreates a warning for a single ignored query parameter.static QueryParameterWarningCreates a warning for a group of ignored query parameters that share the same reason.static QueryParameterWarningCreates a warning for a single query parameter whose value was altered by the system.Returns the formatted value to emit as anX-Warningresponse header.Returns a human-readable diagnostic message suitable for log output.
-
Method Details
-
ignored
Creates a warning for a single ignored query parameter.- Parameters:
parameter- the parameter namereason- human-readable explanation (no trailing period; sentence-case)- Returns:
- the created QueryParameterWarning instance
-
ignored
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 namerequestedValue- the value supplied by the clientappliedValue- the value actually used by the serverreason- human-readable explanation (no trailing period; sentence-case)- Returns:
- the created QueryParameterWarning instance
-
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>".- 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:
toHeaderValuein interfaceServiceWarning- Returns:
- the header value string, never
null
- Ignored:
-
toLogMessage
Returns a human-readable diagnostic message suitable for log output.- Specified by:
toLogMessagein interfaceServiceWarning- Returns:
- the log message string, never
null
-
getKind
Returns the warning flavour.- Returns:
- the kind of warning
-
getParameters
The parameter name(s) covered by this warning.- Returns:
- the parameter names
-
getReason
Human-readable reason, also used in log messages.- Returns:
- the human-readable reason
-
getRequestedValue
The value supplied by the client;nullforQueryParameterWarning.Kind.IGNOREDwarnings.- Returns:
- the requested value
-
getAppliedValue
The value actually applied by the server;nullforQueryParameterWarning.Kind.IGNOREDwarnings.- Returns:
- the applied value
-