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 TypeMethodDescriptionfinal BytesStreamA channel level bytes output that can be reused.booleannewBuilder(XContentType requestContentType, boolean useFiltering) Creates a newXContentBuilderfor a response to be sent using this channel.newBuilder(XContentType requestContentType, XContentType responseContentType, boolean useFiltering) Creates a newXContentBuilderfor a response to be sent using this channel.newBuilder(XContentType requestContentType, XContentType responseContentType, boolean useFiltering, OutputStream outputStream) Creates a newXContentBuilderfor a response to be sent using this channel.protected BytesStreamfinal 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 XContentBuilder newBuilder(@Nullable XContentType requestContentType, boolean useFiltering) throws 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:
IOException
-
newBuilder
public XContentBuilder newBuilder(@Nullable XContentType requestContentType, @Nullable XContentType responseContentType, boolean useFiltering) throws IOException Creates 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
-
newBuilder
public XContentBuilder newBuilder(@Nullable XContentType requestContentType, @Nullable XContentType responseContentType, boolean useFiltering, OutputStream outputStream) throws IOException Creates 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
public final void releaseOutputBuffer()Description copied from interface:RestChannelReleases the current output buffer for this channel. Must be called after the buffer derived fromRestChannel.bytesOutput()is no longer needed.- Specified by:
releaseOutputBufferin interfaceRestChannel
-
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.
-