private Document extractAll(final InputStream in,
LuceneDocumentMetadata documentMetadata,
boolean extractContent,
boolean extractMetadata) {
TikaContent content = extractor.extract(in, extractContent);
if (content == null) {
return null;
}
final Document document = new Document();
if (documentMetadata == null) {
documentMetadata = defaultDocumentMetadata;
}
if (content.getContent() != null) {
document.add(getContentField(documentMetadata, content.getContent()));
}
if (extractMetadata) {
Metadata metadata = content.getMetadata();
for (final String property: metadata.names()) {
document.add(getField(documentMetadata, property, metadata.get(property)));
}
}