Class DeprecationRestHandler

All Implemented Interfaces:

public class DeprecationRestHandler extends FilterRestHandler implements RestHandler
DeprecationRestHandler provides a proxy for any existing RestHandler so that usage of the handler can be logged using the DeprecationLogger.
  • Field Details

  • Constructor Details

    • DeprecationRestHandler

      public DeprecationRestHandler(RestHandler handler, RestRequest.Method method, String path, @Nullable org.apache.logging.log4j.Level deprecationLevel, String deprecationMessage, DeprecationLogger deprecationLogger)
      Create a DeprecationRestHandler that encapsulates the handler using the deprecationLogger to log deprecation warning.
      handler - The rest handler to deprecate (it's possible that the handler is reused with a different name!)
      method - a method of a deprecated endpoint
      path - a path of a deprecated endpoint
      deprecationMessage - The message to warn users with when they use the handler
      deprecationLogger - The deprecation logger
      NullPointerException - if any parameter except deprecationMessage is null
      IllegalArgumentException - if deprecationMessage is 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 DeprecationLogger so that the actual response can be notified of deprecation as well.

      Specified by:
      handleRequest in interface RestHandler
      request - The request to handle
      channel - The channel to write the request response to
      client - A client to use to make internal requests on behalf of the original request
    • validHeaderValue

      public static boolean validHeaderValue(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.

      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.

      value - The header value to check
      true if the value is not obviously wrong.
    • requireValidHeader

      public static String requireValidHeader(String value)
      Throw an exception if the value is not a valid header.
      value - The header value to check
      Always value.
      IllegalArgumentException - if value is not a valid header.