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 RestRequestrequest -
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractRestChannel(RestRequest request, boolean detailedErrorsEnabled)Construct a channel for handling the request. -
Method Summary
Modifier and Type Method Description BytesStreamOutputbytesOutput()A channel level bytes output that can be reused.protected BytesStreamOutputbytesOutputOrNull()An accessor to the raw value of the channel bytes output.booleandetailedErrorsEnabled()org.elasticsearch.common.xcontent.XContentBuildernewBuilder()org.elasticsearch.common.xcontent.XContentBuildernewBuilder(org.elasticsearch.common.xcontent.XContentType requestContentType, boolean useFiltering)Creates a newXContentBuilderfor a response to be sent using this channel.org.elasticsearch.common.xcontent.XContentBuildernewBuilder(org.elasticsearch.common.xcontent.XContentType requestContentType, org.elasticsearch.common.xcontent.XContentType responseContentType, boolean useFiltering)Creates a newXContentBuilderfor a response to be sent using this channel.protected BytesStreamOutputnewBytesOutput()org.elasticsearch.common.xcontent.XContentBuildernewErrorBuilder()RestRequestrequest()
-
Field Details
-
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:
newBuilderin interfaceRestChannel- Throws:
java.io.IOException
-
newErrorBuilder
public org.elasticsearch.common.xcontent.XContentBuilder newErrorBuilder() throws java.io.IOException- Specified by:
newErrorBuilderin 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 newXContentBuilderfor 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 isnullthe output format falls back to JSON.- Specified by:
newBuilderin 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 newXContentBuilderfor a response to be sent using this channel. The builder's type can be sent as a parameter, throughresponseContentTypeor it can fallback tonewBuilder(XContentType, boolean)logic if the sent type value isnull.- Specified by:
newBuilderin 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:
bytesOutputin 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:
requestin interfaceRestChannel
-
detailedErrorsEnabled
public boolean detailedErrorsEnabled()- Specified by:
detailedErrorsEnabledin interfaceRestChannel- Returns:
- true iff an error response should contain additional details like exception traces.
-