Commit version of file types manager with fine grained-control, simpler will be better

This commit is contained in:
Richard Cordovano 2014-12-04 18:46:17 -05:00
parent bc251c7cce
commit a75ebe8028
9 changed files with 145 additions and 127 deletions

View File

@ -1,5 +1,4 @@
OpenIDE-Module-Name=FileTypeId OpenIDE-Module-Name=FileTypeId
FileTypeIdModuleSettingsPanel.skipKnownCheckBox.toolTipText=Depending on how many files have known hashes, checking this box will improve the speed of file type identification.
FileTypeIdIngestModule.moduleName.text=File Type Identification FileTypeIdIngestModule.moduleName.text=File Type Identification
FileTypeIdIngestModule.moduleDesc.text=Matches file types based on binary signatures. FileTypeIdIngestModule.moduleDesc.text=Matches file types based on binary signatures.
FileTypeIdIngestModule.complete.totalProcTime=Total Processing Time FileTypeIdIngestModule.complete.totalProcTime=Total Processing Time
@ -7,17 +6,18 @@ FileTypeIdIngestModule.complete.totalFiles=Total Files Processed
FileTypeIdIngestModule.complete.srvMsg.text=File Type Id Results FileTypeIdIngestModule.complete.srvMsg.text=File Type Id Results
FileTypeIdModuleFactory.getIngestJobSettingsPanel.exception.msg=Expected settings argument to be instanceof FileTypeIdModuleSettings FileTypeIdModuleFactory.getIngestJobSettingsPanel.exception.msg=Expected settings argument to be instanceof FileTypeIdModuleSettings
FileTypeIdModuleFactory.createFileIngestModule.exception.msg=Expected settings argument to be instanceof FileTypeIdModuleSettings FileTypeIdModuleFactory.createFileIngestModule.exception.msg=Expected settings argument to be instanceof FileTypeIdModuleSettings
FileTypeIdModuleSettingsPanel.skipKnownCheckBox.text=Skip known files (NSRL) FileTypeIdIngestJobSettingsPanel.skipKnownCheckBox.toolTipText=Depending on how many files have known hashes, checking this box will improve the speed of file type identification.
FileTypeIdSettingsPanel.mimeTypeTextField.text= FileTypeIdIngestJobSettingsPanel.skipKnownCheckBox.text=Skip known files (NSRL)
FileTypeIdSettingsPanel.mimeTypeLabel.text=Mime Type FileTypeIdGlobalSettingsPanel.hexPrefixLabel.text=0x
FileTypeIdSettingsPanel.signatureTypeLabel.text=Signature Type FileTypeIdGlobalSettingsPanel.saveTypeButton.text=Save Type
FileTypeIdSettingsPanel.signatureLabel.text=Signature FileTypeIdGlobalSettingsPanel.deleteTypeButton.text=DeleteType
FileTypeIdSettingsPanel.offsetLabel.text=Offset FileTypeIdGlobalSettingsPanel.newTypeButton.text=New Type
FileTypeIdSettingsPanel.offsetTextField.text= FileTypeIdGlobalSettingsPanel.offsetTextField.text=
FileTypeIdSettingsPanel.hexPrefixLabel.text=0x FileTypeIdGlobalSettingsPanel.offsetLabel.text=Offset
FileTypeIdSettingsPanel.jTextArea1.text=Enter a MIME type and signature to be used to identify files of that type. If the signature is a byte sequence, enter the sequence using two hex values for each byte, e.g., EEF0 is a two byte signature. FileTypeIdGlobalSettingsPanel.postHitCheckBox.text=Post interesting file hit when found
FileTypeIdSettingsPanel.postHitCheckBox.text=Post interesting file hit when found FileTypeIdGlobalSettingsPanel.signatureTextField.text=
FileTypeIdSettingsPanel.newTypeButton.text=New Type FileTypeIdGlobalSettingsPanel.jTextArea1.text=Enter a MIME type and signature to be used to identify files of that type. If the signature is a byte sequence, enter the sequence using two hex values for each byte, e.g., EEF0 is a two byte signature.
FileTypeIdSettingsPanel.deleteTypeButton.text=DeleteType FileTypeIdGlobalSettingsPanel.signatureTypeLabel.text=Signature Type
FileTypeIdSettingsPanel.saveTypeButton.text=Save Type FileTypeIdGlobalSettingsPanel.mimeTypeTextField.text=
FileTypeIdSettingsPanel.signatureTextField.text= FileTypeIdGlobalSettingsPanel.signatureLabel.text=Signature
FileTypeIdGlobalSettingsPanel.mimeTypeLabel.text=Mime Type

View File

