From 1a70a4e8b298116a596830a7e58094d6249f9af7 Mon Sep 17 00:00:00 2001 From: millmanorama Date: Mon, 12 Dec 2016 17:06:58 +0100 Subject: [PATCH] introduce ArtifactExtractor --- .../keywordsearch/ArtifactExtractor.java | 39 +++++++++++++++++++ .../autopsy/keywordsearch/Ingester.java | 2 +- .../keywordsearch/SolrSearchService.java | 18 ++++----- .../autopsy/keywordsearch/TextExtractor.java | 29 +------------- .../autopsy/keywordsearch/TextProvider.java | 39 +++++++++++++++++++ 5 files changed, 89 insertions(+), 38 deletions(-) create mode 100644 KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ArtifactExtractor.java create mode 100644 KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TextProvider.java diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ArtifactExtractor.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ArtifactExtractor.java new file mode 100644 index 0000000000..f91ea5bca0 --- /dev/null +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/ArtifactExtractor.java @@ -0,0 +1,39 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package org.sleuthkit.autopsy.keywordsearch; + +import java.io.InputStream; +import java.io.Reader; +import org.sleuthkit.datamodel.BlackboardArtifact; + +public class ArtifactExtractor extends TextProvider { + + @Override + boolean noExtractionOptionsAreEnabled() { + return false; + } + + @Override + void logWarning(String msg, Exception ex) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + Void newAppendixProvider() { + return null; + } + + @Override + InputStream getInputStream(BlackboardArtifact source) { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + @Override + Reader getReader(InputStream stream, BlackboardArtifact source, Void appendix) throws Ingester.IngesterException { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + +} diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Ingester.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Ingester.java index 9a16fb8a1f..8a804569a1 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Ingester.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/Ingester.java @@ -328,7 +328,7 @@ class Ingester { * * @throws org.sleuthkit.autopsy.keywordsearch.Ingester.IngesterException */ - private void indexContentStream(ContentStream cs, Map fields, final long size) throws IngesterException { + void indexContentStream(ContentStream cs, Map fields, final long size) throws IngesterException { if (fields.get(Server.Schema.IMAGE_ID.toString()) == null) { //skip the file, image id unknown String msg = NbBundle.getMessage(this.getClass(), diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java index 546614424a..b55009cc25 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2015 Basis Technology Corp. + * Copyright 2011-2016 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,24 +19,24 @@ package org.sleuthkit.autopsy.keywordsearch; import java.io.IOException; +import java.net.InetAddress; import java.util.HashMap; +import java.util.MissingResourceException; import org.apache.solr.client.solrj.SolrServerException; import org.apache.solr.client.solrj.impl.HttpSolrServer; -import org.sleuthkit.datamodel.BlackboardArtifact; -import org.sleuthkit.datamodel.BlackboardAttribute; -import org.sleuthkit.datamodel.TskCoreException; -import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService; import org.apache.solr.common.util.ContentStreamBase.StringStream; +import org.openide.util.NbBundle; import org.openide.util.lookup.ServiceProvider; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.datamodel.ContentUtils; +import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService; +import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException; import org.sleuthkit.datamodel.AbstractFile; +import org.sleuthkit.datamodel.BlackboardArtifact; +import org.sleuthkit.datamodel.BlackboardAttribute; import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.SleuthkitCase; -import org.openide.util.NbBundle; -import java.net.InetAddress; -import java.util.MissingResourceException; -import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException; +import org.sleuthkit.datamodel.TskCoreException; /** * An implementation of the KeywordSearchService interface that uses Solr for diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TextExtractor.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TextExtractor.java index c0068f2609..4d6315474b 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TextExtractor.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TextExtractor.java @@ -18,8 +18,6 @@ */ package org.sleuthkit.autopsy.keywordsearch; -import java.io.InputStream; -import java.io.Reader; import java.util.Arrays; import java.util.List; import org.sleuthkit.datamodel.AbstractFile; @@ -28,11 +26,7 @@ import org.sleuthkit.datamodel.AbstractFile; * Common methods for utilities that extract text and content and divide into * chunks */ -abstract class TextExtractor { - - Ingester getIngester() { - return Server.getIngester(); - } +abstract class TextExtractor extends TextProvider { /** * Common options that can be used by some extractors @@ -86,16 +80,6 @@ abstract class TextExtractor { "application/x-z", //NON-NLS "application/x-compress"); //NON-NLS -// /** -// * Index the Abstract File -// * -// * @param sourceFile file to index -// * -// * @return true if indexed successfully, false otherwise -// * -// * @throws org.sleuthkit.autopsy.keywordsearch.Ingester.IngesterException -// */ -// boolean chunkText(AbstractFile sourceFile, IngestJobContext context) throws Ingester.IngesterException; /** * Determines if the extractor works only for specified types is * supportedTypes() or whether is a generic content extractor (such as @@ -117,17 +101,6 @@ abstract class TextExtractor { */ abstract boolean isSupported(AbstractFile file, String detectedFormat); - abstract boolean noExtractionOptionsAreEnabled(); - abstract void logWarning(final String msg, Exception ex); - void appendDataToFinalChunk(StringBuilder sb, AppendixProvider dataProvider) { - //no-op - } - - abstract AppendixProvider newAppendixProvider(); - - abstract InputStream getInputStream(AbstractFile sourceFile1); - - abstract Reader getReader(InputStream stream, AbstractFile sourceFile, AppendixProvider appendix) throws Ingester.IngesterException; } diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TextProvider.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TextProvider.java new file mode 100644 index 0000000000..5808293edd --- /dev/null +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/TextProvider.java @@ -0,0 +1,39 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2011-16 Basis Technology Corp. + * Contact: carrier sleuthkit org + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.sleuthkit.autopsy.keywordsearch; + +import java.io.InputStream; +import java.io.Reader; + +abstract class TextProvider { + + abstract boolean noExtractionOptionsAreEnabled(); + + abstract void logWarning(final String msg, Exception ex); + + void appendDataToFinalChunk(StringBuilder sb, AppendixProvider dataProvider) { + //no-op + } + + abstract AppendixProvider newAppendixProvider(); + + abstract InputStream getInputStream(TextSource source); + + abstract Reader getReader(InputStream stream, TextSource source, AppendixProvider appendix) throws Ingester.IngesterException; +}