java.lang.Object
org.elasticsearch.rest.RestUtils
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringThe name of the common?include_source_on_errorquery parameter.static final UnaryOperator<String> static final TimeValueThe default value for the common?master_timeoutquery parameter.static final StringThe name of the common?master_timeoutquery parameter.static final StringThe name of the common?timeoutquery parameter. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic PatterncheckCorsSettingForRegex(String corsSetting) Determine if CORS setting is a regexstatic voidstatic String[]corsSettingAsArray(String corsSetting) Return the CORS setting as an array of origins.static StringDecodes a bit of an URL encoded by a browser.static voiddecodeQueryString(String s, int fromIndex, Map<String, String> params) static voiddecodeQueryString(URI uri, Map<String, String> params) extractTraceId(String traceparent) Extract the trace id from the specified traceparent string.static TimeValuegetAckTimeout(RestRequest restRequest) Extract the?timeoutparameter from the request, imposing the common default of30sin case the parameter is missing.static booleangetIncludeSourceOnError(RestRequest restRequest) Extract the?include_source_on_errorparameter from the request, returningtruein case the parameter is missing.static TimeValuegetMasterNodeTimeout(RestRequest restRequest) Extract the?master_timeoutparameter from the request, imposing the common default of30sin case the parameter is missing.static TimeValuegetTimeout(RestRequest restRequest) Extract the?timeoutparameter from the request, returning null in case the parameter is missing.
-
Field Details
-
REST_DECODER
-
REST_MASTER_TIMEOUT_PARAM
The name of the common?master_timeoutquery parameter.- See Also:
-
REST_MASTER_TIMEOUT_DEFAULT
The default value for the common?master_timeoutquery parameter. -
REST_TIMEOUT_PARAM
The name of the common?timeoutquery parameter.- See Also:
-
INCLUDE_SOURCE_ON_ERROR_PARAMETER
The name of the common?include_source_on_errorquery parameter. By default, the document source is included in the error response in case of parsing errors. This parameter allows to disable this.- See Also:
-
-
Constructor Details
-
RestUtils
public RestUtils()
-
-
Method Details
-
decodeQueryString
-
decodeQueryString
-
decodeComponent
Decodes a bit of an URL encoded by a browser.This is equivalent to calling
decodeComponent(String, Charset, boolean)with the UTF-8 charset (recommended to comply with RFC 3986, Section 2).- Parameters:
s- The string to decode (can be empty).- Returns:
- The decoded string, or
sif there's nothing to decode. If the string to decode isnull, returns an empty string. - Throws:
IllegalArgumentException- if the string contains a malformed escape sequence.
-
checkCorsSettingForRegex
Determine if CORS setting is a regex- Returns:
- a corresponding
Patternif so and o.w. null.
-
corsSettingAsArray
Return the CORS setting as an array of origins.- Parameters:
corsSetting- the CORS allow origin setting as configured by the user; should never pass null, but we check for it anyway.- Returns:
- an array of origins if set, otherwise
null.
-
extractTraceId
Extract the trace id from the specified traceparent string.- Parameters:
traceparent- The value from thetraceparentHTTP header- Returns:
- The trace id from the traceparent string, or
Optional.empty()if it is not present. - See Also:
-
getMasterNodeTimeout
Extract the?master_timeoutparameter from the request, imposing the common default of30sin case the parameter is missing.- Parameters:
restRequest- The request from which to extract the?master_timeoutparameter- Returns:
- the timeout from the request, with a default of
REST_MASTER_TIMEOUT_DEFAULT(30s) if the request does not specify the parameter
-
getAckTimeout
Extract the?timeoutparameter from the request, imposing the common default of30sin case the parameter is missing.- Parameters:
restRequest- The request from which to extract the?timeoutparameter- Returns:
- the timeout from the request, with a default of
AcknowledgedRequest.DEFAULT_ACK_TIMEOUT(30s) if the request does not specify the parameter
-
getTimeout
Extract the?timeoutparameter from the request, returning null in case the parameter is missing.- Parameters:
restRequest- The request from which to extract the?timeoutparameter- Returns:
- the timeout from the request, with a default of
nullif the request does not specify the parameter
-
getIncludeSourceOnError
Extract the?include_source_on_errorparameter from the request, returningtruein case the parameter is missing.- Parameters:
restRequest- The request from which to extract the?include_source_on_errorparameter- Returns:
- the value of the
?include_source_on_errorparameter from the request, with a default oftrueif the request
-
consumeDeprecatedLocalParameter
-