@ -1,10 +1,10 @@
OpenIDE-Module-Name=\u30D5\u30A1\u30A4\u30EB\u30BF\u30A4\u30D7\u306E\u7279\u5B9A OpenIDE-Module-Name=\u30d5\u30a1\u30a4\u30eb\u30bf\u30a4\u30d7\u306e\u7279\u5b9a
FileTypeIdModuleSettingsPanel.skipKnownCheckBox.toolTipText=\u65E2\u77E5\u306E\u30CF\u30C3\u30B7\u30E5\u5024\u3092\u6301\u3064\u30D5\u30A1\u30A4\u30EB\u6570\u306B\u3088\u3063\u3066\u306F\u3001\u3053\u306E\u30DC\u30C3\u30AF\u30B9\u3092\u9078\u629E\u3059\u308B\u306E\u306B\u3088\u308A\u3001\u30D5\u30A1\u30A4\u30EB\u30BF\u30A4\u30D7\u306E\u7279\u5B9A\u3092\u52A0\u901F\u3057\u307E\u3059\u3002 FileTypeIdIngestModule.moduleName.text=\u30d5\u30a1\u30a4\u30eb\u30bf\u30a4\u30d7\u306e\u7279\u5b9a
FileTypeIdIngestModule.moduleName.text=\u30D5\u30A1\u30A4\u30EB\u30BF\u30A4\u30D7\u306E\u7279\u5B9A FileTypeIdIngestModule.moduleDesc.text=\u30d0\u30a4\u30ca\u30ea\u7f72\u540d\u306b\u57fa\u3065\u3044\u3066\u30d5\u30a1\u30a4\u30eb\u30bf\u30a4\u30d7\u3092\u4e00\u81f4\u3059\u308b\u3002
FileTypeIdIngestModule.moduleDesc.text=\u30D0\u30A4\u30CA\u30EA\u7F72\u540D\u306B\u57FA\u3065\u3044\u3066\u30D5\u30A1\u30A4\u30EB\u30BF\u30A4\u30D7\u3092\u4E00\u81F4\u3059\u308B\u3002 FileTypeIdIngestModule.complete.totalProcTime=\u5408\u8a08\u51e6\u7406\u6642\u9593
FileTypeIdIngestModule.complete.totalProcTime=\u5408\u8A08\u51E6\u7406\u6642\u9593 FileTypeIdIngestModule.complete.totalFiles=\u5408\u8a08\u51e6\u7406\u30d5\u30a1\u30a4\u30eb\u6570
FileTypeIdIngestModule.complete.totalFiles=\u5408\u8A08\u51E6\u7406\u30D5\u30A1\u30A4\u30EB\u6570 FileTypeIdIngestModule.complete.srvMsg.text=\u30d5\u30a1\u30a4\u30eb\u30bf\u30a4\u30d7\u7279\u5b9a\u306e\u7d50\u679c
FileTypeIdIngestModule.complete.srvMsg.text=\u30D5\u30A1\u30A4\u30EB\u30BF\u30A4\u30D7\u7279\u5B9A\u306E\u7D50\u679C FileTypeIdModuleFactory.getIngestJobSettingsPanel.exception.msg=\u8a2d\u5b9a\u3092\u884c\u3046\u70ba\u306e\u60f3\u5b9a\u3055\u308c\u308b\u5f15\u6570\u306finstanceof FileTypeIdModuleSettings\u3067\u3059\u3002
FileTypeIdModuleSettingsPanel.skipKnownCheckBox.text=\u65E2\u77E5\u30D5\u30A1\u30A4\u30EB\uFF08NSRL\uFF09\u3092\u30B9\u30AD\u30C3\u30D7 FileTypeIdModuleFactory.createFileIngestModule.exception.msg=\u8a2d\u5b9a\u3092\u884c\u3046\u70ba\u306e\u60f3\u5b9a\u3055\u308c\u308b\u5f15\u6570\u306finstanceof FileTypeIdModuleSettings\u3067\u3059\u3002
FileTypeIdModuleFactory.getIngestJobSettingsPanel.exception.msg=\u8A2D\u5B9A\u3092\u884C\u3046\u70BA\u306E\u60F3\u5B9A\u3055\u308C\u308B\u5F15\u6570\u306Finstanceof FileTypeIdModuleSettings\u3067\u3059\u3002 FileTypeIdIngestJobSettingsPanel.skipKnownCheckBox.toolTipText=\u65e2\u77e5\u306e\u30cf\u30c3\u30b7\u30e5\u5024\u3092\u6301\u3064\u30d5\u30a1\u30a4\u30eb\u6570\u306b\u3088\u3063\u3066\u306f\u3001\u3053\u306e\u30dc\u30c3\u30af\u30b9\u3092\u9078\u629e\u3059\u308b\u306e\u306b\u3088\u308a\u3001\u30d5\u30a1\u30a4\u30eb\u30bf\u30a4\u30d7\u306e\u7279\u5b9a\u3092\u52a0\u901f\u3057\u307e\u3059\u3002
FileTypeIdModuleFactory.createFileIngestModule.exception.msg=\u8A2D\u5B9A\u3092\u884C\u3046\u70BA\u306E\u60F3\u5B9A\u3055\u308C\u308B\u5F15\u6570\u306Finstanceof FileTypeIdModuleSettings\u3067\u3059\u3002 FileTypeIdIngestJobSettingsPanel.skipKnownCheckBox.text=\u65e2\u77e5\u30d5\u30a1\u30a4\u30eb\uff08NSRL\uff09\u3092\u30b9\u30ad\u30c3\u30d7

View File

