From 30128516ed4743aeabab47b45227b21057269e9d Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Tue, 4 Apr 2017 14:04:06 -0400 Subject: [PATCH 1/5] 2518 moved managing of ingest data source and ingest kick off to progress panel --- .../AddImageWizardAddingProgressPanel.java | 175 +++++++++++++++++- ...AddImageWizardDataSourceSettingsPanel.java | 16 +- .../AddImageWizardIngestConfigPanel.java | 165 +---------------- .../casemodule/AddImageWizardIterator.java | 6 +- 4 files changed, 192 insertions(+), 170 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java index 8b1a4dd1e0..075d45de94 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java @@ -20,17 +20,30 @@ package org.sleuthkit.autopsy.casemodule; import java.awt.Color; import java.awt.EventQueue; +import java.awt.Window; +import java.util.ArrayList; +import java.util.Collections; import java.util.HashSet; import java.util.Iterator; +import java.util.List; import java.util.Set; +import java.util.UUID; +import javax.swing.JOptionPane; +import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import org.openide.WizardDescriptor; import org.openide.util.HelpCtx; import org.openide.util.Lookup; import org.openide.util.NbBundle; +import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; +import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor; +import org.sleuthkit.autopsy.coreutils.PlatformUtil; +import org.sleuthkit.autopsy.ingest.IngestJobSettings; +import org.sleuthkit.autopsy.ingest.IngestManager; import org.sleuthkit.autopsy.ingest.runIngestModuleWizard.ShortcutWizardDescriptorPanel; +import org.sleuthkit.datamodel.Content; /** * The final panel of the add image wizard. It displays a progress bar and @@ -42,21 +55,35 @@ import org.sleuthkit.autopsy.ingest.runIngestModuleWizard.ShortcutWizardDescript */ class AddImageWizardAddingProgressPanel extends ShortcutWizardDescriptorPanel { + private boolean readyToIngest = false; + // task that will clean up the created database file if the wizard is cancelled before it finishes + private AddImageAction.CleanupTask cleanupTask; + + private final AddImageAction addImageAction; + + private DataSourceProcessor dsProcessor; + private boolean cancelled; /** * flag to indicate that the image adding process is finished and this panel * is completed(valid) */ private boolean imgAdded = false; + private boolean ingested = false; /** * The visual component that displays this panel. If you need to access the * component from this class, just use getComponent(). */ private AddImageWizardAddingProgressVisual component; private final Set listeners = new HashSet<>(1); // or can use ChangeSupport in NB 6.0 - + private final List newContents = Collections.synchronizedList(new ArrayList()); private final DSPProgressMonitorImpl dspProgressMonitorImpl = new DSPProgressMonitorImpl(); + private IngestJobSettings ingestJobSettings; - public DSPProgressMonitorImpl getDSPProgressMonitorImpl() { + AddImageWizardAddingProgressPanel(AddImageAction action) { + this.addImageAction = action; + } + + DSPProgressMonitorImpl getDSPProgressMonitorImpl() { return dspProgressMonitorImpl; } @@ -215,6 +242,19 @@ class AddImageWizardAddingProgressPanel extends ShortcutWizardDescriptorPanel { } } + void resetReadyToIngest() { + this.readyToIngest = false; + } + + void setIngestJobSettings(IngestJobSettings ingestSettings) { + if (!readyToIngest){ + showWarnings(ingestSettings); + this.readyToIngest = true; + this.ingestJobSettings = ingestSettings; + startIngest(); + } + } + /** * this doesn't appear to store anything? plus, there are no settings in * this panel -jm @@ -240,4 +280,135 @@ class AddImageWizardAddingProgressPanel extends ShortcutWizardDescriptorPanel { getComponent().showErrors(errorString, critical); } + /** + * Start ingest after verifying we have a new image, we are ready to ingest, + * and we haven't already ingested. + */ + void startIngest() { + if (!newContents.isEmpty() && readyToIngest && !ingested) { + ingested = true; + IngestManager.getInstance().queueIngestJob(newContents, ingestJobSettings); + setStateFinished(); + } + } + + private static void showWarnings(IngestJobSettings ingestJobSettings) { + List warnings = ingestJobSettings.getWarnings(); + if (warnings.isEmpty() == false) { + StringBuilder warningMessage = new StringBuilder(); + for (String warning : warnings) { + warningMessage.append(warning).append("\n"); + } + JOptionPane.showMessageDialog(null, warningMessage.toString()); + } + } + + /** + * Starts the Data source processing by kicking off the selected + * DataSourceProcessor + */ + void startDataSourceProcessing(DataSourceProcessor dsp) { + final UUID dataSourceId = UUID.randomUUID(); + newContents.clear(); + cleanupTask = null; + readyToIngest = false; + dsProcessor = dsp; + + + // Add a cleanup task to interrupt the background process if the + // wizard exits while the background process is running. + cleanupTask = addImageAction.new CleanupTask() { + @Override + void cleanup() throws Exception { + cancelDataSourceProcessing(dataSourceId); + cancelled = true; + } + }; + + cleanupTask.enable(); + + new Thread(() -> { + Case.getCurrentCase().notifyAddingDataSource(dataSourceId); + }).start(); + DataSourceProcessorCallback cbObj = new DataSourceProcessorCallback() { + @Override + public void doneEDT(DataSourceProcessorCallback.DataSourceProcessorResult result, List errList, List contents) { + dataSourceProcessorDone(dataSourceId, result, errList, contents); + } + }; + + setStateStarted(); + + // Kick off the DSProcessor + dsProcessor.run(getDSPProgressMonitorImpl(), cbObj); + } + + /* + * Cancels the data source processing - in case the users presses 'Cancel' + */ + private void cancelDataSourceProcessing(UUID dataSourceId) { + dsProcessor.cancel(); + } + + /* + * Callback for the data source processor. Invoked by the DSP on the EDT + * thread, when it finishes processing the data source. + */ + private void dataSourceProcessorDone(UUID dataSourceId, DataSourceProcessorCallback.DataSourceProcessorResult result, List errList, List contents) { + // disable the cleanup task + cleanupTask.disable(); + + // Get attention for the process finish + // this caused a crash on OS X + if (PlatformUtil.isWindowsOS() == true) { + java.awt.Toolkit.getDefaultToolkit().beep(); //BEEP! + } + AddImageWizardAddingProgressVisual panel = getComponent(); + if (panel != null) { + Window w = SwingUtilities.getWindowAncestor(panel); + if (w != null) { + w.toFront(); + } + } + // Tell the panel we're done + setStateFinished(); + + //check the result and display to user + if (result == DataSourceProcessorCallback.DataSourceProcessorResult.NO_ERRORS) { + getComponent().setProgressBarTextAndColor( + NbBundle.getMessage(this.getClass(), "AddImageWizardIngestConfigPanel.dsProcDone.noErrs.text"), 100, Color.black); + } else { + getComponent().setProgressBarTextAndColor( + NbBundle.getMessage(this.getClass(), "AddImageWizardIngestConfigPanel.dsProcDone.errs.text"), 100, Color.red); + } + + //if errors, display them on the progress panel + boolean critErr = false; + if (result == DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS) { + critErr = true; + } + for (String err : errList) { + // TBD: there probably should be an error level for each error + addErrors(err, critErr); + } + + //notify the UI of the new content added to the case + new Thread(() -> { + if (!contents.isEmpty()) { + Case.getCurrentCase().notifyDataSourceAdded(contents.get(0), dataSourceId); + } else { + Case.getCurrentCase().notifyFailedAddingDataSource(dataSourceId); + } + }).start(); + + if (!cancelled) { + newContents.clear(); + newContents.addAll(contents); + setStateStarted(); + startIngest(); + } else { + cancelled = false; + } + + } } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardDataSourceSettingsPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardDataSourceSettingsPanel.java index 1643769be0..786acca525 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardDataSourceSettingsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardDataSourceSettingsPanel.java @@ -47,10 +47,12 @@ class AddImageWizardDataSourceSettingsPanel extends ShortcutWizardDescriptorPane */ private AddImageWizardDataSourceSettingsVisual component; private boolean isNextEnable = false; + private final AddImageWizardAddingProgressPanel progressPanel; + private boolean processingStarted = false; // paths to any set hash lookup databases (can be null) - AddImageWizardDataSourceSettingsPanel() { - + AddImageWizardDataSourceSettingsPanel(AddImageWizardAddingProgressPanel proPanel) { + this.progressPanel = proPanel; } /** @@ -169,7 +171,7 @@ class AddImageWizardDataSourceSettingsPanel extends ShortcutWizardDescriptorPane public void readSettings(WizardDescriptor settings) { // Prepopulate the image directory from the properties file try { - + // If there is a process object in the settings, revert it and remove it from the settings AddImageAction.CleanupTask cleanupTask = (AddImageAction.CleanupTask) settings.getProperty(AddImageAction.IMAGECLEANUPTASK_PROP); if (cleanupTask != null) { @@ -184,7 +186,7 @@ class AddImageWizardDataSourceSettingsPanel extends ShortcutWizardDescriptorPane } } catch (Exception e) { } - component.setDspSelection((String)settings.getProperty("SelectedDsp")); //NON-NLS magic string used SelectDataSourceProcessorPanel + component.setDspSelection((String) settings.getProperty("SelectedDsp")); //NON-NLS magic string used SelectDataSourceProcessorPanel } /** @@ -198,6 +200,12 @@ class AddImageWizardDataSourceSettingsPanel extends ShortcutWizardDescriptorPane */ @Override public void storeSettings(WizardDescriptor settings) { + // Start processing the data source by handing it off to the selected DSP, + // so it gets going in the background while the user is still picking the Ingest modules + if (!processingStarted){ //storeSettings is called twice + processingStarted = true; + progressPanel.startDataSourceProcessing(component.getCurrentDSProcessor()); + } } /** diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIngestConfigPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIngestConfigPanel.java index 1d7bbb8a13..ede2bf2c38 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIngestConfigPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIngestConfigPanel.java @@ -19,28 +19,17 @@ package org.sleuthkit.autopsy.casemodule; import org.openide.util.NbBundle; -import java.awt.Color; import java.awt.Component; -import java.awt.Window; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; -import java.util.UUID; import javax.swing.JButton; import javax.swing.JOptionPane; -import javax.swing.SwingUtilities; import javax.swing.event.ChangeListener; import org.openide.WizardDescriptor; import org.openide.util.HelpCtx; import org.openide.util.NbBundle.Messages; -import org.sleuthkit.datamodel.Content; -import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback; -import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; import org.sleuthkit.autopsy.coreutils.ModuleSettings; -import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.autopsy.ingest.IngestJobSettings; import org.sleuthkit.autopsy.ingest.IngestJobSettingsPanel; -import org.sleuthkit.autopsy.ingest.IngestManager; import org.sleuthkit.autopsy.ingest.runIngestModuleWizard.IngestProfileSelectionWizardPanel; import org.sleuthkit.autopsy.ingest.runIngestModuleWizard.ShortcutWizardDescriptorPanel; @@ -60,24 +49,10 @@ class AddImageWizardIngestConfigPanel extends ShortcutWizardDescriptorPanel { */ private Component component = null; private String lastProfileUsed = AddImageWizardIngestConfigPanel.class.getCanonicalName(); - private final List newContents = Collections.synchronizedList(new ArrayList()); - private boolean ingested = false; - private boolean readyToIngest = false; - // task that will clean up the created database file if the wizard is cancelled before it finishes - private AddImageAction.CleanupTask cleanupTask; - - private final AddImageAction addImageAction; - private final AddImageWizardAddingProgressPanel progressPanel; - private final AddImageWizardDataSourceSettingsPanel dataSourcePanel; - private DataSourceProcessor dsProcessor; - private boolean cancelled; - - AddImageWizardIngestConfigPanel(AddImageWizardDataSourceSettingsPanel dsPanel, AddImageAction action, AddImageWizardAddingProgressPanel proPanel) { - this.addImageAction = action; + AddImageWizardIngestConfigPanel(AddImageWizardAddingProgressPanel proPanel) { this.progressPanel = proPanel; - this.dataSourcePanel = dsPanel; IngestJobSettings ingestJobSettings = new IngestJobSettings(AddImageWizardIngestConfigPanel.class.getCanonicalName()); showWarnings(ingestJobSettings); //When this panel is viewed by the user it will always be displaying the @@ -170,12 +145,6 @@ class AddImageWizardIngestConfigPanel extends ShortcutWizardDescriptorPanel { NbBundle.getMessage(this.getClass(), "AddImageWizardIngestConfigPanel.CANCEL_BUTTON.text")); cancel.setEnabled(false); settings.setOptions(new Object[]{WizardDescriptor.PREVIOUS_OPTION, WizardDescriptor.NEXT_OPTION, WizardDescriptor.FINISH_OPTION, cancel}); - cleanupTask = null; - readyToIngest = false; - newContents.clear(); - // Start processing the data source by handing it off to the selected DSP, - // so it gets going in the background while the user is still picking the Ingest modules - startDataSourceProcessing(); } /** @@ -191,11 +160,9 @@ class AddImageWizardIngestConfigPanel extends ShortcutWizardDescriptorPanel { public void storeSettings(WizardDescriptor settings) { IngestJobSettings ingestJobSettings = ingestJobSettingsPanel.getSettings(); ingestJobSettings.save(); - showWarnings(ingestJobSettings); - // Start ingest if it hasn't already been started - readyToIngest = true; - startIngest(); + // Start ingest if it hasn't already been started + progressPanel.setIngestJobSettings(ingestJobSettings); //calls start Ingest } private static void showWarnings(IngestJobSettings ingestJobSettings) { @@ -224,130 +191,6 @@ class AddImageWizardIngestConfigPanel extends ShortcutWizardDescriptorPanel { //swap out the ingestJobSettings for the ones of the chosen profile before //we start processing IngestJobSettings ingestJobSettings = new IngestJobSettings(lastProfileUsed); - ingestJobSettingsPanel = new IngestJobSettingsPanel(ingestJobSettings); - showWarnings(ingestJobSettings); - component = new AddImageWizardIngestConfigVisual(this.ingestJobSettingsPanel); - readyToIngest = true; - startDataSourceProcessing(); - } - - /** - * Start ingest after verifying we have a new image, we are ready to ingest, - * and we haven't already ingested. - */ - private void startIngest() { - if (!newContents.isEmpty() && readyToIngest && !ingested) { - ingested = true; - IngestManager.getInstance().queueIngestJob(newContents, ingestJobSettingsPanel.getSettings()); - progressPanel.setStateFinished(); - } - } - - /** - * Starts the Data source processing by kicking off the selected - * DataSourceProcessor - */ - private void startDataSourceProcessing() { - final UUID dataSourceId = UUID.randomUUID(); - - // Add a cleanup task to interrupt the background process if the - // wizard exits while the background process is running. - cleanupTask = addImageAction.new CleanupTask() { - @Override - void cleanup() throws Exception { - cancelDataSourceProcessing(dataSourceId); - cancelled = true; - } - }; - - cleanupTask.enable(); - - // get the selected DSProcessor - dsProcessor = dataSourcePanel.getComponent().getCurrentDSProcessor(); - - new Thread(() -> { - Case.getCurrentCase().notifyAddingDataSource(dataSourceId); - }).start(); - DataSourceProcessorCallback cbObj = new DataSourceProcessorCallback() { - @Override - public void doneEDT(DataSourceProcessorCallback.DataSourceProcessorResult result, List errList, List contents) { - dataSourceProcessorDone(dataSourceId, result, errList, contents); - } - }; - - progressPanel.setStateStarted(); - - // Kick off the DSProcessor - dsProcessor.run(progressPanel.getDSPProgressMonitorImpl(), cbObj); - - } - - /* - * Cancels the data source processing - in case the users presses 'Cancel' - */ - private void cancelDataSourceProcessing(UUID dataSourceId) { - dsProcessor.cancel(); - } - - /* - * Callback for the data source processor. Invoked by the DSP on the EDT - * thread, when it finishes processing the data source. - */ - private void dataSourceProcessorDone(UUID dataSourceId, DataSourceProcessorCallback.DataSourceProcessorResult result, List errList, List contents) { - // disable the cleanup task - cleanupTask.disable(); - - // Get attention for the process finish - // this caused a crash on OS X - if (PlatformUtil.isWindowsOS() == true) { - java.awt.Toolkit.getDefaultToolkit().beep(); //BEEP! - } - AddImageWizardAddingProgressVisual panel = progressPanel.getComponent(); - if (panel != null) { - Window w = SwingUtilities.getWindowAncestor(panel); - if (w != null) { - w.toFront(); - } - } - // Tell the panel we're done - progressPanel.setStateFinished(); - - //check the result and display to user - if (result == DataSourceProcessorCallback.DataSourceProcessorResult.NO_ERRORS) { - progressPanel.getComponent().setProgressBarTextAndColor( - NbBundle.getMessage(this.getClass(), "AddImageWizardIngestConfigPanel.dsProcDone.noErrs.text"), 100, Color.black); - } else { - progressPanel.getComponent().setProgressBarTextAndColor( - NbBundle.getMessage(this.getClass(), "AddImageWizardIngestConfigPanel.dsProcDone.errs.text"), 100, Color.red); - } - - //if errors, display them on the progress panel - boolean critErr = false; - if (result == DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS) { - critErr = true; - } - for (String err : errList) { - // TBD: there probably should be an error level for each error - progressPanel.addErrors(err, critErr); - } - - //notify the UI of the new content added to the case - new Thread(() -> { - if (!contents.isEmpty()) { - Case.getCurrentCase().notifyDataSourceAdded(contents.get(0), dataSourceId); - } else { - Case.getCurrentCase().notifyFailedAddingDataSource(dataSourceId); - } - }).start(); - - if (!cancelled) { - newContents.clear(); - newContents.addAll(contents); - progressPanel.setStateStarted(); - startIngest(); - } else { - cancelled = false; - } - + progressPanel.setIngestJobSettings(ingestJobSettings); //calls start ingest } } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIterator.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIterator.java index 3558ffe83b..bf379e41f1 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIterator.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIterator.java @@ -56,10 +56,10 @@ class AddImageWizardIterator implements WizardDescriptor.Iterator(); AddImageWizardSelectDspPanel dspSelection = new AddImageWizardSelectDspPanel(); panels.add(dspSelection); - AddImageWizardAddingProgressPanel progressPanel = new AddImageWizardAddingProgressPanel(); + AddImageWizardAddingProgressPanel progressPanel = new AddImageWizardAddingProgressPanel(action); - AddImageWizardDataSourceSettingsPanel dsPanel = new AddImageWizardDataSourceSettingsPanel(); - AddImageWizardIngestConfigPanel ingestConfigPanel = new AddImageWizardIngestConfigPanel(dsPanel, action, progressPanel); + AddImageWizardDataSourceSettingsPanel dsPanel = new AddImageWizardDataSourceSettingsPanel(progressPanel); + AddImageWizardIngestConfigPanel ingestConfigPanel = new AddImageWizardIngestConfigPanel(progressPanel); panels.add(dsPanel); List profiles = IngestProfiles.getIngestProfiles(); if (!profiles.isEmpty()) { From e2225136a7b092886357f05cd3346d14992099f2 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Tue, 4 Apr 2017 14:08:47 -0400 Subject: [PATCH 2/5] 2518 made ingest started when progress panel opened should also fix 2280 --- .../AddImageWizardAddingProgressPanel.java | 71 +++++++++---------- 1 file changed, 34 insertions(+), 37 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java index 075d45de94..a8d803c80b 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java @@ -236,6 +236,7 @@ class AddImageWizardAddingProgressPanel extends ShortcutWizardDescriptorPanel { */ @Override public void readSettings(WizardDescriptor settings) { + startIngest(); settings.setOptions(new Object[]{WizardDescriptor.PREVIOUS_OPTION, WizardDescriptor.NEXT_OPTION, WizardDescriptor.FINISH_OPTION, WizardDescriptor.CANCEL_OPTION}); if (imgAdded) { getComponent().setStateFinished(); @@ -247,12 +248,9 @@ class AddImageWizardAddingProgressPanel extends ShortcutWizardDescriptorPanel { } void setIngestJobSettings(IngestJobSettings ingestSettings) { - if (!readyToIngest){ - showWarnings(ingestSettings); - this.readyToIngest = true; - this.ingestJobSettings = ingestSettings; - startIngest(); - } + showWarnings(ingestSettings); + this.readyToIngest = true; + this.ingestJobSettings = ingestSettings; } /** @@ -284,14 +282,14 @@ class AddImageWizardAddingProgressPanel extends ShortcutWizardDescriptorPanel { * Start ingest after verifying we have a new image, we are ready to ingest, * and we haven't already ingested. */ - void startIngest() { + private void startIngest() { if (!newContents.isEmpty() && readyToIngest && !ingested) { ingested = true; IngestManager.getInstance().queueIngestJob(newContents, ingestJobSettings); setStateFinished(); } } - + private static void showWarnings(IngestJobSettings ingestJobSettings) { List warnings = ingestJobSettings.getWarnings(); if (warnings.isEmpty() == false) { @@ -302,45 +300,44 @@ class AddImageWizardAddingProgressPanel extends ShortcutWizardDescriptorPanel { JOptionPane.showMessageDialog(null, warningMessage.toString()); } } - + /** * Starts the Data source processing by kicking off the selected * DataSourceProcessor */ void startDataSourceProcessing(DataSourceProcessor dsp) { - final UUID dataSourceId = UUID.randomUUID(); - newContents.clear(); - cleanupTask = null; - readyToIngest = false; - dsProcessor = dsp; - + final UUID dataSourceId = UUID.randomUUID(); + newContents.clear(); + cleanupTask = null; + readyToIngest = false; + dsProcessor = dsp; - // Add a cleanup task to interrupt the background process if the - // wizard exits while the background process is running. - cleanupTask = addImageAction.new CleanupTask() { - @Override - void cleanup() throws Exception { - cancelDataSourceProcessing(dataSourceId); - cancelled = true; - } - }; + // Add a cleanup task to interrupt the background process if the + // wizard exits while the background process is running. + cleanupTask = addImageAction.new CleanupTask() { + @Override + void cleanup() throws Exception { + cancelDataSourceProcessing(dataSourceId); + cancelled = true; + } + }; - cleanupTask.enable(); + cleanupTask.enable(); - new Thread(() -> { - Case.getCurrentCase().notifyAddingDataSource(dataSourceId); - }).start(); - DataSourceProcessorCallback cbObj = new DataSourceProcessorCallback() { - @Override - public void doneEDT(DataSourceProcessorCallback.DataSourceProcessorResult result, List errList, List contents) { - dataSourceProcessorDone(dataSourceId, result, errList, contents); - } - }; + new Thread(() -> { + Case.getCurrentCase().notifyAddingDataSource(dataSourceId); + }).start(); + DataSourceProcessorCallback cbObj = new DataSourceProcessorCallback() { + @Override + public void doneEDT(DataSourceProcessorCallback.DataSourceProcessorResult result, List errList, List contents) { + dataSourceProcessorDone(dataSourceId, result, errList, contents); + } + }; - setStateStarted(); + setStateStarted(); - // Kick off the DSProcessor - dsProcessor.run(getDSPProgressMonitorImpl(), cbObj); + // Kick off the DSProcessor + dsProcessor.run(getDSPProgressMonitorImpl(), cbObj); } /* From b56bb8094aeba8163f0ce3bd0dcd54c8eba315d2 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Tue, 4 Apr 2017 14:26:33 -0400 Subject: [PATCH 3/5] 2518 minor auto-format change --- .../casemodule/AddImageWizardDataSourceSettingsPanel.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardDataSourceSettingsPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardDataSourceSettingsPanel.java index 786acca525..d83b9ef46c 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardDataSourceSettingsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardDataSourceSettingsPanel.java @@ -202,7 +202,7 @@ class AddImageWizardDataSourceSettingsPanel extends ShortcutWizardDescriptorPane public void storeSettings(WizardDescriptor settings) { // Start processing the data source by handing it off to the selected DSP, // so it gets going in the background while the user is still picking the Ingest modules - if (!processingStarted){ //storeSettings is called twice + if (!processingStarted) { //storeSettings is called twice processingStarted = true; progressPanel.startDataSourceProcessing(component.getCurrentDSProcessor()); } From 28a706efde992e6c023c0c3e18d457d677ea3d09 Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Tue, 4 Apr 2017 14:30:42 -0400 Subject: [PATCH 4/5] 2518 corrected a couple comments to reflect when ingest is actually started now --- .../casemodule/AddImageWizardAddingProgressPanel.java | 1 + .../casemodule/AddImageWizardIngestConfigPanel.java | 9 +++------ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java index a8d803c80b..fad2b807ef 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java @@ -236,6 +236,7 @@ class AddImageWizardAddingProgressPanel extends ShortcutWizardDescriptorPanel { */ @Override public void readSettings(WizardDescriptor settings) { + // Start ingest if it hasn't already been started startIngest(); settings.setOptions(new Object[]{WizardDescriptor.PREVIOUS_OPTION, WizardDescriptor.NEXT_OPTION, WizardDescriptor.FINISH_OPTION, WizardDescriptor.CANCEL_OPTION}); if (imgAdded) { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIngestConfigPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIngestConfigPanel.java index ede2bf2c38..2dad6784c3 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIngestConfigPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIngestConfigPanel.java @@ -159,10 +159,8 @@ class AddImageWizardIngestConfigPanel extends ShortcutWizardDescriptorPanel { @Override public void storeSettings(WizardDescriptor settings) { IngestJobSettings ingestJobSettings = ingestJobSettingsPanel.getSettings(); - ingestJobSettings.save(); - - // Start ingest if it hasn't already been started - progressPanel.setIngestJobSettings(ingestJobSettings); //calls start Ingest + ingestJobSettings.save(); + progressPanel.setIngestJobSettings(ingestJobSettings); //prepare ingest for being started } private static void showWarnings(IngestJobSettings ingestJobSettings) { @@ -189,8 +187,7 @@ class AddImageWizardIngestConfigPanel extends ShortcutWizardDescriptorPanel { } //Because this panel kicks off ingest during the wizard we need to //swap out the ingestJobSettings for the ones of the chosen profile before - //we start processing IngestJobSettings ingestJobSettings = new IngestJobSettings(lastProfileUsed); - progressPanel.setIngestJobSettings(ingestJobSettings); //calls start ingest + progressPanel.setIngestJobSettings(ingestJobSettings); //prepare ingest for being started } } From 3aad466133cb4eca624f6dfb0e81a3d3fce0756b Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Wed, 5 Apr 2017 11:52:12 -0400 Subject: [PATCH 5/5] 2518 moved startDataSourceProcessing call to AddImageWizardIterator --- .../AddImageWizardAddingProgressPanel.java | 58 ++++++++++--------- ...AddImageWizardDataSourceSettingsPanel.java | 13 +---- .../casemodule/AddImageWizardIterator.java | 10 +++- 3 files changed, 40 insertions(+), 41 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java index fad2b807ef..22a6ee9762 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java @@ -61,7 +61,7 @@ class AddImageWizardAddingProgressPanel extends ShortcutWizardDescriptorPanel { private final AddImageAction addImageAction; - private DataSourceProcessor dsProcessor; + private DataSourceProcessor dsProcessor = null; private boolean cancelled; /** * flag to indicate that the image adding process is finished and this panel @@ -307,38 +307,40 @@ class AddImageWizardAddingProgressPanel extends ShortcutWizardDescriptorPanel { * DataSourceProcessor */ void startDataSourceProcessing(DataSourceProcessor dsp) { - final UUID dataSourceId = UUID.randomUUID(); - newContents.clear(); - cleanupTask = null; - readyToIngest = false; - dsProcessor = dsp; + if (dsProcessor == null) { //this can only be run once + final UUID dataSourceId = UUID.randomUUID(); + newContents.clear(); + cleanupTask = null; + readyToIngest = false; + dsProcessor = dsp; - // Add a cleanup task to interrupt the background process if the - // wizard exits while the background process is running. - cleanupTask = addImageAction.new CleanupTask() { - @Override - void cleanup() throws Exception { - cancelDataSourceProcessing(dataSourceId); - cancelled = true; - } - }; + // Add a cleanup task to interrupt the background process if the + // wizard exits while the background process is running. + cleanupTask = addImageAction.new CleanupTask() { + @Override + void cleanup() throws Exception { + cancelDataSourceProcessing(dataSourceId); + cancelled = true; + } + }; - cleanupTask.enable(); + cleanupTask.enable(); - new Thread(() -> { - Case.getCurrentCase().notifyAddingDataSource(dataSourceId); - }).start(); - DataSourceProcessorCallback cbObj = new DataSourceProcessorCallback() { - @Override - public void doneEDT(DataSourceProcessorCallback.DataSourceProcessorResult result, List errList, List contents) { - dataSourceProcessorDone(dataSourceId, result, errList, contents); - } - }; + new Thread(() -> { + Case.getCurrentCase().notifyAddingDataSource(dataSourceId); + }).start(); + DataSourceProcessorCallback cbObj = new DataSourceProcessorCallback() { + @Override + public void doneEDT(DataSourceProcessorCallback.DataSourceProcessorResult result, List errList, List contents) { + dataSourceProcessorDone(dataSourceId, result, errList, contents); + } + }; - setStateStarted(); + setStateStarted(); - // Kick off the DSProcessor - dsProcessor.run(getDSPProgressMonitorImpl(), cbObj); + // Kick off the DSProcessor + dsProcessor.run(getDSPProgressMonitorImpl(), cbObj); + } } /* diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardDataSourceSettingsPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardDataSourceSettingsPanel.java index d83b9ef46c..8f1dc59444 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardDataSourceSettingsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardDataSourceSettingsPanel.java @@ -47,12 +47,9 @@ class AddImageWizardDataSourceSettingsPanel extends ShortcutWizardDescriptorPane */ private AddImageWizardDataSourceSettingsVisual component; private boolean isNextEnable = false; - private final AddImageWizardAddingProgressPanel progressPanel; - private boolean processingStarted = false; // paths to any set hash lookup databases (can be null) - AddImageWizardDataSourceSettingsPanel(AddImageWizardAddingProgressPanel proPanel) { - this.progressPanel = proPanel; + AddImageWizardDataSourceSettingsPanel() { } /** @@ -199,13 +196,7 @@ class AddImageWizardDataSourceSettingsPanel extends ShortcutWizardDescriptorPane * @param settings the setting to be stored to */ @Override - public void storeSettings(WizardDescriptor settings) { - // Start processing the data source by handing it off to the selected DSP, - // so it gets going in the background while the user is still picking the Ingest modules - if (!processingStarted) { //storeSettings is called twice - processingStarted = true; - progressPanel.startDataSourceProcessing(component.getCurrentDSProcessor()); - } + public void storeSettings(WizardDescriptor settings) { } /** diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIterator.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIterator.java index bf379e41f1..9dad21446e 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIterator.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIterator.java @@ -58,7 +58,7 @@ class AddImageWizardIterator implements WizardDescriptor.Iterator profiles = IngestProfiles.getIngestProfiles(); @@ -174,7 +174,13 @@ class AddImageWizardIterator implements WizardDescriptor.Iterator