message = message + "\n" + sbApiMapErr.toString();
}//TESTED (by hand)
if ((null != source.getHarvestStatus()) && (HarvestEnum.error == source.getHarvestStatus().getHarvest_status())) {
rp.setResponse(new ResponseObject("Test Source",false,"source error: " + message));
rp.setData(toAdd, new DocumentPojoApiMap());
}
else {
if ((null == message) || message.isEmpty()) {
message = "no messages from harvester";
}
rp.setResponse(new ResponseObject("Test Source",true,"successfully returned " + toAdd.size() + " docs: " + message));
try {
// If grabbing full text
// Also some logstash specific logic - these aren't docs so just output the entire record
boolean isLogstash = (null != source.getExtractType()) && source.getExtractType().equalsIgnoreCase("logstash");
List<BasicDBObject> logstashRecords = null;
if (bReturnFullText || isLogstash) {
for (DocumentPojo doc: toAdd) {
if (isLogstash) {
if (null == logstashRecords) {
logstashRecords = new ArrayList<BasicDBObject>(toAdd.size());
}
BasicDBObject dbo = (BasicDBObject) doc.getMetadata().get("logstash_record")[0];
Object test = dbo.get("_id");
if ((null != test) && (test instanceof ObjectId)) {
dbo.remove("_id"); // (unless it's a custom _id added from logstash then remove it)
}
logstashRecords.add(dbo);
}//TESTED
else if (bReturnFullText) {
doc.makeFullTextNonTransient();
}
}
}//TESTED
if (null != logstashRecords) {
rp.setData(logstashRecords, (BasePojoApiMap<BasicDBObject>)null);
}//TESTED
else {
rp.setData(toAdd, new DocumentPojoApiMap());
}//TESTED
//Test deserialization:
rp.toApi();
}