Improve robustness, usability: ImageDSProcessor, LocalDiskDSProcessor

This commit is contained in:
Richard Cordovano 2016-01-22 08:05:17 -05:00
parent 7078fccc92
commit c1cb91a78b
2 changed files with 94 additions and 92 deletions

View File

@ -31,7 +31,10 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; 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) @ServiceProvider(service = DataSourceProcessor.class)
public class ImageDSProcessor implements DataSourceProcessor { public class ImageDSProcessor implements DataSourceProcessor {
@ -60,12 +63,11 @@ public class ImageDSProcessor implements DataSourceProcessor {
} }
/** /**
* Constructs an uninitialized image data source processor with a * Constructs a local drive data source processor with a configuration
* configuration panel. The data source processor should not be run until * panel. This data source processor implements the DataSourceProcessor
* further initialization using the configuration panel has been completed * service provider interface to allow integration with the add data source
* and validated or the setDataSourceOptions method has been called. * wizard. It also provides a run method overload to allow it to be used
* * independently of the configuration UI.
* TODO (AUT-1867): Configuration is not currently enforced.
*/ */
public ImageDSProcessor() { public ImageDSProcessor() {
imageFilePanel = ImageFilePanel.createInstance(ImageDSProcessor.class.getName(), filtersList); 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 * @param monitor Progress monitor to report progress during processing.
* processing. * @param cbObj Callback to call when processing is done.
* @param cbObj Callback to call when processing is done.
*/ */
@Override @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) { if (!configured) {
imageFilePanel.storeSettings(); imageFilePanel.storeSettings();
if (null == dataSourceId) { if (null == dataSourceId) {
@ -132,10 +138,35 @@ public class ImageDSProcessor implements DataSourceProcessor {
timeZone = imageFilePanel.getTimeZone(); timeZone = imageFilePanel.getTimeZone();
ignoreFatOrphanFiles = imageFilePanel.getNoFatOrphans(); ignoreFatOrphanFiles = imageFilePanel.getNoFatOrphans();
} }
addImageTask = new AddImageTask(imagePath, timeZone, ignoreFatOrphanFiles, progressMonitor, cbObj); addImageTask = new AddImageTask(imagePath, timeZone, ignoreFatOrphanFiles, monitor, cbObj);
new Thread(addImageTask).start(); 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. * Cancels the processing of the data source.
*/ */
@ -167,46 +198,16 @@ public class ImageDSProcessor implements DataSourceProcessor {
* @param imagePath Path to the image file. * @param imagePath Path to the image file.
* @param ignoreFatOrphanFiles Whether to parse orphans if the image has a * @param ignoreFatOrphanFiles Whether to parse orphans if the image has a
* FAT filesystem. * FAT filesystem.
*
* @deprecated Use the run method instead.
*/ */
@Deprecated
public void setDataSourceOptions(String imagePath, boolean ignoreFatOrphanFiles) { public void setDataSourceOptions(String imagePath, boolean ignoreFatOrphanFiles) {
setDataSourceOptions(imagePath, Calendar.getInstance().getTimeZone().getID(), ignoreFatOrphanFiles); this.dataSourceId = UUID.randomUUID().toString();
}
/**
* 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.imagePath = imagePath; this.imagePath = imagePath;
this.timeZone = timeZone; this.timeZone = Calendar.getInstance().getTimeZone().getID();
this.ignoreFatOrphanFiles = ignoreFatOrphanFiles; this.ignoreFatOrphanFiles = ignoreFatOrphanFiles;
configured = true; this.configured = true;
} }
} }

View File

@ -28,7 +28,11 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgress
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; 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) @ServiceProvider(service = DataSourceProcessor.class)
public class LocalDiskDSProcessor implements DataSourceProcessor { public class LocalDiskDSProcessor implements DataSourceProcessor {
@ -43,12 +47,11 @@ public class LocalDiskDSProcessor implements DataSourceProcessor {
private AddImageTask addDiskTask; private AddImageTask addDiskTask;
/** /**
* Constructs an uninitialized local drive data source processor with a * Constructs an image data source processor with a configuration panel.
* configuration panel. The data source processor should not be run until * This data source processor implements the DataSourceProcessor service
* further initialization using the configuration panel has been completed * provider interface to allow integration with the add data source wizard.
* and validated or the setDataSourceOptions method has been called. * It also provides a run method overload to allow it to be used
* * independently of the configuration UI.
* TODO (AUT-1867): Configuration is not currently enforced.
*/ */
public LocalDiskDSProcessor() { public LocalDiskDSProcessor() {
configPanel = LocalDiskPanel.getDefault(); configPanel = LocalDiskPanel.getDefault();
@ -103,10 +106,13 @@ public class LocalDiskDSProcessor implements DataSourceProcessor {
* @param progressMonitor Progress monitor to report progress during * @param progressMonitor Progress monitor to report progress during
* processing. * processing.
* @param cbObj Callback to call when processing is done. * @param cbObj Callback to call when processing is done.
*
*/ */
@Override @Override
public void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback cbObj) { 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 (!configured) {
if (null == dataSourceId) { if (null == dataSourceId) {
dataSourceId = UUID.randomUUID().toString(); dataSourceId = UUID.randomUUID().toString();
@ -120,6 +126,31 @@ public class LocalDiskDSProcessor implements DataSourceProcessor {
new Thread(addDiskTask).start(); 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. * Cancels the processing of the data source.
*/ */
@ -151,44 +182,14 @@ public class LocalDiskDSProcessor implements DataSourceProcessor {
* @param drivePath Path to the local drive. * @param drivePath Path to the local drive.
* @param ignoreFatOrphanFiles Whether to parse orphans if the image has a * @param ignoreFatOrphanFiles Whether to parse orphans if the image has a
* FAT filesystem. * FAT filesystem.
*
* @deprecated Use the run method instead.
*/ */
@Deprecated
public void setDataSourceOptions(String drivePath, boolean ignoreFatOrphanFiles) { public void setDataSourceOptions(String drivePath, boolean ignoreFatOrphanFiles) {
setDataSourceOptions(drivePath, Calendar.getInstance().getTimeZone().getID(), ignoreFatOrphanFiles); this.dataSourceId = UUID.randomUUID().toString();
}
/**
* 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.drivePath = drivePath; this.drivePath = drivePath;
this.timeZone = timeZone; this.timeZone = Calendar.getInstance().getTimeZone().getID();
this.ignoreFatOrphanFiles = ignoreFatOrphanFiles; this.ignoreFatOrphanFiles = ignoreFatOrphanFiles;
configured = true; configured = true;
} }