diff --git a/Core/src/org/sleuthkit/autopsy/configurelogicalimager/ConfigVisualPanel1.java b/Core/src/org/sleuthkit/autopsy/configurelogicalimager/ConfigVisualPanel1.java index a7f6c87bdc..6b35114b15 100644 --- a/Core/src/org/sleuthkit/autopsy/configurelogicalimager/ConfigVisualPanel1.java +++ b/Core/src/org/sleuthkit/autopsy/configurelogicalimager/ConfigVisualPanel1.java @@ -40,7 +40,7 @@ import org.openide.util.NbBundle; /** * Configuration Visual Panel 1 */ -public final class ConfigVisualPanel1 extends JPanel implements DocumentListener { +public final class ConfigVisualPanel1 extends JPanel { private LogicalImagerConfig config; private String configFilename; @@ -144,7 +144,7 @@ public final class ConfigVisualPanel1 extends JPanel implements DocumentListener configFilename = path; configFileTextField.setText(path); newFile = false; - } catch (Exception ex) { + } catch (JsonIOException | JsonSyntaxException | IOException ex) { JOptionPane.showMessageDialog(this, Bundle.ConfigVisualPanel1_invalidConfigJson() + ex.getMessage() , Bundle.ConfigVisualPanel1_configurationError(), @@ -203,22 +203,13 @@ public final class ConfigVisualPanel1 extends JPanel implements DocumentListener configFileTextField.setText(filename); } - @Override - public void insertUpdate(DocumentEvent e) { - } - - @Override - public void removeUpdate(DocumentEvent e) { - } - - @Override - public void changedUpdate(DocumentEvent e) { - } - public boolean isPanelValid() { return (newFile || !configFileTextField.getText().isEmpty()); } + /** + * Document Listener for textfield + */ private static class MyDocumentListener implements DocumentListener { private final ConfigVisualPanel1 panel; diff --git a/Core/src/org/sleuthkit/autopsy/configurelogicalimager/ConfigVisualPanel2.java b/Core/src/org/sleuthkit/autopsy/configurelogicalimager/ConfigVisualPanel2.java index db0732f0f4..39d003c485 100644 --- a/Core/src/org/sleuthkit/autopsy/configurelogicalimager/ConfigVisualPanel2.java +++ b/Core/src/org/sleuthkit/autopsy/configurelogicalimager/ConfigVisualPanel2.java @@ -18,6 +18,7 @@ */ package org.sleuthkit.autopsy.configurelogicalimager; +import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; @@ -555,7 +556,7 @@ public final class ConfigVisualPanel2 extends JPanel { ImmutablePair ruleMap = panel.toRule(); appendRow(ruleMap); break; - } catch (Exception ex) { + } catch (IOException | NumberFormatException ex) { JOptionPane.showMessageDialog(this, ex.getMessage(), "New rule error", @@ -696,7 +697,7 @@ public final class ConfigVisualPanel2 extends JPanel { for (LogicalImagerRule rule : ruleSet.getRules()) { rulesTableModel.setValueAt(rule.getName(), row, 0); - if (rowSelectionkey != null && rule.getName().equals(rowSelectionkey)) { + if (rowSelectionkey != null && rowSelectionkey.equals(rule.getName())) { selectThisRow = row; } rulesTableModel.setValueAt(rule.getDescription(), row, 1); @@ -839,6 +840,9 @@ public final class ConfigVisualPanel2 extends JPanel { } } + /** + * RulesTableModel for rules table + */ private class RulesTableModel extends AbstractTableModel { private final List ruleName = new ArrayList<>(); @@ -925,6 +929,9 @@ public final class ConfigVisualPanel2 extends JPanel { } } + /** + * Table model for single column list table. + */ private class SingleColumnTableModel extends AbstractTableModel { private final List list = new ArrayList<>(); @@ -947,12 +954,10 @@ public final class ConfigVisualPanel2 extends JPanel { @Override public Object getValueAt(int rowIndex, int columnIndex) { Object ret = null; - switch (columnIndex) { - case 0: - ret = list.get(rowIndex); - break; - default: - throw new UnsupportedOperationException("Invalid table column index: " + columnIndex); //NON-NLS + if (columnIndex == 0) { + ret = list.get(rowIndex); + } else { + throw new UnsupportedOperationException("Invalid table column index: " + columnIndex); //NON-NLS } return ret; } @@ -964,12 +969,10 @@ public final class ConfigVisualPanel2 extends JPanel { @Override public void setValueAt(Object aValue, int rowIndex, int columnIndex) { - switch (columnIndex) { - case 0: - list.add((String) aValue); - break; - default: - throw new UnsupportedOperationException("Invalid table column index: " + columnIndex); //NON-NLS + if (columnIndex == 0) { + list.add((String) aValue); + } else { + throw new UnsupportedOperationException("Invalid table column index: " + columnIndex); //NON-NLS } } } diff --git a/Core/src/org/sleuthkit/autopsy/configurelogicalimager/ConfigWizardPanel1.java b/Core/src/org/sleuthkit/autopsy/configurelogicalimager/ConfigWizardPanel1.java index 727880b1d5..1dffe5887c 100644 --- a/Core/src/org/sleuthkit/autopsy/configurelogicalimager/ConfigWizardPanel1.java +++ b/Core/src/org/sleuthkit/autopsy/configurelogicalimager/ConfigWizardPanel1.java @@ -39,10 +39,7 @@ public class ConfigWizardPanel1 implements WizardDescriptor.ValidatingPanel newFullPaths = new ArrayList<>(); private final JTextArea fullPathsTextArea; - private boolean editing = false; - /** * Creates new form EditFullPathsRulePanel */ @@ -53,7 +51,6 @@ public class EditFullPathsRulePanel extends javax.swing.JPanel { public EditFullPathsRulePanel(JButton okButton, JButton cancelButton, String ruleName, LogicalImagerRule rule, boolean editing) { initComponents(); - this.editing = editing; if (editing) { ruleNameTextField.setEnabled(!editing); } diff --git a/Core/src/org/sleuthkit/autopsy/configurelogicalimager/EditNonFullPathsRulePanel.java b/Core/src/org/sleuthkit/autopsy/configurelogicalimager/EditNonFullPathsRulePanel.java index a72e77a3c7..ce0af5d2be 100644 --- a/Core/src/org/sleuthkit/autopsy/configurelogicalimager/EditNonFullPathsRulePanel.java +++ b/Core/src/org/sleuthkit/autopsy/configurelogicalimager/EditNonFullPathsRulePanel.java @@ -46,7 +46,6 @@ public class EditNonFullPathsRulePanel extends javax.swing.JPanel { private JButton cancelButton; private final javax.swing.JTextArea filenamesTextArea; private final javax.swing.JTextArea folderNamesTextArea; - private boolean editing = true; /** * Creates new form EditRulePanel @@ -58,7 +57,6 @@ public class EditNonFullPathsRulePanel extends javax.swing.JPanel { EditNonFullPathsRulePanel(JButton okButton, JButton cancelButton, String ruleName, LogicalImagerRule rule, boolean editing) { initComponents(); - this.editing = editing; if (editing) { ruleNameTextField.setEnabled(!editing); } @@ -472,7 +470,7 @@ public class EditNonFullPathsRulePanel extends javax.swing.JPanel { } builder.minDays(minDays); } catch (NumberFormatException | ParseException ex) { - throw new IOException(Bundle.EditNonFullPathsRulePanel_modifiedDaysMustBeNumberException(ex.getMessage())); + throw new IOException(Bundle.EditNonFullPathsRulePanel_modifiedDaysMustBeNumberException(ex.getMessage()), ex); } } @@ -485,7 +483,7 @@ public class EditNonFullPathsRulePanel extends javax.swing.JPanel { throw new IOException(Bundle.EditNonFullPathsRulePanel_minFileSizeNotPositiveException()); } } catch (NumberFormatException | ParseException ex) { - throw new IOException(Bundle.EditNonFullPathsRulePanel_minFileSizeMustBeNumberException(ex.getMessage())); + throw new IOException(Bundle.EditNonFullPathsRulePanel_minFileSizeMustBeNumberException(ex.getMessage()), ex); } } @@ -498,7 +496,7 @@ public class EditNonFullPathsRulePanel extends javax.swing.JPanel { throw new IOException(Bundle.EditNonFullPathsRulePanel_maxFileSizeNotPositiveException()); } } catch (NumberFormatException | ParseException ex) { - throw new IOException(Bundle.EditNonFullPathsRulePanel_maxFileSizeMustBeNumberException(ex.getMessage())); + throw new IOException(Bundle.EditNonFullPathsRulePanel_maxFileSizeMustBeNumberException(ex.getMessage()), ex); } } @@ -520,10 +518,10 @@ public class EditNonFullPathsRulePanel extends javax.swing.JPanel { "EditNonFullPathsRulePanel.emptyExtensionException=Extensions cannot have an empty entry", }) private List validateExtensions(JTextField textField) throws IOException { - List extensions = new ArrayList<>(); if (isBlank(textField.getText())) { return null; } + List extensions = new ArrayList<>(); for (String extension : textField.getText().split(",")) { extension = strip(extension); if (extension.isEmpty()) { diff --git a/Core/src/org/sleuthkit/autopsy/configurelogicalimager/EditRulePanel.java b/Core/src/org/sleuthkit/autopsy/configurelogicalimager/EditRulePanel.java index 19b0f51dc5..14c46ba261 100644 --- a/Core/src/org/sleuthkit/autopsy/configurelogicalimager/EditRulePanel.java +++ b/Core/src/org/sleuthkit/autopsy/configurelogicalimager/EditRulePanel.java @@ -103,10 +103,10 @@ public class EditRulePanel extends JPanel { "EditRulePanel.blankLineException={0} cannot have a blank line", }) static public List validateTextList(JTextArea textArea, String fieldName) throws IOException { - List list = new ArrayList<>(); if (isBlank(textArea.getText())) { return null; } + List list = new ArrayList<>(); for (String line : textArea.getText().split("\\n")) { // NON-NLS line = strip(line); if (line.isEmpty()) { diff --git a/Core/src/org/sleuthkit/autopsy/configurelogicalimager/EncryptionProgramsRule.java b/Core/src/org/sleuthkit/autopsy/configurelogicalimager/EncryptionProgramsRule.java index 61d18e4d37..86049b797b 100644 --- a/Core/src/org/sleuthkit/autopsy/configurelogicalimager/EncryptionProgramsRule.java +++ b/Core/src/org/sleuthkit/autopsy/configurelogicalimager/EncryptionProgramsRule.java @@ -35,6 +35,8 @@ public final class EncryptionProgramsRule { private static final String ENCRYPTION_PROGRAMS_RULE_DESCRIPTION = Bundle.EncryptionProgramsRule_encryptionProgramsRuleDescription(); private static final List FILENAMES = new ArrayList<>(); + private EncryptionProgramsRule() {} + // TODO: Add more files here static { FILENAMES.add("truecrypt.exe"); //NON-NLS diff --git a/Core/src/org/sleuthkit/autopsy/configurelogicalimager/LogicalImagerConfigDeserializer.java b/Core/src/org/sleuthkit/autopsy/configurelogicalimager/LogicalImagerConfigDeserializer.java index c198edf5e7..f96f338515 100644 --- a/Core/src/org/sleuthkit/autopsy/configurelogicalimager/LogicalImagerConfigDeserializer.java +++ b/Core/src/org/sleuthkit/autopsy/configurelogicalimager/LogicalImagerConfigDeserializer.java @@ -45,7 +45,6 @@ public class LogicalImagerConfigDeserializer implements JsonDeserializer ruleSets = new ArrayList<>(); final JsonObject jsonObject = je.getAsJsonObject(); final JsonElement jsonFinalizeImageWriter = jsonObject.get("finalize-image-writer"); // NON-NLS @@ -57,6 +56,8 @@ public class LogicalImagerConfigDeserializer implements JsonDeserializer ruleSets = new ArrayList<>(); for (JsonElement element: asJsonArray) { String setName = null; List rules = null; @@ -149,7 +150,7 @@ public class LogicalImagerConfigDeserializer implements JsonDeserializer fullPaths = new ArrayList<>(); @SerializedName("size-range") @Expose(serialize = true) - private Map sizeRange = new HashMap<>(); + final private Map sizeRange = new HashMap<>(); @SerializedName("date-range") @Expose(serialize = true) - private Map dateRange = new HashMap<>(); + final private Map dateRange = new HashMap<>(); // The following fields should not be serialized, internal use only @Expose(serialize = false) @@ -160,6 +160,9 @@ public class LogicalImagerRule { return maxDate; } + /** + * Builder class + */ public static class Builder { private Boolean shouldAlert = null; private Boolean shouldSave = null; @@ -174,8 +177,6 @@ public class LogicalImagerRule { private Integer minDays = null; private Integer minDate = null; private Integer maxDate = null; - - public Builder() {} public Builder shouldAlert(boolean shouldAlert) { this.shouldAlert = shouldAlert; diff --git a/Core/src/org/sleuthkit/autopsy/configurelogicalimager/LogicalImagerRuleSet.java b/Core/src/org/sleuthkit/autopsy/configurelogicalimager/LogicalImagerRuleSet.java index 674efc992d..ba08d9a16b 100644 --- a/Core/src/org/sleuthkit/autopsy/configurelogicalimager/LogicalImagerRuleSet.java +++ b/Core/src/org/sleuthkit/autopsy/configurelogicalimager/LogicalImagerRuleSet.java @@ -29,11 +29,11 @@ public class LogicalImagerRuleSet { @SerializedName("set-name") @Expose(serialize = true) - private String setName; + final private String setName; @SerializedName("rules") @Expose(serialize = true) - private List rules; + private final List rules; public LogicalImagerRuleSet(String setName, List rules) { this.setName = setName; diff --git a/Core/src/org/sleuthkit/autopsy/configurelogicalimager/NewRuleSetPanel.java b/Core/src/org/sleuthkit/autopsy/configurelogicalimager/NewRuleSetPanel.java index 0a99990959..da56e943c9 100644 --- a/Core/src/org/sleuthkit/autopsy/configurelogicalimager/NewRuleSetPanel.java +++ b/Core/src/org/sleuthkit/autopsy/configurelogicalimager/NewRuleSetPanel.java @@ -48,8 +48,8 @@ public class NewRuleSetPanel extends javax.swing.JPanel { editFullPathsRulePanel = new EditFullPathsRulePanel(okButton, cancelButton, "", new LogicalImagerRule(), false); fullPathsPanel.add(editFullPathsRulePanel, BorderLayout.NORTH); - sharedLayeredPane.add(nonFullPathsJPanel, new Integer(0)); - sharedLayeredPane.add(fullPathsPanel, new Integer(1)); + sharedLayeredPane.add(nonFullPathsJPanel, Integer.valueOf(0)); + sharedLayeredPane.add(fullPathsPanel, Integer.valueOf(1)); nonFullPathsJPanel.setVisible(true); fullPathsPanel.setVisible(false); }