if (null != destElement) {
logger.warn("Parsed element '"+fieldName+"' already present in document. Will not overwrite.");
return;
}
ParseOutput out = parser.parse("",bodyElement.getText().getBytes("UTF-8"),"UTF-8");
for (String field: extraFields) {
String content = out.getField(field);
if (null == content) {
logger.debug("had document without " + field + " field. Continuing with other fields.");
continue;
}
Element docField = DocumentHelper.createElement("field");
docField.addText(content);
docField.addAttribute("name",field);
docField.addAttribute("indexed", Boolean.toString(INDEXED));
docField.addAttribute("stored", Boolean.toString(STORED));
docField.addAttribute("tokenized", "true");
bodyElement.getParent().add(docField);
}
String text = out.getText();
Element field = DocumentHelper.createElement("field");
field.addText(text);
field.addAttribute("name", fieldName);
field.addAttribute("indexed", Boolean.toString(INDEXED));
field.addAttribute("stored", Boolean.toString(STORED));