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()XContentBuildernewBuilder()XContentBuildernewBuilder(XContentType requestContentType, boolean useFiltering)Creates a newXContentBuilderfor a response to be sent using this channel.protected BytesStreamOutputnewBytesOutput()XContentBuildernewErrorBuilder()RestRequestrequest()-
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 Detail
-
request
protected final RestRequest request
-
-
Constructor Detail
-
AbstractRestChannel
protected AbstractRestChannel(RestRequest request, boolean detailedErrorsEnabled)
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 Detail
-
newBuilder
public XContentBuilder newBuilder() throws java.io.IOException
- Specified by:
newBuilderin interfaceRestChannel- Throws:
java.io.IOException
-
newErrorBuilder
public XContentBuilder newErrorBuilder() throws java.io.IOException
- Specified by:
newErrorBuilderin interfaceRestChannel- Throws:
java.io.IOException
-
newBuilder
public XContentBuilder newBuilder(@Nullable XContentType requestContentType, boolean useFiltering) throws java.io.IOException
Creates 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
-
bytesOutput
public final BytesStreamOutput 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
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:
requestin interfaceRestChannel
-
detailedErrorsEnabled
public boolean detailedErrorsEnabled()
- Specified by:
detailedErrorsEnabledin interfaceRestChannel- Returns:
- true iff an error response should contain additional details like exception traces.
-
-