java.lang.Object
org.elasticsearch.rest.FilterRestHandler
org.elasticsearch.rest.DeprecationRestHandler
- All Implemented Interfaces:
RestHandler
DeprecationRestHandler provides a proxy for any existing RestHandler so that usage of the handler can be
logged using the DeprecationLogger.-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.rest.RestHandler
RestHandler.Route -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDeprecationRestHandler(RestHandler handler, RestRequest.Method method, String path, org.apache.logging.log4j.Level deprecationLevel, String deprecationMessage, DeprecationLogger deprecationLogger, boolean compatibleVersionWarning) Create aDeprecationRestHandlerthat encapsulates thehandlerusing thedeprecationLoggerto log deprecationwarning. -
Method Summary
Modifier and TypeMethodDescriptionvoidhandleRequest(RestRequest request, RestChannel channel, NodeClient client) Handles a rest request.static StringrequireValidHeader(String value) Throw an exception if thevalueis not avalid header.static booleanvalidHeaderValue(String value) This does a very basic pass at validating that a header's value contains only expected characters according to RFC-5987, and those that it references.Methods inherited from class org.elasticsearch.rest.FilterRestHandler
allowSystemIndexAccessByDefault, canTripCircuitBreaker, getConcreteRestHandler, getDelegate, mediaTypesValid, routes, supportsBulkContentMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.rest.RestHandler
allowSystemIndexAccessByDefault, allSupportedParameters, canTripCircuitBreaker, getConcreteRestHandler, getName, getServerlessScope, mediaTypesValid, routes, supportedCapabilities, supportedQueryParameters, supportsBulkContent, supportsContentStream
-
Field Details
-
DEPRECATED_ROUTE_KEY
- See Also:
-
-
Constructor Details
-
DeprecationRestHandler
public DeprecationRestHandler(RestHandler handler, RestRequest.Method method, String path, org.apache.logging.log4j.Level deprecationLevel, String deprecationMessage, DeprecationLogger deprecationLogger, boolean compatibleVersionWarning) Create aDeprecationRestHandlerthat encapsulates thehandlerusing thedeprecationLoggerto log deprecationwarning.- Parameters:
handler- The rest handler to deprecate (it's possible that the handler is reused with a different name!)method- a method of a deprecated endpointpath- a path of a deprecated endpointdeprecationLevel- The level of the deprecation warning, must be non-null and eitherLevel.WARNorDeprecationLogger.CRITICALdeprecationMessage- The message to warn users with when they use thehandlerdeprecationLogger- The deprecation loggercompatibleVersionWarning- set to false so that a deprecation warning will be issued for the handled request, set to true to that a compatibility api warning will be issue for the handled request- Throws:
NullPointerException- if any parameter exceptdeprecationMessageisnullIllegalArgumentException- ifdeprecationMessageis not a valid header
-
-
Method Details
-
handleRequest
public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws Exception Handles a rest request.Usage is logged via the
DeprecationLoggerso that the actual response can be notified of deprecation as well.- Specified by:
handleRequestin interfaceRestHandler- Parameters:
request- The request to handlechannel- The channel to write the request response toclient- A client to use to make internal requests on behalf of the original request- Throws:
Exception
-
validHeaderValue
This does a very basic pass at validating that a header's value contains only expected characters according to RFC-5987, and those that it references.https://tools.ietf.org/html/rfc5987
This is only expected to be used for assertions. The idea is that only readable US-ASCII characters are expected; the rest must be encoded with percent encoding, which makes checking for a valid character range very simple.
- Parameters:
value- The header value to check- Returns:
trueif thevalueis not obviously wrong.
-
requireValidHeader
Throw an exception if thevalueis not avalid header.- Parameters:
value- The header value to check- Returns:
- Always
value. - Throws:
IllegalArgumentException- ifvalueis not avalid header.
-