From dd17770a05b06dbdec7a1fe9604e231d7e11d2ac Mon Sep 17 00:00:00 2001 From: "U-BASIS\\dsmyda" Date: Mon, 11 Feb 2019 13:35:15 -0500 Subject: [PATCH] Cleaned up the logic to be less verbose --- .../textextractors/TikaTextExtractor.java | 27 +++++++------------ 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/textextractors/TikaTextExtractor.java b/Core/src/org/sleuthkit/autopsy/textextractors/TikaTextExtractor.java index 420c25a1a4..a75ccab260 100644 --- a/Core/src/org/sleuthkit/autopsy/textextractors/TikaTextExtractor.java +++ b/Core/src/org/sleuthkit/autopsy/textextractors/TikaTextExtractor.java @@ -147,25 +147,16 @@ final class TikaTextExtractor implements TextExtractor { public TikaTextExtractor(Content content) { this.content = content; + + parser = new AutoDetectParser(); - if (!(content instanceof AbstractFile)) { - parser = new AutoDetectParser(); - return; - } - - AbstractFile file = (AbstractFile) content; - if (file.getMIMEType() == null) { - parser = new AutoDetectParser(); - } else { - parser = new AutoDetectParser(new Detector() { - /** - * Set the Tika logic to use the pre-computed mime type - */ - @Override - public MediaType detect(InputStream in, Metadata mtdt) throws IOException { - return MediaType.parse(file.getMIMEType()); - } - }); + if (content instanceof AbstractFile) { + AbstractFile file = (AbstractFile) content; + if(file.getMIMEType() != null) { + //Set the Tika logic to use the pre-computed mime type + parser.setDetector((InputStream inStream, Metadata metaData) -> + MediaType.parse(file.getMIMEType())); + } } }