From c1d90f878feb95f7f228456d813bb6a54149ed9b Mon Sep 17 00:00:00 2001 From: raman-bt Date: Fri, 21 Feb 2014 13:10:47 -0500 Subject: [PATCH] Defined IngestModuleException that an ingest module may throw if init() fails. --- .../examples/SampleDataSourceIngestModule.java | 2 +- .../autopsy/examples/SampleFileIngestModule.java | 2 +- .../autopsy/ingest/IngestDataSourceThread.java | 5 +++-- .../org/sleuthkit/autopsy/ingest/IngestManager.java | 3 ++- .../autopsy/ingest/IngestModuleAbstract.java | 13 +++++++++++-- .../exifparser/ExifParserFileIngestModule.java | 2 +- .../FileExtMismatchIngestModule.java | 2 +- .../autopsy/filetypeid/FileTypeIdIngestModule.java | 2 +- .../autopsy/hashdatabase/HashDbIngestModule.java | 3 ++- .../keywordsearch/KeywordSearchIngestModule.java | 2 +- .../sleuthkit/autopsy/recentactivity/Chrome.java | 2 +- .../sleuthkit/autopsy/recentactivity/ExtractIE.java | 2 +- .../autopsy/recentactivity/ExtractRegistry.java | 2 +- .../sleuthkit/autopsy/recentactivity/Firefox.java | 2 +- .../autopsy/recentactivity/RAImageIngestModule.java | 4 ++-- .../recentactivity/RecentDocumentsByLnk.java | 2 +- .../SearchEngineURLQueryAnalyzer.java | 2 +- .../autopsy/sevenzip/SevenZipIngestModule.java | 2 +- .../autopsy/ewfverify/EwfVerifyIngestModule.java | 2 +- .../ThunderbirdMboxFileIngestModule.java | 2 +- 20 files changed, 35 insertions(+), 23 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/examples/SampleDataSourceIngestModule.java b/Core/src/org/sleuthkit/autopsy/examples/SampleDataSourceIngestModule.java index da4a7b99b7..8b47e77101 100755 --- a/Core/src/org/sleuthkit/autopsy/examples/SampleDataSourceIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/examples/SampleDataSourceIngestModule.java @@ -89,7 +89,7 @@ import org.sleuthkit.datamodel.TskCoreException; } @Override - public void init(IngestModuleInit initContext) { + public void init(IngestModuleInit initContext) throws IngestModuleException { // do nothing } diff --git a/Core/src/org/sleuthkit/autopsy/examples/SampleFileIngestModule.java b/Core/src/org/sleuthkit/autopsy/examples/SampleFileIngestModule.java index 464c79888c..23c2bf6c31 100755 --- a/Core/src/org/sleuthkit/autopsy/examples/SampleFileIngestModule.java +++ b/Core/src/org/sleuthkit/autopsy/examples/SampleFileIngestModule.java @@ -72,7 +72,7 @@ import org.sleuthkit.datamodel.TskData; @Override - public void init(IngestModuleInit initContext) { + public void init(IngestModuleInit initContext) throws IngestModuleException { /* For this demo, we are going to make a private attribute to post our * results to the blackbaord with. There are many standard blackboard artifact * and attribute types and you should first consider using one of those before diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestDataSourceThread.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestDataSourceThread.java index f599edf44a..8c427eeff1 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestDataSourceThread.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestDataSourceThread.java @@ -31,6 +31,7 @@ import org.openide.util.Cancellable; import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.autopsy.coreutils.StopWatch; import org.sleuthkit.autopsy.ingest.IngestManager.IngestModuleEvent; +import org.sleuthkit.autopsy.ingest.IngestModuleAbstract.IngestModuleException; import org.sleuthkit.datamodel.Content; /** @@ -75,13 +76,13 @@ import org.sleuthkit.datamodel.Content; return module; } - public void init() { + public void init() throws IngestModuleException{ logger.log(Level.INFO, "Initializing module: " + module.getName()); try { module.init(init); inited = true; - } catch (Exception e) { + } catch (IngestModuleException e) { logger.log(Level.INFO, "Failed initializing module: " + module.getName() + ", will not run."); //will not run inited = false; diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java index 6e079a2d53..6ccd1b89dd 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java @@ -42,6 +42,7 @@ import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.autopsy.coreutils.StopWatch; import org.sleuthkit.autopsy.ingest.IngestMessage.MessageType; import org.sleuthkit.autopsy.ingest.IngestScheduler.FileScheduler.FileTask; +import org.sleuthkit.autopsy.ingest.IngestModuleAbstract.IngestModuleException; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.Content; @@ -459,7 +460,7 @@ public class IngestManager { IngestModuleInit moduleInit = new IngestModuleInit(); try { s.init(moduleInit); - } catch (Exception e) { + } catch (IngestModuleException e) { logger.log(Level.SEVERE, "File ingest module failed init(): " + s.getName(), e); allInited = false; failedModule = s; diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleAbstract.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleAbstract.java index 6bf6b36f57..fddb365e09 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleAbstract.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleAbstract.java @@ -23,7 +23,7 @@ package org.sleuthkit.autopsy.ingest; /** * Base interface for ingest modules */ - abstract class IngestModuleAbstract { + public abstract class IngestModuleAbstract { private String args; @@ -41,6 +41,13 @@ package org.sleuthkit.autopsy.ingest; */ AbstractFile }; + + public class IngestModuleException extends Exception { + IngestModuleException(String msg) { + super(msg); + } + } + /** * Invoked every time an ingest session is started by the framework. @@ -55,8 +62,10 @@ package org.sleuthkit.autopsy.ingest; * NEVER initialize IngestServices handle in the member declaration, because it might result * in multiple instances of the singleton -- different class loaders are used in different modules. * @param initContext context used to initialize some modules + * + * @throws IngestModuleException if a critical error occurs in initializing the module. */ - abstract public void init(IngestModuleInit initContext); + abstract public void init(IngestModuleInit initContext) throws IngestModuleException; /** * Invoked when an ingest session completes. diff --git a/ExifParser/src/org/sleuthkit/autopsy/exifparser/ExifParserFileIngestModule.java b/ExifParser/src/org/sleuthkit/autopsy/exifparser/ExifParserFileIngestModule.java index f2283e814a..5d21b71e3b 100644 --- a/ExifParser/src/org/sleuthkit/autopsy/exifparser/ExifParserFileIngestModule.java +++ b/ExifParser/src/org/sleuthkit/autopsy/exifparser/ExifParserFileIngestModule.java @@ -226,7 +226,7 @@ public final class ExifParserFileIngestModule extends IngestModuleAbstractFile { } @Override - public void init(IngestModuleInit initContext) { + public void init(IngestModuleInit initContext) throws IngestModuleException { services = IngestServices.getDefault(); logger.log(Level.INFO, "init() " + this.toString()); diff --git a/FileExtMismatch/src/org/sleuthkit/autopsy/fileextmismatch/FileExtMismatchIngestModule.java b/FileExtMismatch/src/org/sleuthkit/autopsy/fileextmismatch/FileExtMismatchIngestModule.java index 0e95916063..ce8e530d29 100644 --- a/FileExtMismatch/src/org/sleuthkit/autopsy/fileextmismatch/FileExtMismatchIngestModule.java +++ b/FileExtMismatch/src/org/sleuthkit/autopsy/fileextmismatch/FileExtMismatchIngestModule.java @@ -83,7 +83,7 @@ public class FileExtMismatchIngestModule extends org.sleuthkit.autopsy.ingest.In @Override - public void init(IngestModuleInit initContext) { + public void init(IngestModuleInit initContext) throws IngestModuleException { services = IngestServices.getDefault(); // Load mapping diff --git a/FileTypeId/src/org/sleuthkit/autopsy/filetypeid/FileTypeIdIngestModule.java b/FileTypeId/src/org/sleuthkit/autopsy/filetypeid/FileTypeIdIngestModule.java index 8ab0b53bbe..a32a7ba109 100644 --- a/FileTypeId/src/org/sleuthkit/autopsy/filetypeid/FileTypeIdIngestModule.java +++ b/FileTypeId/src/org/sleuthkit/autopsy/filetypeid/FileTypeIdIngestModule.java @@ -76,7 +76,7 @@ import org.sleuthkit.datamodel.TskException; @Override - public void init(IngestModuleInit initContext) { + public void init(IngestModuleInit initContext) throws IngestModuleException { services = IngestServices.getDefault(); } diff --git a/HashDatabase/src/org/sleuthkit/autopsy/hashdatabase/HashDbIngestModule.java b/HashDatabase/src/org/sleuthkit/autopsy/hashdatabase/HashDbIngestModule.java index 412b67d4b2..78bf96bae1 100644 --- a/HashDatabase/src/org/sleuthkit/autopsy/hashdatabase/HashDbIngestModule.java +++ b/HashDatabase/src/org/sleuthkit/autopsy/hashdatabase/HashDbIngestModule.java @@ -45,6 +45,7 @@ import org.sleuthkit.datamodel.TskCoreException; import org.sleuthkit.datamodel.TskData; import org.sleuthkit.datamodel.TskException; import org.sleuthkit.autopsy.hashdatabase.HashDbManager.HashDb; +import org.sleuthkit.autopsy.ingest.IngestModuleAbstract.IngestModuleException; import org.sleuthkit.datamodel.HashInfo; public class HashDbIngestModule extends IngestModuleAbstractFile { @@ -145,7 +146,7 @@ public class HashDbIngestModule extends IngestModuleAbstractFile { } @Override - public void init(IngestModuleInit initContext) { + public void init(IngestModuleInit initContext) throws IngestModuleException { services = IngestServices.getDefault(); skCase = Case.getCurrentCase().getSleuthkitCase(); diff --git a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestModule.java b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestModule.java index 1caa9e47cd..821999419c 100755 --- a/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestModule.java +++ b/KeywordSearch/src/org/sleuthkit/autopsy/keywordsearch/KeywordSearchIngestModule.java @@ -343,7 +343,7 @@ public final class KeywordSearchIngestModule extends IngestModuleAbstractFile { * */ @Override - public void init(IngestModuleInit initContext) { + public void init(IngestModuleInit initContext) throws IngestModuleException { logger.log(Level.INFO, "init()"); services = IngestServices.getDefault(); initialized = false; diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Chrome.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Chrome.java index 100d3a9322..66e2b9a21b 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Chrome.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Chrome.java @@ -502,7 +502,7 @@ class Chrome extends Extract { } @Override - public void init(IngestModuleInit initContext) { + public void init(IngestModuleInit initContext) throws IngestModuleException { services = IngestServices.getDefault(); } diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractIE.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractIE.java index 1af2322b1c..5d3c298070 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractIE.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractIE.java @@ -480,7 +480,7 @@ class ExtractIE extends Extract { } @Override - public void init(IngestModuleInit initContext) { + public void init(IngestModuleInit initContext) throws IngestModuleException { services = IngestServices.getDefault(); } diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractRegistry.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractRegistry.java index 49da26db4f..94b9728b30 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractRegistry.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/ExtractRegistry.java @@ -540,7 +540,7 @@ class ExtractRegistry extends Extract { } @Override - public void init(IngestModuleInit initContext) { + public void init(IngestModuleInit initContext) throws IngestModuleException { } @Override diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Firefox.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Firefox.java index e5e4967525..fe12e4ae05 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Firefox.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/Firefox.java @@ -479,7 +479,7 @@ class Firefox extends Extract { } @Override - public void init(IngestModuleInit initContext) { + public void init(IngestModuleInit initContext) throws IngestModuleException { services = IngestServices.getDefault(); } diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java index e403c78117..99f0a6856c 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RAImageIngestModule.java @@ -150,7 +150,7 @@ public final class RAImageIngestModule extends IngestModuleDataSource { } @Override - public void init(IngestModuleInit initContext) { + public void init(IngestModuleInit initContext) throws IngestModuleException { modules = new ArrayList<>(); browserModules = new ArrayList(); logger.log(Level.INFO, "init() {0}", this.toString()); @@ -180,7 +180,7 @@ public final class RAImageIngestModule extends IngestModuleDataSource { for (Extract module : modules) { try { module.init(initContext); - } catch (Exception ex) { + } catch (IngestModuleException ex) { logger.log(Level.SEVERE, "Exception during init() of " + module.getName(), ex); } } diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RecentDocumentsByLnk.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RecentDocumentsByLnk.java index 880427e832..e304df8c7b 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RecentDocumentsByLnk.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/RecentDocumentsByLnk.java @@ -121,7 +121,7 @@ class RecentDocumentsByLnk extends Extract { } @Override - public void init(IngestModuleInit initContext) { + public void init(IngestModuleInit initContext) throws IngestModuleException { services = IngestServices.getDefault(); } diff --git a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/SearchEngineURLQueryAnalyzer.java b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/SearchEngineURLQueryAnalyzer.java index 4477271dd9..24da74feef 100644 --- a/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/SearchEngineURLQueryAnalyzer.java +++ b/RecentActivity/src/org/sleuthkit/autopsy/recentactivity/SearchEngineURLQueryAnalyzer.java @@ -333,7 +333,7 @@ class SearchEngineURLQueryAnalyzer extends Extract { } @Override - public void init(IngestModuleInit initContext) { + public void init(IngestModuleInit initContext) throws IngestModuleException { try{ services = IngestServices.getDefault(); PlatformUtil.extractResourceToUserConfigDir(SearchEngineURLQueryAnalyzer.class, XMLFILE); diff --git a/SevenZip/src/org/sleuthkit/autopsy/sevenzip/SevenZipIngestModule.java b/SevenZip/src/org/sleuthkit/autopsy/sevenzip/SevenZipIngestModule.java index 4f79973dcd..861e7e4828 100644 --- a/SevenZip/src/org/sleuthkit/autopsy/sevenzip/SevenZipIngestModule.java +++ b/SevenZip/src/org/sleuthkit/autopsy/sevenzip/SevenZipIngestModule.java @@ -113,7 +113,7 @@ public final class SevenZipIngestModule extends IngestModuleAbstractFile { } @Override - public void init(IngestModuleInit initContext) { + public void init(IngestModuleInit initContext) throws IngestModuleException { services = IngestServices.getDefault(); initialized = false; diff --git a/ewfVerify/src/org/sleuthkit/autopsy/ewfverify/EwfVerifyIngestModule.java b/ewfVerify/src/org/sleuthkit/autopsy/ewfverify/EwfVerifyIngestModule.java index c6afccff95..2719bf2033 100755 --- a/ewfVerify/src/org/sleuthkit/autopsy/ewfverify/EwfVerifyIngestModule.java +++ b/ewfVerify/src/org/sleuthkit/autopsy/ewfverify/EwfVerifyIngestModule.java @@ -153,7 +153,7 @@ public class EwfVerifyIngestModule extends IngestModuleDataSource { } @Override - public void init(IngestModuleInit initContext) { + public void init(IngestModuleInit initContext) throws IngestModuleException { services = IngestServices.getDefault(); skCase = Case.getCurrentCase().getSleuthkitCase(); running = false; diff --git a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java index 4527cf737b..82a4ffcb6e 100644 --- a/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java +++ b/thunderbirdparser/src/org/sleuthkit/autopsy/thunderbirdparser/ThunderbirdMboxFileIngestModule.java @@ -285,7 +285,7 @@ public class ThunderbirdMboxFileIngestModule extends IngestModuleAbstractFile { @Override - public void init(IngestModuleInit initContext) { + public void init(IngestModuleInit initContext) throws IngestModuleException { services = IngestServices.getDefault(); fileManager = Case.getCurrentCase().getServices().getFileManager(); }