From f84ab97cf230f4f187f4e321fbf6b8ca3ff9c726 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Wed, 4 Nov 2015 15:51:16 -0500 Subject: [PATCH 01/12] Deprecated old KWS api, using new one --- .../keywordsearchservice/KeywordSearchService.java | 3 ++- .../keywordsearch/KeywordSearchIngestModule.java | 4 ++-- .../autopsy/keywordsearch/SolrSearchService.java | 14 ++++++++++++-- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/keywordsearchservice/KeywordSearchService.java b/Core/src/org/sleuthkit/autopsy/keywordsearchservice/KeywordSearchService.java index 69b7c57f4f..fed52adec8 100644 --- a/Core/src/org/sleuthkit/autopsy/keywordsearchservice/KeywordSearchService.java +++ b/Core/src/org/sleuthkit/autopsy/keywordsearchservice/KeywordSearchService.java @@ -23,8 +23,9 @@ import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.TskCoreException; /** - * + * @deprecated Use org.sleuthkit.datamodel.KeywordSearchService instead. */ +@Deprecated public interface KeywordSearchService extends Closeable { /** diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestModule.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestModule.java index bb86774bbe..2a60c48e54 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestModule.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestModule.java @@ -37,8 +37,8 @@ import org.sleuthkit.autopsy.ingest.IngestMessage.MessageType; import org.sleuthkit.autopsy.ingest.IngestModuleReferenceCounter; import org.sleuthkit.autopsy.ingest.IngestServices; import org.sleuthkit.autopsy.keywordsearch.Ingester.IngesterException; -import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService; -import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException; +import org.sleuthkit.datamodel.KeywordSearchService; +import org.sleuthkit.datamodel.KeywordSearchServiceException; import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.TskCoreException; diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java index dbc6598e2c..57d6e20733 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java @@ -25,7 +25,8 @@ 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.sleuthkit.datamodel.KeywordSearchService; +import org.sleuthkit.datamodel.KeywordSearchServiceException; import org.apache.solr.common.util.ContentStreamBase.StringStream; import org.openide.util.lookup.ServiceProvider; import org.sleuthkit.autopsy.casemodule.Case; @@ -36,7 +37,6 @@ import org.sleuthkit.datamodel.SleuthkitCase; import org.openide.util.NbBundle; import java.net.InetAddress; import java.util.MissingResourceException; -import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException; /** * An implementation of the KeywordSearchService interface that uses Solr for @@ -223,4 +223,14 @@ public class SolrSearchService implements KeywordSearchService { @Override public void close() throws IOException { } + + /** + * Returns whether or not keyword search is enabled for the current job. + * + * @return True is keyword search is enabled for the current job, false + * otherwise. + */ + public boolean isActive() { + return true; + } } From eafd71827b7ba99d08708e19a47096368eb32d7b Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Wed, 4 Nov 2015 15:54:42 -0500 Subject: [PATCH 02/12] Comments --- .../org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java index 57d6e20733..e07f9bf294 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java @@ -230,6 +230,7 @@ public class SolrSearchService implements KeywordSearchService { * @return True is keyword search is enabled for the current job, false * otherwise. */ + @Override public boolean isActive() { return true; } From 462ba34963dac83a8decd5278ae6509f6378039e Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Wed, 4 Nov 2015 15:56:09 -0500 Subject: [PATCH 03/12] Edited Javadocs --- .../org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java index e07f9bf294..e5897068ed 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java @@ -175,8 +175,7 @@ public class SolrSearchService implements KeywordSearchService { * * @param host the remote hostname or IP address of the Solr server * @param port the remote port for Solr - * - * @throws org.sleuthkit.autopsy.keywordsearch.KeywordSearchServiceException + * @throws org.sleuthkit.datamodel.KeywordSearchServiceException * */ @Override From c500746fb50c0805955a2b341c5205f3de114ae4 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Fri, 6 Nov 2015 14:04:52 -0500 Subject: [PATCH 04/12] Changed code to conform to design changes --- .../casemodule/services/Blackboard.java | 96 +++++++++++++++++++ .../KeywordSearchService.java | 3 +- .../KeywordSearchIngestModule.java | 4 +- .../keywordsearch/SolrSearchService.java | 18 +--- 4 files changed, 103 insertions(+), 18 deletions(-) create mode 100644 Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java b/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java new file mode 100644 index 0000000000..9f2327cc50 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java @@ -0,0 +1,96 @@ +/* + * Sleuth Kit Data Model + * + * Copyright 2011-2015 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.casemodule.services; + +import java.io.Closeable; +import java.io.IOException; +import org.openide.util.Exceptions; +import org.openide.util.Lookup; +import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService; +import org.sleuthkit.datamodel.BlackboardArtifact; +import org.sleuthkit.datamodel.TskCoreException; + +/** + * Provides utility methods for blackboard artifact indexing. + */ +public final class Blackboard implements Closeable { + + Blackboard() { + } + + /** + * Index the text associated with the given artifact. + * + * @param artifact The artifact to be indexed. + * + * @throws + * org.sleuthkit.autopsy.casemodule.services.Blackboard.BlackboardException + */ + public static void indexArtifact(BlackboardArtifact artifact) throws BlackboardException { + KeywordSearchService searchService = Lookup.getDefault().lookup(KeywordSearchService.class); + if (null != searchService) { + throw new BlackboardException("Keyword search service not found"); + } + + try { + searchService.indexArtifact(artifact); + } catch (TskCoreException ex) { + throw new BlackboardException("Unable to index blackboard artifact", ex); + } + } + + @Override + public void close() throws IOException { + throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. + } + + /** + * Provides a system exception for the Keyword Search package. + */ + public static final class BlackboardException extends Exception { + + private static final long serialVersionUID = 1L; + + /** + * Constructs a new exception with null as its message. + */ + public BlackboardException() { + super(); + } + + /** + * Constructs a new exception with the specified message. + * + * @param message The message. + */ + public BlackboardException(String message) { + super(message); + } + + /** + * Constructs a new exception with the specified message and cause. + * + * @param message The message. + * @param cause The cause. + */ + public BlackboardException(String message, Throwable cause) { + super(message, cause); + } + } +} diff --git a/Core/src/org/sleuthkit/autopsy/keywordsearchservice/KeywordSearchService.java b/Core/src/org/sleuthkit/autopsy/keywordsearchservice/KeywordSearchService.java index fed52adec8..5a03a8e8ff 100644 --- a/Core/src/org/sleuthkit/autopsy/keywordsearchservice/KeywordSearchService.java +++ b/Core/src/org/sleuthkit/autopsy/keywordsearchservice/KeywordSearchService.java @@ -23,9 +23,8 @@ import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.TskCoreException; /** - * @deprecated Use org.sleuthkit.datamodel.KeywordSearchService instead. + * */ -@Deprecated public interface KeywordSearchService extends Closeable { /** diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestModule.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestModule.java index 2a60c48e54..bb86774bbe 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestModule.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestModule.java @@ -37,8 +37,8 @@ import org.sleuthkit.autopsy.ingest.IngestMessage.MessageType; import org.sleuthkit.autopsy.ingest.IngestModuleReferenceCounter; import org.sleuthkit.autopsy.ingest.IngestServices; import org.sleuthkit.autopsy.keywordsearch.Ingester.IngesterException; -import org.sleuthkit.datamodel.KeywordSearchService; -import org.sleuthkit.datamodel.KeywordSearchServiceException; +import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService; +import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException; import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.TskCoreException; diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java index e5897068ed..58878c32b0 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java @@ -25,8 +25,8 @@ 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.datamodel.KeywordSearchService; -import org.sleuthkit.datamodel.KeywordSearchServiceException; +import org.sleuthkit.autopsy.keywordsearch.Ingester.IngesterException; +import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService; import org.apache.solr.common.util.ContentStreamBase.StringStream; import org.openide.util.lookup.ServiceProvider; import org.sleuthkit.autopsy.casemodule.Case; @@ -37,6 +37,7 @@ import org.sleuthkit.datamodel.SleuthkitCase; import org.openide.util.NbBundle; import java.net.InetAddress; import java.util.MissingResourceException; +import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException; /** * An implementation of the KeywordSearchService interface that uses Solr for @@ -175,7 +176,7 @@ public class SolrSearchService implements KeywordSearchService { * * @param host the remote hostname or IP address of the Solr server * @param port the remote port for Solr - * @throws org.sleuthkit.datamodel.KeywordSearchServiceException + * @throws org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException * */ @Override @@ -222,15 +223,4 @@ public class SolrSearchService implements KeywordSearchService { @Override public void close() throws IOException { } - - /** - * Returns whether or not keyword search is enabled for the current job. - * - * @return True is keyword search is enabled for the current job, false - * otherwise. - */ - @Override - public boolean isActive() { - return true; - } } From 7ee82794adf16f9d9913a86e9c5fe1d30a92c211 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Fri, 6 Nov 2015 14:19:08 -0500 Subject: [PATCH 05/12] instance created and obtained from the Services object for a Case object --- .../sleuthkit/autopsy/casemodule/services/Blackboard.java | 4 +--- .../sleuthkit/autopsy/casemodule/services/Services.java | 8 ++++++++ .../keywordsearchservice/KeywordSearchService.java | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java b/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java index 9f2327cc50..e4b83a0378 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java @@ -20,7 +20,6 @@ package org.sleuthkit.autopsy.casemodule.services; import java.io.Closeable; import java.io.IOException; -import org.openide.util.Exceptions; import org.openide.util.Lookup; import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService; import org.sleuthkit.datamodel.BlackboardArtifact; @@ -44,7 +43,7 @@ public final class Blackboard implements Closeable { */ public static void indexArtifact(BlackboardArtifact artifact) throws BlackboardException { KeywordSearchService searchService = Lookup.getDefault().lookup(KeywordSearchService.class); - if (null != searchService) { + if (null == searchService) { throw new BlackboardException("Keyword search service not found"); } @@ -57,7 +56,6 @@ public final class Blackboard implements Closeable { @Override public void close() throws IOException { - throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } /** diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/Services.java b/Core/src/org/sleuthkit/autopsy/casemodule/services/Services.java index a163e3d4ca..880bc8008e 100755 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/Services.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/Services.java @@ -39,6 +39,7 @@ public class Services implements Closeable { private final FileManager fileManager; private final TagsManager tagsManager; private final KeywordSearchService keywordSearchService; + private final Blackboard blackboard; public Services(SleuthkitCase tskCase) { fileManager = new FileManager(tskCase); @@ -49,6 +50,9 @@ public class Services implements Closeable { keywordSearchService = Lookup.getDefault().lookup(KeywordSearchService.class); services.add(keywordSearchService); + + blackboard = new Blackboard(); + services.add(blackboard); } public FileManager getFileManager() { @@ -62,6 +66,10 @@ public class Services implements Closeable { public KeywordSearchService getKeywordSearchService() { return keywordSearchService; } + + public Blackboard getBlackboard() { + return blackboard; + } @Override public void close() throws IOException { diff --git a/Core/src/org/sleuthkit/autopsy/keywordsearchservice/KeywordSearchService.java b/Core/src/org/sleuthkit/autopsy/keywordsearchservice/KeywordSearchService.java index 5a03a8e8ff..69b7c57f4f 100644 --- a/Core/src/org/sleuthkit/autopsy/keywordsearchservice/KeywordSearchService.java +++ b/Core/src/org/sleuthkit/autopsy/keywordsearchservice/KeywordSearchService.java @@ -23,7 +23,7 @@ import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.TskCoreException; /** - * + * */ public interface KeywordSearchService extends Closeable { From 2db0f57f2d94e5b5c35a5c2f0585c1e0cbbe0acc Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Fri, 6 Nov 2015 14:37:00 -0500 Subject: [PATCH 06/12] Finishing touches on Blackboard implementation --- .../sleuthkit/autopsy/casemodule/services/Blackboard.java | 7 ++++--- .../autopsy/casemodule/services/Bundle.properties | 2 ++ .../sleuthkit/autopsy/keywordsearch/SolrSearchService.java | 1 + 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java b/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java index e4b83a0378..d33c304f4c 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java @@ -21,6 +21,7 @@ package org.sleuthkit.autopsy.casemodule.services; import java.io.Closeable; import java.io.IOException; import org.openide.util.Lookup; +import org.openide.util.NbBundle; import org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchService; import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.TskCoreException; @@ -41,16 +42,16 @@ public final class Blackboard implements Closeable { * @throws * org.sleuthkit.autopsy.casemodule.services.Blackboard.BlackboardException */ - public static void indexArtifact(BlackboardArtifact artifact) throws BlackboardException { + public void indexArtifact(BlackboardArtifact artifact) throws BlackboardException { KeywordSearchService searchService = Lookup.getDefault().lookup(KeywordSearchService.class); if (null == searchService) { - throw new BlackboardException("Keyword search service not found"); + throw new BlackboardException(NbBundle.getMessage(this.getClass(), "Blackboard.keywordSearchNotFound.exception.msg")); } try { searchService.indexArtifact(artifact); } catch (TskCoreException ex) { - throw new BlackboardException("Unable to index blackboard artifact", ex); + throw new BlackboardException(NbBundle.getMessage(this.getClass(), "Blackboard.unableToIndexArtifact.exception.msg"), ex); } } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/Bundle.properties b/Core/src/org/sleuthkit/autopsy/casemodule/services/Bundle.properties index 67ed2fe8cd..4a95fbfae2 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/Bundle.properties @@ -19,3 +19,5 @@ TagsManager.addContentTag.noCaseWarning=Failed to publish new content tag event. TagsManager.deleteContentTag.noCaseWarning=Failed to publish content tag deleted event. There is no case open. TagsManager.addBlackboardArtifactTag.noCaseWarning=Failed to publish new blackboard artifact tag event. There is no case open. TagsManager.deleteBlackboardArtifactTag.noCaseWarning=Failed to publish blackboard artifact tag deleted event. There is no case open. +Blackboard.keywordSearchNotFound.exception.msg=Keyword search service not found. +Blackboard.unableToIndexArtifact.exception.msg=Unable to index blackboard artifact. \ No newline at end of file diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java index 58878c32b0..698c5e17a9 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java @@ -146,6 +146,7 @@ public class SolrSearchService implements KeywordSearchService { try { Ingester.getDefault().ingest(new StringStream(""), solrFields, 0); } catch (Ingester.IngesterException ex) { + throw new TskCoreException(ex.getCause().getMessage(), ex); } // Next create the index entry for the document content. From 37bb85cf747ff88f8b4854dfd9055abbb498f1a0 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Fri, 6 Nov 2015 14:40:37 -0500 Subject: [PATCH 07/12] Minor --- .../sleuthkit/autopsy/keywordsearch/SolrSearchService.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java index 698c5e17a9..adc1b5eb1d 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java @@ -177,7 +177,9 @@ public class SolrSearchService implements KeywordSearchService { * * @param host the remote hostname or IP address of the Solr server * @param port the remote port for Solr - * @throws org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException + * + * @throws + * org.sleuthkit.autopsy.keywordsearchservice.KeywordSearchServiceException * */ @Override From 8d01cc64d74713df732712764a65c581f355f4a6 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Fri, 6 Nov 2015 16:03:30 -0500 Subject: [PATCH 08/12] Modified ContactAnalyzer --- .../autopsy/modules/android/ContactAnalyzer.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/modules/android/ContactAnalyzer.java b/Core/src/org/sleuthkit/autopsy/modules/android/ContactAnalyzer.java index 2b22d21277..c5428f9b8a 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/android/ContactAnalyzer.java +++ b/Core/src/org/sleuthkit/autopsy/modules/android/ContactAnalyzer.java @@ -25,18 +25,18 @@ import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; -import java.util.ArrayList; import java.util.List; import java.util.logging.Level; import org.sleuthkit.autopsy.casemodule.Case; +import org.sleuthkit.autopsy.casemodule.services.Blackboard; import org.sleuthkit.autopsy.casemodule.services.FileManager; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.datamodel.ContentUtils; +import org.sleuthkit.autopsy.ingest.IngestModule.IngestModuleException; 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.sleuthkit.datamodel.TskCoreException; /** @@ -78,10 +78,11 @@ class ContactAnalyzer { * path The fileId will be the Abstract file associated * with the artifacts */ - private static void findContactsInDB(String databasePath, AbstractFile f) { + private static void findContactsInDB(String databasePath, AbstractFile f) throws IngestModuleException { Connection connection = null; ResultSet resultSet = null; Statement statement = null; + Blackboard blackboard = Case.getCurrentCase().getServices().getBlackboard(); if (databasePath == null || databasePath.isEmpty()) { return; @@ -148,6 +149,13 @@ class ContactAnalyzer { bba.addAttribute(new BlackboardAttribute(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL.getTypeID(), moduleName, data1)); } oldName = name; + + try { + // index the artifact for keyword search + blackboard.indexArtifact(bba); + } catch (Blackboard.BlackboardException ex) { + throw new IngestModuleException(ex.getMessage()); + } } } catch (SQLException e) { From cfffbdf489fc15493fb0180559ce0e616cf0c2e5 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Mon, 9 Nov 2015 12:59:43 -0500 Subject: [PATCH 09/12] Modified exception handling per stand-up discusion --- .../autopsy/casemodule/services/Blackboard.java | 2 +- .../autopsy/casemodule/services/Bundle.properties | 2 +- .../autopsy/modules/android/ContactAnalyzer.java | 9 ++++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java b/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java index d33c304f4c..46a4b9bb17 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java @@ -51,7 +51,7 @@ public final class Blackboard implements Closeable { try { searchService.indexArtifact(artifact); } catch (TskCoreException ex) { - throw new BlackboardException(NbBundle.getMessage(this.getClass(), "Blackboard.unableToIndexArtifact.exception.msg"), ex); + throw new BlackboardException(NbBundle.getMessage(this.getClass(), "Blackboard.unableToIndexArtifact.exception.msg") + artifact.getDisplayName(), ex); } } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/Bundle.properties b/Core/src/org/sleuthkit/autopsy/casemodule/services/Bundle.properties index 4a95fbfae2..27449b26cc 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/Bundle.properties @@ -20,4 +20,4 @@ TagsManager.deleteContentTag.noCaseWarning=Failed to publish content tag deleted TagsManager.addBlackboardArtifactTag.noCaseWarning=Failed to publish new blackboard artifact tag event. There is no case open. TagsManager.deleteBlackboardArtifactTag.noCaseWarning=Failed to publish blackboard artifact tag deleted event. There is no case open. Blackboard.keywordSearchNotFound.exception.msg=Keyword search service not found. -Blackboard.unableToIndexArtifact.exception.msg=Unable to index blackboard artifact. \ No newline at end of file +Blackboard.unableToIndexArtifact.exception.msg=Unable to index blackboard artifact {0} \ No newline at end of file diff --git a/Core/src/org/sleuthkit/autopsy/modules/android/ContactAnalyzer.java b/Core/src/org/sleuthkit/autopsy/modules/android/ContactAnalyzer.java index c5428f9b8a..f470038972 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/android/ContactAnalyzer.java +++ b/Core/src/org/sleuthkit/autopsy/modules/android/ContactAnalyzer.java @@ -27,12 +27,13 @@ import java.sql.SQLException; import java.sql.Statement; import java.util.List; import java.util.logging.Level; +import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.services.Blackboard; import org.sleuthkit.autopsy.casemodule.services.FileManager; import org.sleuthkit.autopsy.coreutils.Logger; +import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil; import org.sleuthkit.autopsy.datamodel.ContentUtils; -import org.sleuthkit.autopsy.ingest.IngestModule.IngestModuleException; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.BlackboardArtifact; import org.sleuthkit.datamodel.BlackboardAttribute; @@ -78,7 +79,7 @@ class ContactAnalyzer { * path The fileId will be the Abstract file associated * with the artifacts */ - private static void findContactsInDB(String databasePath, AbstractFile f) throws IngestModuleException { + private static void findContactsInDB(String databasePath, AbstractFile f) { Connection connection = null; ResultSet resultSet = null; Statement statement = null; @@ -154,7 +155,9 @@ class ContactAnalyzer { // index the artifact for keyword search blackboard.indexArtifact(bba); } catch (Blackboard.BlackboardException ex) { - throw new IngestModuleException(ex.getMessage()); + logger.log(Level.SEVERE, NbBundle.getMessage(ContactAnalyzer.class, "Blackboard.unableToIndexArtifact.exception.msg") + bba.getDisplayName(), ex); //NON-NLS + MessageNotifyUtil.Notify.error( + NbBundle.getMessage(ContactAnalyzer.class, "Blackboard.unableToIndexArtifact.exception.msg"), bba.getDisplayName()); } } From 999e98d2db34b4b7672f6c1fa8959056ec54cc8b Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Mon, 9 Nov 2015 13:54:09 -0500 Subject: [PATCH 10/12] Fixes for logging and exception handling --- .../org/sleuthkit/autopsy/casemodule/services/Blackboard.java | 2 +- .../sleuthkit/autopsy/casemodule/services/Bundle.properties | 3 ++- .../sleuthkit/autopsy/modules/android/ContactAnalyzer.java | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java b/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java index 46a4b9bb17..d33c304f4c 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java @@ -51,7 +51,7 @@ public final class Blackboard implements Closeable { try { searchService.indexArtifact(artifact); } catch (TskCoreException ex) { - throw new BlackboardException(NbBundle.getMessage(this.getClass(), "Blackboard.unableToIndexArtifact.exception.msg") + artifact.getDisplayName(), ex); + throw new BlackboardException(NbBundle.getMessage(this.getClass(), "Blackboard.unableToIndexArtifact.exception.msg"), ex); } } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/Bundle.properties b/Core/src/org/sleuthkit/autopsy/casemodule/services/Bundle.properties index 27449b26cc..2d75572fd9 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/Bundle.properties +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/Bundle.properties @@ -20,4 +20,5 @@ TagsManager.deleteContentTag.noCaseWarning=Failed to publish content tag deleted TagsManager.addBlackboardArtifactTag.noCaseWarning=Failed to publish new blackboard artifact tag event. There is no case open. TagsManager.deleteBlackboardArtifactTag.noCaseWarning=Failed to publish blackboard artifact tag deleted event. There is no case open. Blackboard.keywordSearchNotFound.exception.msg=Keyword search service not found. -Blackboard.unableToIndexArtifact.exception.msg=Unable to index blackboard artifact {0} \ No newline at end of file +Blackboard.unableToIndexArtifact.exception.msg=Unable to index blackboard artifact +Blackboard.unableToIndexArtifact.error.msg=Unable to index blackboard artifact {0} diff --git a/Core/src/org/sleuthkit/autopsy/modules/android/ContactAnalyzer.java b/Core/src/org/sleuthkit/autopsy/modules/android/ContactAnalyzer.java index f470038972..c3bc4f6b61 100755 --- a/Core/src/org/sleuthkit/autopsy/modules/android/ContactAnalyzer.java +++ b/Core/src/org/sleuthkit/autopsy/modules/android/ContactAnalyzer.java @@ -155,9 +155,9 @@ class ContactAnalyzer { // index the artifact for keyword search blackboard.indexArtifact(bba); } catch (Blackboard.BlackboardException ex) { - logger.log(Level.SEVERE, NbBundle.getMessage(ContactAnalyzer.class, "Blackboard.unableToIndexArtifact.exception.msg") + bba.getDisplayName(), ex); //NON-NLS + logger.log(Level.SEVERE, NbBundle.getMessage(Blackboard.class, "Blackboard.unableToIndexArtifact.error.msg", bba.getDisplayName()), ex); //NON-NLS MessageNotifyUtil.Notify.error( - NbBundle.getMessage(ContactAnalyzer.class, "Blackboard.unableToIndexArtifact.exception.msg"), bba.getDisplayName()); + NbBundle.getMessage(Blackboard.class, "Blackboard.unableToIndexArtifact.exception.msg"), bba.getDisplayName()); } } From 78e090e9baf4098baa42976a518a9ea91d75e2aa Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Mon, 9 Nov 2015 14:19:19 -0500 Subject: [PATCH 11/12] KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java --- .../org/sleuthkit/autopsy/casemodule/services/Blackboard.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java b/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java index d33c304f4c..b84dc1c6d7 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/services/Blackboard.java @@ -31,9 +31,6 @@ import org.sleuthkit.datamodel.TskCoreException; */ public final class Blackboard implements Closeable { - Blackboard() { - } - /** * Index the text associated with the given artifact. * From 39090cf8d4713e6e2c0d59ba3090f09688413ae7 Mon Sep 17 00:00:00 2001 From: Eugene Livis Date: Mon, 9 Nov 2015 14:20:11 -0500 Subject: [PATCH 12/12] Code review feedback --- .../org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java | 1 + 1 file changed, 1 insertion(+) diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java index adc1b5eb1d..ed22f37557 100644 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/SolrSearchService.java @@ -162,6 +162,7 @@ public class SolrSearchService implements KeywordSearchService { try { Ingester.getDefault().ingest(contentStream, solrFields, contentStream.getSize()); } catch (Ingester.IngesterException ex) { + throw new TskCoreException(ex.getCause().getMessage(), ex); } }