Code review

This commit is contained in:
Eugene Livis 2019-08-12 12:12:26 -04:00
parent d2cd43be75
commit 53b5eac2a7
8 changed files with 38 additions and 36 deletions

View File

@ -26,21 +26,26 @@ import java.util.Map;
* Class for persisting the file properties used by FileReportGenerator to drive
* report generation by FileReportModules.
*/
class FileReportSettings implements Serializable {
final class FileReportSettings implements Serializable {
private static final long serialVersionUID = 1L;
private Map<FileReportDataTypes, Boolean> filePropertiesInfo = new HashMap<>();
/**
* Creates FileReportSettings object.
*
* @param fileReportInfo the Information that should be included about each
*
* @param fileReportInfo The information that should be included about each
* file in the report.
*/
FileReportSettings(Map<FileReportDataTypes, Boolean> fileReportInfo) {
this.filePropertiesInfo = fileReportInfo;
}
/**
* Gets file report settings.
*
* @return File report settings
*/
Map<FileReportDataTypes, Boolean> getFileProperties() {
return filePropertiesInfo;
}

View File

@ -21,10 +21,10 @@ package org.sleuthkit.autopsy.report;
import java.io.Serializable;
/**
* Class for persisting information about ReportModule (e.g. whether the report
* Class for persisting information about a report module (e.g. whether the report
* module is enabled).
*/
class ModuleStatus implements Serializable {
final class ModuleStatus implements Serializable {
private static final long serialVersionUID = 1L;
private final String moduleName;
@ -33,8 +33,8 @@ class ModuleStatus implements Serializable {
/**
* Creates ModuleStatus object.
*
* @param module implementation of a ReportModule interface
* @param enabled boolean flag whether the module is enabled
* @param module Implementation of a ReportModule interface
* @param enabled Boolean flag whether the module is enabled
*/
ModuleStatus(ReportModule module, boolean enabled) {
this.moduleName = module.getClass().getCanonicalName();

View File

@ -20,7 +20,7 @@ package org.sleuthkit.autopsy.report;
/**
* Implementation of the ReportModuleSettings interface for use by report
* modules that do not have per report job options.
* modules that do not have settings.
*/
public final class NoReportModuleSettings implements ReportModuleSettings {

View File

@ -20,9 +20,9 @@ package org.sleuthkit.autopsy.report;
/**
* Instances of this exception class are thrown when there is an error during
* serialization and deserialization of reporting configuration.
* serialization and deserialization of a reporting configuration.
*/
class ReportConfigException extends Exception {
final class ReportConfigException extends Exception {
private static final long serialVersionUID = 1L;

View File

@ -22,9 +22,7 @@ import java.awt.BorderLayout;
import java.awt.Component;
import java.util.ArrayList;
import static java.util.Collections.swap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import javax.swing.JList;
import javax.swing.JPanel;
@ -35,7 +33,6 @@ import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import org.openide.DialogDisplayer;
import org.openide.NotifyDescriptor;
import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.coreutils.Logger;
@ -70,14 +67,14 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener {
tableModules = ReportModuleLoader.getTableReportModules();
generalModules = ReportModuleLoader.getGeneralReportModules();
fileModules = ReportModuleLoader.getFileReportModules();
for (TableReportModule module : tableModules) {
if (!moduleIsValid(module)) {
popupWarning(module);
tableModules.remove(module);
tableModules.remove(module);
}
}
for (GeneralReportModule module : generalModules) {
if (!moduleIsValid(module)) {
popupWarning(module);
@ -88,15 +85,15 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener {
for (FileReportModule module : fileModules) {
if (!moduleIsValid(module)) {
popupWarning(module);
fileModules.remove(module);
fileModules.remove(module);
}
}
// our theory is that the report table modules are more common, so they go on top
modules.addAll(tableModules);
modules.addAll(fileModules);
modules.addAll(generalModules);
portableCaseModule = new PortableCaseReportModule();
if (moduleIsValid(portableCaseModule)) {
modules.add(portableCaseModule);
@ -113,7 +110,7 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener {
indexOfHTMLReportModule++;
}
swap(modules, indexOfHTMLReportModule, 0);
modulesJList.getSelectionModel().addListSelectionListener(this);
modulesJList.setCellRenderer(new ModuleCellRenderer());
modulesJList.setListData(modules.toArray(new ReportModule[modules.size()]));
@ -181,7 +178,7 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener {
}
return null;
}
/**
* Get the selection status of the Portable Case report module.
*
@ -303,7 +300,7 @@ final class ReportVisualPanel1 extends JPanel implements ListSelectionListener {
configurationPanel.add(panel, BorderLayout.CENTER);
configurationPanel.revalidate();
configurationPanel.repaint();
boolean generalModuleSelected = (module instanceof GeneralReportModule);
wizPanel.setNext(!generalModuleSelected);

View File

@ -25,7 +25,7 @@ import java.util.List;
/**
* A bundling of all the settings objects that define a report configuration.
*/
class ReportingConfig implements Serializable {
final class ReportingConfig implements Serializable {
private static final long serialVersionUID = 1L;
private String configName;
@ -79,7 +79,7 @@ class ReportingConfig implements Serializable {
this.fileReportSettings = settings;
}
FileReportSettings getFileReportModuleSettings() {
FileReportSettings getFileReportSettings() {
return this.fileReportSettings;
}

View File

@ -34,11 +34,11 @@ import org.sleuthkit.autopsy.coreutils.PlatformUtil;
* all of the settings that make up a reporting configuration in an atomic,
* thread safe way.
*/
class ReportingConfigLoader {
final class ReportingConfigLoader {
private static final String REPORT_CONFIG_FOLDER = "ReportingConfigs"; //NON-NLS
private static final String REPORT_CONFIG_FOLDER_PATH = Paths.get(PlatformUtil.getUserConfigDirectory(), ReportingConfigLoader.REPORT_CONFIG_FOLDER).toAbsolutePath().toString();
private static final String REPORT_CONFIG_FILE_NAME = "ReportingConfiguration.properties";
private static final String REPORT_CONFIG_FILE_EXTENSION = ".settings";
/**
* Deserialize all of the settings that make up a reporting configuration in
@ -53,7 +53,7 @@ class ReportingConfigLoader {
static synchronized ReportingConfig loadConfig(String configName) throws ReportConfigException {
// construct the file path
Path reportFilePath = Paths.get(ReportingConfigLoader.REPORT_CONFIG_FOLDER_PATH, configName, REPORT_CONFIG_FILE_NAME);
Path reportFilePath = Paths.get(ReportingConfigLoader.REPORT_CONFIG_FOLDER_PATH, configName + REPORT_CONFIG_FILE_EXTENSION);
File reportFile = reportFilePath.toFile();
// Return null if a reporting configuration for the given name does not exist.
@ -65,7 +65,7 @@ class ReportingConfigLoader {
throw new ReportConfigException("Unable to read reporting configuration file " + reportFilePath.toString());
}
// read in the confuguration
// read in the configuration
ReportingConfig config = null;
try (NbObjectInputStream in = new NbObjectInputStream(new FileInputStream(reportFilePath.toString()))) {
config = (ReportingConfig) in.readObject();
@ -87,7 +87,7 @@ class ReportingConfigLoader {
static synchronized void saveConfig(ReportingConfig config) throws ReportConfigException {
// 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);
// create configuration directory
try {
@ -97,11 +97,11 @@ class ReportingConfigLoader {
}
// save the configuration
String filePath = pathToConfigDir.toString() + File.separator + REPORT_CONFIG_FILE_NAME;
String filePath = pathToConfigDir.toString() + File.separator + config.getName() + REPORT_CONFIG_FILE_EXTENSION;
try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(filePath))) {
out.writeObject(config);
} catch (IOException ex) {
throw new ReportConfigException("Unable to save reporting configuration " + pathToConfigDir.toString(), ex);
throw new ReportConfigException("Unable to save reporting configuration " + filePath, ex);
}
}

View File

@ -28,7 +28,7 @@ import org.sleuthkit.datamodel.BlackboardArtifact;
* by the TableReportGenerator class to drive report generation by
* TableReportModules.
*/
class TableReportSettings implements Serializable {
final class TableReportSettings implements Serializable {
private static final long serialVersionUID = 1L;
private Map<BlackboardArtifact.Type, Boolean> artifactTypeSelections = new HashMap<>();
@ -37,9 +37,9 @@ class TableReportSettings implements Serializable {
/**
* Creates TableReportSettings object.
*
* @param artifactTypeSelections the enabled/disabled state of the artifact
* @param artifactTypeSelections The enabled/disabled state of the artifact
* types to be included in the report
* @param tagNameSelections the enabled/disabled state of the tag names to
* @param tagNameSelections The enabled/disabled state of the tag names to
* be included in the report
*/
TableReportSettings(Map<BlackboardArtifact.Type, Boolean> artifactTypeSelections, Map<String, Boolean> tagNameSelections) {