Package org.elasticsearch.rest
Class DeprecationRestHandler
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
-
Constructor Summary
ConstructorDescriptionDeprecationRestHandler(RestHandler handler, RestRequest.Method method, path, deprecationMessage, DeprecationLogger deprecationLogger)
Create aDeprecationRestHandler
that encapsulates thehandler
using thedeprecationLogger
to log deprecationwarning
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
handleRequest(RestRequest request, RestChannel channel, NodeClient client)
Handles a rest request.static
value)
Throw an exception if thevalue
is not avalid header
.boolean
Indicates if the RestHandler supports content as a stream.static boolean
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 java.lang.
, , , , , , , , , ,
Methods inherited from interface org.elasticsearch.rest.RestHandler
allowsUnsafeBuffers, allowSystemIndexAccessByDefault, canTripCircuitBreaker, routes
-
Field Details
-
DEPRECATED_ROUTE_KEY
public static final DEPRECATED_ROUTE_KEY- See Also:
- Constant Field Values
-
-
Constructor Details
-
DeprecationRestHandler
public DeprecationRestHandler(RestHandler handler, RestRequest.Method method, path, deprecationMessage, DeprecationLogger deprecationLogger)Create aDeprecationRestHandler
that encapsulates thehandler
using thedeprecationLogger
to 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 endpointdeprecationMessage
- The message to warn users with when they use thehandler
deprecationLogger
- The deprecation logger- Throws:
- if any parameter except
deprecationMessage
isnull
- if
deprecationMessage
is not a valid header
-
-
Method Details
-
handleRequest
Handles a rest request.Usage is logged via the
DeprecationLogger
so that the actual response can be notified of deprecation as well.- Specified by:
handleRequest
in 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:
-
supportsContentStream
public boolean supportsContentStream()Description copied from interface:RestHandler
Indicates if the RestHandler supports content as a stream. A stream would be multiple objects delineated byXContent.streamSeparator()
. If a handler returns true this will affect the types of content that can be sent to this endpoint.- Specified by:
supportsContentStream
in interfaceRestHandler
-
validHeaderValue
public static boolean validHeaderValue( 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.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:
true
if thevalue
is not obviously wrong.
-
requireValidHeader
public static requireValidHeader( value)Throw an exception if thevalue
is not avalid header
.- Parameters:
value
- The header value to check- Returns:
- Always
value
. - Throws:
- if
value
is not avalid header
.
-