Package org.elasticsearch.rest
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 newXContentBuilder
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 newXContentBuilder
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
-
request
-
-
Constructor Details
-
AbstractRestChannel
Construct a channel for handling the request.- Parameters:
request
- the requestdetailedErrorsEnabled
- 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 interfaceRestChannel
- Throws:
java.io.IOException
-
newErrorBuilder
public org.elasticsearch.common.xcontent.XContentBuilder newErrorBuilder() throws java.io.IOException- Specified by:
newErrorBuilder
in interfaceRestChannel
- Throws:
java.io.IOException
-
newBuilder
public org.elasticsearch.common.xcontent.XContentBuilder newBuilder(@Nullable org.elasticsearch.common.xcontent.XContentType requestContentType, boolean useFiltering) throws java.io.IOExceptionCreates a newXContentBuilder
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 anXContentType
. If there is no format parameter, the HTTP Accept header is checked to see if it can be matched to aXContentType
. If this first attempt to map fails, the request content type will be used if the value is notnull
; if the value isnull
the output format falls back to JSON.- Specified by:
newBuilder
in interfaceRestChannel
- 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.IOExceptionCreates a newXContentBuilder
for a response to be sent using this channel. The builder's type can be sent as a parameter, throughresponseContentType
or it can fallback tonewBuilder(XContentType, boolean)
logic if the sent type value isnull
.- Specified by:
newBuilder
in interfaceRestChannel
- Throws:
java.io.IOException
-
bytesOutput
A channel level bytes output that can be reused. The bytes output is lazily instantiated by a call tonewBytesOutput()
. Once the stream is created, it gets reset on each call to this method.- Specified by:
bytesOutput
in interfaceRestChannel
-
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
-
request
- Specified by:
request
in interfaceRestChannel
-
detailedErrorsEnabled
public boolean detailedErrorsEnabled()- Specified by:
detailedErrorsEnabled
in interfaceRestChannel
- Returns:
- true iff an error response should contain additional details like exception traces.
-