Changed ReportingConfig to use a Map, wizard configuration changes

This commit is contained in:
Eugene Livis 2019-08-15 12:32:07 -04:00
parent 5c670e2a6d
commit f5b1f7b4c9
10 changed files with 62 additions and 24 deletions

View File

@ -1,6 +1,6 @@
OpenIDE-Module-Name=Report OpenIDE-Module-Name=Report
CTL_ReportWizardAction=Run Report CTL_ReportWizardAction=Run Report
ArtifactSelectionDialog.titleLabel.text=Select which artifacts you would like to report on: ArtifactSelectionDialog.titleLabel.text=Select which result types you would like to report on:
ArtifactSelectionDialog.okButton.text=OK ArtifactSelectionDialog.okButton.text=OK
PortableCaseInterestingItemsListPanel.error.errorLoadingTags=Error loading interesting item set names PortableCaseInterestingItemsListPanel.error.errorLoadingTags=Error loading interesting item set names
PortableCaseInterestingItemsListPanel.error.errorTitle=Error getting intesting item set names for case PortableCaseInterestingItemsListPanel.error.errorTitle=Error getting intesting item set names for case
@ -77,7 +77,7 @@ ReportVisualPanel2.allResultsRadioButton.text=All Results
ReportWizardFileOptionsVisualPanel.selectAllButton.text=Select All ReportWizardFileOptionsVisualPanel.selectAllButton.text=Select All
ReportWizardFileOptionsVisualPanel.deselectAllButton.text=Deselect All ReportWizardFileOptionsVisualPanel.deselectAllButton.text=Deselect All
ReportWizardFileOptionsVisualPanel.jLabel1.text=Select items to include in File Report: ReportWizardFileOptionsVisualPanel.jLabel1.text=Select items to include in File Report:
ArtifactSelectionDialog.dlgTitle.text=Advanced Artifact Selection ArtifactSelectionDialog.dlgTitle.text=Result Type Selection
FileReportDataTypes.filename.text=Name FileReportDataTypes.filename.text=Name
FileReportDataTypes.fileExt.text=File Extension FileReportDataTypes.fileExt.text=File Extension
FileReportDataTypes.fileType.text=File Type FileReportDataTypes.fileType.text=File Type
@ -331,5 +331,6 @@ ReportProgressDialog.reportLabel.text=reportLabel
ReportProgressDialog.statusMessageLabel.text=processingLabel ReportProgressDialog.statusMessageLabel.text=processingLabel
ReportVisualPanel2.specificTaggedResultsRadioButton.text=Specific Tagged Results ReportVisualPanel2.specificTaggedResultsRadioButton.text=Specific Tagged Results
ReportVisualPanel2.allTaggedResultsRadioButton.text=All Tagged Results ReportVisualPanel2.allTaggedResultsRadioButton.text=All Tagged Results
ArtifactSelectionDialog.titleLabel.toolTipText=
ReportWizardPortableCaseOptionsVisualPanel.getName.title=Choose Portable Case settings ReportWizardPortableCaseOptionsVisualPanel.getName.title=Choose Portable Case settings
TableReportGenerator.StatusColumn.Header=Review Status TableReportGenerator.StatusColumn.Header=Review Status

View File

