mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 09:17:42 +00:00
Cleanup comments, logging, javadocs etc.
This commit is contained in:
parent
f67cd305fc
commit
aa01261c9a
@ -180,10 +180,11 @@ class AddImageWizardChooseDataSourcePanel implements WizardDescriptor.Panel<Wiza
|
||||
|
||||
// Prepopulate the image directory from the properties file
|
||||
try {
|
||||
/******* RAMAN TBD: all settings read/store needs to be moved into the DSP panel
|
||||
String lastDataSourceDirectory = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_LASTDATASOURCE_PATH);
|
||||
String lastDataSourceType = ModuleSettings.getConfigSetting(ModuleSettings.MAIN_SETTINGS, PROP_LASTDATASOURCE_TYPE);
|
||||
|
||||
/******* RAMAN TBD: all settings read/store needs to be moved into the DSP
|
||||
|
||||
//set the last path for the content panel for which it was saved
|
||||
if (component.getContentType().toString().equals(lastDataSourceType)) {
|
||||
component.setContentPath(lastDataSourceDirectory);
|
||||
@ -226,15 +227,9 @@ class AddImageWizardChooseDataSourcePanel implements WizardDescriptor.Panel<Wiza
|
||||
@Override
|
||||
public void storeSettings(WizardDescriptor settings) {
|
||||
/******* RAMAN TBD: all settings read/store needs to be moved into the DSP
|
||||
settings.putProperty(AddImageAction.DATASOURCEPATH_PROP, getComponent().getContentPaths());
|
||||
settings.putProperty(AddImageAction.DATASOURCETYPE_PROP, getComponent().getContentType());
|
||||
|
||||
settings.putProperty(AddImageAction.TIMEZONE_PROP, getComponent().getSelectedTimezone()); // store the timezone
|
||||
settings.putProperty(AddImageAction.NOFATORPHANS_PROP, Boolean.valueOf(getComponent().getNoFatOrphans()));
|
||||
//settings.putProperty(AddImageAction.LOOKUPFILES_PROP, getComponent().getLookupFilesCheckboxChecked());
|
||||
//settings.putProperty(AddImageAction.SOLR_PROP, getComponent().getIndexImageCheckboxChecked());
|
||||
******************/
|
||||
/******* RAMAN TBD: all settings read/store needs to be moved into the DSP
|
||||
|
||||
// Store the path to the first image selected into the properties file
|
||||
String firstImage = getComponent().getContentPaths();
|
||||
String firstImagePath = firstImage.substring(0, firstImage.lastIndexOf(File.separator) + 1);
|
||||
|
@ -105,11 +105,7 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel {
|
||||
|
||||
private void discoverDataSourceProcessors() {
|
||||
|
||||
logger.log(Level.INFO, "RAMAN discoverDataSourceProcessors()...");
|
||||
|
||||
for (DataSourceProcessor dsProcessor: Lookup.getDefault().lookupAll(DataSourceProcessor.class)) {
|
||||
logger.log(Level.INFO, "RAMAN discoverDataSourceProcessors()L found a DSP for type = " + dsProcessor.getType() );
|
||||
|
||||
if (!datasourceProcessorsMap.containsKey(dsProcessor.getType()) ) {
|
||||
if (!datasourceProcessorsMap.containsKey(dsProcessor.getType()) ) {
|
||||
|
||||
@ -117,7 +113,7 @@ final class AddImageWizardChooseDataSourceVisual extends JPanel {
|
||||
datasourceProcessorsMap.put(dsProcessor.getType(), dsProcessor);
|
||||
}
|
||||
else {
|
||||
logger.log(Level.SEVERE, "RAMAN discoverDataSourceProcessors(): A DataSourceProcessor already exisits for type = " + dsProcessor.getType() );
|
||||
logger.log(Level.SEVERE, "discoverDataSourceProcessors(): A DataSourceProcessor already exists for type = " + dsProcessor.getType() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -226,18 +226,13 @@ class AddImageWizardIngestConfigPanel implements WizardDescriptor.Panel<WizardDe
|
||||
}
|
||||
|
||||
/**
|
||||
* Start the Data source handling by kicking of the selected DataSourceProcessor
|
||||
* Starts the Data source processing by kicking off the selected DataSourceProcessor
|
||||
*/
|
||||
private void startDataSourceProcessing(WizardDescriptor settings) {
|
||||
|
||||
logger.log(Level.INFO, "RAMAN startDataSourceProcessing()...");
|
||||
|
||||
// get the selected DSProcessor
|
||||
dsProcessor = dataSourcePanel.getComponent().GetCurrentDSProcessor();
|
||||
|
||||
|
||||
|
||||
// Add a cleanup task to interrupt the backgroud process if the
|
||||
// Add a cleanup task to interrupt the background process if the
|
||||
// wizard exits while the background process is running.
|
||||
cleanupTask = addImageAction.new CleanupTask() {
|
||||
@Override
|
||||
@ -246,9 +241,11 @@ class AddImageWizardIngestConfigPanel implements WizardDescriptor.Panel<WizardDe
|
||||
}
|
||||
};
|
||||
|
||||
// RAMAN TBD: this cleanup task needs to be cancelled, if dsProcessor runs successfully
|
||||
cleanupTask.enable();
|
||||
|
||||
// get the selected DSProcessor
|
||||
dsProcessor = dataSourcePanel.getComponent().GetCurrentDSProcessor();
|
||||
|
||||
DSPCallback cbObj = new DSPCallback () {
|
||||
@Override
|
||||
public void doneEDT(DSPCallback.DSP_Result result, List<String> errList, List<Content> contents) {
|
||||
@ -264,18 +261,22 @@ class AddImageWizardIngestConfigPanel implements WizardDescriptor.Panel<WizardDe
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* Cancels the data source processing - in case the users presses 'Cancel'
|
||||
*/
|
||||
private void cancelDataSourceProcessing() {
|
||||
logger.log(Level.INFO, "RAMAN cancelDataSourceProcessing().");
|
||||
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(DSPCallback.DSP_Result result, List<String> errList, List<Content> contents) {
|
||||
logger.log(Level.INFO, "RAMAN dataSourceProcessorDone().");
|
||||
|
||||
// disable the cleanup task
|
||||
cleanupTask.disable();
|
||||
|
||||
|
||||
// Get attention for the process finish
|
||||
java.awt.Toolkit.getDefaultToolkit().beep(); //BEEP!
|
||||
AddImageWizardAddingProgressVisual panel = progressPanel.getComponent();
|
||||
@ -295,8 +296,8 @@ class AddImageWizardIngestConfigPanel implements WizardDescriptor.Panel<WizardDe
|
||||
|
||||
//if errors, display them on the progress panel
|
||||
for ( String err: errList ) {
|
||||
// RAMAN TBD: there should be an error level for each error
|
||||
progressPanel.addErrors(err, false);
|
||||
// RAMANM TBD: there probably should be an error level for each error
|
||||
progressPanel.addErrors(err, false);
|
||||
}
|
||||
|
||||
newContents.clear();
|
||||
|
@ -1,96 +0,0 @@
|
||||
/*
|
||||
* Autopsy Forensic Browser
|
||||
*
|
||||
* Copyright 2012 Basis Technology Corp.
|
||||
* Contact: carrier <at> sleuthkit <dot> org
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.sleuthkit.autopsy.casemodule;
|
||||
|
||||
import java.beans.PropertyChangeListener;
|
||||
import javax.swing.JPanel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/************
|
||||
abstract class ContentTypePanel extends JPanel {
|
||||
|
||||
// Collection of panels that are dynamically discovered and registered
|
||||
private static List<ContentTypePanel> registeredPanels = new ArrayList<ContentTypePanel>();;
|
||||
|
||||
public static void RegisterPanel(ContentTypePanel panel)
|
||||
{
|
||||
// RAMAN TBD: check if this panel is already regsitered...
|
||||
|
||||
registeredPanels.add(panel);
|
||||
|
||||
|
||||
}
|
||||
//public enum ContentType{IMAGE, DISK, LOCAL};
|
||||
|
||||
|
||||
private String contentType;
|
||||
|
||||
//
|
||||
// * Returns a list off all the panels extending ImageTypePanel.
|
||||
// * @return list of all ImageTypePanels
|
||||
//
|
||||
public static ContentTypePanel[] getPanels() {
|
||||
//return new ContentTypePanel[] {ImageFilePanel.getDefault(), LocalDiskPanel.getDefault(), LocalFilesPanel.getDefault() };
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return registeredPanels.toArray(new ContentTypePanel[registeredPanels.size()]);
|
||||
}
|
||||
|
||||
//
|
||||
// * Return the path of the selected content in this panel.
|
||||
// * @return paths to selected content (one or more if multiselect supported)
|
||||
//
|
||||
abstract public String getContentPaths();
|
||||
|
||||
//
|
||||
// * Set the selected content in this panel to the provided path.
|
||||
// * This function is optional.
|
||||
// * @param s path to selected content
|
||||
//
|
||||
abstract public void setContentPath(String s);
|
||||
|
||||
//
|
||||
// * Get content type (image, disk, local file) of the source this wizard panel is for
|
||||
// * @return ContentType of the source panel
|
||||
//
|
||||
abstract public String getContentType();
|
||||
|
||||
//
|
||||
// * Returns if the next button should be enabled in the current wizard.
|
||||
// * @return true if the next button should be enabled, false otherwise
|
||||
//
|
||||
abstract public boolean enableNext();
|
||||
|
||||
//
|
||||
// * Tells this panel to reset itself
|
||||
//
|
||||
abstract public void reset();
|
||||
|
||||
//
|
||||
// * Tells this panel it has been selected.
|
||||
//
|
||||
abstract public void select();
|
||||
|
||||
|
||||
}
|
||||
***************/
|
@ -34,81 +34,101 @@ import org.sleuthkit.autopsy.corecomponentinterfaces.DSPCallback;
|
||||
import org.sleuthkit.autopsy.corecomponentinterfaces.DataSourceProcessor;
|
||||
|
||||
/**
|
||||
* Image data source processor.
|
||||
* Handles the addition of "disk images" to Autopsy.
|
||||
*
|
||||
* An instance of this class is created via the Netbeans Lookup() method.
|
||||
*
|
||||
* @author raman
|
||||
*/
|
||||
@ServiceProvider(service = DataSourceProcessor.class)
|
||||
public class ImageDSProcessor implements DataSourceProcessor {
|
||||
|
||||
static final Logger logger = Logger.getLogger(ImageDSProcessor.class.getName());
|
||||
|
||||
// The Config UI panel that plugins into the Choose Data Source Wizard
|
||||
private ImageFilePanel imageFilePanel;
|
||||
|
||||
// The Background task that does the actual work of adding the image
|
||||
private AddImageTask addImageTask;
|
||||
|
||||
// true of cancelled by the caller
|
||||
private boolean cancelled = false;
|
||||
|
||||
DSPCallback callbackObj = null;
|
||||
|
||||
// set to TRUE if the image options have been set via API and config Jpanel should be ignored
|
||||
private boolean imageOptionsSet = false;
|
||||
|
||||
// image options
|
||||
private String imagePath;
|
||||
private String timeZone;
|
||||
private boolean noFatOrphans;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* A no argument constructor is required for the NM lookup() method to create an object
|
||||
*/
|
||||
public ImageDSProcessor() {
|
||||
logger.log(Level.INFO, "RAMAN ImageDSProcessor()...");
|
||||
|
||||
// Create the config panel
|
||||
imageFilePanel = ImageFilePanel.getDefault();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the Data source type (string) handled by this DSP
|
||||
*
|
||||
* @return String the data source type
|
||||
**/
|
||||
@Override
|
||||
public String getType() {
|
||||
|
||||
logger.log(Level.INFO, "RAMAN getName()...");
|
||||
|
||||
return imageFilePanel.getContentType();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the JPanel for collecting the Data source information
|
||||
*
|
||||
* @return JPanel the config panel
|
||||
**/
|
||||
@Override
|
||||
public JPanel getPanel() {
|
||||
|
||||
logger.log(Level.INFO, "RAMAN getPanel()...");
|
||||
|
||||
// RAMAN TBD: we should ask the panel to preload with any saved settings
|
||||
|
||||
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 String validatePanel() {
|
||||
|
||||
logger.log(Level.INFO, "RAMAN validatePanel()...");
|
||||
|
||||
if (imageFilePanel.validatePanel() )
|
||||
return null;
|
||||
else
|
||||
return "Error in panel";
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the data source processor.
|
||||
* This must kick off processing the data source in background
|
||||
*
|
||||
* @param progressMonitor Progress monitor to report progress during processing
|
||||
* @param cbObj callback to call when processing is done.
|
||||
**/
|
||||
@Override
|
||||
public void run(DSPProgressMonitor progressMonitor, DSPCallback cbObj) {
|
||||
|
||||
logger.log(Level.INFO, "RAMAN run()...");
|
||||
|
||||
callbackObj = cbObj;
|
||||
cancelled = false;
|
||||
|
||||
if (!imageOptionsSet)
|
||||
{
|
||||
// RAMAN TBD: we should ask the panel to save the current settings now
|
||||
|
||||
// get the image options from the panel
|
||||
imagePath = imageFilePanel.getContentPaths();
|
||||
timeZone = imageFilePanel.getTimeZone();
|
||||
@ -125,23 +145,24 @@ public class ImageDSProcessor implements DataSourceProcessor {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel the data source processing
|
||||
**/
|
||||
@Override
|
||||
public void cancel() {
|
||||
|
||||
logger.log(Level.INFO, "RAMAN cancelProcessing()...");
|
||||
|
||||
cancelled = true;
|
||||
addImageTask.cancelTask();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Reset the data source processor
|
||||
**/
|
||||
@Override
|
||||
public void reset() {
|
||||
|
||||
logger.log(Level.INFO, "RAMAN reset()...");
|
||||
|
||||
// reset the config panel
|
||||
imageFilePanel.reset();
|
||||
|
||||
@ -154,6 +175,15 @@ public class ImageDSProcessor implements DataSourceProcessor {
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the data source options externally.
|
||||
* To be used by a client that does not have a UI and does not use the JPanel to
|
||||
* collect this information from a user.
|
||||
*
|
||||
* @param imgPath path to thew image or first image
|
||||
* @param String timeZone
|
||||
* @param noFat whether to parse FAT orphans
|
||||
**/
|
||||
public void SetDataSourceOptions(String imgPath, String tz, boolean noFat) {
|
||||
|
||||
this.imagePath = imgPath;
|
||||
@ -164,7 +194,9 @@ public class ImageDSProcessor implements DataSourceProcessor {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Background task that actualy adds the image
|
||||
*/
|
||||
private class AddImageTask extends SwingWorker<Integer, Integer> {
|
||||
|
||||
private Logger logger = Logger.getLogger(AddImageTask.class.getName());
|
||||
@ -193,14 +225,19 @@ public class ImageDSProcessor implements DataSourceProcessor {
|
||||
boolean noFatOrphans;
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Sets the name/path and other options for the iimage to be processed
|
||||
*/
|
||||
public void SetImageOptions(String imgPath, String tz, boolean noOrphans) {
|
||||
this.imagePath = imgPath;
|
||||
this.timeZone = tz;
|
||||
this.noFatOrphans = noOrphans;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* A Swingworker that updates the progressMonitor with the name of the
|
||||
* directory currently being processed by the AddImageTask
|
||||
*/
|
||||
private class CurrentDirectoryFetcher extends SwingWorker<Integer, Integer> {
|
||||
|
||||
DSPProgressMonitor progressMonitor;
|
||||
@ -209,7 +246,6 @@ public class ImageDSProcessor implements DataSourceProcessor {
|
||||
CurrentDirectoryFetcher(DSPProgressMonitor aProgressMonitor, SleuthkitJNI.CaseDbHandle.AddImageProcess proc) {
|
||||
this.progressMonitor = aProgressMonitor;
|
||||
this.process = proc;
|
||||
// this.progressBar = aProgressBar;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -253,14 +289,9 @@ public class ImageDSProcessor implements DataSourceProcessor {
|
||||
@Override
|
||||
protected Integer doInBackground() {
|
||||
|
||||
logger.log(Level.INFO, "RAMAN: doInBackground()");
|
||||
|
||||
this.setProgress(0);
|
||||
|
||||
errorList.clear();
|
||||
|
||||
|
||||
|
||||
try {
|
||||
//lock DB for writes in EWT thread
|
||||
//wait until lock acquired in EWT
|
||||
@ -315,8 +346,6 @@ public class ImageDSProcessor implements DataSourceProcessor {
|
||||
*/
|
||||
private void commitImage() throws Exception {
|
||||
|
||||
logger.log(Level.INFO, "RAMAN: commitImage()...");
|
||||
|
||||
long imageId = 0;
|
||||
try {
|
||||
imageId = addImageProcess.commit();
|
||||
@ -352,43 +381,33 @@ public class ImageDSProcessor implements DataSourceProcessor {
|
||||
*
|
||||
* (called by EventDispatch Thread after doInBackground finishes)
|
||||
*
|
||||
* Must Not return without invoking the callBack.
|
||||
* Must Not return without invoking the callBack, unless the caller canceled
|
||||
*/
|
||||
@Override
|
||||
protected void done() {
|
||||
|
||||
logger.log(Level.INFO, "RAMAN: done()...");
|
||||
|
||||
setProgress(100);
|
||||
|
||||
// cancel
|
||||
// cancel the directory fetcher
|
||||
fetcher.cancel(true);
|
||||
|
||||
addImageDone = true;
|
||||
|
||||
// attempt actions that might fail and force the process to stop
|
||||
if (cancelled || hasCritError) {
|
||||
logger.log(Level.INFO, "Handling errors or interruption that occured in add image process");
|
||||
revert();
|
||||
// Do not return yet. Callback must be called
|
||||
}
|
||||
if (!errorList.isEmpty()) {
|
||||
|
||||
logger.log(Level.INFO, "Handling non-critical errors that occured in add image process");
|
||||
|
||||
// error are returned back to the caller
|
||||
}
|
||||
|
||||
// When everything happens without an error:
|
||||
if (!(cancelled || hasCritError)) {
|
||||
|
||||
try {
|
||||
|
||||
|
||||
// Tell the panel we're done
|
||||
// Tell the progress monitor we're done
|
||||
progressMonitor.setProgress(100);
|
||||
|
||||
|
||||
if (newContents.isEmpty()) {
|
||||
if (addImageProcess != null) { // and if we're done configuring ingest
|
||||
// commit anything
|
||||
@ -408,8 +427,6 @@ public class ImageDSProcessor implements DataSourceProcessor {
|
||||
logger.log(Level.INFO, "Assuming image already committed, will not commit.");
|
||||
}
|
||||
|
||||
|
||||
|
||||
} catch (Exception ex) {
|
||||
//handle unchecked exceptions post image add
|
||||
|
||||
@ -428,13 +445,14 @@ public class ImageDSProcessor implements DataSourceProcessor {
|
||||
if (!cancelled)
|
||||
doCallBack();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void doCallBack()
|
||||
/*
|
||||
* Call the callback with proper parameters
|
||||
*/
|
||||
private void doCallBack()
|
||||
{
|
||||
logger.log(Level.INFO, "RAMAN In doCallback()");
|
||||
|
||||
DSPCallback.DSP_Result result;
|
||||
|
||||
if (hasCritError) {
|
||||
@ -447,13 +465,14 @@ public class ImageDSProcessor implements DataSourceProcessor {
|
||||
result = DSPCallback.DSP_Result.NO_ERRORS;
|
||||
}
|
||||
|
||||
// invoke the callcak, passing it the result, list of new contents, and list of errors
|
||||
callbackObj.done(result, errorList, newContents);
|
||||
}
|
||||
|
||||
|
||||
void cancelTask() {
|
||||
|
||||
logger.log(Level.INFO, "RAMAN: cancelTask()...");
|
||||
/*
|
||||
* cancel the image addition, if possible
|
||||
*/
|
||||
public void cancelTask() {
|
||||
|
||||
cancelled = true;
|
||||
|
||||
@ -474,11 +493,11 @@ public class ImageDSProcessor implements DataSourceProcessor {
|
||||
}
|
||||
}
|
||||
}
|
||||
void interrupt() throws Exception {
|
||||
/*
|
||||
* Interrurp the add image process if it is still running
|
||||
*/
|
||||
private void interrupt() throws Exception {
|
||||
|
||||
logger.log(Level.INFO, "RAMAN: interrupt()...");
|
||||
|
||||
//interrupted = true;
|
||||
try {
|
||||
logger.log(Level.INFO, "interrupt() add image process");
|
||||
addImageProcess.stop(); //it might take time to truly stop processing and writing to db
|
||||
@ -487,10 +506,11 @@ public class ImageDSProcessor implements DataSourceProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
//runs in EWT
|
||||
/*
|
||||
* Revert - if image has already been added but not committed yet
|
||||
*/
|
||||
void revert() {
|
||||
|
||||
logger.log(Level.INFO, "RAMAN: revert()...");
|
||||
if (!reverted) {
|
||||
|
||||
try {
|
||||
|
@ -9,8 +9,7 @@ import java.util.List;
|
||||
import org.sleuthkit.datamodel.Content;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author raman
|
||||
* Abstract class for a callback
|
||||
*/
|
||||
public abstract class DSPCallback {
|
||||
|
||||
@ -21,6 +20,9 @@ public abstract class DSPCallback {
|
||||
NONCRITICAL_ERRORS,
|
||||
};
|
||||
|
||||
/*
|
||||
* Invoke the caller supplied callback function on the EDT thread
|
||||
*/
|
||||
public void done(DSP_Result result, List<String> errList, List<Content> newContents)
|
||||
{
|
||||
|
||||
@ -38,5 +40,8 @@ public abstract class DSPCallback {
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* calling code overrides to provide its own calllback
|
||||
*/
|
||||
public abstract void doneEDT(DSP_Result result, List<String> errList, List<Content> newContents);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user