mirror of
https://github.com/elisspace/autopsy.git
synced 2026-10-03 15:59:52 +00:00
Merge in of GeneralIngestConfigurator, alternative 1
This commit is contained in:
@@ -109,7 +109,7 @@ public final class AddImageAction extends CallableSystemAction implements Presen
|
||||
Logger.noteAction(AddImageAction.class);
|
||||
|
||||
final IngestConfigurator ingestConfig = Lookup.getDefault().lookup(IngestConfigurator.class);
|
||||
if (ingestConfig.isIngestRunning()) {
|
||||
if (null != ingestConfig && ingestConfig.isIngestRunning()) {
|
||||
final String msg = "<html>Ingest is ongoing on another data source. Adding a new source now might slow down the current ingest.<br />Do you want to proceed and add a new data source now?</html>";
|
||||
if (JOptionPane.showConfirmDialog(null, msg, "Ingest in progress", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) == JOptionPane.NO_OPTION) {
|
||||
return;
|
||||
@@ -128,7 +128,6 @@ public final class AddImageAction extends CallableSystemAction implements Presen
|
||||
dialog.setVisible(true);
|
||||
dialog.toFront();
|
||||
|
||||
|
||||
// Do any cleanup that needs to happen (potentially: stopping the
|
||||
//add-image process, reverting an image)
|
||||
runCleanupTasks();
|
||||
|
||||
@@ -22,6 +22,7 @@ package org.sleuthkit.autopsy.casemodule;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import javax.swing.JPanel;
|
||||
import org.openide.util.lookup.ServiceProvider;
|
||||
import org.sleuthkit.autopsy.coreutils.ModuleSettings;
|
||||
import org.sleuthkit.autopsy.ingest.IngestDialogPanel;
|
||||
import static org.sleuthkit.autopsy.ingest.IngestDialogPanel.DISABLED_MOD;
|
||||
@@ -30,23 +31,31 @@ import org.sleuthkit.autopsy.ingest.IngestManager;
|
||||
import org.sleuthkit.autopsy.ingest.IngestModuleAbstract;
|
||||
import org.sleuthkit.datamodel.Content;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class GeneralIngestConfigurator implements IngestConfigurator {
|
||||
|
||||
@ServiceProvider(service = IngestConfigurator.class)
|
||||
public class GeneralIngestConfigurator implements IngestConfigurator {
|
||||
private static final String DEFAULT_MODULE_CONTEXT = IngestManager.MODULE_PROPERTIES;
|
||||
private List<Content> contentToIngest;
|
||||
private IngestManager manager;
|
||||
private IngestDialogPanel ingestDialogPanel;
|
||||
private String moduleContext;
|
||||
|
||||
public GeneralIngestConfigurator(String moduleContext) {
|
||||
this.moduleContext = moduleContext;
|
||||
|
||||
public GeneralIngestConfigurator() {
|
||||
this.moduleContext = DEFAULT_MODULE_CONTEXT;
|
||||
ingestDialogPanel = new IngestDialogPanel();
|
||||
manager = IngestManager.getDefault();
|
||||
reload();
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDefaultModuleContext() {
|
||||
return DEFAULT_MODULE_CONTEXT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setModuleContext(String moduleContext) {
|
||||
this.moduleContext = moduleContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JPanel getIngestConfigPanel() {
|
||||
return ingestDialogPanel;
|
||||
@@ -59,13 +68,13 @@ public class GeneralIngestConfigurator implements IngestConfigurator {
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
|
||||
//pick the modules
|
||||
// Get the list of ingest modules selected by the user.
|
||||
List<IngestModuleAbstract> modulesToStart = ingestDialogPanel.getModulesToStart();
|
||||
|
||||
//update ingest proc. unalloc space
|
||||
// Get the user's selection of whether or not to process unallocated space.
|
||||
manager.setProcessUnallocSpace(ingestDialogPanel.processUnallocSpaceEnabled());
|
||||
|
||||
// Start the ingest.
|
||||
if (!modulesToStart.isEmpty()) {
|
||||
manager.execute(modulesToStart, contentToIngest);
|
||||
}
|
||||
@@ -73,27 +82,34 @@ public class GeneralIngestConfigurator implements IngestConfigurator {
|
||||
|
||||
@Override
|
||||
public void save() {
|
||||
|
||||
// Save the current module
|
||||
// Save the user's configuration of the currently selected module.
|
||||
IngestModuleAbstract currentModule = ingestDialogPanel.getCurrentIngestModule();
|
||||
if (currentModule != null && currentModule.hasSimpleConfiguration()) {
|
||||
currentModule.saveSimpleConfiguration();
|
||||
}
|
||||
|
||||
// create a list of disabled modules
|
||||
// Create a list of the modules the user wants to be disabled.
|
||||
List<IngestModuleAbstract> disabledModules = IngestManager.getDefault().enumerateAllModules();
|
||||
disabledModules.removeAll(ingestDialogPanel.getModulesToStart());
|
||||
|
||||
// create a csv list
|
||||
disabledModules.removeAll(ingestDialogPanel.getModulesToStart());
|
||||
String disabledModulesCsv = moduleListToCsv(disabledModules);
|
||||
|
||||
// Save the user's general ingest configuration.
|
||||
ModuleSettings.setConfigSetting(moduleContext, DISABLED_MOD, disabledModulesCsv);
|
||||
String processUnalloc = Boolean.toString(ingestDialogPanel.processUnallocSpaceEnabled());
|
||||
ModuleSettings.setConfigSetting(moduleContext, PARSE_UNALLOC, processUnalloc);
|
||||
}
|
||||
|
||||
public static String moduleListToCsv(List<IngestModuleAbstract> lst) {
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
loadSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIngestRunning() {
|
||||
return manager.isIngestRunning();
|
||||
}
|
||||
|
||||
private static String moduleListToCsv(List<IngestModuleAbstract> lst) {
|
||||
if (lst == null || lst.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
@@ -109,7 +125,7 @@ public class GeneralIngestConfigurator implements IngestConfigurator {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
public static List<IngestModuleAbstract> csvToModuleList(String csv) {
|
||||
private static List<IngestModuleAbstract> csvToModuleList(String csv) {
|
||||
List<IngestModuleAbstract> modules = new ArrayList<>();
|
||||
|
||||
if (csv == null || csv.isEmpty()) {
|
||||
@@ -130,24 +146,17 @@ public class GeneralIngestConfigurator implements IngestConfigurator {
|
||||
return modules;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
|
||||
private void loadSettings() {
|
||||
// get the csv list of disabled modules
|
||||
String disabledModulesCsv = ModuleSettings.getConfigSetting(moduleContext, DISABLED_MOD);
|
||||
|
||||
// create a list of modules from it
|
||||
List<IngestModuleAbstract> disabledModules = csvToModuleList(disabledModulesCsv);
|
||||
|
||||
// tell th ingestDialogPanel to unselect these modules
|
||||
// tell the ingestDialogPanel to unselect these modules
|
||||
ingestDialogPanel.setDisabledModules(disabledModules);
|
||||
|
||||
boolean processUnalloc = Boolean.parseBoolean(ModuleSettings.getConfigSetting(moduleContext, PARSE_UNALLOC));
|
||||
ingestDialogPanel.setProcessUnallocSpaceEnabled(processUnalloc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isIngestRunning() {
|
||||
return manager.isIngestRunning();
|
||||
ingestDialogPanel.setProcessUnallocSpaceEnabled(processUnalloc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,18 @@ import org.sleuthkit.datamodel.Content;
|
||||
* Lookup interface for ingest configuration dialog
|
||||
*/
|
||||
public interface IngestConfigurator {
|
||||
/**
|
||||
* Get the default context for running the ingest modules.
|
||||
* @return The default context.
|
||||
*/
|
||||
String getDefaultModuleContext();
|
||||
|
||||
/**
|
||||
* Set the context for running the ingest modules.
|
||||
* @param moduleContext
|
||||
*/
|
||||
void setModuleContext(String moduleContext);
|
||||
|
||||
/**
|
||||
* get JPanel container with the configurator
|
||||
* @return
|
||||
|
||||
@@ -31,8 +31,8 @@ import javax.swing.JButton;
|
||||
import javax.swing.JDialog;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import org.openide.util.Lookup;
|
||||
import org.sleuthkit.datamodel.Content;
|
||||
import org.sleuthkit.autopsy.casemodule.GeneralIngestConfigurator;
|
||||
import org.sleuthkit.autopsy.casemodule.IngestConfigurator;
|
||||
|
||||
/**
|
||||
@@ -40,14 +40,13 @@ import org.sleuthkit.autopsy.casemodule.IngestConfigurator;
|
||||
*/
|
||||
public class IngestDialog extends JDialog {
|
||||
|
||||
private static final String MODULE_CONTEXT = "MainIngest";
|
||||
private static final String TITLE = "Ingest Modules";
|
||||
private static Dimension DIMENSIONS = new Dimension(500, 300);
|
||||
private IngestConfigurator ingestConfigurator;
|
||||
|
||||
public IngestDialog(JFrame frame, String title, boolean modal) {
|
||||
super(frame, title, modal);
|
||||
ingestConfigurator = new GeneralIngestConfigurator(MODULE_CONTEXT);
|
||||
ingestConfigurator = Lookup.getDefault().lookup(IngestConfigurator.class);
|
||||
ingestConfigurator.reload();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user