Class AbstractRestChannel

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

public abstract class AbstractRestChannel
extends java.lang.Object
implements RestChannel
  • Field Summary

    Fields
    Modifier and Type Field Description
    protected RestRequest request  
  • 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
    BytesStreamOutput bytesOutput()
    A channel level bytes output that can be reused.
    protected BytesStreamOutput bytesOutputOrNull()
    An accessor to the raw value of the channel bytes output.
    boolean detailedErrorsEnabled()  
    org.elasticsearch.common.xcontent.XContentBuilder newBuilder()  
    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.
    protected BytesStreamOutput newBytesOutput()  
    org.elasticsearch.common.xcontent.XContentBuilder newErrorBuilder()  
    RestRequest request()  

    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:
      java.lang.IllegalArgumentException - if parsing the pretty or human parameters fails
  • Method Details

    • newBuilder

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

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

      public org.elasticsearch.common.xcontent.XContentBuilder newBuilder​(@Nullable org.elasticsearch.common.xcontent.XContentType requestContentType, boolean useFiltering) throws java.io.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:
      java.io.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 java.io.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:
      java.io.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(). Once the stream is created, it gets reset on each call to this method.
      Specified by:
      bytesOutput in interface RestChannel
    • bytesOutputOrNull

      protected final BytesStreamOutput bytesOutputOrNull()
      An accessor to the raw value of the channel bytes output. This method will not instantiate a new stream if one does not exist and this method will not reset the stream.
    • 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.