@ -178,70 +178,70 @@
<Component class="javax.swing.JLabel" name="mimeTypeLabel"> <Component class="javax.swing.JLabel" name="mimeTypeLabel">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdSettingsPanel.mimeTypeLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdGlobalSettingsPanel.mimeTypeLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JTextField" name="mimeTypeTextField"> <Component class="javax.swing.JTextField" name="mimeTypeTextField">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdSettingsPanel.mimeTypeTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdGlobalSettingsPanel.mimeTypeTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="signatureTypeLabel"> <Component class="javax.swing.JLabel" name="signatureTypeLabel">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdSettingsPanel.signatureTypeLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdGlobalSettingsPanel.signatureTypeLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JTextField" name="signatureTextField"> <Component class="javax.swing.JTextField" name="signatureTextField">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdSettingsPanel.signatureTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdGlobalSettingsPanel.signatureTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="offsetLabel"> <Component class="javax.swing.JLabel" name="offsetLabel">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdSettingsPanel.offsetLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdGlobalSettingsPanel.offsetLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JTextField" name="offsetTextField"> <Component class="javax.swing.JTextField" name="offsetTextField">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdSettingsPanel.offsetTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdGlobalSettingsPanel.offsetTextField.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JButton" name="newTypeButton"> <Component class="javax.swing.JButton" name="newTypeButton">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdSettingsPanel.newTypeButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdGlobalSettingsPanel.newTypeButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JButton" name="deleteTypeButton"> <Component class="javax.swing.JButton" name="deleteTypeButton">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdSettingsPanel.deleteTypeButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdGlobalSettingsPanel.deleteTypeButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JButton" name="saveTypeButton"> <Component class="javax.swing.JButton" name="saveTypeButton">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdSettingsPanel.saveTypeButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdGlobalSettingsPanel.saveTypeButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="hexPrefixLabel"> <Component class="javax.swing.JLabel" name="hexPrefixLabel">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdSettingsPanel.hexPrefixLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdGlobalSettingsPanel.hexPrefixLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
@ -259,7 +259,7 @@
<Component class="javax.swing.JLabel" name="signatureLabel"> <Component class="javax.swing.JLabel" name="signatureLabel">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdSettingsPanel.signatureLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdGlobalSettingsPanel.signatureLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
@ -280,7 +280,7 @@
<Property name="lineWrap" type="boolean" value="true"/> <Property name="lineWrap" type="boolean" value="true"/>
<Property name="rows" type="int" value="5"/> <Property name="rows" type="int" value="5"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdSettingsPanel.jTextArea1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdGlobalSettingsPanel.jTextArea1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
<Property name="wrapStyleWord" type="boolean" value="true"/> <Property name="wrapStyleWord" type="boolean" value="true"/>
</Properties> </Properties>
@ -290,7 +290,7 @@
<Component class="javax.swing.JCheckBox" name="postHitCheckBox"> <Component class="javax.swing.JCheckBox" name="postHitCheckBox">
<Properties> <Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdSettingsPanel.postHitCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdGlobalSettingsPanel.postHitCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
</Component> </Component>

View File

