diff --git a/Core/src/org/sleuthkit/autopsy/casemodule/GeneralIngestConfigurator.java b/Core/src/org/sleuthkit/autopsy/casemodule/GeneralIngestConfigurator.java new file mode 100644 index 0000000000..3026336b87 --- /dev/null +++ b/Core/src/org/sleuthkit/autopsy/casemodule/GeneralIngestConfigurator.java @@ -0,0 +1,153 @@ +/* + * Autopsy Forensic Browser + * + * Copyright 2013 Basis Technology Corp. + * Contact: carrier sleuthkit 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.util.ArrayList; +import java.util.List; +import javax.swing.JPanel; +import org.sleuthkit.autopsy.coreutils.ModuleSettings; +import org.sleuthkit.autopsy.ingest.IngestDialogPanel; +import static org.sleuthkit.autopsy.ingest.IngestDialogPanel.DISABLED_MOD; +import static org.sleuthkit.autopsy.ingest.IngestDialogPanel.PARSE_UNALLOC; +import org.sleuthkit.autopsy.ingest.IngestManager; +import org.sleuthkit.autopsy.ingest.IngestModuleAbstract; +import org.sleuthkit.datamodel.Content; + +/** + * + */ +public class GeneralIngestConfigurator implements IngestConfigurator { + + private List contentToIngest; + private IngestManager manager; + private IngestDialogPanel ingestDialogPanel; + private String moduleContext; + + public GeneralIngestConfigurator(String moduleContext) { + this.moduleContext = moduleContext; + ingestDialogPanel = new IngestDialogPanel(); + manager = IngestManager.getDefault(); + reload(); + } + + @Override + public JPanel getIngestConfigPanel() { + return ingestDialogPanel; + } + + @Override + public void setContent(List inputContent) { + this.contentToIngest = inputContent; + } + + @Override + public void start() { + + //pick the modules + List modulesToStart = ingestDialogPanel.getModulesToStart(); + + if (!modulesToStart.isEmpty()) { + manager.execute(modulesToStart, contentToIngest); + } + + //update ingest proc. unalloc space + manager.setProcessUnallocSpace(ingestDialogPanel.processUnallocSpaceEnabled()); + } + + @Override + public void save() { + + // Save the current module + IngestModuleAbstract currentModule = ingestDialogPanel.getCurrentIngestModule(); + if (currentModule != null && currentModule.hasSimpleConfiguration()) { + currentModule.saveSimpleConfiguration(); + } + + // create a list of disabled modules + List disabledModules = IngestManager.getDefault().enumerateAllModules(); + disabledModules.removeAll(ingestDialogPanel.getModulesToStart()); + + // create a csv list + String disabledModulesCsv = moduleListToCsv(disabledModules); + + ModuleSettings.setConfigSetting(moduleContext, DISABLED_MOD, disabledModulesCsv); + String processUnalloc = Boolean.toString(ingestDialogPanel.processUnallocSpaceEnabled()); + ModuleSettings.setConfigSetting(moduleContext, PARSE_UNALLOC, processUnalloc); + } + + public static String moduleListToCsv(List lst) { + + if (lst == null || lst.isEmpty()) { + return ""; + } + + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < lst.size() - 1; ++i) { + sb.append(lst.get(i).getName()).append(", "); + } + + // and the last one + sb.append(lst.get(lst.size() - 1).getName()); + + return sb.toString(); + } + + public static List csvToModuleList(String csv) { + List modules = new ArrayList<>(); + + if (csv == null || csv.isEmpty()) { + return modules; + } + + String[] moduleNames = csv.split(", "); + List allModules = IngestManager.getDefault().enumerateAllModules(); + for (String moduleName : moduleNames) { + for (IngestModuleAbstract module : allModules) { + if (moduleName.equals(module.getName())) { + modules.add(module); + break; + } + } + } + + return modules; + } + + @Override + public void reload() { + + // get the csv list of disabled modules + String disabledModulesCsv = ModuleSettings.getConfigSetting(moduleContext, DISABLED_MOD); + + // create a list of modules from it + List disabledModules = csvToModuleList(disabledModulesCsv); + + // tell th 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(); + } +} diff --git a/Core/src/org/sleuthkit/autopsy/coreutils/ModuleSettings.java b/Core/src/org/sleuthkit/autopsy/coreutils/ModuleSettings.java index 117c5eb4ab..4eff288380 100644 --- a/Core/src/org/sleuthkit/autopsy/coreutils/ModuleSettings.java +++ b/Core/src/org/sleuthkit/autopsy/coreutils/ModuleSettings.java @@ -19,12 +19,17 @@ package org.sleuthkit.autopsy.coreutils; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; import java.util.HashMap; import java.util.Map; import java.util.Properties; import java.util.Set; import java.util.logging.Level; + /** * This class contains the framework to read, add, update, and remove * from the property files located at %USERDIR%/Config/x.properties @@ -33,15 +38,11 @@ public class ModuleSettings { // The directory where the properties file is lcoated private final static String moduleDirPath = PlatformUtil.getUserConfigDirectory(); - public static final String MAIN_SETTINGS="Case"; + public static final String MAIN_SETTINGS = "Case"; - /** the constructor */ - private ModuleSettings() { - - } - - + private ModuleSettings() {} + /** * Makes a new config file of the specified name. Do not include the extension. * @param moduleName - The name of the config file to make @@ -161,9 +162,7 @@ public class ModuleSettings { return null; } } - - - + /** * Sets the given properties file to the given setting map. * @param moduleName - The name of the module to be written to. @@ -215,14 +214,12 @@ public class ModuleSettings { Logger.getLogger(ModuleSettings.class.getName()).log(Level.WARNING, "Property file exists for [" + moduleName + "] at [" + getPropertyPath(moduleName) + "] but could not be loaded.", e); } } - /** * Removes the given key from the given properties file. * @param moduleName - The name of the properties file to be modified. * @param key - the name of the key to remove. */ - public static synchronized void removeProperty(String moduleName, String key){ try{ if(getConfigSetting(moduleName, key) != null){ @@ -268,5 +265,4 @@ public class ModuleSettings { return new File(getPropertyPath(moduleName)); } } - } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestDialog.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestDialog.java index 01cfba4239..970cd249dc 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestDialog.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestDialog.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011 Basis Technology Corp. + * Copyright 2013 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,36 +26,35 @@ import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.List; -import org.sleuthkit.autopsy.coreutils.Logger; import javax.swing.BoxLayout; import javax.swing.JButton; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.JPanel; import org.sleuthkit.datamodel.Content; +import org.sleuthkit.autopsy.casemodule.GeneralIngestConfigurator; +import org.sleuthkit.autopsy.casemodule.IngestConfigurator; /** * IngestDialog shown on Case.CASE_ADD_IMAGE property change */ 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 IngestDialogPanel panel = null; + private IngestConfigurator ingestConfigurator; - private static final Logger logger = Logger.getLogger(IngestDialog.class.getName()); - public IngestDialog(JFrame frame, String title, boolean modal) { super(frame, title, modal); - panel = new IngestDialogPanel(); + ingestConfigurator = new GeneralIngestConfigurator(MODULE_CONTEXT); + ingestConfigurator.reload(); } public IngestDialog(){ this(new JFrame(TITLE), TITLE, true); } - - /** * Shows the Ingest dialog. */ @@ -71,17 +70,14 @@ public class IngestDialog extends JDialog { // set the location of the popUp Window on the center of the screen setLocation((screenDimension.width - w) / 2, (screenDimension.height - h) / 2); - panel.reload(); // reload the simple panel - add(panel, BorderLayout.PAGE_START); + add(ingestConfigurator.getIngestConfigPanel(), BorderLayout.PAGE_START); JButton startButton = new JButton("Start"); JButton closeButton = new JButton("Close"); startButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { - - panel.save(); - panel.start(); + ingestConfigurator.start(); close(); } }); @@ -89,7 +85,7 @@ public class IngestDialog extends JDialog { @Override public void actionPerformed(ActionEvent e) { - panel.save(); + ingestConfigurator.save(); close(); } }); @@ -97,7 +93,7 @@ public class IngestDialog extends JDialog { @Override public void windowClosing(WindowEvent e) { - panel.save(); + ingestConfigurator.save(); close(); } }); @@ -113,11 +109,10 @@ public class IngestDialog extends JDialog { setResizable(false); setVisible(true); } - + public void setContent(List inputContent) { - panel.setContent(inputContent); - } - + ingestConfigurator.setContent(inputContent); + } /** * Closes the Ingest dialog @@ -126,6 +121,4 @@ public class IngestDialog extends JDialog { setVisible(false); dispose(); } - - } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestDialogPanel.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestDialogPanel.java index d6e65d2bac..98d7c197fe 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestDialogPanel.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestDialogPanel.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011 Basis Technology Corp. + * Copyright 2013 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -18,24 +18,15 @@ */ package org.sleuthkit.autopsy.ingest; -import java.awt.Color; import java.awt.Component; -import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; +import java.util.AbstractMap; import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.logging.Level; -import org.sleuthkit.autopsy.coreutils.Logger; -import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; @@ -43,80 +34,47 @@ import javax.swing.event.ListSelectionListener; import javax.swing.table.AbstractTableModel; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableColumn; -import org.openide.util.lookup.ServiceProvider; -import org.sleuthkit.autopsy.casemodule.IngestConfigurator; import org.sleuthkit.autopsy.corecomponents.AdvancedConfigurationDialog; -import org.sleuthkit.autopsy.coreutils.ModuleSettings; -import org.sleuthkit.autopsy.ingest.IngestModuleAbstract.ModuleType; -import org.sleuthkit.datamodel.Content; -import org.sleuthkit.datamodel.TskCoreException; /** * main configuration panel for all ingest modules, reusable JPanel component */ -@ServiceProvider(service = IngestConfigurator.class) -public class IngestDialogPanel extends javax.swing.JPanel implements IngestConfigurator { +public class IngestDialogPanel extends javax.swing.JPanel { - private IngestManager manager = null; - private List modules; private IngestModuleAbstract currentModule; - private Map moduleStates; private ModulesTableModel tableModel; - private static final Logger logger = Logger.getLogger(IngestDialogPanel.class.getName()); public static final String DISABLED_MOD = "Disabled_Ingest_Modules"; public static final String PARSE_UNALLOC = "Process_Unallocated_Space"; - // The input content that's just been added to the database - private List inputContent; - // private static IngestDialogPanel instance = null; /** * Creates new form IngestDialogPanel */ public IngestDialogPanel() { tableModel = new ModulesTableModel(); - modules = new ArrayList(); - moduleStates = new HashMap(); initComponents(); customizeComponents(); } - private void loadModules() { - this.modules.clear(); - //this.moduleStates.clear(); maintain the state - Collection imageModules = manager.enumerateDataSourceModules(); - for (final IngestModuleDataSource module : imageModules) { - addModule(module); - } - Collection fsModules = manager.enumerateAbstractFileModules(); - for (final IngestModuleAbstractFile module : fsModules) { - addModule(module); - } + public IngestModuleAbstract getCurrentIngestModule() { + return currentModule; + } + + public List getModulesToStart() { + return tableModel.getSelectedModules(); + } + + public boolean processUnallocSpaceEnabled() { + return processUnallocCheckbox.isSelected(); } private void customizeComponents() { modulesTable.setModel(tableModel); - this.manager = IngestManager.getDefault(); - - loadModules(); - try { - IngestModuleLoader.getDefault().addModulesReloadedListener(new PropertyChangeListener() { - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getPropertyName().equals(IngestModuleLoader.Event.ModulesReloaded.toString())) { - loadModules(); - } - } - }); - } catch (IngestModuleLoaderException ex) { - logger.log(Level.SEVERE, "Could not initialize ingest module loader to listen for module config changes", ex); - } - modulesTable.setTableHeader(null); modulesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); //custom renderer for tooltips - ModulesTableRenderer renderer = new ModulesTableRenderer(); + //customize column witdhs final int width = modulesScrollPane.getPreferredSize().width; TableColumn column = null; @@ -135,40 +93,30 @@ public class IngestDialogPanel extends javax.swing.JPanel implements IngestConfi public void valueChanged(ListSelectionEvent e) { ListSelectionModel listSelectionModel = (ListSelectionModel) e.getSource(); if (!listSelectionModel.isSelectionEmpty()) { - save(); int index = listSelectionModel.getMinSelectionIndex(); - currentModule = modules.get(index); - reload(); + currentModule = tableModel.getModule(index); + + // add the module-specific configuration panel, if there is one + simplePanel.removeAll(); + if (currentModule.hasSimpleConfiguration()) { + simplePanel.add(currentModule.getSimpleConfiguration()); + } + simplePanel.revalidate(); + simplePanel.repaint(); advancedButton.setEnabled(currentModule.hasAdvancedConfiguration()); } else { currentModule = null; } } }); - - processUnallocCheckbox.setSelected(manager.getProcessUnallocSpace()); - } - private void setProcessUnallocSpaceEnabled(boolean enabled) { - processUnallocCheckbox.setEnabled(enabled); + public void setProcessUnallocSpaceEnabled(final boolean enabled) { + processUnallocCheckbox.setSelected(enabled); } - - @Override - public void paint(Graphics g) { - super.paint(g); - if (manager.isIngestRunning()) { - setProcessUnallocSpaceEnabled(false); - - } else { - setProcessUnallocSpaceEnabled(true); - } - } - - private void addModule(IngestModuleAbstract module) { - final String moduleName = module.getName(); - modules.add(module); - moduleStates.put(moduleName, true); + + public void setDisabledModules(List disabledModules) { + tableModel.setUnselectedModules(disabledModules); } /** @@ -311,22 +259,19 @@ public class IngestDialogPanel extends javax.swing.JPanel implements IngestConfi public void actionPerformed(ActionEvent e) { dialog.close(); currentModule.saveAdvancedConfiguration(); - reload(); } }); dialog.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { dialog.close(); - reload(); } }); - save(); // save the simple panel - dialog.display(currentModule.getAdvancedConfiguration(null)); + dialog.display(currentModule.getAdvancedConfiguration()); }//GEN-LAST:event_advancedButtonActionPerformed private void processUnallocCheckboxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_processUnallocCheckboxActionPerformed - // TODO add your handling code here: + // nothing to do here }//GEN-LAST:event_processUnallocCheckboxActionPerformed // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton advancedButton; @@ -342,10 +287,19 @@ public class IngestDialogPanel extends javax.swing.JPanel implements IngestConfi // End of variables declaration//GEN-END:variables private class ModulesTableModel extends AbstractTableModel { + + private List>moduleData = new ArrayList<>(); + + public ModulesTableModel() { + List modules = IngestManager.getDefault().enumerateAllModules(); + for (IngestModuleAbstract ingestModuleAbstract : modules) { + moduleData.add(new AbstractMap.SimpleEntry<>(ingestModuleAbstract, Boolean.TRUE)); + } + } @Override public int getRowCount() { - return modules.size(); + return moduleData.size(); } @Override @@ -355,11 +309,11 @@ public class IngestDialogPanel extends javax.swing.JPanel implements IngestConfi @Override public Object getValueAt(int rowIndex, int columnIndex) { - String name = modules.get(rowIndex).getName(); + Map.Entry entry = moduleData.get(rowIndex); if (columnIndex == 0) { - return moduleStates.get(name); + return entry.getValue(); } else { - return name; + return entry.getKey().getName(); } } @@ -371,8 +325,7 @@ public class IngestDialogPanel extends javax.swing.JPanel implements IngestConfi @Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { if (columnIndex == 0) { - moduleStates.put((String) getValueAt(rowIndex, 1), (Boolean) aValue); - + moduleData.get(rowIndex).setValue((Boolean)aValue); } } @@ -380,183 +333,96 @@ public class IngestDialogPanel extends javax.swing.JPanel implements IngestConfi public Class getColumnClass(int c) { return getValueAt(0, c).getClass(); } - } - - List getModulesToStart() { - List modulesToStart = new ArrayList(); - for (IngestModuleAbstract module : modules) { - boolean moduleEnabled = moduleStates.get(module.getName()); - if (moduleEnabled) { - modulesToStart.add(module); - } - } - return modulesToStart; - } - - private boolean processUnallocSpaceEnabled() { - return processUnallocCheckbox.isEnabled(); - } - - /** - * To be called whenever the next, close, or start buttons are pressed. - * - */ - @Override - public void save() { - // Save the current module - if (currentModule != null && currentModule.hasSimpleConfiguration()) { - currentModule.saveSimpleConfiguration(); - } - // Save this panel - List modulesDisabled = new ArrayList(); - for (int i = 0; i < modulesTable.getRowCount(); i++) { - // Column 0 is always the module's checkbox (which is retreived as a boolean) - Boolean enabled = (Boolean) modulesTable.getValueAt(i, 0); - if (!enabled) { - // Column 1 is always the module name - String moduleName = (String) modulesTable.getValueAt(i, 1); - modulesDisabled.add(moduleName); - } - } - // Add all the enabled modules to the properties separated by a coma - String list = ""; - for (int i = 0; i < modulesDisabled.size(); i++) { - list += modulesDisabled.get(i); - if (i + 1 < modulesDisabled.size()) { - list += ", "; - } - } - ModuleSettings.setConfigSetting(IngestManager.MODULE_PROPERTIES, DISABLED_MOD, list); - String processUnalloc = Boolean.toString(processUnallocCheckbox.isSelected()); - ModuleSettings.setConfigSetting(IngestManager.MODULE_PROPERTIES, PARSE_UNALLOC, processUnalloc); - - } - - /** - * Called when the dialog needs to be reloaded. Most commonly used to - * refresh the simple panel. - * - * Called every time this panel is displayed. - */ - @Override - public void reload() { - // Reload the simple panel - if (this.modulesTable.getSelectedRow() != -1) { - simplePanel.removeAll(); - if (currentModule.hasSimpleConfiguration()) { - simplePanel.add(currentModule.getSimpleConfiguration(null)); - } - simplePanel.revalidate(); - simplePanel.repaint(); - } - // Reload this panel - String list = ModuleSettings.getConfigSetting(IngestManager.MODULE_PROPERTIES, DISABLED_MOD); - if (list != null) { // if no property is found, list will be null - List modulesDisabled = new ArrayList(Arrays.asList(list.split(", "))); - // For every row, see if that module name is in the ArrayList - for (int i = 0; i < modulesTable.getRowCount(); i++) { - String moduleName = (String) modulesTable.getValueAt(i, 1); - if (modulesDisabled.contains(moduleName)) { - modulesTable.setValueAt(false, i, 0); // we found it, disable the module - } else { - modulesTable.setValueAt(true, i, 0); // not on disabled list, or a new module, enable it + + public List getSelectedModules() { + List selectedModules = new ArrayList<>(); + for (Map.Entry entry : moduleData) { + if (entry.getValue().booleanValue()) { + selectedModules.add(entry.getKey()); } } + return selectedModules; } - String processUnalloc = ModuleSettings.getConfigSetting(IngestManager.MODULE_PROPERTIES, PARSE_UNALLOC); - if (processUnalloc != null) { - processUnallocCheckbox.setSelected(Boolean.parseBoolean(processUnalloc)); + + /** + * Sets the given modules as selected in the modules table + * @param selectedModules + */ + public void setSelectedModules(List selectedModules) { + // unselect all modules + for (Map.Entry entry : moduleData) { + entry.setValue(Boolean.FALSE); + } + + // select only the given modules + for (IngestModuleAbstract selectedModule : selectedModules) { + getEntryForModule(selectedModule).setValue(Boolean.TRUE); + } + + // tell everyone about it + fireTableDataChanged(); } - } - - @Override - public JPanel getIngestConfigPanel() { - this.reload(); - return this; - } - - @Override - public void setContent(List inputContent) { - this.inputContent = inputContent; - } - - @Override - public void start() { - //pick the modules - List modulesToStart = getModulesToStart(); - - //update ingest proc. unalloc space - if (processUnallocSpaceEnabled()) { - manager.setProcessUnallocSpace(processUnallocCheckbox.isSelected()); + + /** + * Sets the given modules as NOT selected in the modules table + * @param selectedModules + */ + public void setUnselectedModules(List unselectedModules) { + // select all modules + for (Map.Entry entry : moduleData) { + entry.setValue(Boolean.TRUE); + } + + // unselect only the given modules + for (IngestModuleAbstract unselectedModule : unselectedModules) { + getEntryForModule(unselectedModule).setValue(Boolean.FALSE); + } + + // tell everyone about it + fireTableDataChanged(); } - - if (!modulesToStart.isEmpty()) { - manager.execute(modulesToStart, inputContent); + + public IngestModuleAbstract getModule(int row) { + return moduleData.get(row).getKey(); + } + + private Map.Entry getEntryForModule(IngestModuleAbstract module) { + Map.Entry entry = null; + for (Map.Entry anEntry : moduleData) { + if (anEntry.getKey().equals(module)) { + entry = anEntry; + break; + } + } + return entry; } - - } - - @Override - public boolean isIngestRunning() { - return manager.isIngestRunning(); } /** * Custom cell renderer for tooltips with module description */ private class ModulesTableRenderer extends DefaultTableCellRenderer { + + List tooltips = new ArrayList<>(); + + public ModulesTableRenderer() { + List modules = IngestManager.getDefault().enumerateAllModules(); + for (IngestModuleAbstract ingestModuleAbstract : modules) { + tooltips.add(ingestModuleAbstract.getDescription()); + } + } @Override public Component getTableCellRendererComponent( JTable table, Object value, boolean isSelected, boolean hasFocus, - int row, int column) { - - final Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); + int row, int column) { + super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); if (column == 1) { - //String moduleName = (String) table.getModel().getValueAt(row, column); - IngestModuleAbstract module = modules.get(row); - String moduleDescr = module.getDescription(); - String toolTip = moduleDescr; - - if (inputContent != null && module.getType().equals(ModuleType.DataSource)) { - - //DataSource module accepts only data source, does not work on any child - //show warning to user and set fg red for that module - boolean isDataSource = true; - for (Content content : inputContent) { - try { - if (content.getParent() != null) { - isDataSource = false; - break; - } - } catch (TskCoreException e) { - logger.log(Level.SEVERE, "Error checking if module input content is parentless data source", e); - } - - } - - if (! isDataSource ) { - cell.setForeground(Color.red); - toolTip = toolTip + "
WARNING: this module will not run on current selection because it operates only on root-level data-source (such as Image, Filesets)."; - } - else { - cell.setForeground(Color.black); - } - - - - } //end data source - else { - cell.setForeground(Color.black); - } - // - - setToolTipText("" + toolTip+ ""); + setToolTipText(tooltips.get(row)); } - - return cell; + return this; } } } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java index 171cd5ca61..f801b421d8 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestManager.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2012 Basis Technology Corp. + * Copyright 2013 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -154,8 +154,6 @@ public class IngestManager { } catch (IngestModuleLoaderException ex) { logger.log(Level.SEVERE, "Error getting module loader"); } - - } /** @@ -243,7 +241,6 @@ public class IngestManager { if (ui != null) { ui.restoreMessages(); } - } /** @@ -346,8 +343,6 @@ public class IngestManager { } } } - //} - //AbstractFile ingester boolean startAbstractFileIngester = false; @@ -421,7 +416,6 @@ public class IngestManager { List toStop = new ArrayList(); toStop.addAll(dataSourceIngesters); - for (IngestDataSourceThread dataSourceWorker : toStop) { IngestModuleDataSource s = dataSourceWorker.getModule(); @@ -440,7 +434,6 @@ public class IngestManager { logger.log(Level.WARNING, "Exception while stopping module: " + s.getName(), e); } } - } logger.log(Level.INFO, "stopped all"); @@ -545,7 +538,6 @@ public class IngestManager { return module.hasBackgroundJobsRunning(); } - } else { //data source module synchronized (this) { @@ -570,10 +562,7 @@ public class IngestManager { return false; } } - } - - } /** @@ -607,7 +596,7 @@ public class IngestManager { * * @param processUnallocSpace */ - void setProcessUnallocSpace(boolean processUnallocSpace) { + public void setProcessUnallocSpace(boolean processUnallocSpace) { this.processUnallocSpace = processUnallocSpace; } @@ -671,6 +660,13 @@ public class IngestManager { public List enumerateAbstractFileModules() { return moduleLoader.getAbstractFileIngestModules(); } + + public List enumerateAllModules() { + List modules = new ArrayList<>(); + modules.addAll(enumerateDataSourceModules()); + modules.addAll(enumerateAbstractFileModules()); + return modules; + } //data source worker to remove itself when complete or interrupted void removeDataSourceIngestWorker(IngestDataSourceThread worker) { @@ -697,7 +693,6 @@ public class IngestManager { IngestManagerStats() { errors = new HashMap(); - } /** @@ -775,19 +770,8 @@ public class IngestManager { public String toHtmlString() { StringBuilder sb = new StringBuilder(); sb.append(""); - sb.append("Ingest time: ").append(getTotalTimeString()).append("
"); sb.append("Total errors: ").append(errorsTotal).append("
"); - /* - if (errorsTotal > 0) { - sb.append("Errors per module:"); - for (IngestModuleAbstract module : errors.keySet()) { - final int errorsModule = errors.get(module); - sb.append("\t").append(module.getName()).append(": ").append(errorsModule).append("
"); - } - } - * */ - sb.append(""); return sb.toString(); } diff --git a/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleAbstract.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleAbstract.java index d30e57f785..f8ff21bb82 100644 --- a/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleAbstract.java +++ b/Core/src/org/sleuthkit/autopsy/ingest/IngestModuleAbstract.java @@ -145,35 +145,28 @@ public abstract class IngestModuleAbstract { */ public void saveAdvancedConfiguration() {} - /** - * Returns a panel that displays the simple (run-time) configuration - * for the given configuration context (such as pipeline instance). - * This is presented to the user before ingest starts and only basic - * settings should be given here. Use the advanced (general) configuration - * panel for more in-depth interfaces. - * The module (or its configuration controller object) is responsible for preserving / saving its configuration state - * In addition, saveSimpleConfiguration() can be used as the trigger. - * - * @param context the configuration context to use in the panel - * @return JPanel containing basic configuration widgets or null if simple configuration is not available - */ - public javax.swing.JPanel getSimpleConfiguration(String context) { - return null; - } - /** - * Returns a panel that displays the advanced (run-time) configuration - * for the given configuration context (such as pipeline instance). - * Implements advanced module configuration exposed to the user before ingest starts. - * - * The module (or its configuration controller object) - * is responsible for preserving / saving its configuration state - * In addition, saveAdvancedConfiguration() can be used as the trigger. - * - * @param context the configuration context to use in the panel - * @return JPanel containing advanced configuration widgets or null if advanced configuration is not available - */ - public javax.swing.JPanel getAdvancedConfiguration(String context) { - return null; - }; -} + * Returns a panel that displays the simple (run-time) configuration. + * This is presented to the user before ingest starts and only basic + * settings should be given here. use the advanced (general) configuration + * panel for more in-depth interfaces. + * The module is responsible for preserving / saving its configuration state + * In addition, saveSimpleConfiguration() can be used + * + * @return JPanel containing basic configuration widgets or null if simple configuration is not available + */ + public javax.swing.JPanel getSimpleConfiguration() { + return null; + } + + /** + * Implements advanced module configuration exposed to the user before ingest starts + * The module is responsible for preserving / saving its configuration state + * In addition, saveAdvancedConfiguration() can be used + * + * @return JPanel containing basic configuration widgets or null if advanced configuration is not available + */ + public javax.swing.JPanel getAdvancedConfiguration() { + return null; + }; + } \ No newline at end of file