Package org.elasticsearch.rest
Class DeprecationRestHandler
- java.lang.Object
-
- org.elasticsearch.rest.DeprecationRestHandler
-
- All Implemented Interfaces:
RestHandler
public class DeprecationRestHandler extends java.lang.Object implements RestHandler
DeprecationRestHandlerprovides a proxy for any existingRestHandlerso that usage of the handler can be logged using theDeprecationLogger.
-
-
Constructor Summary
Constructors Constructor Description DeprecationRestHandler(RestHandler handler, java.lang.String deprecationMessage, DeprecationLogger deprecationLogger)Create aDeprecationRestHandlerthat encapsulates thehandlerusing thedeprecationLoggerto log deprecationwarning.
-
Method Summary
Modifier and Type Method Description voidhandleRequest(RestRequest request, RestChannel channel, NodeClient client)Handles a rest request.static java.lang.StringrequireValidHeader(java.lang.String value)Throw an exception if thevalueis not avalid header.booleansupportsContentStream()Indicates if the RestHandler supports content as a stream.static booleanvalidHeaderValue(java.lang.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 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.elasticsearch.rest.RestHandler
canTripCircuitBreaker
-
-
-
-
Constructor Detail
-
DeprecationRestHandler
public DeprecationRestHandler(RestHandler handler, java.lang.String deprecationMessage, DeprecationLogger deprecationLogger)
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!)deprecationMessage- The message to warn users with when they use thehandlerdeprecationLogger- The deprecation logger- Throws:
java.lang.NullPointerException- if any parameter exceptdeprecationMessageisnulljava.lang.IllegalArgumentException- ifdeprecationMessageis not a valid header
-
-
Method Detail
-
handleRequest
public void handleRequest(RestRequest request, RestChannel channel, NodeClient client) throws java.lang.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:
java.lang.Exception
-
supportsContentStream
public boolean supportsContentStream()
Description copied from interface:RestHandlerIndicates 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:
supportsContentStreamin interfaceRestHandler
-
validHeaderValue
public static boolean validHeaderValue(java.lang.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.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
public static java.lang.String requireValidHeader(java.lang.String value)
Throw an exception if thevalueis not avalid header.- Parameters:
value- The header value to check- Returns:
- Always
value. - Throws:
java.lang.IllegalArgumentException- ifvalueis not avalid header.
-
-