Package org.elasticsearch.rest
Class AbstractRestChannel
java.lang.Object
org.elasticsearch.rest.AbstractRestChannel
- All Implemented Interfaces:
RestChannel
- Direct Known Subclasses:
DefaultRestChannel
-
Field Summary
-
Constructor Summary
ModifierConstructorDescriptionprotected
AbstractRestChannel(RestRequest request, boolean detailedErrorsEnabled)
Construct a channel for handling the request. -
Method Summary
Modifier and TypeMethodDescriptionA 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 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
org.elasticsearch.common.xcontent.XContentBuilder
protected void
Releases the current output buffer for this channel.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:
IllegalArgumentException
- if parsing the pretty or human parameters fails
-
-
Method Details
-
newBuilder
- Specified by:
newBuilder
in interfaceRestChannel
- Throws:
IOException
-
newErrorBuilder
- Specified by:
newErrorBuilder
in interfaceRestChannel
- Throws:
IOException
-
newBuilder
public org.elasticsearch.common.xcontent.XContentBuilder newBuilder(@Nullable org.elasticsearch.common.xcontent.XContentType requestContentType, boolean useFiltering) throws 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:
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 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:
IOException
-
bytesOutput
A channel level bytes output that can be reused. The bytes output is lazily instantiated by a call tonewBytesOutput()
. This method should only be called once per request.- Specified by:
bytesOutput
in interfaceRestChannel
-
releaseOutputBuffer
protected final void releaseOutputBuffer()Releases the current output buffer for this channel. Must be called after the buffer derived frombytesOutput()
is no longer needed. -
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.
-