}
return supportedMediaTypes.contains(MediaType.parse(type));
}
private String parseStringValue(Blob v, Metadata metadata) {
WriteOutContentHandler handler = new WriteOutContentHandler();
try {
InputStream stream = v.getNewStream();
try {
parser.parse(stream, handler, metadata, new ParseContext());
} finally {
stream.close();
}
} catch (LinkageError e) {
// Capture and ignore errors caused by extraction libraries
// not being present. This is equivalent to disabling
// selected media types in configuration, so we can simply
// ignore these errors.
} catch (Throwable t) {
// Capture and report any other full text extraction problems.
// The special STOP exception is used for normal termination.
if (!handler.isWriteLimitReached(t)) {
log.debug("Failed to extract text from a binary property."
+ " This is a fairly common case, and nothing to"
+ " worry about. The stack trace is included to"
+ " help improve the text extraction feature.", t);
return "TextExtractionError";
}
}
return handler.toString();
}