Introduced ok & acknowledged constant in AcknowledgedRestResponseActionListener

This commit is contained in:
Luca Cavanna 2013-12-11 21:28:54 +01:00
parent b1fa147968
commit 24434063b6
1 changed files with 8 additions and 2 deletions

View File

@ -21,6 +21,7 @@ package org.elasticsearch.rest;
import org.elasticsearch.action.support.master.AcknowledgedResponse;
import org.elasticsearch.common.logging.ESLogger;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.rest.action.support.RestXContentBuilder;
import java.io.IOException;
@ -40,8 +41,8 @@ public class AcknowledgedRestResponseActionListener<T extends AcknowledgedRespon
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
builder.startObject()
.field("ok", true)
.field("acknowledged", response.isAcknowledged());
.field(Fields.OK, true)
.field(Fields.ACKNOWLEDGED, response.isAcknowledged());
addCustomFields(builder, response);
builder.endObject();
channel.sendResponse(new XContentRestResponse(request, OK, builder));
@ -57,4 +58,9 @@ public class AcknowledgedRestResponseActionListener<T extends AcknowledgedRespon
protected void addCustomFields(XContentBuilder builder, T response) throws IOException {
}
static final class Fields {
static final XContentBuilderString OK = new XContentBuilderString("ok");
static final XContentBuilderString ACKNOWLEDGED = new XContentBuilderString("acknowledged");
}
}