From c1cb91a78b73e62d9fe2ea6c869be7d4ad83676b Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Fri, 22 Jan 2016 08:05:17 -0500 Subject: [PATCH] Improve robustness, usability: ImageDSProcessor, LocalDiskDSProcessor --- .../autopsy/casemodule/ImageDSProcessor.java | 99 ++++++++++--------- .../casemodule/LocalDiskDSProcessor.java | 87 ++++++++-------- 2 files changed, 94 insertions(+), 92 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/ImageDSProcessor.java b/Core/src/org/sleuthkit/autopsy/casemodule/ImageDSProcessor.java index b345a588e8..c50bf05257 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/ImageDSProcessor.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/ImageDSProcessor.java @@ -31,7 +31,10 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; /** - * Image data source processor. + * An image data source processor with a configuration panel. This data source + * processor implements the DataSourceProcessor service provider interface to + * allow integration with the add data source wizard. It also provides a run + * method overload to allow it to be used independently of the configuration UI. */ @ServiceProvider(service = DataSourceProcessor.class) public class ImageDSProcessor implements DataSourceProcessor { @@ -60,12 +63,11 @@ public class ImageDSProcessor implements DataSourceProcessor { } /** - * Constructs an uninitialized image data source processor with a - * configuration panel. The data source processor should not be run until - * further initialization using the configuration panel has been completed - * and validated or the setDataSourceOptions method has been called. - * - * TODO (AUT-1867): Configuration is not currently enforced. + * Constructs a local drive data source processor with a configuration + * panel. This data source processor implements the DataSourceProcessor + * service provider interface to allow integration with the add data source + * wizard. It also provides a run method overload to allow it to be used + * independently of the configuration UI. */ public ImageDSProcessor() { imageFilePanel = ImageFilePanel.createInstance(ImageDSProcessor.class.getName(), filtersList); @@ -115,14 +117,18 @@ public class ImageDSProcessor implements DataSourceProcessor { } /** - * Runs the data source processor in a separate thread. + * Runs the data source processor in a separate thread. Should only be + * called after further configuration has been completed. * - * @param progressMonitor Progress monitor to report progress during - * processing. - * @param cbObj Callback to call when processing is done. + * @param monitor Progress monitor to report progress during processing. + * @param cbObj Callback to call when processing is done. */ @Override - public void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback cbObj) { + public void run(DataSourceProcessorProgressMonitor monitor, DataSourceProcessorCallback cbObj) { + /* + * TODO (AUT-1867): Configuration is not currently enforced. This code + * assumes that the ingest panel is providing validated inputs. + */ if (!configured) { imageFilePanel.storeSettings(); if (null == dataSourceId) { @@ -132,10 +138,35 @@ public class ImageDSProcessor implements DataSourceProcessor { timeZone = imageFilePanel.getTimeZone(); ignoreFatOrphanFiles = imageFilePanel.getNoFatOrphans(); } - addImageTask = new AddImageTask(imagePath, timeZone, ignoreFatOrphanFiles, progressMonitor, cbObj); + addImageTask = new AddImageTask(imagePath, timeZone, ignoreFatOrphanFiles, monitor, cbObj); new Thread(addImageTask).start(); } + /** + * Runs the data source processor in a separate thread without requiring use + * the configuration panel. + * + * @param dataSourceId A identifier for the data source that is + * unique across multiple cases (e.g., a UUID). + * @param imagePath Path to the image file. + * @param timeZone The time zone to use when processing dates + * and times for the image, obtained from + * java.util.TimeZone.getID. + * @param ignoreFatOrphanFiles Whether to parse orphans if the image has a + * FAT filesystem. + * @param monitor Progress monitor to report progress during + * processing. + * @param cbObj Callback to call when processing is done. + */ + public void run(String dataSourceId, String imagePath, String timeZone, boolean ignoreFatOrphanFiles, DataSourceProcessorProgressMonitor monitor, DataSourceProcessorCallback cbObj) { + this.dataSourceId = dataSourceId; + this.imagePath = imagePath; + this.timeZone = timeZone; + this.ignoreFatOrphanFiles = ignoreFatOrphanFiles; + configured = true; + run(monitor, cbObj); + } + /** * Cancels the processing of the data source. */ @@ -167,46 +198,16 @@ public class ImageDSProcessor implements DataSourceProcessor { * @param imagePath Path to the image file. * @param ignoreFatOrphanFiles Whether to parse orphans if the image has a * FAT filesystem. + * + * @deprecated Use the run method instead. */ + @Deprecated public void setDataSourceOptions(String imagePath, boolean ignoreFatOrphanFiles) { - setDataSourceOptions(imagePath, Calendar.getInstance().getTimeZone().getID(), ignoreFatOrphanFiles); - } - - /** - * Sets the configuration of the data source processor without using the - * configuration panel. The data source processor will assign a UUID to the - * data source. - * - * @param imagePath Path to the image file. - * @param timeZone The time zone to use when processing dates - * and times for the image, obtained from - * java.util.TimeZone.getID. - * @param ignoreFatOrphanFiles Whether to parse orphans if the image has a - * FAT filesystem. - */ - public void setDataSourceOptions(String imagePath, String timeZone, boolean ignoreFatOrphanFiles) { - setDataSourceOptions(UUID.randomUUID().toString(), imagePath, timeZone, ignoreFatOrphanFiles); - } - - /** - * Sets the configuration of the data source processor without using the - * configuration panel. - * - * @param dataSourceId A identifier for the data source that is - * unique across multiple cases (e.g., a UUID). - * @param imagePath Path to the image file. - * @param timeZone The time zone to use when processing dates - * and times for the image, obtained from - * java.util.TimeZone.getID. - * @param ignoreFatOrphanFiles Whether to parse orphans if the image has a - * FAT filesystem. - */ - public void setDataSourceOptions(String dataSourceId, String imagePath, String timeZone, boolean ignoreFatOrphanFiles) { - this.dataSourceId = dataSourceId; + this.dataSourceId = UUID.randomUUID().toString(); this.imagePath = imagePath; - this.timeZone = timeZone; + this.timeZone = Calendar.getInstance().getTimeZone().getID(); this.ignoreFatOrphanFiles = ignoreFatOrphanFiles; - configured = true; + this.configured = true; } } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskDSProcessor.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskDSProcessor.java index 4fc7edcff1..cff54942d2 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskDSProcessor.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskDSProcessor.java @@ -28,7 +28,11 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgress import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; /** - * Local drive data source processor. + * A local drive data source processor with a configuration panel. This data + * source processor implements the DataSourceProcessor service provider + * interface to allow integration with the add data source wizard. It also + * provides a run method overload to allow it to be used independently of the + * configuration UI. */ @ServiceProvider(service = DataSourceProcessor.class) public class LocalDiskDSProcessor implements DataSourceProcessor { @@ -43,12 +47,11 @@ public class LocalDiskDSProcessor implements DataSourceProcessor { private AddImageTask addDiskTask; /** - * Constructs an uninitialized local drive data source processor with a - * configuration panel. The data source processor should not be run until - * further initialization using the configuration panel has been completed - * and validated or the setDataSourceOptions method has been called. - * - * TODO (AUT-1867): Configuration is not currently enforced. + * Constructs an image data source processor with a configuration panel. + * This data source processor implements the DataSourceProcessor service + * provider interface to allow integration with the add data source wizard. + * It also provides a run method overload to allow it to be used + * independently of the configuration UI. */ public LocalDiskDSProcessor() { configPanel = LocalDiskPanel.getDefault(); @@ -103,10 +106,13 @@ public class LocalDiskDSProcessor implements DataSourceProcessor { * @param progressMonitor Progress monitor to report progress during * processing. * @param cbObj Callback to call when processing is done. - * */ @Override public void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback cbObj) { + /* + * TODO (AUT-1867): Configuration is not currently enforced. This code + * assumes that the ingest panel is providing validated inputs. + */ if (!configured) { if (null == dataSourceId) { dataSourceId = UUID.randomUUID().toString(); @@ -120,6 +126,31 @@ public class LocalDiskDSProcessor implements DataSourceProcessor { new Thread(addDiskTask).start(); } + /** + * Runs the data source processor in a separate thread without requiring use + * the configuration panel. + * + * @param dataSourceId A identifier for the data source that is + * unique across multiple cases (e.g., a UUID). + * @param drivePath Path to the local drive. + * @param timeZone The time zone to use when processing dates + * and times for the image, obtained from + * java.util.TimeZone.getID. + * @param ignoreFatOrphanFiles Whether to parse orphans if the image has a + * FAT filesystem. + * @param monitor Progress monitor to report progress during + * processing. + * @param cbObj Callback to call when processing is done. + */ + public void run(String dataSourceId, String drivePath, String timeZone, boolean ignoreFatOrphanFiles, DataSourceProcessorProgressMonitor monitor, DataSourceProcessorCallback cbObj) { + this.dataSourceId = dataSourceId; + this.drivePath = drivePath; + this.timeZone = timeZone; + this.ignoreFatOrphanFiles = ignoreFatOrphanFiles; + configured = true; + run(monitor, cbObj); + } + /** * Cancels the processing of the data source. */ @@ -151,44 +182,14 @@ public class LocalDiskDSProcessor implements DataSourceProcessor { * @param drivePath Path to the local drive. * @param ignoreFatOrphanFiles Whether to parse orphans if the image has a * FAT filesystem. + * + * @deprecated Use the run method instead. */ + @Deprecated public void setDataSourceOptions(String drivePath, boolean ignoreFatOrphanFiles) { - setDataSourceOptions(drivePath, Calendar.getInstance().getTimeZone().getID(), ignoreFatOrphanFiles); - } - - /** - * Sets the configuration of the data source processor without using the - * configuration panel. The data source processor will assign a UUID to the - * data source. - * - * @param drivePath Path to the local drive. - * @param timeZone The time zone to use when processing dates - * and times for the image, obtained from - * java.util.TimeZone.getID. - * @param ignoreFatOrphanFiles Whether to parse orphans if the image has a - * FAT filesystem. - */ - public void setDataSourceOptions(String drivePath, String timeZone, boolean ignoreFatOrphanFiles) { - setDataSourceOptions(UUID.randomUUID().toString(), drivePath, timeZone, ignoreFatOrphanFiles); - } - - /** - * Sets the configuration of the data source processor without using the - * configuration panel. - * - * @param dataSourceId A identifier for the data source that is - * unique across multiple cases (e.g., a UUID). - * @param drivePath Path to the local drive. - * @param timeZone The time zone to use when processing dates - * and times for the image, obtained from - * java.util.TimeZone.getID. - * @param ignoreFatOrphanFiles Whether to parse orphans if the image has a - * FAT filesystem. - */ - public void setDataSourceOptions(String dataSourceId, String drivePath, String timeZone, boolean ignoreFatOrphanFiles) { - this.dataSourceId = dataSourceId; + this.dataSourceId = UUID.randomUUID().toString(); this.drivePath = drivePath; - this.timeZone = timeZone; + this.timeZone = Calendar.getInstance().getTimeZone().getID(); this.ignoreFatOrphanFiles = ignoreFatOrphanFiles; configured = true; }