diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageTask.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageTask.java index c0c39db742..dc1a65b009 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageTask.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageTask.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2013 Basis Technology Corp. + * Copyright 2013-2014 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -24,8 +24,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.logging.Level; -import org.sleuthkit.autopsy.corecomponentinterfaces.DSPCallback; -import org.sleuthkit.autopsy.corecomponentinterfaces.DSPProgressMonitor; +import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback; +import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.PlatformUtil; import org.sleuthkit.datamodel.Content; @@ -45,9 +45,9 @@ import org.sleuthkit.datamodel.TskException; */ class AddImageTask implements Runnable { - private Logger logger = Logger.getLogger(AddImageTask.class.getName()); + private final Logger logger = Logger.getLogger(AddImageTask.class.getName()); - private Case currentCase; + private final Case currentCase; // true if the process was requested to cancel private final Object lock = new Object(); // synchronization object for cancelRequested @@ -59,32 +59,30 @@ import org.sleuthkit.datamodel.TskException; // true if there was a critical error in adding the data source private boolean hasCritError = false; - private List errorList = new ArrayList(); + private final List errorList = new ArrayList<>(); - private DSPProgressMonitor progressMonitor; - private DSPCallback callbackObj; + private final DataSourceProcessorProgressMonitor progressMonitor; + private final DataSourceProcessorCallback callbackObj; private final List newContents = Collections.synchronizedList(new ArrayList()); private SleuthkitJNI.CaseDbHandle.AddImageProcess addImageProcess; private Thread dirFetcher; - private String imagePath; - private String dataSourcetype; + private final String imagePath; String timeZone; boolean noFatOrphans; - - + /* * A Swingworker that updates the progressMonitor with the name of the * directory currently being processed by the AddImageTask */ private class CurrentDirectoryFetcher implements Runnable { - DSPProgressMonitor progressMonitor; + DataSourceProcessorProgressMonitor progressMonitor; SleuthkitJNI.CaseDbHandle.AddImageProcess process; - CurrentDirectoryFetcher(DSPProgressMonitor aProgressMonitor, SleuthkitJNI.CaseDbHandle.AddImageProcess proc) { + CurrentDirectoryFetcher(DataSourceProcessorProgressMonitor aProgressMonitor, SleuthkitJNI.CaseDbHandle.AddImageProcess proc) { this.progressMonitor = aProgressMonitor; this.process = proc; } @@ -102,17 +100,18 @@ import org.sleuthkit.datamodel.TskException; progressMonitor.setProgressText("Adding: " + currDir); } } + // this sleep here prevents the UI from locking up + // due to too frequent updates to the progressMonitor above Thread.sleep(2 * 1000); } - return; } catch (InterruptedException ie) { - return; + // nothing to do, thread was interrupted externally + // signaling the end of AddImageProcess } } } - - - protected AddImageTask(String imgPath, String tz, boolean noOrphans, DSPProgressMonitor aProgressMonitor, DSPCallback cbObj ) { + + public AddImageTask(String imgPath, String tz, boolean noOrphans, DataSourceProcessorProgressMonitor aProgressMonitor, DataSourceProcessorCallback cbObj ) { currentCase = Case.getCurrentCase(); @@ -134,7 +133,6 @@ import org.sleuthkit.datamodel.TskException; @Override public void run() { - errorList.clear(); //lock DB for writes in this thread @@ -165,9 +163,7 @@ import org.sleuthkit.datamodel.TskException; postProcess(); // unclock the DB - SleuthkitCase.dbWriteUnlock(); - - return; + SleuthkitCase.dbWriteUnlock(); } /** @@ -181,11 +177,10 @@ import org.sleuthkit.datamodel.TskException; long imageId = 0; try { imageId = addImageProcess.commit(); - } catch (TskException e) { + } catch (TskCoreException e) { logger.log(Level.WARNING, "Errors occured while committing the image", e); errorList.add(e.getMessage()); } finally { - if (imageId != 0) { // get the newly added Image so we can return to caller Image newImage = currentCase.getSleuthkitCase().getImageById(imageId); @@ -201,7 +196,7 @@ import org.sleuthkit.datamodel.TskException; newContents.add(newImage); } - logger.log(Level.INFO, "Image committed, imageId: " + imageId); + logger.log(Level.INFO, "Image committed, imageId: {0}", imageId); logger.log(Level.INFO, PlatformUtil.getAllMemUsageInfo()); } } @@ -212,11 +207,9 @@ import org.sleuthkit.datamodel.TskException; */ private void postProcess() { - // cancel the directory fetcher dirFetcher.interrupt(); - if (cancelRequested() || hasCritError) { logger.log(Level.WARNING, "Critical errors or interruption in add image process. Image will not be committed."); revert(); @@ -226,32 +219,24 @@ import org.sleuthkit.datamodel.TskException; logger.log(Level.INFO, "There were errors that occured in add image process"); } - // When everything happens without an error: if (!(cancelRequested() || hasCritError)) { - try { - if (newContents.isEmpty()) { - if (addImageProcess != null) { - // commit image - try { - commitImage(); - } catch (Exception ex) { - errorList.add(ex.getMessage()); - // Log error/display warning - logger.log(Level.SEVERE, "Error adding image to case.", ex); - } - } else { - logger.log(Level.SEVERE, "Missing image process object"); + if (addImageProcess != null) { + // commit image + try { + commitImage(); + } catch (Exception ex) { + errorList.add(ex.getMessage()); + // Log error/display warning + logger.log(Level.SEVERE, "Error adding image to case.", ex); } + } else { + logger.log(Level.SEVERE, "Missing image process object"); } - - else { //already commited? - logger.log(Level.INFO, "Assuming image already committed, will not commit."); - } + // Tell the progress monitor we're done progressMonitor.setProgress(100); - } catch (Exception ex) { //handle unchecked exceptions post image add errorList.add(ex.getMessage()); @@ -265,27 +250,23 @@ import org.sleuthkit.datamodel.TskException; if (!cancelRequested()) { doCallBack(); } - - return; } - - - + /* * Call the callback with results, new content, and errors, if any */ private void doCallBack() { - DSPCallback.DSP_Result result; + DataSourceProcessorCallback.DataSourceProcessorResult result; if (hasCritError) { - result = DSPCallback.DSP_Result.CRITICAL_ERRORS; + result = DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS; } else if (!errorList.isEmpty()) { - result = DSPCallback.DSP_Result.NONCRITICAL_ERRORS; + result = DataSourceProcessorCallback.DataSourceProcessorResult.NONCRITICAL_ERRORS; } else { - result = DSPCallback.DSP_Result.NO_ERRORS; + result = DataSourceProcessorCallback.DataSourceProcessorResult.NO_ERRORS; } // invoke the callback, passing it the result, list of new contents, and list of errors @@ -307,6 +288,7 @@ import org.sleuthkit.datamodel.TskException; } } } + /* * Interrupt the add image process if it is still running */ @@ -315,7 +297,7 @@ import org.sleuthkit.datamodel.TskException; try { logger.log(Level.INFO, "interrupt() add image process"); addImageProcess.stop(); //it might take time to truly stop processing and writing to db - } catch (TskException ex) { + } catch (TskCoreException ex) { throw new Exception("Error stopping add-image process.", ex); } } @@ -324,6 +306,7 @@ import org.sleuthkit.datamodel.TskException; * Revert - if image has already been added but not committed yet */ private void revert() { + if (!reverted) { logger.log(Level.INFO, "Revert after add image process"); try { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java index 476bbdd1df..951d60c834 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardAddingProgressPanel.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011 Basis Technology Corp. + * Copyright 2011-2014 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -29,7 +29,7 @@ import javax.swing.event.ChangeListener; import org.openide.WizardDescriptor; import org.openide.util.HelpCtx; import org.openide.util.Lookup; -import org.sleuthkit.autopsy.corecomponentinterfaces.DSPProgressMonitor; +import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor; /** * The final panel of the add image wizard. It displays a progress bar and @@ -59,7 +59,7 @@ class AddImageWizardAddingProgressPanel implements WizardDescriptor.FinishablePa return dspProgressMonitorImpl; } - private class DSPProgressMonitorImpl implements DSPProgressMonitor { + private class DSPProgressMonitorImpl implements DataSourceProcessorProgressMonitor { @Override public void setIndeterminate(final boolean indeterminate) { // update the progress bar asynchronously diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java index 885b5cced0..65a97761dd 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardChooseDataSourceVisual.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011 Basis Technology Corp. + * Copyright 2011-2014 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -82,9 +82,9 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { // make a list of core DSPs // ensure that the core DSPs are at the top and in a fixed order - coreDSPTypes.add(ImageDSProcessor.dsType); - coreDSPTypes.add(LocalDiskDSProcessor.dsType); - coreDSPTypes.add(LocalFilesDSProcessor.dsType); + coreDSPTypes.add(ImageDSProcessor.getType()); + coreDSPTypes.add(LocalDiskDSProcessor.getType()); + coreDSPTypes.add(LocalFilesDSProcessor.getType()); for(String dspType:coreDSPTypes){ typeComboBox.addItem(dspType); @@ -120,12 +120,11 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { for (DataSourceProcessor dsProcessor: Lookup.getDefault().lookupAll(DataSourceProcessor.class)) { - if (!datasourceProcessorsMap.containsKey(dsProcessor.getType()) ) { - dsProcessor.reset(); - datasourceProcessorsMap.put(dsProcessor.getType(), dsProcessor); + if (!datasourceProcessorsMap.containsKey(dsProcessor.getDataSourceType()) ) { + datasourceProcessorsMap.put(dsProcessor.getDataSourceType(), dsProcessor); } else { - logger.log(Level.SEVERE, "discoverDataSourceProcessors(): A DataSourceProcessor already exists for type = " + dsProcessor.getType() ); + logger.log(Level.SEVERE, "discoverDataSourceProcessors(): A DataSourceProcessor already exists for type = " + dsProcessor.getDataSourceType() ); } } } @@ -166,7 +165,7 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { * Returns the currently selected DS Processor * @return DataSourceProcessor the DataSourceProcessor corresponding to the data source type selected in the combobox */ - public DataSourceProcessor getCurrentDSProcessor() { + protected DataSourceProcessor getCurrentDSProcessor() { // get the type of the currently selected panel and then look up // the correspodning DS Handler in the map String dsType = (String) typeComboBox.getSelectedItem(); @@ -307,7 +306,7 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel { */ public void updateUI(DocumentEvent e) { // Enable the Next button if the current DSP panel is valid - this.wizPanel.enableNextButton(getCurrentDSProcessor().validatePanel()); + this.wizPanel.enableNextButton(getCurrentDSProcessor().isPanelValid()); } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIngestConfigPanel.java b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIngestConfigPanel.java index a83d4549dc..c4c2f6d4dd 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIngestConfigPanel.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/AddImageWizardIngestConfigPanel.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011 Basis Technology Corp. + * Copyright 2011-2014 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -35,7 +35,7 @@ import org.openide.util.HelpCtx; import org.openide.util.Lookup; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.datamodel.Content; -import org.sleuthkit.autopsy.corecomponentinterfaces.DSPCallback; +import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; /** * second panel of add image wizard, allows user to configure ingest modules. @@ -229,9 +229,9 @@ class AddImageWizardIngestConfigPanel implements WizardDescriptor.Panel errList, List contents) { + public void doneEDT(DataSourceProcessorCallback.DataSourceProcessorResult result, List errList, List contents) { dataSourceProcessorDone(result, errList, contents ); } @@ -255,7 +255,7 @@ class AddImageWizardIngestConfigPanel implements WizardDescriptor.Panel errList, List contents) { + private void dataSourceProcessorDone(DataSourceProcessorCallback.DataSourceProcessorResult result, List errList, List contents) { // disable the cleanup task cleanupTask.disable(); @@ -274,7 +274,7 @@ class AddImageWizardIngestConfigPanel implements WizardDescriptor.Panel sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -23,8 +23,8 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.logging.Level; -import org.sleuthkit.autopsy.corecomponentinterfaces.DSPCallback; -import org.sleuthkit.autopsy.corecomponentinterfaces.DSPProgressMonitor; +import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback; +import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.Content; @@ -42,22 +42,25 @@ import org.sleuthkit.datamodel.TskCoreException; */ class AddLocalFilesTask implements Runnable { - private Logger logger = Logger.getLogger(AddLocalFilesTask.class.getName()); + private final Logger logger = Logger.getLogger(AddLocalFilesTask.class.getName()); - private String dataSourcePath; - private DSPProgressMonitor progressMonitor; - private DSPCallback callbackObj; + private final String dataSourcePath; + private final DataSourceProcessorProgressMonitor progressMonitor; + private final DataSourceProcessorCallback callbackObj; - private Case currentCase; + private final Case currentCase; + + // synchronization object for cancelRequested + private final Object lock = new Object(); // true if the process was requested to stop - private volatile boolean cancelled = false; + private volatile boolean cancelRequested = false; + private boolean hasCritError = false; - private List errorList = new ArrayList(); - private final List newContents = Collections.synchronizedList(new ArrayList()); + private final List errorList = new ArrayList<>(); + private final List newContents = Collections.synchronizedList(new ArrayList()); - - protected AddLocalFilesTask(String dataSourcePath, DSPProgressMonitor aProgressMonitor, DSPCallback cbObj) { + public AddLocalFilesTask(String dataSourcePath, DataSourceProcessorProgressMonitor aProgressMonitor, DataSourceProcessorCallback cbObj) { currentCase = Case.getCurrentCase(); @@ -67,7 +70,7 @@ import org.sleuthkit.datamodel.TskCoreException; } /** - * Starts the addImage process, but does not commit the results. + * Add local files and directories to the case * * @return * @@ -86,7 +89,7 @@ import org.sleuthkit.datamodel.TskCoreException; final FileManager fileManager = currentCase.getServices().getFileManager(); String[] paths = dataSourcePath.split(LocalFilesPanel.FILES_SEP); - List absLocalPaths = new ArrayList(); + List absLocalPaths = new ArrayList<>(); for (String path : paths) { absLocalPaths.add(path); } @@ -95,38 +98,31 @@ import org.sleuthkit.datamodel.TskCoreException; logger.log(Level.WARNING, "Errors occurred while running add logical files. ", ex); hasCritError = true; errorList.add(ex.getMessage()); - } finally { - - } + } // handle done postProcess(); - return; } - /** - * - * (called by EventDispatch Thread after doInBackground finishes) - */ - protected void postProcess() { + + private void postProcess() { - if (cancelled || hasCritError) { - logger.log(Level.WARNING, "Handling errors or interruption that occured in logical files process"); - + if (cancelRequested() || hasCritError) { + logger.log(Level.WARNING, "Handling errors or interruption that occured in logical files process"); } if (!errorList.isEmpty()) { //data error (non-critical) logger.log(Level.WARNING, "Handling non-critical errors that occured in logical files process"); } - if (!(cancelled || hasCritError)) { + if (!(cancelRequested() || hasCritError)) { progressMonitor.setProgress(100); progressMonitor.setIndeterminate(false); } // invoke the callBack, unless the caller cancelled - if (!cancelled) { + if (!cancelRequested()) { doCallBack(); } @@ -137,16 +133,16 @@ import org.sleuthkit.datamodel.TskCoreException; */ private void doCallBack() { - DSPCallback.DSP_Result result; + DataSourceProcessorCallback.DataSourceProcessorResult result; if (hasCritError) { - result = DSPCallback.DSP_Result.CRITICAL_ERRORS; + result = DataSourceProcessorCallback.DataSourceProcessorResult.CRITICAL_ERRORS; } else if (!errorList.isEmpty()) { - result = DSPCallback.DSP_Result.NONCRITICAL_ERRORS; + result = DataSourceProcessorCallback.DataSourceProcessorResult.NONCRITICAL_ERRORS; } else { - result = DSPCallback.DSP_Result.NO_ERRORS; + result = DataSourceProcessorCallback.DataSourceProcessorResult.NO_ERRORS; } // invoke the callback, passing it the result, list of new contents, and list of errors @@ -156,21 +152,27 @@ import org.sleuthkit.datamodel.TskCoreException; /* * cancel the files addition, if possible */ - public void cancelTask() { - cancelled = true; - + public void cancelTask() { + synchronized(lock) { + cancelRequested = true; + } } - + + private boolean cancelRequested() { + synchronized (lock) { + return cancelRequested; + } + } + /** * Updates the wizard status with logical file/folder */ private class LocalFilesAddProgressUpdater implements FileManager.FileAddProgressUpdater { private int count = 0; - private DSPProgressMonitor progressMonitor; + private final DataSourceProcessorProgressMonitor progressMonitor; - - LocalFilesAddProgressUpdater(DSPProgressMonitor progressMonitor) { + LocalFilesAddProgressUpdater(DataSourceProcessorProgressMonitor progressMonitor) { this.progressMonitor = progressMonitor; } diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java index 6e38c66574..2dc6861360 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/Case.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/Case.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011-2013 Basis Technology Corp. + * Copyright 2011-2014 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -463,14 +463,7 @@ public class Case implements SleuthkitCase.ErrorObserver { @Deprecated void addLocalDataSource(Content newDataSource) { - try { - pcs.firePropertyChange(CASE_ADD_DATA_SOURCE, null, newDataSource); - } - catch (Exception e) { - logger.log(Level.SEVERE, "Case listener threw exception", e); - MessageNotifyUtil.Notify.show("Module Error", "A module caused an error listening to Case updates. See log to determine which module. Some data could be incomplete.", MessageNotifyUtil.MessageType.ERROR); - } - CoreComponentControl.openCoreWindows(); + notifyNewDataSource(newDataSource); } /** diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/ImageDSProcessor.java b/Core/src/org/sleuthkit/autopsy/casemodule/ImageDSProcessor.java index a60cf66468..b22b94f300 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/ImageDSProcessor.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/ImageDSProcessor.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2013 Basis Technology Corp. + * Copyright 2013-2014 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,17 +18,14 @@ */ package org.sleuthkit.autopsy.casemodule; - -import java.util.logging.Level; import javax.swing.JPanel; import java.util.ArrayList; -import java.util.Arrays; import java.util.List; import javax.swing.filechooser.FileFilter; import org.openide.util.lookup.ServiceProvider; import org.sleuthkit.autopsy.coreutils.Logger; -import org.sleuthkit.autopsy.corecomponentinterfaces.DSPProgressMonitor; -import org.sleuthkit.autopsy.corecomponentinterfaces.DSPCallback; +import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor; +import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; /** @@ -41,15 +38,13 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; @ServiceProvider(service = DataSourceProcessor.class) public class ImageDSProcessor implements DataSourceProcessor { - - static final Logger logger = Logger.getLogger(ImageDSProcessor.class.getName()); // Data source type handled by this processor - protected final static String dsType = "Image File"; + private final static String dsType = "Image File"; // The Config UI panel that plugins into the Choose Data Source Wizard - private ImageFilePanel imageFilePanel; + private final ImageFilePanel imageFilePanel; // The Background task that does the actual work of adding the image private AddImageTask addImageTask; @@ -57,7 +52,7 @@ public class ImageDSProcessor implements DataSourceProcessor { // true of cancelled by the caller private boolean cancelled = false; - DSPCallback callbackObj = null; + DataSourceProcessorCallback callbackObj = null; // set to TRUE if the image options have been set via API and config Jpanel should be ignored private boolean imageOptionsSet = false; @@ -67,13 +62,10 @@ public class ImageDSProcessor implements DataSourceProcessor { private String timeZone; private boolean noFatOrphans; - - - static final GeneralFilter rawFilter = new GeneralFilter(GeneralFilter.RAW_IMAGE_EXTS, GeneralFilter.RAW_IMAGE_DESC); static final GeneralFilter encaseFilter = new GeneralFilter(GeneralFilter.ENCASE_IMAGE_EXTS, GeneralFilter.ENCASE_IMAGE_DESC); - static final List allExt = new ArrayList(); + static final List allExt = new ArrayList<>(); static { allExt.addAll(GeneralFilter.RAW_IMAGE_EXTS); allExt.addAll(GeneralFilter.ENCASE_IMAGE_EXTS); @@ -81,7 +73,7 @@ public class ImageDSProcessor implements DataSourceProcessor { static final String allDesc = "All Supported Types"; static final GeneralFilter allFilter = new GeneralFilter(allExt, allDesc); - static final List filtersList = new ArrayList(); + static final List filtersList = new ArrayList<>(); static { filtersList.add(allFilter); @@ -89,7 +81,6 @@ public class ImageDSProcessor implements DataSourceProcessor { filtersList.add(encaseFilter); } - /* * A no argument constructor is required for the NM lookup() method to create an object */ @@ -100,13 +91,18 @@ public class ImageDSProcessor implements DataSourceProcessor { } + // this static method is used by the wizard to determine dsp type for 'core' data source processors + public static String getType() { + return dsType; + } + /** * Returns the Data source type (string) handled by this DSP * * @return String the data source type **/ @Override - public String getType() { + public String getDataSourceType() { return dsType; } @@ -118,22 +114,23 @@ public class ImageDSProcessor implements DataSourceProcessor { @Override public JPanel getPanel() { - imageFilePanel.readSettings(); imageFilePanel.select(); return imageFilePanel; } + /** * Validates the data collected by the JPanel * * @return String returns NULL if success, error string if there is any errors **/ @Override - public boolean validatePanel() { + public boolean isPanelValid() { return imageFilePanel.validatePanel(); } + /** * Runs the data source processor. * This must kick off processing the data source in background @@ -142,7 +139,7 @@ public class ImageDSProcessor implements DataSourceProcessor { * @param cbObj callback to call when processing is done. **/ @Override - public void run(DSPProgressMonitor progressMonitor, DSPCallback cbObj) { + public void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback cbObj) { callbackObj = cbObj; cancelled = false; @@ -161,7 +158,6 @@ public class ImageDSProcessor implements DataSourceProcessor { addImageTask = new AddImageTask(imagePath, timeZone, noFatOrphans, progressMonitor, cbObj); new Thread(addImageTask).start(); - return; } /** @@ -171,15 +167,12 @@ public class ImageDSProcessor implements DataSourceProcessor { public void cancel() { cancelled = true; - addImageTask.cancelTask(); - - return; } /** * Reset the data source processor - **/ + **/ @Override public void reset() { @@ -191,8 +184,6 @@ public class ImageDSProcessor implements DataSourceProcessor { imagePath = null; timeZone = null; noFatOrphans = false; - - return; } /** @@ -201,7 +192,7 @@ public class ImageDSProcessor implements DataSourceProcessor { * collect this information from a user. * * @param imgPath path to thew image or first image - * @param String timeZone + * @param tz timeZone * @param noFat whether to parse FAT orphans **/ public void setDataSourceOptions(String imgPath, String tz, boolean noFat) { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskDSProcessor.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskDSProcessor.java index cbaa520249..5a74b31a7c 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskDSProcessor.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalDiskDSProcessor.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2013 Basis Technology Corp. + * Copyright 2013-2014 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,8 +21,8 @@ package org.sleuthkit.autopsy.casemodule; import javax.swing.JPanel; import org.openide.util.lookup.ServiceProvider; -import org.sleuthkit.autopsy.corecomponentinterfaces.DSPCallback; -import org.sleuthkit.autopsy.corecomponentinterfaces.DSPProgressMonitor; +import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback; +import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; import org.sleuthkit.autopsy.coreutils.Logger; @@ -33,10 +33,10 @@ public class LocalDiskDSProcessor implements DataSourceProcessor { static final Logger logger = Logger.getLogger(ImageDSProcessor.class.getName()); // Data source type handled by this processor - static protected final String dsType = "Local Disk"; + private static final String dsType = "Local Disk"; // The Config UI panel that plugins into the Choose Data Source Wizard - private LocalDiskPanel localDiskPanel; + private final LocalDiskPanel localDiskPanel; // The Background task that does the actual work of adding the local Disk // Adding a local disk is exactly same as adding an Image. @@ -45,7 +45,7 @@ public class LocalDiskDSProcessor implements DataSourceProcessor { // true if cancelled by the caller private boolean cancelled = false; - DSPCallback callbackObj = null; + DataSourceProcessorCallback callbackObj = null; // set to TRUE if the image options have been set via API and config Jpanel should be ignored private boolean localDiskOptionsSet = false; @@ -55,8 +55,6 @@ public class LocalDiskDSProcessor implements DataSourceProcessor { private String timeZone; private boolean noFatOrphans; - - /* * A no argument constructor is required for the NM lookup() method to create an object */ @@ -67,13 +65,18 @@ public class LocalDiskDSProcessor implements DataSourceProcessor { } + // this static method is used by the wizard to determine dsp type for 'core' data source processors + public static String getType() { + return dsType; + } + /** * Returns the Data source type (string) handled by this DSP * * @return String the data source type **/ @Override - public String getType() { + public String getDataSourceType() { return dsType; } @@ -94,12 +97,10 @@ public class LocalDiskDSProcessor implements DataSourceProcessor { * @return String returns NULL if success, error string if there is any errors **/ @Override - public boolean validatePanel() { + public boolean isPanelValid() { return localDiskPanel.validatePanel(); } - - /** * Runs the data source processor. * This must kick off processing the data source in background @@ -108,7 +109,7 @@ public class LocalDiskDSProcessor implements DataSourceProcessor { * @param cbObj callback to call when processing is done. **/ @Override - public void run(DSPProgressMonitor progressMonitor, DSPCallback cbObj) { + public void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback cbObj) { callbackObj = cbObj; cancelled = false; @@ -123,15 +124,8 @@ public class LocalDiskDSProcessor implements DataSourceProcessor { addDiskTask = new AddImageTask(localDiskPath, timeZone, noFatOrphans, progressMonitor, cbObj); new Thread(addDiskTask).start(); - return; } - - - - - - - + /** * Cancel the data source processing **/ @@ -141,13 +135,11 @@ public class LocalDiskDSProcessor implements DataSourceProcessor { cancelled = true; addDiskTask.cancelTask(); - - return; } /** * Reset the data source processor - **/ + **/ @Override public void reset() { @@ -160,7 +152,6 @@ public class LocalDiskDSProcessor implements DataSourceProcessor { timeZone = null; noFatOrphans = false; - return; } /** @@ -169,7 +160,7 @@ public class LocalDiskDSProcessor implements DataSourceProcessor { * collect this information from a user. * * @param diskPath path to the local disk - * @param String timeZone + * @param tz time zone * @param noFat whether to parse FAT orphans **/ public void setDataSourceOptions(String diskPath, String tz, boolean noFat) { diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesDSProcessor.java b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesDSProcessor.java index 3c6089d4a3..7ff306ae9a 100644 --- a/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesDSProcessor.java +++ b/Core/src/org/sleuthkit/autopsy/casemodule/LocalFilesDSProcessor.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2013 Basis Technology Corp. + * Copyright 2013-2014 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,8 +21,8 @@ package org.sleuthkit.autopsy.casemodule; import javax.swing.JPanel; import org.openide.util.lookup.ServiceProvider; -import org.sleuthkit.autopsy.corecomponentinterfaces.DSPCallback; -import org.sleuthkit.autopsy.corecomponentinterfaces.DSPProgressMonitor; +import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorCallback; +import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessorProgressMonitor; import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor; import org.sleuthkit.autopsy.coreutils.Logger; @@ -32,10 +32,10 @@ public class LocalFilesDSProcessor implements DataSourceProcessor { static final Logger logger = Logger.getLogger(LocalFilesDSProcessor.class.getName()); // Data source type handled by this processor - protected static final String dsType = "Logical Files"; + private static final String dsType = "Logical Files"; // The Config UI panel that plugins into the Choose Data Source Wizard - private LocalFilesPanel localFilesPanel; + private final LocalFilesPanel localFilesPanel; // The Background task that does the actual work of adding the files private AddLocalFilesTask addFilesTask; @@ -43,7 +43,7 @@ public class LocalFilesDSProcessor implements DataSourceProcessor { // true if cancelled by the caller private boolean cancelled = false; - DSPCallback callbackObj = null; + DataSourceProcessorCallback callbackObj = null; // set to TRUE if the image options have been set via API and config Jpanel should be ignored private boolean localFilesOptionsSet = false; @@ -51,8 +51,6 @@ public class LocalFilesDSProcessor implements DataSourceProcessor { // data source options private String localFilesPath; - - /* * A no argument constructor is required for the NM lookup() method to create an object */ @@ -62,13 +60,18 @@ public class LocalFilesDSProcessor implements DataSourceProcessor { localFilesPanel = LocalFilesPanel.getDefault(); } + // this static method is used by the wizard to determine dsp type for 'core' data source processors + public static String getType() { + return dsType; + } + /** * Returns the Data source type (string) handled by this DSP * * @return String the data source type **/ @Override - public String getType() { + public String getDataSourceType() { return dsType; } @@ -82,18 +85,17 @@ public class LocalFilesDSProcessor implements DataSourceProcessor { localFilesPanel.select(); return localFilesPanel; } + /** * Validates the data collected by the JPanel * * @return String returns NULL if success, error string if there is any errors **/ @Override - public boolean validatePanel() { + public boolean isPanelValid() { return localFilesPanel.validatePanel(); } - - /** * Runs the data source processor. * This must kick off processing the data source in background @@ -102,7 +104,7 @@ public class LocalFilesDSProcessor implements DataSourceProcessor { * @param cbObj callback to call when processing is done. **/ @Override - public void run(DSPProgressMonitor progressMonitor, DSPCallback cbObj) { + public void run(DataSourceProcessorProgressMonitor progressMonitor, DataSourceProcessorCallback cbObj) { callbackObj = cbObj; cancelled = false; @@ -115,7 +117,6 @@ public class LocalFilesDSProcessor implements DataSourceProcessor { addFilesTask = new AddLocalFilesTask(localFilesPath, progressMonitor, cbObj); new Thread(addFilesTask).start(); - return; } /** @@ -126,13 +127,12 @@ public class LocalFilesDSProcessor implements DataSourceProcessor { cancelled = true; addFilesTask.cancelTask(); - - return; + } /** * Reset the data source processor - **/ + **/ @Override public void reset() { @@ -143,8 +143,6 @@ public class LocalFilesDSProcessor implements DataSourceProcessor { localFilesOptionsSet = false; localFilesPath = null; - - return; } /** @@ -157,7 +155,7 @@ public class LocalFilesDSProcessor implements DataSourceProcessor { **/ public void setDataSourceOptions(String filesPath) { - this.localFilesPath = filesPath; + localFilesPath = filesPath; localFilesOptionsSet = true; diff --git a/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DataSourceProcessor.java b/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DataSourceProcessor.java index af67e78b68..e150e871ac 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DataSourceProcessor.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DataSourceProcessor.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011-2013 Basis Technology Corp. + * Copyright 2011-2014 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -44,7 +44,7 @@ public interface DataSourceProcessor { enum DSP_PANEL_EVENT { UPDATE_UI, // the content of JPanel has changed that MAY warrant updates to the caller UI - FOCUS_NEXT // the caller UI may move focus the the next UI element, floowing the panel. + FOCUS_NEXT // the caller UI may move focus the the next UI element, following the panel. }; @@ -52,7 +52,7 @@ public interface DataSourceProcessor { * Returns the type of Data Source it handles. * This name gets displayed in the drop-down listbox **/ - String getType(); + String getDataSourceType(); /** * Returns the picker panel to be displayed along with any other @@ -65,7 +65,7 @@ public interface DataSourceProcessor { * Returns true if no errors, or * Returns false if there is an error. **/ - boolean validatePanel(); + boolean isPanelValid(); /** * Called to invoke the handling of Data source in the background. @@ -74,7 +74,7 @@ public interface DataSourceProcessor { * @param progressPanel progress panel to be updated while processing * **/ - void run(DSPProgressMonitor progressPanel, DSPCallback dspCallback); + void run(DataSourceProcessorProgressMonitor progressPanel, DataSourceProcessorCallback dspCallback); /** @@ -84,9 +84,6 @@ public interface DataSourceProcessor { /** * Called to reset/reinitialize the DSP. - * **/ void reset(); - - } diff --git a/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DSPCallback.java b/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DataSourceProcessorCallback.java similarity index 79% rename from Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DSPCallback.java rename to Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DataSourceProcessorCallback.java index f3bdf028da..1b69c03c17 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DSPCallback.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DataSourceProcessorCallback.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2013 Basis Technology Corp. + * Copyright 2013-2014 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,9 +30,9 @@ import org.sleuthkit.datamodel.Content; * in the EDT thread. * */ -public abstract class DSPCallback { +public abstract class DataSourceProcessorCallback { - public enum DSP_Result + public enum DataSourceProcessorResult { NO_ERRORS, CRITICAL_ERRORS, @@ -42,10 +42,10 @@ public abstract class DSPCallback { /* * Invoke the caller supplied callback function on the EDT thread */ - public void done(DSP_Result result, List errList, List newContents) + public void done(DataSourceProcessorResult result, List errList, List newContents) { - final DSP_Result resultf = result; + final DataSourceProcessorResult resultf = result; final List errListf = errList; final List newContentsf = newContents; @@ -62,5 +62,5 @@ public abstract class DSPCallback { /* * calling code overrides to provide its own calllback */ - public abstract void doneEDT(DSP_Result result, List errList, List newContents); + public abstract void doneEDT(DataSourceProcessorResult result, List errList, List newContents); }; diff --git a/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DSPProgressMonitor.java b/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DataSourceProcessorProgressMonitor.java similarity index 83% rename from Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DSPProgressMonitor.java rename to Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DataSourceProcessorProgressMonitor.java index 88d6b5e04c..7495979d71 100644 --- a/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DSPProgressMonitor.java +++ b/Core/src/org/sleuthkit/autopsy/corecomponentinterfaces/DataSourceProcessorProgressMonitor.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2013 Basis Technology Corp. + * Copyright 2013-2014 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -19,11 +19,11 @@ package org.sleuthkit.autopsy.corecomponentinterfaces; /* - * An GUI agnostic DSPProgressMonitor interface for DataSourceProcesssors to + * An GUI agnostic DataSourceProcessorProgressMonitor interface for DataSourceProcesssors to * indicate progress. * It models after a JProgressbar though it could use any underlying implementation */ -public interface DSPProgressMonitor { +public interface DataSourceProcessorProgressMonitor { void setIndeterminate(boolean indeterminate);