@ -30,7 +30,7 @@ import org.sleuthkit.autopsy.modules.filetypeid.UserDefinedFileTypesManager.User
/** /**
* A panel to allow a user to make custom file type definitions. * A panel to allow a user to make custom file type definitions.
*/ */
final class FileTypeIdSettingsPanel extends IngestModuleGlobalSettingsPanel implements OptionsPanel { final class FileTypeIdGlobalSettingsPanel extends IngestModuleGlobalSettingsPanel implements OptionsPanel {
private final HashMap<String, FileType> fileTypes = new HashMap<>(); private final HashMap<String, FileType> fileTypes = new HashMap<>();
private final HashMap<String, FileType> changedFileTypes = new HashMap<>(); private final HashMap<String, FileType> changedFileTypes = new HashMap<>();
@ -39,7 +39,7 @@ final class FileTypeIdSettingsPanel extends IngestModuleGlobalSettingsPanel impl
/** /**
* Creates a panel to allow a user to make custom file type definitions. * Creates a panel to allow a user to make custom file type definitions.
*/ */
FileTypeIdSettingsPanel() { FileTypeIdGlobalSettingsPanel() {
initComponents(); initComponents();
} }
@ -139,40 +139,40 @@ final class FileTypeIdSettingsPanel extends IngestModuleGlobalSettingsPanel impl
jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL); jSeparator1.setOrientation(javax.swing.SwingConstants.VERTICAL);
org.openide.awt.Mnemonics.setLocalizedText(mimeTypeLabel, org.openide.util.NbBundle.getMessage(FileTypeIdSettingsPanel.class, "FileTypeIdSettingsPanel.mimeTypeLabel.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(mimeTypeLabel, org.openide.util.NbBundle.getMessage(FileTypeIdGlobalSettingsPanel.class, "FileTypeIdGlobalSettingsPanel.mimeTypeLabel.text")); // NOI18N
mimeTypeTextField.setText(org.openide.util.NbBundle.getMessage(FileTypeIdSettingsPanel.class, "FileTypeIdSettingsPanel.mimeTypeTextField.text")); // NOI18N mimeTypeTextField.setText(org.openide.util.NbBundle.getMessage(FileTypeIdGlobalSettingsPanel.class, "FileTypeIdGlobalSettingsPanel.mimeTypeTextField.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(signatureTypeLabel, org.openide.util.NbBundle.getMessage(FileTypeIdSettingsPanel.class, "FileTypeIdSettingsPanel.signatureTypeLabel.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(signatureTypeLabel, org.openide.util.NbBundle.getMessage(FileTypeIdGlobalSettingsPanel.class, "FileTypeIdGlobalSettingsPanel.signatureTypeLabel.text")); // NOI18N
signatureTextField.setText(org.openide.util.NbBundle.getMessage(FileTypeIdSettingsPanel.class, "FileTypeIdSettingsPanel.signatureTextField.text")); // NOI18N signatureTextField.setText(org.openide.util.NbBundle.getMessage(FileTypeIdGlobalSettingsPanel.class, "FileTypeIdGlobalSettingsPanel.signatureTextField.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(offsetLabel, org.openide.util.NbBundle.getMessage(FileTypeIdSettingsPanel.class, "FileTypeIdSettingsPanel.offsetLabel.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(offsetLabel, org.openide.util.NbBundle.getMessage(FileTypeIdGlobalSettingsPanel.class, "FileTypeIdGlobalSettingsPanel.offsetLabel.text")); // NOI18N
offsetTextField.setText(org.openide.util.NbBundle.getMessage(FileTypeIdSettingsPanel.class, "FileTypeIdSettingsPanel.offsetTextField.text")); // NOI18N offsetTextField.setText(org.openide.util.NbBundle.getMessage(FileTypeIdGlobalSettingsPanel.class, "FileTypeIdGlobalSettingsPanel.offsetTextField.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(newTypeButton, org.openide.util.NbBundle.getMessage(FileTypeIdSettingsPanel.class, "FileTypeIdSettingsPanel.newTypeButton.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(newTypeButton, org.openide.util.NbBundle.getMessage(FileTypeIdGlobalSettingsPanel.class, "FileTypeIdGlobalSettingsPanel.newTypeButton.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(deleteTypeButton, org.openide.util.NbBundle.getMessage(FileTypeIdSettingsPanel.class, "FileTypeIdSettingsPanel.deleteTypeButton.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(deleteTypeButton, org.openide.util.NbBundle.getMessage(FileTypeIdGlobalSettingsPanel.class, "FileTypeIdGlobalSettingsPanel.deleteTypeButton.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(saveTypeButton, org.openide.util.NbBundle.getMessage(FileTypeIdSettingsPanel.class, "FileTypeIdSettingsPanel.saveTypeButton.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(saveTypeButton, org.openide.util.NbBundle.getMessage(FileTypeIdGlobalSettingsPanel.class, "FileTypeIdGlobalSettingsPanel.saveTypeButton.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(hexPrefixLabel, org.openide.util.NbBundle.getMessage(FileTypeIdSettingsPanel.class, "FileTypeIdSettingsPanel.hexPrefixLabel.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(hexPrefixLabel, org.openide.util.NbBundle.getMessage(FileTypeIdGlobalSettingsPanel.class, "FileTypeIdGlobalSettingsPanel.hexPrefixLabel.text")); // NOI18N
signatureTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Bytes (Hex)", "String", " " })); signatureTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Bytes (Hex)", "String", " " }));
org.openide.awt.Mnemonics.setLocalizedText(signatureLabel, org.openide.util.NbBundle.getMessage(FileTypeIdSettingsPanel.class, "FileTypeIdSettingsPanel.signatureLabel.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(signatureLabel, org.openide.util.NbBundle.getMessage(FileTypeIdGlobalSettingsPanel.class, "FileTypeIdGlobalSettingsPanel.signatureLabel.text")); // NOI18N
jTextArea1.setEditable(false); jTextArea1.setEditable(false);
jTextArea1.setColumns(20); jTextArea1.setColumns(20);
jTextArea1.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N jTextArea1.setFont(new java.awt.Font("Tahoma", 0, 11)); // NOI18N
jTextArea1.setLineWrap(true); jTextArea1.setLineWrap(true);
jTextArea1.setRows(5); jTextArea1.setRows(5);
jTextArea1.setText(org.openide.util.NbBundle.getMessage(FileTypeIdSettingsPanel.class, "FileTypeIdSettingsPanel.jTextArea1.text")); // NOI18N jTextArea1.setText(org.openide.util.NbBundle.getMessage(FileTypeIdGlobalSettingsPanel.class, "FileTypeIdGlobalSettingsPanel.jTextArea1.text")); // NOI18N
jTextArea1.setWrapStyleWord(true); jTextArea1.setWrapStyleWord(true);
jScrollPane2.setViewportView(jTextArea1); jScrollPane2.setViewportView(jTextArea1);
org.openide.awt.Mnemonics.setLocalizedText(postHitCheckBox, org.openide.util.NbBundle.getMessage(FileTypeIdSettingsPanel.class, "FileTypeIdSettingsPanel.postHitCheckBox.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(postHitCheckBox, org.openide.util.NbBundle.getMessage(FileTypeIdGlobalSettingsPanel.class, "FileTypeIdGlobalSettingsPanel.postHitCheckBox.text")); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);

View File

@ -38,10 +38,10 @@
<Properties> <Properties>
<Property name="selected" type="boolean" value="true"/> <Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdModuleSettingsPanel.skipKnownCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdIngestJobSettingsPanel.skipKnownCheckBox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
<Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"> <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdModuleSettingsPanel.skipKnownCheckBox.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/> <ResourceString bundle="org/sleuthkit/autopsy/modules/filetypeid/Bundle.properties" key="FileTypeIdIngestJobSettingsPanel.skipKnownCheckBox.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property> </Property>
</Properties> </Properties>
<Events> <Events>

View File

@ -25,13 +25,13 @@ import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettingsPanel;
* UI component used to set ingest job options for file type identifier ingest * UI component used to set ingest job options for file type identifier ingest
* modules. * modules.
*/ */
final class FileTypeIdModuleSettingsPanel extends IngestModuleIngestJobSettingsPanel { final class FileTypeIdIngestJobSettingsPanel extends IngestModuleIngestJobSettingsPanel {
private final FileTypeIdModuleSettings settings; private final FileTypeIdModuleSettings settings;
// NOTE: This was declared public, but was inaccessible because the class is // NOTE: This was declared public, but was inaccessible because the class is
// not public // not public
FileTypeIdModuleSettingsPanel(FileTypeIdModuleSettings settings) { FileTypeIdIngestJobSettingsPanel(FileTypeIdModuleSettings settings) {
this.settings = settings; this.settings = settings;
initComponents(); initComponents();
customizeComponents(); customizeComponents();
@ -61,8 +61,8 @@ final class FileTypeIdModuleSettingsPanel extends IngestModuleIngestJobSettingsP
skipKnownCheckBox = new javax.swing.JCheckBox(); skipKnownCheckBox = new javax.swing.JCheckBox();
skipKnownCheckBox.setSelected(true); skipKnownCheckBox.setSelected(true);
skipKnownCheckBox.setText(org.openide.util.NbBundle.getMessage(FileTypeIdModuleSettingsPanel.class, "FileTypeIdModuleSettingsPanel.skipKnownCheckBox.text")); // NOI18N skipKnownCheckBox.setText(org.openide.util.NbBundle.getMessage(FileTypeIdIngestJobSettingsPanel.class, "FileTypeIdIngestJobSettingsPanel.skipKnownCheckBox.text")); // NOI18N
skipKnownCheckBox.setToolTipText(org.openide.util.NbBundle.getMessage(FileTypeIdModuleSettingsPanel.class, "FileTypeIdModuleSettingsPanel.skipKnownCheckBox.toolTipText")); // NOI18N skipKnownCheckBox.setToolTipText(org.openide.util.NbBundle.getMessage(FileTypeIdIngestJobSettingsPanel.class, "FileTypeIdIngestJobSettingsPanel.skipKnownCheckBox.toolTipText")); // NOI18N
skipKnownCheckBox.addActionListener(new java.awt.event.ActionListener() { skipKnownCheckBox.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
skipKnownCheckBoxActionPerformed(evt); skipKnownCheckBoxActionPerformed(evt);

View File

@ -82,7 +82,7 @@ public class FileTypeIdModuleFactory extends IngestModuleFactoryAdapter {
*/ */
@Override @Override
public IngestModuleGlobalSettingsPanel getGlobalSettingsPanel() { public IngestModuleGlobalSettingsPanel getGlobalSettingsPanel() {
return new FileTypeIdSettingsPanel(); return new FileTypeIdGlobalSettingsPanel();
} }
/** /**
@ -111,7 +111,7 @@ public class FileTypeIdModuleFactory extends IngestModuleFactoryAdapter {
throw new IllegalArgumentException(NbBundle.getMessage(this.getClass(), throw new IllegalArgumentException(NbBundle.getMessage(this.getClass(),
"FileTypeIdModuleFactory.getIngestJobSettingsPanel.exception.msg")); "FileTypeIdModuleFactory.getIngestJobSettingsPanel.exception.msg"));
} }
return new FileTypeIdModuleSettingsPanel((FileTypeIdModuleSettings) settings); return new FileTypeIdIngestJobSettingsPanel((FileTypeIdModuleSettings) settings);
} }
/** /**

View File

@ -22,7 +22,7 @@ import org.openide.util.Lookup;
@org.openide.util.NbBundle.Messages({"OptionsCategory_Name_FileTypeId=FileTypeId", "OptionsCategory_Keywords_FileTypeId=FileTypeId"}) @org.openide.util.NbBundle.Messages({"OptionsCategory_Name_FileTypeId=FileTypeId", "OptionsCategory_Keywords_FileTypeId=FileTypeId"})
public final class FileTypeIdOptionsPanelController extends OptionsPanelController { public final class FileTypeIdOptionsPanelController extends OptionsPanelController {
private FileTypeIdSettingsPanel panel; private FileTypeIdGlobalSettingsPanel panel;
private final PropertyChangeSupport pcs = new PropertyChangeSupport(this); private final PropertyChangeSupport pcs = new PropertyChangeSupport(this);
private boolean changed; private boolean changed;
@ -77,9 +77,9 @@ public final class FileTypeIdOptionsPanelController extends OptionsPanelControll
pcs.removePropertyChangeListener(l); pcs.removePropertyChangeListener(l);
} }
private FileTypeIdSettingsPanel getPanel() { private FileTypeIdGlobalSettingsPanel getPanel() {
if (panel == null) { if (panel == null) {
panel = new FileTypeIdSettingsPanel(); panel = new FileTypeIdGlobalSettingsPanel();
} }
return panel; return panel;
} }

View File

@ -25,6 +25,7 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -57,11 +58,25 @@ final class UserDefinedFileTypesManager {
private static final String SIGNATURE_TYPE_ATTRIBUTE = "type"; //NON-NLS private static final String SIGNATURE_TYPE_ATTRIBUTE = "type"; //NON-NLS
private static final String BYTES_TAG_NAME = "bytes"; //NON-NLS private static final String BYTES_TAG_NAME = "bytes"; //NON-NLS
private static final String OFFSET_TAG_NAME = "offset"; //NON-NLS private static final String OFFSET_TAG_NAME = "offset"; //NON-NLS
private static final String ENCODING = "UTF-8"; //NON-NLS private static final String ENCODING_FOR_XML_FILE = "UTF-8"; //NON-NLS
private static final String ASCII_ENCODING = "US-ASCII"; //NON-NLS private static final String ASCII_ENCODING = "US-ASCII"; //NON-NLS
private static UserDefinedFileTypesManager instance; private static UserDefinedFileTypesManager instance;
private final Map<String, FileType> predefinedFileTypes = new HashMap<>();
/**
* User-defined file types to be persisted to the user-defined file type
* definitions file are stored in this mapping of file type names to file
* types. Access to this map is guarded by the intrinsic lock of the
* user-defined file types manager for thread-safety.
*/
private final Map<String, FileType> userDefinedFileTypes = new HashMap<>(); private final Map<String, FileType> userDefinedFileTypes = new HashMap<>();
/**
* The combined set of user-defined file types and file types predefined by
* Autopsy are stored in this mapping of file type names to file types. This
* is the current working set of file types. Access to this map is guarded
* by the intrinsic lock of the user-defined file types manager for
* thread-safety.
*/
private final Map<String, FileType> fileTypes = new HashMap<>(); private final Map<String, FileType> fileTypes = new HashMap<>();
/** /**
@ -70,10 +85,10 @@ final class UserDefinedFileTypesManager {
* @return A singleton user-defined file types manager. * @return A singleton user-defined file types manager.
*/ */
synchronized static UserDefinedFileTypesManager getInstance() { synchronized static UserDefinedFileTypesManager getInstance() {
if (instance == null) { if (UserDefinedFileTypesManager.instance == null) {
instance = new UserDefinedFileTypesManager(); UserDefinedFileTypesManager.instance = new UserDefinedFileTypesManager();
} }
return instance; return UserDefinedFileTypesManager.instance;
} }
/** /**
@ -90,7 +105,7 @@ final class UserDefinedFileTypesManager {
* names to predefined file types. * names to predefined file types.
*/ */
private void loadPredefinedFileTypes() { private void loadPredefinedFileTypes() {
// RJCTODO: Remove // RJCTODO: Remove test type
/** /**
* Create a file type that should match $MBR in Small2 image. * Create a file type that should match $MBR in Small2 image.
*/ */
@ -99,11 +114,11 @@ final class UserDefinedFileTypesManager {
/** /**
* Create a file type that should match test.txt in the Small2 image. * Create a file type that should match test.txt in the Small2 image.
*/ */
// RJCTODO: Remove // RJCTODO: Remove test type
try { try {
this.fileTypes.put("predefinedASCII", new FileType("predefinedASCII", new Signature("hello".getBytes(ASCII_ENCODING), 0L, FileType.Signature.Type.ASCII), true)); this.fileTypes.put("predefinedASCII", new FileType("predefinedASCII", new Signature("hello".getBytes(UserDefinedFileTypesManager.ASCII_ENCODING), 0L, FileType.Signature.Type.ASCII), true));
} catch (UnsupportedEncodingException ex) { } catch (UnsupportedEncodingException ex) {
logger.log(Level.SEVERE, "Unable to create 'predefinedASCII' predefined file type definition", ex); //NON-NLS UserDefinedFileTypesManager.logger.log(Level.SEVERE, "Unable to create 'predefinedASCII' predefined file type definition", ex); //NON-NLS
} }
try { try {
@ -129,9 +144,13 @@ final class UserDefinedFileTypesManager {
// catch (IndexOutOfBoundsException e) { // catch (IndexOutOfBoundsException e) {
// // do nothing // // do nothing
// } // }
this.predefinedFileTypes.put("text/xml", new FileType("text/xml", new Signature("<?xml".getBytes(ASCII_ENCODING), 0L, FileType.Signature.Type.ASCII), false)); this.fileTypes.put("text/xml", new FileType("text/xml", new Signature("<?xml".getBytes(UserDefinedFileTypesManager.ASCII_ENCODING), 0L, FileType.Signature.Type.ASCII), false));
} catch (UnsupportedEncodingException ex) { } catch (UnsupportedEncodingException ex) {
logger.log(Level.SEVERE, "Unable to create 'text/xml' predefined file type definition", ex); //NON-NLS /**
* Using an all-or-none strategy.
*/
UserDefinedFileTypesManager.logger.log(Level.SEVERE, "Unable to create predefined file type definitions", ex); //NON-NLS
this.fileTypes.clear();
} }
} }
@ -141,29 +160,27 @@ final class UserDefinedFileTypesManager {
*/ */
private void loadUserDefinedFileTypes() { private void loadUserDefinedFileTypes() {
try { try {
String filePath = getFileTypeDefinitionsFilePath(UserDefinedFileTypesManager.USER_DEFINED_TYPE_DEFINITIONS_FILE);
/**
* Read the user-defined types from the backing XML file. These
* types are put into one map that will be used to write changes to
* the XML backing a file, and to another ,map where user-defined
* types overwrite predefined types of the same name.
*/
String filePath = getFileTypeDefinitionsFilePath(USER_DEFINED_TYPE_DEFINITIONS_FILE);
File file = new File(filePath); File file = new File(filePath);
if (file.exists() && file.canRead()) { if (file.exists() && file.canRead()) {
for (FileType fileType : XMLReader.readFileTypes(filePath)) { for (FileType fileType : XMLReader.readFileTypes(filePath)) {
userDefinedFileTypes.put(fileType.getTypeName(), fileType); this.userDefinedFileTypes.put(fileType.getTypeName(), fileType);
fileTypes.put(fileType.getTypeName(), fileType); this.fileTypes.put(fileType.getTypeName(), fileType);
} }
} }
} catch (InvalidXMLException ex) { } catch (UserDefinedFileTypesManager.InvalidXMLException ex) {
// RJCTODO: /**
* Using an all-or-none strategy.
*/
UserDefinedFileTypesManager.logger.log(Level.SEVERE, "Unable to load user-defined types", ex); //NON-NLS
this.fileTypes.clear();
this.userDefinedFileTypes.clear();
} }
} }
/** /**
* Gets the file types. * Gets the user-defined file types.
* *
* @return A mapping of file type names to file types, possibly empty. * @return A mapping of file type names to file types, possibly empty.
*/ */
@ -176,50 +193,50 @@ final class UserDefinedFileTypesManager {
} }
/** /**
* Adds a new file type definition, overwriting any file type with the same * Adds a new user-defined file type, overwriting any existing file type
* type name that already exists. * with the same type name.
* *
* @param fileType The file type to add. * @param fileType The file type to add.
* @throws * @throws
* org.sleuthkit.autopsy.modules.filetypeid.UserDefinedFileTypesManager.UserDefinedFileTypesException * org.sleuthkit.autopsy.modules.filetypeid.UserDefinedFileTypesManager.UserDefinedFileTypesException
*/ */
synchronized void addFileType(FileType fileType) throws UserDefinedFileTypesException { synchronized void addFileType(FileType fileType) throws UserDefinedFileTypesException {
List<FileType> newFileTypes = new ArrayList<>(); this.addFileTypes(Collections.singletonList(fileType));
newFileTypes.add(fileType);
addFileTypes(newFileTypes);
} }
/** /**
* Adds a set of new file types, overwriting any file types with the same * Adds a collection of new user-defined file types, overwriting any
* type names that already exist. * existing file types with the same type names.
* *
* @param newFileTypes The file types to add. * @param newFileTypes The file types to add.
* @throws * @throws
* org.sleuthkit.autopsy.modules.filetypeid.UserDefinedFileTypesManager.UserDefinedFileTypesException * org.sleuthkit.autopsy.modules.filetypeid.UserDefinedFileTypesManager.UserDefinedFileTypesException
*/ */
synchronized void addFileTypes(Collection<FileType> newFileTypes) throws UserDefinedFileTypesException { synchronized void addFileTypes(Collection<FileType> newFileTypes) throws UserDefinedFileTypesException {
/**
* It is safe to hold references to client-constructed file type objects
* because they are immutable.
*/
for (FileType fileType : newFileTypes) { for (FileType fileType : newFileTypes) {
userDefinedFileTypes.put(fileType.getTypeName(), fileType); this.userDefinedFileTypes.put(fileType.getTypeName(), fileType);
fileTypes.put(fileType.getTypeName(), fileType); this.fileTypes.put(fileType.getTypeName(), fileType);
} }
saveUserDefinedTypes(); this.saveUserDefinedTypes();
} }
/** /**
* Deletes a file type. * Deletes a user-defined file type.
* *
* @param fileType The file type to delete. * @param fileType The file type to delete.
* @throws * @throws
* org.sleuthkit.autopsy.modules.filetypeid.UserDefinedFileTypesManager.UserDefinedFileTypesException * org.sleuthkit.autopsy.modules.filetypeid.UserDefinedFileTypesManager.UserDefinedFileTypesException
*/ */
synchronized void deleteFileType(FileType fileType) throws UserDefinedFileTypesException { synchronized void deleteFileType(FileType fileType) throws UserDefinedFileTypesException {
List<FileType> deletedFileTypes = new ArrayList<>(); this.deleteFileTypes(Collections.singletonList(fileType));
deletedFileTypes.add(fileType);
deleteFileTypes(deletedFileTypes);
} }
/** /**
* Deletes a set of file types. * Deletes a set of user-defined file types.
* *
* @param deletedFileTypes The file types to delete. * @param deletedFileTypes The file types to delete.
* @throws * @throws
@ -227,21 +244,21 @@ final class UserDefinedFileTypesManager {
*/ */
synchronized void deleteFileTypes(Collection<FileType> deletedFileTypes) throws UserDefinedFileTypesException { synchronized void deleteFileTypes(Collection<FileType> deletedFileTypes) throws UserDefinedFileTypesException {
for (FileType fileType : deletedFileTypes) { for (FileType fileType : deletedFileTypes) {
userDefinedFileTypes.remove(fileType.getTypeName(), fileType); this.userDefinedFileTypes.remove(fileType.getTypeName(), fileType);
fileTypes.remove(fileType.getTypeName(), fileType); this.fileTypes.remove(fileType.getTypeName(), fileType);
} }
saveUserDefinedTypes(); this.saveUserDefinedTypes();
} }
/** /**
* Persist the user-defined file type definitions. * Persists the user-defined file type definitions.
* *
* @throws * @throws
* org.sleuthkit.autopsy.modules.filetypeid.UserDefinedFileTypesManager.UserDefinedFileTypesException * org.sleuthkit.autopsy.modules.filetypeid.UserDefinedFileTypesManager.UserDefinedFileTypesException
*/ */
private void saveUserDefinedTypes() throws UserDefinedFileTypesException { private void saveUserDefinedTypes() throws UserDefinedFileTypesException {
String filePath = getFileTypeDefinitionsFilePath(USER_DEFINED_TYPE_DEFINITIONS_FILE); String filePath = UserDefinedFileTypesManager.getFileTypeDefinitionsFilePath(UserDefinedFileTypesManager.USER_DEFINED_TYPE_DEFINITIONS_FILE);
writeFileTypes(userDefinedFileTypes.values(), filePath); UserDefinedFileTypesManager.writeFileTypes(this.userDefinedFileTypes.values(), filePath);
} }
/** /**
@ -253,10 +270,10 @@ final class UserDefinedFileTypesManager {
*/ */
private static void writeFileTypes(Collection<FileType> fileTypes, String filePath) throws UserDefinedFileTypesException { private static void writeFileTypes(Collection<FileType> fileTypes, String filePath) throws UserDefinedFileTypesException {
try { try {
XMLWriter.writeFileTypes(fileTypes, filePath); UserDefinedFileTypesManager.XMLWriter.writeFileTypes(fileTypes, filePath);
} catch (ParserConfigurationException | IOException ex) { } catch (ParserConfigurationException | IOException ex) {
UserDefinedFileTypesManager.logger.log(Level.SEVERE, "Failed to write file types file", ex); UserDefinedFileTypesManager.logger.log(Level.SEVERE, "Failed to write file types file", ex);
throw new UserDefinedFileTypesException(ex.getLocalizedMessage()); // RJCTODO: Create a bundled message throw new UserDefinedFileTypesManager.UserDefinedFileTypesException(ex.getLocalizedMessage()); // RJCTODO: Create a bundled message
} }
} }
@ -291,7 +308,7 @@ final class UserDefinedFileTypesManager {
Element fileTypeElem = UserDefinedFileTypesManager.XMLWriter.createFileTypeElement(fileType, doc); Element fileTypeElem = UserDefinedFileTypesManager.XMLWriter.createFileTypeElement(fileType, doc);
fileTypesElem.appendChild(fileTypeElem); fileTypesElem.appendChild(fileTypeElem);
} }
if (!XMLUtil.saveDoc(HashDbManager.class, filePath, UserDefinedFileTypesManager.ENCODING, doc)) { if (!XMLUtil.saveDoc(HashDbManager.class, filePath, UserDefinedFileTypesManager.ENCODING_FOR_XML_FILE, doc)) {
// RJCTODO: If time permits add XMLUtil that properly throws and deprecate this one // RJCTODO: If time permits add XMLUtil that properly throws and deprecate this one
throw new IOException("Error saving user defined file types, see log for details"); //NON-NLS throw new IOException("Error saving user defined file types, see log for details"); //NON-NLS
} }
@ -459,9 +476,10 @@ final class UserDefinedFileTypesManager {
} }
/** /**
* RJCTODO * Used for exceptions when parsing user-defined types XML elements and
* attributes.
*/ */
static class InvalidXMLException extends Exception { private static class InvalidXMLException extends Exception {
InvalidXMLException(String message) { InvalidXMLException(String message) {
super(message); super(message);