@ -23,6 +23,7 @@ import java.awt.Component;
import java.util.ArrayList; import java.util.ArrayList;
import static java.util.Collections.swap; import static java.util.Collections.swap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.logging.Level; import java.util.logging.Level;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -49,13 +50,15 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener {
private List<TableReportModule> tableModules = new ArrayList<>(); private List<TableReportModule> tableModules = new ArrayList<>();
private List<FileReportModule> fileModules = new ArrayList<>(); private List<FileReportModule> fileModules = new ArrayList<>();
private PortableCaseReportModule portableCaseModule; private PortableCaseReportModule portableCaseModule;
private Map<String, ReportModuleConfig> moduleConfigs;
private Integer selectedIndex; private Integer selectedIndex;
/** /**
* Creates new form ReportVisualPanel1 * Creates new form ReportVisualPanel1
*/ */
public ReportVisualPanel1(ReportWizardPanel1 wizPanel) { public ReportVisualPanel1(ReportWizardPanel1 wizPanel, Map<String, ReportModuleConfig> moduleConfigs) {
this.wizPanel = wizPanel; this.wizPanel = wizPanel;
this.moduleConfigs = moduleConfigs;
initComponents(); initComponents();
configurationPanel.setLayout(new BorderLayout()); configurationPanel.setLayout(new BorderLayout());
descriptionTextPane.setEditable(false); descriptionTextPane.setEditable(false);

View File

@ -54,6 +54,9 @@ import org.sleuthkit.datamodel.BlackboardArtifact;
@ActionReference(path = "Toolbars/Case", position = 105)}) @ActionReference(path = "Toolbars/Case", position = 105)})
public final class ReportWizardAction extends CallableSystemAction implements Presenter.Toolbar, ActionListener { public final class ReportWizardAction extends CallableSystemAction implements Presenter.Toolbar, ActionListener {
private static final String REPORTING_CONFIGURATION_NAME = "EXAMINER_MODE";
private static final boolean DISPLAY_CASE_SPECIFIC_DATA = true;
private static final boolean RUN_REPORTS = true;
private final JButton toolbarButton = new JButton(); private final JButton toolbarButton = new JButton();
private static final String ACTION_NAME = NbBundle.getMessage(ReportWizardAction.class, "ReportWizardAction.actionName.text"); private static final String ACTION_NAME = NbBundle.getMessage(ReportWizardAction.class, "ReportWizardAction.actionName.text");
@ -64,7 +67,7 @@ public final class ReportWizardAction extends CallableSystemAction implements Pr
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static void doReportWizard() { public static void doReportWizard() {
WizardDescriptor wiz = new WizardDescriptor(new ReportWizardIterator()); WizardDescriptor wiz = new WizardDescriptor(new ReportWizardIterator(REPORTING_CONFIGURATION_NAME, DISPLAY_CASE_SPECIFIC_DATA, RUN_REPORTS));
wiz.setTitleFormat(new MessageFormat("{0} {1}")); wiz.setTitleFormat(new MessageFormat("{0} {1}"));
wiz.setTitle(NbBundle.getMessage(ReportWizardAction.class, "ReportWizardAction.reportWiz.title")); wiz.setTitle(NbBundle.getMessage(ReportWizardAction.class, "ReportWizardAction.reportWiz.title"));
if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) { if (DialogDisplayer.getDefault().notify(wiz) == WizardDescriptor.FINISH_OPTION) {

View File

@ -37,7 +37,7 @@ class ReportWizardFileOptionsPanel implements WizardDescriptor.FinishablePanel<W
private ReportWizardFileOptionsVisualPanel component; private ReportWizardFileOptionsVisualPanel component;
private JButton finishButton; private JButton finishButton;
ReportWizardFileOptionsPanel() { ReportWizardFileOptionsPanel(FileReportSettings fileReportSettings) {
finishButton = new JButton( finishButton = new JButton(
NbBundle.getMessage(this.getClass(), "ReportWizardFileOptionsPanel.finishButton.text")); NbBundle.getMessage(this.getClass(), "ReportWizardFileOptionsPanel.finishButton.text"));
finishButton.setEnabled(false); finishButton.setEnabled(false);

View File

@ -22,13 +22,16 @@ import java.awt.Component;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.logging.Level;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import org.openide.WizardDescriptor; import org.openide.WizardDescriptor;
import org.openide.util.NbPreferences; import org.openide.util.NbPreferences;
import org.sleuthkit.autopsy.coreutils.Logger;
final class ReportWizardIterator implements WizardDescriptor.Iterator<WizardDescriptor> { final class ReportWizardIterator implements WizardDescriptor.Iterator<WizardDescriptor> {
private static final Logger logger = Logger.getLogger(ReportWizardIterator.class.getName());
private int index; private int index;
private final ReportWizardPanel1 firstPanel; private final ReportWizardPanel1 firstPanel;
@ -55,11 +58,26 @@ final class ReportWizardIterator implements WizardDescriptor.Iterator<WizardDesc
private final WizardDescriptor.Panel<WizardDescriptor>[] portableCaseConfigPanels; private final WizardDescriptor.Panel<WizardDescriptor>[] portableCaseConfigPanels;
@SuppressWarnings({"rawtypes", "unchecked"}) @SuppressWarnings({"rawtypes", "unchecked"})
ReportWizardIterator() { ReportWizardIterator(String reportingConfigurationName, boolean displayCaseSpecificData, boolean runReports) {
firstPanel = new ReportWizardPanel1();
tableConfigPanel = new ReportWizardPanel2(); ReportingConfig config = null;
fileConfigPanel = new ReportWizardFileOptionsPanel(); try {
portableCaseConfigPanel = new ReportWizardPortableCaseOptionsPanel(); config = ReportingConfigLoader.loadConfig(reportingConfigurationName);
} catch (ReportConfigException ex) {
logger.log(Level.SEVERE, "Unable to load reporting configuration " + reportingConfigurationName + ". Using default settings", ex);
}
if (config != null) {
firstPanel = new ReportWizardPanel1(config.getModuleConfigs());
tableConfigPanel = new ReportWizardPanel2(config.getTableReportSettings());
fileConfigPanel = new ReportWizardFileOptionsPanel(config.getFileReportSettings());
portableCaseConfigPanel = new ReportWizardPortableCaseOptionsPanel(config.getModuleConfigs());
} else {
firstPanel = new ReportWizardPanel1(null);
tableConfigPanel = new ReportWizardPanel2(null);
fileConfigPanel = new ReportWizardFileOptionsPanel(null);
portableCaseConfigPanel = new ReportWizardPortableCaseOptionsPanel(null);
}
allConfigPanels = new WizardDescriptor.Panel[]{firstPanel, tableConfigPanel, fileConfigPanel, portableCaseConfigPanel}; allConfigPanels = new WizardDescriptor.Panel[]{firstPanel, tableConfigPanel, fileConfigPanel, portableCaseConfigPanel};
tableConfigPanels = new WizardDescriptor.Panel[]{firstPanel, tableConfigPanel}; tableConfigPanels = new WizardDescriptor.Panel[]{firstPanel, tableConfigPanel};

View File

@ -21,6 +21,8 @@ package org.sleuthkit.autopsy.report;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.Collection; import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.prefs.Preferences; import java.util.prefs.Preferences;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
@ -33,10 +35,12 @@ class ReportWizardPanel1 implements WizardDescriptor.FinishablePanel<WizardDescr
private WizardDescriptor wiz; private WizardDescriptor wiz;
private ReportVisualPanel1 component; private ReportVisualPanel1 component;
private Map<String, ReportModuleConfig> moduleConfigs;
private final JButton nextButton; private final JButton nextButton;
private final JButton finishButton; private final JButton finishButton;
ReportWizardPanel1() { ReportWizardPanel1(Map<String, ReportModuleConfig> moduleConfigs) {
this.moduleConfigs = moduleConfigs;
nextButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel1.nextButton.text")); nextButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel1.nextButton.text"));
finishButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel1.finishButton.text")); finishButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel1.finishButton.text"));
finishButton.setEnabled(false); finishButton.setEnabled(false);
@ -60,7 +64,7 @@ class ReportWizardPanel1 implements WizardDescriptor.FinishablePanel<WizardDescr
@Override @Override
public ReportVisualPanel1 getComponent() { public ReportVisualPanel1 getComponent() {
if (component == null) { if (component == null) {
component = new ReportVisualPanel1(this); component = new ReportVisualPanel1(this, moduleConfigs);
} }
return component; return component;
} }

View File

@ -33,7 +33,7 @@ class ReportWizardPanel2 implements WizardDescriptor.Panel<WizardDescriptor> {
private final JButton nextButton; private final JButton nextButton;
private WizardDescriptor wiz; private WizardDescriptor wiz;
ReportWizardPanel2() { ReportWizardPanel2(TableReportSettings tableReportSettings) {
finishButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel2.finishButton.text")); finishButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel2.finishButton.text"));
nextButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel2.nextButton.text")); nextButton = new JButton(NbBundle.getMessage(this.getClass(), "ReportWizardPanel2.nextButton.text"));

View File

@ -20,6 +20,7 @@ package org.sleuthkit.autopsy.report;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.util.Map;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import org.openide.WizardDescriptor; import org.openide.WizardDescriptor;
@ -36,7 +37,7 @@ class ReportWizardPortableCaseOptionsPanel implements WizardDescriptor.Finishabl
private ReportWizardPortableCaseOptionsVisualPanel component; private ReportWizardPortableCaseOptionsVisualPanel component;
private final JButton finishButton; private final JButton finishButton;
ReportWizardPortableCaseOptionsPanel() { ReportWizardPortableCaseOptionsPanel(Map<String, ReportModuleConfig> moduleConfigs) {
finishButton = new JButton( finishButton = new JButton(
NbBundle.getMessage(this.getClass(), "ReportWizardFileOptionsPanel.finishButton.text")); NbBundle.getMessage(this.getClass(), "ReportWizardFileOptionsPanel.finishButton.text"));
finishButton.setEnabled(false); finishButton.setEnabled(false);

View File

@ -19,8 +19,9 @@
package org.sleuthkit.autopsy.report; package org.sleuthkit.autopsy.report;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* A bundling of all the settings objects that define a report configuration. * A bundling of all the settings objects that define a report configuration.
@ -29,7 +30,7 @@ final class ReportingConfig implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private String configName; private String configName;
private List<ReportModuleConfig> moduleConfigs = new ArrayList<>(); private Map<String, ReportModuleConfig> moduleConfigs = new HashMap<>();
private TableReportSettings tableReportSettings; private TableReportSettings tableReportSettings;
private FileReportSettings fileReportSettings; private FileReportSettings fileReportSettings;
@ -51,10 +52,12 @@ final class ReportingConfig implements Serializable {
} }
void setModuleConfigs(List<ReportModuleConfig> moduleConfigs) { void setModuleConfigs(List<ReportModuleConfig> moduleConfigs) {
this.moduleConfigs = moduleConfigs; for (ReportModuleConfig config : moduleConfigs) {
this.moduleConfigs.put(config.getModuleClassName(), config);
}
} }
List<ReportModuleConfig> getModuleConfigs() { Map<String, ReportModuleConfig> getModuleConfigs() {
return this.moduleConfigs; return this.moduleConfigs;
} }

View File

@ -25,6 +25,7 @@ import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@ -129,14 +130,14 @@ final class ReportingConfigLoader {
* Serialize all of the settings that make up a reporting configuration in * Serialize all of the settings that make up a reporting configuration in
* an atomic, thread safe way. * an atomic, thread safe way.
* *
* @param config ReportingConfig object to serialize to disk * @param reportConfig ReportingConfig object to serialize to disk
* @throws ReportConfigException if an error occurred while saving the * @throws ReportConfigException if an error occurred while saving the
* configuration * configuration
*/ */
static synchronized void saveConfig(ReportingConfig config) throws ReportConfigException { static synchronized void saveConfig(ReportingConfig reportConfig) throws ReportConfigException {
// construct the configuration directory path // construct the configuration directory path
Path pathToConfigDir = Paths.get(ReportingConfigLoader.REPORT_CONFIG_FOLDER_PATH, config.getName()); Path pathToConfigDir = Paths.get(ReportingConfigLoader.REPORT_CONFIG_FOLDER_PATH, reportConfig.getName());
// create configuration directory // create configuration directory
try { try {
@ -148,7 +149,7 @@ final class ReportingConfigLoader {
// save table report settings // save table report settings
String filePath = pathToConfigDir.toString() + File.separator + TABLE_REPORT_CONFIG_FILE; String filePath = pathToConfigDir.toString() + File.separator + TABLE_REPORT_CONFIG_FILE;
try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(filePath))) { try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(filePath))) {
out.writeObject(config.getTableReportSettings()); out.writeObject(reportConfig.getTableReportSettings());
} catch (IOException ex) { } catch (IOException ex) {
throw new ReportConfigException("Unable to save table report configuration " + filePath, ex); throw new ReportConfigException("Unable to save table report configuration " + filePath, ex);
} }
@ -156,14 +157,18 @@ final class ReportingConfigLoader {
// save file report settings // save file report settings
filePath = pathToConfigDir.toString() + File.separator + FILE_REPORT_CONFIG_FILE; filePath = pathToConfigDir.toString() + File.separator + FILE_REPORT_CONFIG_FILE;
try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(filePath))) { try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(filePath))) {
out.writeObject(config.getFileReportSettings()); out.writeObject(reportConfig.getFileReportSettings());
} catch (IOException ex) { } catch (IOException ex) {
throw new ReportConfigException("Unable to save file report configuration " + filePath, ex); throw new ReportConfigException("Unable to save file report configuration " + filePath, ex);
} }
// save list of module configuration objects // save list of module configuration objects
filePath = pathToConfigDir.toString() + File.separator + MODULE_CONFIG_FILE; filePath = pathToConfigDir.toString() + File.separator + MODULE_CONFIG_FILE;
List<ReportModuleConfig> moduleConfigs = config.getModuleConfigs(); List<ReportModuleConfig> moduleConfigs = new ArrayList<>();
for (ReportModuleConfig config : reportConfig.getModuleConfigs().values()) {
moduleConfigs.add(config);
}
try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(filePath))) { try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(filePath))) {
out.writeObject(moduleConfigs); out.writeObject(moduleConfigs);
} catch (IOException ex) { } catch (IOException ex) {