diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettings.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettings.java index fc56739cb3..9f9e6feab5 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettings.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestJobSettings.java @@ -53,12 +53,24 @@ public class IngestJobSettings { private static final String MODULE_SETTINGS_FILE_EXT = ".settings"; //NON-NLS private static final Logger logger = Logger.getLogger(IngestJobSettings.class.getName()); private final String context; + private final IngestType ingestType; private String moduleSettingsFolderPath; private static final CharSequence pythonModuleSettingsPrefixCS = "org.python.proxies.".subSequence(0, "org.python.proxies.".length() - 1); private final List moduleTemplates; private boolean processUnallocatedSpace; private final List warnings; + // Determines which modeules to run + public enum IngestType { + + // Run all modules + ALL_MODULES, + // Run only data source modules + DATA_SOURCE_ONLY, + // Run only files modules + FILES_ONLY + } + /** * Constructs an ingest job settings object for a given context. * @@ -66,6 +78,29 @@ public class IngestJobSettings { */ public IngestJobSettings(String context) { this.context = context; + this.ingestType = IngestType.ALL_MODULES; + this.moduleTemplates = new ArrayList<>(); + this.processUnallocatedSpace = Boolean.parseBoolean(IngestJobSettings.PROCESS_UNALLOC_SPACE_DEFAULT); + this.warnings = new ArrayList<>(); + this.createSavedModuleSettingsFolder(); + this.load(); + } + + /** + * Constructs an ingest job settings object for a given context. + * + * @param context The context identifier string. + * @param ingestType The type of modules ingest is running. + */ + public IngestJobSettings(String context, IngestType ingestType) { + this.ingestType = ingestType; + + if (!this.ingestType.equals(IngestType.ALL_MODULES)) { + this.context = context + this.ingestType.name(); + } else { + this.context = context; + } + this.moduleTemplates = new ArrayList<>(); this.processUnallocatedSpace = Boolean.parseBoolean(IngestJobSettings.PROCESS_UNALLOC_SPACE_DEFAULT); this.warnings = new ArrayList<>(); @@ -145,10 +180,10 @@ public class IngestJobSettings { void setProcessUnallocatedSpace(boolean processUnallocatedSpace) { this.processUnallocatedSpace = processUnallocatedSpace; } - + /** * Returns the path to the ingest module settings folder. - * + * * @return path to the module settings folder */ public Path getSavedModuleSettingsFolder(){ @@ -180,13 +215,19 @@ public class IngestJobSettings { */ List moduleFactories = new ArrayList<>(); List tempModuleFactories = IngestModuleFactoryLoader.getIngestModuleFactories(); - HashSet loadedModuleNames = new HashSet<>(); - - for(IngestModuleFactory moduleFactory : tempModuleFactories) { - if(!context.endsWith(".isDir") || moduleFactory.isFileIngestModuleFactory()) + HashSet loadedModuleNames = new HashSet<>(); + + // Add modules that are going to be used for this ingest depending on type. + for (IngestModuleFactory moduleFactory : tempModuleFactories) { + if (this.ingestType.equals(IngestType.ALL_MODULES)) { moduleFactories.add(moduleFactory); + } else if (this.ingestType.equals(IngestType.DATA_SOURCE_ONLY) && moduleFactory.isDataSourceIngestModuleFactory()) { + moduleFactories.add(moduleFactory); + } else if (this.ingestType.equals(IngestType.FILES_ONLY) && moduleFactory.isFileIngestModuleFactory()) { + moduleFactories.add(moduleFactory); + } } - + for (IngestModuleFactory moduleFactory : moduleFactories) { loadedModuleNames.add(moduleFactory.getModuleDisplayName()); } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/RunIngestModulesDialog.java b/Core/src/org/sleuthkit/autopsy/ingest/RunIngestModulesDialog.java index 29e6cfe79e..27b7f3ecf5 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/RunIngestModulesDialog.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/RunIngestModulesDialog.java @@ -34,6 +34,7 @@ import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; import org.openide.util.NbBundle; +import org.sleuthkit.autopsy.ingest.IngestJobSettings.IngestType; import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.Directory; @@ -44,7 +45,7 @@ import org.sleuthkit.datamodel.Directory; public final class RunIngestModulesDialog extends JDialog { private static final String TITLE = NbBundle.getMessage(RunIngestModulesDialog.class, "IngestDialog.title.text"); - private final String context; + private final IngestType ingestType; private static Dimension DIMENSIONS = new Dimension(500, 300); private final List dataSources = new ArrayList<>(); private IngestJobSettingsPanel ingestJobSettingsPanel; @@ -61,7 +62,7 @@ public final class RunIngestModulesDialog extends JDialog { public RunIngestModulesDialog(JFrame frame, String title, boolean modal, List dataSources) { super(frame, title, modal); this.dataSources.addAll(dataSources); - this.context = RunIngestModulesDialog.class.getCanonicalName(); + this.ingestType = IngestType.ALL_MODULES; } /** @@ -76,7 +77,7 @@ public final class RunIngestModulesDialog extends JDialog { public RunIngestModulesDialog(Directory dir) { this.dataSources.add(dir); - this.context = RunIngestModulesDialog.class.getCanonicalName() + ".isDir"; + this.ingestType = IngestType.FILES_ONLY; } /** @@ -92,7 +93,7 @@ public final class RunIngestModulesDialog extends JDialog { @Deprecated public RunIngestModulesDialog(JFrame frame, String title, boolean modal) { super(frame, title, modal); - this.context = RunIngestModulesDialog.class.getCanonicalName(); + this.ingestType = IngestType.ALL_MODULES; } /** @@ -138,7 +139,7 @@ public final class RunIngestModulesDialog extends JDialog { * Get the default or saved ingest job settings for this context and use * them to create and add an ingest job settings panel. */ - IngestJobSettings ingestJobSettings = new IngestJobSettings(context); + IngestJobSettings ingestJobSettings = new IngestJobSettings(RunIngestModulesDialog.class.getCanonicalName(), this.ingestType); RunIngestModulesDialog.showWarnings(ingestJobSettings); this.ingestJobSettingsPanel = new IngestJobSettingsPanel(ingestJobSettings); add(this.ingestJobSettingsPanel, BorderLayout.PAGE_START);