exportRequest.types(splitTypes(request.param("type")));
exportRequest.preference(request.param("preference", "_primary"));
} 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) {
logger.error("Failed to send failure response", e1);
}
return;
}
client.execute(action(), exportRequest, new ActionListener<ExportResponse>() {
public void onResponse(ExportResponse response) {
try {
XContentBuilder builder = RestXContentBuilder.restContentBuilder(request);
response.toXContent(builder, request);
channel.sendResponse(new XContentRestResponse(request, OK, builder));
} catch (Exception e) {
onFailure(e);
}
}