Class AbstractRestChannel

java.lang.Object
org.elasticsearch.rest.AbstractRestChannel
All Implemented Interfaces:
RestChannel
Direct Known Subclasses:
DefaultRestChannel

public abstract class AbstractRestChannel extends Object implements RestChannel
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected RestRequest
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    AbstractRestChannel​(RestRequest request, boolean detailedErrorsEnabled)
    Construct a channel for handling the request.
  • Method Summary

    Modifier and Type
    Method
    Description
    A channel level bytes output that can be reused.
    boolean
     
    org.elasticsearch.common.xcontent.XContentBuilder
     
    org.elasticsearch.common.xcontent.XContentBuilder
    newBuilder​(org.elasticsearch.common.xcontent.XContentType requestContentType, boolean useFiltering)
    Creates a new XContentBuilder for a response to be sent using this channel.
    org.elasticsearch.common.xcontent.XContentBuilder
    newBuilder​(org.elasticsearch.common.xcontent.XContentType requestContentType, org.elasticsearch.common.xcontent.XContentType responseContentType, boolean useFiltering)
    Creates a new XContentBuilder for a response to be sent using this channel.
     
    org.elasticsearch.common.xcontent.XContentBuilder
     
    protected void
    Releases the current output buffer for this channel.
     

    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.RestChannel

    sendResponse
  • Field Details

  • Constructor Details

    • AbstractRestChannel

      protected AbstractRestChannel(RestRequest request, boolean detailedErrorsEnabled)
      Construct a channel for handling the request.
      Parameters:
      request - the request
      detailedErrorsEnabled - if detailed errors should be reported to the channel
      Throws:
      IllegalArgumentException - if parsing the pretty or human parameters fails
  • Method Details

    • newBuilder

      public org.elasticsearch.common.xcontent.XContentBuilder newBuilder() throws IOException
      Specified by:
      newBuilder in interface RestChannel
      Throws:
      IOException
    • newErrorBuilder

      public org.elasticsearch.common.xcontent.XContentBuilder newErrorBuilder() throws IOException
      Specified by:
      newErrorBuilder in interface RestChannel
      Throws:
      IOException
    • newBuilder

      public org.elasticsearch.common.xcontent.XContentBuilder newBuilder(@Nullable org.elasticsearch.common.xcontent.XContentType requestContentType, boolean useFiltering) throws IOException
      Creates a new XContentBuilder for a response to be sent using this channel. The builder's type is determined by the following logic. If the request has a format parameter that will be used to attempt to map to an XContentType. If there is no format parameter, the HTTP Accept header is checked to see if it can be matched to a XContentType. If this first attempt to map fails, the request content type will be used if the value is not null; if the value is null the output format falls back to JSON.
      Specified by:
      newBuilder in interface RestChannel
      Throws:
      IOException
    • newBuilder

      public org.elasticsearch.common.xcontent.XContentBuilder newBuilder(@Nullable org.elasticsearch.common.xcontent.XContentType requestContentType, @Nullable org.elasticsearch.common.xcontent.XContentType responseContentType, boolean useFiltering) throws IOException
      Creates a new XContentBuilder for a response to be sent using this channel. The builder's type can be sent as a parameter, through responseContentType or it can fallback to newBuilder(XContentType, boolean) logic if the sent type value is null.
      Specified by:
      newBuilder in interface RestChannel
      Throws:
      IOException
    • bytesOutput

      public final BytesStreamOutput bytesOutput()
      A channel level bytes output that can be reused. The bytes output is lazily instantiated by a call to newBytesOutput(). This method should only be called once per request.
      Specified by:
      bytesOutput in interface RestChannel
    • releaseOutputBuffer

      protected final void releaseOutputBuffer()
      Releases the current output buffer for this channel. Must be called after the buffer derived from bytesOutput() is no longer needed.
    • newBytesOutput

      protected BytesStreamOutput newBytesOutput()
    • request

      public RestRequest request()
      Specified by:
      request in interface RestChannel
    • detailedErrorsEnabled

      public boolean detailedErrorsEnabled()
      Specified by:
      detailedErrorsEnabled in interface RestChannel
      Returns:
      true iff an error response should contain additional details like exception traces.