}
} catch (Exception e) {
// some sort of error processing the xml input
try {
logger.error("Error processing xml input", e);
channel.sendResponse(new XContentThrowableRestResponse(request, e));
} catch (IOException e1) {
logger.error("Failed to send error response", e1);
}
}
} else if (handler.equals("javabin")) {
// JavaBin Content
try {
// We will use the JavaBin codec from solrj
// unmarshal the input to a SolrUpdate request
JavaBinUpdateRequestCodec codec = new JavaBinUpdateRequestCodec();
UpdateRequest req = codec.unmarshal(new ByteArrayInputStream(request.contentByteArray()), null);
// Get the list of documents to index out of the UpdateRequest
// Add each document to the bulk request
// convert the SolrInputDocument into a map which will be used as the ES source field
List<SolrInputDocument> docs = req.getDocuments();
if (docs != null) {
for (SolrInputDocument doc : docs) {
bulkRequest.add(getIndexRequest(convertToMap(doc), request));
}
}
// See if we have any documents to delete
// if yes, add them to the bulk request
if (req.getDeleteById() != null) {
for (String id : req.getDeleteById()) {
bulkRequest.add(getDeleteRequest(id, request));
}
}
} catch (Exception e) {
// some sort of error processing the javabin input
try {
logger.error("Error processing javabin input", e);
channel.sendResponse(new XContentThrowableRestResponse(request, e));
} catch (IOException e1) {
logger.error("Failed to send error response", e1);
}
}
}