protected Action action() {
return ImportAction.INSTANCE;
}
public void handleRequest(final RestRequest request, final RestChannel channel) {
ImportRequest importRequest = new ImportRequest();
importRequest.listenerThreaded(false);
try {
if (request.hasContent()) {
importRequest.source(request.content(), request.contentUnsafe());
} else {
String source = request.param("source");
if (source != null) {
importRequest.source(source);
} else {
BytesReference querySource = RestActions.parseQuerySource(request);
if (querySource != null) {
importRequest.source(querySource, false);
}
}
}
importRequest.index(request.param("index"));
importRequest.type(request.param("type"));
} catch (Exception e) {
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
channel.sendResponse(new XContentRestResponse(request, BAD_REQUEST, builder.startObject().field("error", e.getMessage()).endObject()));
} catch (IOException e1) {