Package org.elasticsearch.rest
Class AbstractRestChannel
java.lang.Object
org.elasticsearch.rest.AbstractRestChannel
- All Implemented Interfaces:
RestChannel
- Direct Known Subclasses:
DefaultRestChannel
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedAbstractRestChannel(RestRequest request, boolean detailedErrorsEnabled)Construct a channel for handling the request. -
Method Summary
Modifier and TypeMethodDescriptionA channel level bytes output that can be reused.booleanorg.elasticsearch.common.xcontent.XContentBuilderorg.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 BytesStreamOutputorg.elasticsearch.common.xcontent.XContentBuilderprotected voidReleases 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, waitMethods 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:
newBuilderin interfaceRestChannel- Throws:
IOException
-
newErrorBuilder
- Specified by:
newErrorBuilderin interfaceRestChannel- Throws:
IOException
-
newBuilder
public org.elasticsearch.common.xcontent.XContentBuilder newBuilder(@Nullable org.elasticsearch.common.xcontent.XContentType requestContentType, boolean useFiltering) throws 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:
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 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:
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:
bytesOutputin 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:
requestin interfaceRestChannel
-
detailedErrorsEnabled
public boolean detailedErrorsEnabled()- Specified by:
detailedErrorsEnabledin interfaceRestChannel- Returns:
- true iff an error response should contain additional details like exception traces.
-