mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-08 14:19:32 +00:00
Move configure ingest modules before add image
This commit is contained in:
parent
23d9ed64eb
commit
2227116f04
@ -123,6 +123,7 @@ public final class AddImageAction extends CallableSystemAction implements Presen
|
|||||||
dialog.setVisible(false); // hide the old one
|
dialog.setVisible(false); // hide the old one
|
||||||
}
|
}
|
||||||
dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
|
dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
|
||||||
|
dialog.setSize(800, 500);
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
dialog.toFront();
|
dialog.toFront();
|
||||||
|
|
||||||
|
@ -48,9 +48,9 @@ class AddImageWizardIterator implements WizardDescriptor.Iterator<WizardDescript
|
|||||||
private List<WizardDescriptor.Panel<WizardDescriptor>> getPanels() {
|
private List<WizardDescriptor.Panel<WizardDescriptor>> getPanels() {
|
||||||
if (panels == null) {
|
if (panels == null) {
|
||||||
panels = new ArrayList<WizardDescriptor.Panel<WizardDescriptor>>();
|
panels = new ArrayList<WizardDescriptor.Panel<WizardDescriptor>>();
|
||||||
|
panels.add(new AddImageWizardPanel3());
|
||||||
panels.add(new AddImageWizardPanel1());
|
panels.add(new AddImageWizardPanel1());
|
||||||
panels.add(new AddImageWizardPanel2(action));
|
panels.add(new AddImageWizardPanel2(action));
|
||||||
panels.add(new AddImageWizardPanel3());
|
|
||||||
panels.add(new AddImageWizardPanel4());
|
panels.add(new AddImageWizardPanel4());
|
||||||
|
|
||||||
String[] steps = new String[panels.size()];
|
String[] steps = new String[panels.size()];
|
||||||
|
@ -27,16 +27,16 @@ import java.util.Iterator;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
|
||||||
import javax.swing.JProgressBar;
|
import javax.swing.JProgressBar;
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
import javax.swing.SwingWorker;
|
import javax.swing.SwingWorker;
|
||||||
import javax.swing.event.ChangeEvent;
|
import javax.swing.event.ChangeEvent;
|
||||||
import javax.swing.event.ChangeListener;
|
import javax.swing.event.ChangeListener;
|
||||||
import org.openide.WizardDescriptor;
|
import org.openide.WizardDescriptor;
|
||||||
import org.openide.util.Exceptions;
|
|
||||||
import org.openide.util.HelpCtx;
|
import org.openide.util.HelpCtx;
|
||||||
import org.openide.util.Lookup;
|
import org.openide.util.Lookup;
|
||||||
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
|
import org.sleuthkit.datamodel.Image;
|
||||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
import org.sleuthkit.datamodel.SleuthkitCase;
|
||||||
import org.sleuthkit.datamodel.SleuthkitJNI.CaseDbHandle.AddImageProcess;
|
import org.sleuthkit.datamodel.SleuthkitJNI.CaseDbHandle.AddImageProcess;
|
||||||
import org.sleuthkit.datamodel.TskCoreException;
|
import org.sleuthkit.datamodel.TskCoreException;
|
||||||
@ -62,6 +62,10 @@ class AddImageWizardPanel2 implements WizardDescriptor.Panel<WizardDescriptor> {
|
|||||||
private AddImageProcess process;
|
private AddImageProcess process;
|
||||||
private AddImgTask addImageTask;
|
private AddImgTask addImageTask;
|
||||||
private static final Logger logger = Logger.getLogger(AddImageWizardPanel2.class.getName());
|
private static final Logger logger = Logger.getLogger(AddImageWizardPanel2.class.getName());
|
||||||
|
|
||||||
|
private Image newImage = null;
|
||||||
|
private IngestConfigurator ingestConfig = Lookup.getDefault().lookup(IngestConfigurator.class);
|
||||||
|
private boolean ingested = false;
|
||||||
/**
|
/**
|
||||||
* The visual component that displays this panel. If you need to access the
|
* The visual component that displays this panel. If you need to access the
|
||||||
* component from this class, just use getComponent().
|
* component from this class, just use getComponent().
|
||||||
@ -121,11 +125,11 @@ class AddImageWizardPanel2 implements WizardDescriptor.Panel<WizardDescriptor> {
|
|||||||
* Creates the database and adds the image to the XML configuration file.
|
* Creates the database and adds the image to the XML configuration file.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private void startAddImage() {
|
private void startAddImage(WizardDescriptor settings) {
|
||||||
component.getCrDbProgressBar().setIndeterminate(true);
|
component.getCrDbProgressBar().setIndeterminate(true);
|
||||||
component.changeProgressBarTextAndColor("*Adding the image may take some time for large images.", 0, Color.black);
|
component.changeProgressBarTextAndColor("*Adding the image may take some time for large images.", 0, Color.black);
|
||||||
|
|
||||||
addImageTask = new AddImgTask();
|
addImageTask = new AddImgTask(settings);
|
||||||
addImageTask.execute();
|
addImageTask.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,7 +200,7 @@ class AddImageWizardPanel2 implements WizardDescriptor.Panel<WizardDescriptor> {
|
|||||||
|
|
||||||
getComponent().resetInfoPanel();
|
getComponent().resetInfoPanel();
|
||||||
|
|
||||||
startAddImage();
|
startAddImage(settings);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -228,12 +232,14 @@ class AddImageWizardPanel2 implements WizardDescriptor.Panel<WizardDescriptor> {
|
|||||||
private boolean interrupted = false;
|
private boolean interrupted = false;
|
||||||
private boolean hasCritError = false;
|
private boolean hasCritError = false;
|
||||||
private String errorString = null;
|
private String errorString = null;
|
||||||
|
private WizardDescriptor settings;
|
||||||
|
|
||||||
private long start;
|
private long start;
|
||||||
|
|
||||||
protected AddImgTask() {
|
protected AddImgTask(WizardDescriptor settings) {
|
||||||
this.progressBar = getComponent().getCrDbProgressBar();
|
this.progressBar = getComponent().getCrDbProgressBar();
|
||||||
currentCase = Case.getCurrentCase();
|
currentCase = Case.getCurrentCase();
|
||||||
|
this.settings = settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -361,6 +367,31 @@ class AddImageWizardPanel2 implements WizardDescriptor.Panel<WizardDescriptor> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setDbCreated(true);
|
setDbCreated(true);
|
||||||
|
|
||||||
|
// Commit the image
|
||||||
|
if (newImage != null) //already commited
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (process != null) {
|
||||||
|
// commit anything
|
||||||
|
try {
|
||||||
|
commitImage(settings);
|
||||||
|
} catch (Exception ex) {
|
||||||
|
// Log error/display warning
|
||||||
|
logger.log(Level.SEVERE, "Error adding image to case.", ex);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
logger.log(Level.SEVERE, "Missing image process object");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start the ingest process
|
||||||
|
if (newImage != null && !ingested) {
|
||||||
|
ingestConfig.setImage(newImage);
|
||||||
|
ingestConfig.start();
|
||||||
|
ingested = true;
|
||||||
|
}
|
||||||
|
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
//handle unchecked exceptions post image add
|
//handle unchecked exceptions post image add
|
||||||
@ -401,4 +432,39 @@ class AddImageWizardPanel2 implements WizardDescriptor.Panel<WizardDescriptor> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commit the finished AddImageProcess, and cancel the CleanupTask that
|
||||||
|
* would have reverted it.
|
||||||
|
* @param settings property set to get AddImageProcess and CleanupTask from
|
||||||
|
* @throws Exception if commit or adding the image to the case failed
|
||||||
|
*/
|
||||||
|
private void commitImage(WizardDescriptor settings) throws Exception {
|
||||||
|
|
||||||
|
String timezone = settings.getProperty(AddImageAction.TIMEZONE_PROP).toString();
|
||||||
|
settings.putProperty(AddImageAction.IMAGEID_PROP, "");
|
||||||
|
|
||||||
|
long imageId = 0;
|
||||||
|
try {
|
||||||
|
imageId = process.commit();
|
||||||
|
}
|
||||||
|
catch (TskException e) {
|
||||||
|
logger.log(Level.WARNING, "Errors occured while committing the image", e);
|
||||||
|
}
|
||||||
|
finally {
|
||||||
|
//commit done, unlock db write in EWT thread
|
||||||
|
//before doing anything else
|
||||||
|
SleuthkitCase.dbWriteUnlock();
|
||||||
|
|
||||||
|
if (imageId != 0) {
|
||||||
|
newImage = Case.getCurrentCase().addImage(imgPath, imageId, timezone);
|
||||||
|
settings.putProperty(AddImageAction.IMAGEID_PROP, imageId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Can't bail and revert image add after commit, so disable image cleanup
|
||||||
|
// task
|
||||||
|
cleanupImage.disable();
|
||||||
|
settings.putProperty(AddImageAction.IMAGECLEANUPTASK_PROP, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,16 +19,11 @@
|
|||||||
package org.sleuthkit.autopsy.casemodule;
|
package org.sleuthkit.autopsy.casemodule;
|
||||||
|
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.util.logging.Level;
|
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
|
||||||
import javax.swing.event.ChangeListener;
|
import javax.swing.event.ChangeListener;
|
||||||
import org.openide.WizardDescriptor;
|
import org.openide.WizardDescriptor;
|
||||||
import org.openide.util.HelpCtx;
|
import org.openide.util.HelpCtx;
|
||||||
import org.openide.util.Lookup;
|
import org.openide.util.Lookup;
|
||||||
import org.sleuthkit.datamodel.Image;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
import org.sleuthkit.datamodel.SleuthkitCase;
|
|
||||||
import org.sleuthkit.datamodel.SleuthkitJNI;
|
|
||||||
import org.sleuthkit.datamodel.TskException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The "Add Image" wizard panel3. Presents the
|
* The "Add Image" wizard panel3. Presents the
|
||||||
@ -43,8 +38,6 @@ class AddImageWizardPanel3 implements WizardDescriptor.Panel<WizardDescriptor> {
|
|||||||
* component from this class, just use getComponent().
|
* component from this class, just use getComponent().
|
||||||
*/
|
*/
|
||||||
private Component component = null;
|
private Component component = null;
|
||||||
private Image newImage = null;
|
|
||||||
private boolean ingested = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the visual component for the panel. In this template, the component
|
* Get the visual component for the panel. In this template, the component
|
||||||
@ -126,23 +119,6 @@ class AddImageWizardPanel3 implements WizardDescriptor.Panel<WizardDescriptor> {
|
|||||||
@Override
|
@Override
|
||||||
public void readSettings(WizardDescriptor settings) {
|
public void readSettings(WizardDescriptor settings) {
|
||||||
//logger.log(Level.INFO, "readSettings, will commit image");
|
//logger.log(Level.INFO, "readSettings, will commit image");
|
||||||
|
|
||||||
if (newImage != null) //already commited
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((SleuthkitJNI.CaseDbHandle.AddImageProcess) settings.getProperty(AddImageAction.PROCESS_PROP) != null) {
|
|
||||||
// commit anything
|
|
||||||
try {
|
|
||||||
commitImage(settings);
|
|
||||||
} catch (Exception ex) {
|
|
||||||
// Log error/display warning
|
|
||||||
logger.log(Level.SEVERE, "Error adding image to case.", ex);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
logger.log(Level.SEVERE, "Missing image process object");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -160,51 +136,5 @@ class AddImageWizardPanel3 implements WizardDescriptor.Panel<WizardDescriptor> {
|
|||||||
|
|
||||||
//save previously selected config
|
//save previously selected config
|
||||||
ingestConfig.save();
|
ingestConfig.save();
|
||||||
|
|
||||||
final boolean cancelled = settings.getValue() == WizardDescriptor.CANCEL_OPTION || settings.getValue() == WizardDescriptor.CLOSED_OPTION;
|
|
||||||
//start / enqueue ingest if next/finish pressed
|
|
||||||
if (!cancelled && newImage != null && !ingested) {
|
|
||||||
ingestConfig.setImage(newImage);
|
|
||||||
ingestConfig.start();
|
|
||||||
ingested = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Commit the finished AddImageProcess, and cancel the CleanupTask that
|
|
||||||
* would have reverted it.
|
|
||||||
* @param settings property set to get AddImageProcess and CleanupTask from
|
|
||||||
* @throws Exception if commit or adding the image to the case failed
|
|
||||||
*/
|
|
||||||
private void commitImage(WizardDescriptor settings) throws Exception {
|
|
||||||
|
|
||||||
String imgPath = (String) settings.getProperty(AddImageAction.IMGPATH_PROP);
|
|
||||||
String timezone = settings.getProperty(AddImageAction.TIMEZONE_PROP).toString();
|
|
||||||
settings.putProperty(AddImageAction.IMAGEID_PROP, "");
|
|
||||||
SleuthkitJNI.CaseDbHandle.AddImageProcess process = (SleuthkitJNI.CaseDbHandle.AddImageProcess) settings.getProperty(AddImageAction.PROCESS_PROP);
|
|
||||||
|
|
||||||
long imageId = 0;
|
|
||||||
try {
|
|
||||||
imageId = process.commit();
|
|
||||||
}
|
|
||||||
catch (TskException e) {
|
|
||||||
logger.log(Level.WARNING, "Errors occured while committing the image", e);
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
//commit done, unlock db write in EWT thread
|
|
||||||
//before doing anything else
|
|
||||||
SleuthkitCase.dbWriteUnlock();
|
|
||||||
|
|
||||||
if (imageId != 0) {
|
|
||||||
newImage = Case.getCurrentCase().addImage(imgPath, imageId, timezone);
|
|
||||||
settings.putProperty(AddImageAction.IMAGEID_PROP, imageId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Can't bail and revert image add after commit, so disable image cleanup
|
|
||||||
// task
|
|
||||||
AddImageAction.CleanupTask cleanupImage = (AddImageAction.CleanupTask) settings.getProperty(AddImageAction.IMAGECLEANUPTASK_PROP);
|
|
||||||
cleanupImage.disable();
|
|
||||||
settings.putProperty(AddImageAction.IMAGECLEANUPTASK_PROP, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user