mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-13 16:36:15 +00:00
Made changes as per pr notes
This commit is contained in:
parent
4ca31dacba
commit
2bb8ce29fb
@ -6,15 +6,6 @@
|
|||||||
<code-name-base>org.sleuthkit.autopsy.core</code-name-base>
|
<code-name-base>org.sleuthkit.autopsy.core</code-name-base>
|
||||||
<suite-component/>
|
<suite-component/>
|
||||||
<module-dependencies>
|
<module-dependencies>
|
||||||
<dependency>
|
|
||||||
<code-name-base>org.jdesktop.beansbinding</code-name-base>
|
|
||||||
<build-prerequisite/>
|
|
||||||
<compile-dependency/>
|
|
||||||
<run-dependency>
|
|
||||||
<release-version>1</release-version>
|
|
||||||
<specification-version>1.24.1.121</specification-version>
|
|
||||||
</run-dependency>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<code-name-base>org.netbeans.api.progress</code-name-base>
|
<code-name-base>org.netbeans.api.progress</code-name-base>
|
||||||
<build-prerequisite/>
|
<build-prerequisite/>
|
||||||
|
@ -62,6 +62,6 @@ FilesSetRulePanel.nameCheck.text=Name Pattern:
|
|||||||
FilesSetRulePanel.pathCheck.text=Path Pattern:
|
FilesSetRulePanel.pathCheck.text=Path Pattern:
|
||||||
FilesSetRulePanel.mimeCheck.text=MIME Type:
|
FilesSetRulePanel.mimeCheck.text=MIME Type:
|
||||||
FilesSetRulePanel.fileSizeCheck.text=File Size:
|
FilesSetRulePanel.fileSizeCheck.text=File Size:
|
||||||
FilesSetRulePanel.filesRadio.text=Files
|
FilesSetRulePanel.filesRadioButton.text=Files
|
||||||
FilesSetRulePanel.dirsRadio.text=Directories
|
FilesSetRulePanel.dirsRadioButton.text=Directories
|
||||||
FilesSetRulePanel.filesAndDirsRadio.text=Files and Directories
|
FilesSetRulePanel.filesAndDirsRadioButton.text=Files and Directories
|
||||||
|
@ -26,6 +26,8 @@ import java.util.TreeMap;
|
|||||||
import javax.swing.JTable;
|
import javax.swing.JTable;
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
import javax.swing.table.TableColumn;
|
import javax.swing.table.TableColumn;
|
||||||
|
import org.openide.util.Exceptions;
|
||||||
|
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
||||||
import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings;
|
import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettings;
|
||||||
import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettingsPanel;
|
import org.sleuthkit.autopsy.ingest.IngestModuleIngestJobSettingsPanel;
|
||||||
|
|
||||||
@ -75,7 +77,11 @@ final class FilesIdentifierIngestJobSettingsPanel extends IngestModuleIngestJobS
|
|||||||
* Observer.update().
|
* Observer.update().
|
||||||
*/
|
*/
|
||||||
List<FilesSetRow> filesSetRows = new ArrayList<>();
|
List<FilesSetRow> filesSetRows = new ArrayList<>();
|
||||||
|
try {
|
||||||
this.filesSetSnapshot = new TreeMap<>(InterestingItemDefsManager.getInstance().getInterestingFilesSets());
|
this.filesSetSnapshot = new TreeMap<>(InterestingItemDefsManager.getInstance().getInterestingFilesSets());
|
||||||
|
} catch (InterestingItemDefsManager.InterestingItemDefsManagerException ex) {
|
||||||
|
MessageNotifyUtil.Message.error("Test Error");
|
||||||
|
}
|
||||||
for (FilesSet set : this.filesSetSnapshot.values()) {
|
for (FilesSet set : this.filesSetSnapshot.values()) {
|
||||||
filesSetRows.add(new FilesSetRow(set, settings.interestingFilesSetIsEnabled(set.getName())));
|
filesSetRows.add(new FilesSetRow(set, settings.interestingFilesSetIsEnabled(set.getName())));
|
||||||
}
|
}
|
||||||
@ -130,7 +136,13 @@ final class FilesIdentifierIngestJobSettingsPanel extends IngestModuleIngestJobS
|
|||||||
|
|
||||||
// Refresh the view of the interesting files set definitions.
|
// Refresh the view of the interesting files set definitions.
|
||||||
List<FilesSetRow> rowModels = new ArrayList<>();
|
List<FilesSetRow> rowModels = new ArrayList<>();
|
||||||
TreeMap<String, FilesSet> newFilesSetSnapshot = new TreeMap<>(InterestingItemDefsManager.getInstance().getInterestingFilesSets());
|
TreeMap<String, FilesSet> newFilesSetSnapshot;
|
||||||
|
try {
|
||||||
|
newFilesSetSnapshot = new TreeMap<>(InterestingItemDefsManager.getInstance().getInterestingFilesSets());
|
||||||
|
} catch (InterestingItemDefsManager.InterestingItemDefsManagerException ex) {
|
||||||
|
MessageNotifyUtil.Message.error("Test error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (FilesSet set : newFilesSetSnapshot.values()) {
|
for (FilesSet set : newFilesSetSnapshot.values()) {
|
||||||
if (this.filesSetSnapshot.keySet().contains(set.getName())) {
|
if (this.filesSetSnapshot.keySet().contains(set.getName())) {
|
||||||
// Preserve the current enabled/diabled state of the set.
|
// Preserve the current enabled/diabled state of the set.
|
||||||
|
@ -24,6 +24,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
import org.openide.util.Exceptions;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.sleuthkit.autopsy.casemodule.Case;
|
import org.sleuthkit.autopsy.casemodule.Case;
|
||||||
import org.sleuthkit.autopsy.casemodule.services.Blackboard;
|
import org.sleuthkit.autopsy.casemodule.services.Blackboard;
|
||||||
@ -77,11 +78,15 @@ final class FilesIdentifierIngestModule implements FileIngestModule {
|
|||||||
// synchronized definitions manager method eliminates the need
|
// synchronized definitions manager method eliminates the need
|
||||||
// to disable the interesting files set definition UI during ingest.
|
// to disable the interesting files set definition UI during ingest.
|
||||||
List<FilesSet> filesSets = new ArrayList<>();
|
List<FilesSet> filesSets = new ArrayList<>();
|
||||||
|
try {
|
||||||
for (FilesSet set : InterestingItemDefsManager.getInstance().getInterestingFilesSets().values()) {
|
for (FilesSet set : InterestingItemDefsManager.getInstance().getInterestingFilesSets().values()) {
|
||||||
if (settings.interestingFilesSetIsEnabled(set.getName())) {
|
if (settings.interestingFilesSetIsEnabled(set.getName())) {
|
||||||
filesSets.add(set);
|
filesSets.add(set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch (InterestingItemDefsManager.InterestingItemDefsManagerException ex) {
|
||||||
|
throw new IngestModuleException("Test");
|
||||||
|
}
|
||||||
FilesIdentifierIngestModule.interestingFileSetsByJob.put(context.getJobId(), filesSets);
|
FilesIdentifierIngestModule.interestingFileSetsByJob.put(context.getJobId(), filesSets);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -153,9 +153,11 @@ final class FilesSet implements Serializable {
|
|||||||
* Construct an interesting files set membership rule.
|
* Construct an interesting files set membership rule.
|
||||||
*
|
*
|
||||||
* @param ruleName The name of the rule. Can be empty string.
|
* @param ruleName The name of the rule. Can be empty string.
|
||||||
* @param fileNameCondition A file name condition.
|
* @param fileNameCondition A file name condition, may be null.
|
||||||
* @param metaTypeCondition A file meta-type condition.
|
* @param metaTypeCondition A file meta-type condition.
|
||||||
* @param pathCondition A file path condition, may be null.
|
* @param pathCondition A file path condition, may be null.
|
||||||
|
* @param mimeTypeCondition A file mime type condition, may be null.
|
||||||
|
* @param fileSizeCondition A file size condition, may be null.
|
||||||
*/
|
*/
|
||||||
Rule(String ruleName, FileNameCondition fileNameCondition, MetaTypeCondition metaTypeCondition, ParentPathCondition pathCondition, MimeTypeCondition mimeTypeCondition, FileSizeCondition fileSizeCondition) {
|
Rule(String ruleName, FileNameCondition fileNameCondition, MetaTypeCondition metaTypeCondition, ParentPathCondition pathCondition, MimeTypeCondition mimeTypeCondition, FileSizeCondition fileSizeCondition) {
|
||||||
// since ruleName is optional, ruleUUID can be used to uniquely identify a rule.
|
// since ruleName is optional, ruleUUID can be used to uniquely identify a rule.
|
||||||
@ -227,7 +229,7 @@ final class FilesSet implements Serializable {
|
|||||||
/**
|
/**
|
||||||
* Get the path condition for the rule.
|
* Get the path condition for the rule.
|
||||||
*
|
*
|
||||||
* @return A path condition, may be null. Can be null.
|
* @return A path condition, may be null.
|
||||||
*/
|
*/
|
||||||
ParentPathCondition getPathCondition() {
|
ParentPathCondition getPathCondition() {
|
||||||
return this.pathCondition;
|
return this.pathCondition;
|
||||||
@ -299,8 +301,7 @@ final class FilesSet implements Serializable {
|
|||||||
static interface FileAttributeCondition extends Serializable {
|
static interface FileAttributeCondition extends Serializable {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests whether or not a file satisfies the conditions of a
|
* Tests whether or not a file satisfies the condition.
|
||||||
* condition.
|
|
||||||
*
|
*
|
||||||
* @param file The file to test.
|
* @param file The file to test.
|
||||||
*
|
*
|
||||||
@ -353,32 +354,6 @@ final class FilesSet implements Serializable {
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the comparator of this condition
|
|
||||||
*
|
|
||||||
* @return the comparator
|
|
||||||
*/
|
|
||||||
COMPARATOR getComparator() {
|
|
||||||
return comparator;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the unit for the size of this condition
|
|
||||||
*
|
|
||||||
* @return the unit
|
|
||||||
*/
|
|
||||||
SIZE_UNIT getUnit() {
|
|
||||||
return unit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the size value of this condition
|
|
||||||
*
|
|
||||||
* @return the size value
|
|
||||||
*/
|
|
||||||
int getSizeValue() {
|
|
||||||
return sizeValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a comparison item for file size
|
* Represents a comparison item for file size
|
||||||
@ -468,6 +443,34 @@ final class FilesSet implements Serializable {
|
|||||||
this.sizeValue = sizeValue;
|
this.sizeValue = sizeValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the comparator of this condition
|
||||||
|
*
|
||||||
|
* @return the comparator
|
||||||
|
*/
|
||||||
|
COMPARATOR getComparator() {
|
||||||
|
return comparator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the unit for the size of this condition
|
||||||
|
*
|
||||||
|
* @return the unit
|
||||||
|
*/
|
||||||
|
SIZE_UNIT getUnit() {
|
||||||
|
return unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the size value of this condition
|
||||||
|
*
|
||||||
|
* @return the size value
|
||||||
|
*/
|
||||||
|
int getSizeValue() {
|
||||||
|
return sizeValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean passes(AbstractFile file) {
|
public boolean passes(AbstractFile file) {
|
||||||
long fileSize = file.getSize();
|
long fileSize = file.getSize();
|
||||||
|
@ -38,11 +38,11 @@
|
|||||||
<Group type="102" attributes="0">
|
<Group type="102" attributes="0">
|
||||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace min="-2" pref="65" max="-2" attributes="0"/>
|
<EmptySpace min="-2" pref="65" max="-2" attributes="0"/>
|
||||||
<Component id="filesRadio" min="-2" max="-2" attributes="0"/>
|
<Component id="filesRadioButton" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="dirsRadio" min="-2" max="-2" attributes="0"/>
|
<Component id="dirsRadioButton" min="-2" max="-2" attributes="0"/>
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="filesAndDirsRadio" min="-2" max="-2" attributes="0"/>
|
<Component id="filesAndDirsRadioButton" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||||
@ -109,9 +109,9 @@
|
|||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="3" attributes="0">
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="filesRadio" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="filesRadioButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="dirsRadio" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="dirsRadioButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
<Component id="filesAndDirsRadio" alignment="3" min="-2" max="-2" attributes="0"/>
|
<Component id="filesAndDirsRadioButton" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
<EmptySpace min="-2" pref="5" max="-2" attributes="0"/>
|
<EmptySpace min="-2" pref="5" max="-2" attributes="0"/>
|
||||||
<Group type="103" groupAlignment="3" attributes="0">
|
<Group type="103" groupAlignment="3" attributes="0">
|
||||||
@ -199,6 +199,9 @@
|
|||||||
</Property>
|
</Property>
|
||||||
<Property name="enabled" type="boolean" value="false"/>
|
<Property name="enabled" type="boolean" value="false"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
|
<Events>
|
||||||
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="fullNameRadioButtonActionPerformed"/>
|
||||||
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JRadioButton" name="extensionRadioButton">
|
<Component class="javax.swing.JRadioButton" name="extensionRadioButton">
|
||||||
<Properties>
|
<Properties>
|
||||||
@ -261,9 +264,6 @@
|
|||||||
</Property>
|
</Property>
|
||||||
<Property name="enabled" type="boolean" value="false"/>
|
<Property name="enabled" type="boolean" value="false"/>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Events>
|
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="mimeTypeComboBoxActionPerformed"/>
|
|
||||||
</Events>
|
|
||||||
<AuxValues>
|
<AuxValues>
|
||||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new javax.swing.JComboBox<String>()"/>
|
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new javax.swing.JComboBox<String>()"/>
|
||||||
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="<String>"/>
|
||||||
@ -344,43 +344,43 @@
|
|||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="fileSizeCheckActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="fileSizeCheckActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JRadioButton" name="filesRadio">
|
<Component class="javax.swing.JRadioButton" name="filesRadioButton">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||||
<ComponentRef name="typeButtonGroup"/>
|
<ComponentRef name="typeButtonGroup"/>
|
||||||
</Property>
|
</Property>
|
||||||
<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/interestingitems/Bundle.properties" key="FilesSetRulePanel.filesRadio.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
<ResourceString bundle="org/sleuthkit/autopsy/modules/interestingitems/Bundle.properties" key="FilesSetRulePanel.filesRadioButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||||
</Property>
|
</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Events>
|
<Events>
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="filesRadioActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="filesRadioButtonActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JRadioButton" name="dirsRadio">
|
<Component class="javax.swing.JRadioButton" name="dirsRadioButton">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||||
<ComponentRef name="typeButtonGroup"/>
|
<ComponentRef name="typeButtonGroup"/>
|
||||||
</Property>
|
</Property>
|
||||||
<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/interestingitems/Bundle.properties" key="FilesSetRulePanel.dirsRadio.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
<ResourceString bundle="org/sleuthkit/autopsy/modules/interestingitems/Bundle.properties" key="FilesSetRulePanel.dirsRadioButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||||
</Property>
|
</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Events>
|
<Events>
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="dirsRadioActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="dirsRadioButtonActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
<Component class="javax.swing.JRadioButton" name="filesAndDirsRadio">
|
<Component class="javax.swing.JRadioButton" name="filesAndDirsRadioButton">
|
||||||
<Properties>
|
<Properties>
|
||||||
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
|
||||||
<ComponentRef name="typeButtonGroup"/>
|
<ComponentRef name="typeButtonGroup"/>
|
||||||
</Property>
|
</Property>
|
||||||
<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/interestingitems/Bundle.properties" key="FilesSetRulePanel.filesAndDirsRadio.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
<ResourceString bundle="org/sleuthkit/autopsy/modules/interestingitems/Bundle.properties" key="FilesSetRulePanel.filesAndDirsRadioButton.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||||
</Property>
|
</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
<Events>
|
<Events>
|
||||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="filesAndDirsRadioActionPerformed"/>
|
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="filesAndDirsRadioButtonActionPerformed"/>
|
||||||
</Events>
|
</Events>
|
||||||
</Component>
|
</Component>
|
||||||
</SubComponents>
|
</SubComponents>
|
||||||
|
@ -69,10 +69,11 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
|
|||||||
/**
|
/**
|
||||||
* Constructs a files set rule panel in create rule mode.
|
* Constructs a files set rule panel in create rule mode.
|
||||||
*/
|
*/
|
||||||
FilesSetRulePanel() {
|
FilesSetRulePanel(JButton okButton, JButton cancelButton) {
|
||||||
initComponents();
|
initComponents();
|
||||||
|
populateMimeTypesComboBox();
|
||||||
populateComponentsWithDefaultValues();
|
populateComponentsWithDefaultValues();
|
||||||
customInit();
|
this.setButtons(okButton, cancelButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -80,26 +81,29 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
|
|||||||
*
|
*
|
||||||
* @param rule The files set rule to be edited.
|
* @param rule The files set rule to be edited.
|
||||||
*/
|
*/
|
||||||
FilesSetRulePanel(FilesSet.Rule rule) {
|
FilesSetRulePanel(FilesSet.Rule rule, JButton okButton, JButton cancelButton) {
|
||||||
initComponents();
|
initComponents();
|
||||||
|
populateMimeTypesComboBox();
|
||||||
populateRuleNameComponent(rule);
|
populateRuleNameComponent(rule);
|
||||||
populateTypeConditionComponents(rule);
|
populateTypeConditionComponents(rule);
|
||||||
populateNameConditionComponents(rule);
|
populateNameConditionComponents(rule);
|
||||||
populatePathConditionComponents(rule);
|
populatePathConditionComponents(rule);
|
||||||
customInit();
|
populateMimeConditionComponents(rule);
|
||||||
|
this.setButtons(okButton, cancelButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Populates the UI components with default values.
|
* Populates the UI components with default values.
|
||||||
*/
|
*/
|
||||||
private void populateComponentsWithDefaultValues() {
|
private void populateComponentsWithDefaultValues() {
|
||||||
this.filesRadio.setSelected(true);
|
this.filesRadioButton.setSelected(true);
|
||||||
this.fullNameRadioButton.setSelected(true);
|
this.fullNameRadioButton.setSelected(true);
|
||||||
this.equalitySymbolComboBox.setSelectedIndex(2);
|
this.equalitySymbolComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.COMPARATOR.GREATER_THAN_EQUAL.getSymbol());
|
||||||
this.fileSizeComboBox.setSelectedIndex(1);
|
this.fileSizeComboBox.setSelectedItem(FilesSet.Rule.FileSizeCondition.SIZE_UNIT.KILOBYTE.getName());
|
||||||
|
this.mimeTypeComboBox.setSelectedIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void customInit() {
|
private void populateMimeTypesComboBox() {
|
||||||
Set<String> fileTypesCollated = new HashSet<>();
|
Set<String> fileTypesCollated = new HashSet<>();
|
||||||
for (MediaType mediaType : mediaTypes) {
|
for (MediaType mediaType : mediaTypes) {
|
||||||
fileTypesCollated.add(mediaType.toString());
|
fileTypesCollated.add(mediaType.toString());
|
||||||
@ -139,18 +143,21 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
|
|||||||
this.ruleNameTextField.setText(rule.getName());
|
this.ruleNameTextField.setText(rule.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void populateMimeConditionComponents(FilesSet.Rule rule) {
|
||||||
|
FilesSet.Rule.MimeTypeCondition mimeTypeCondition = rule.getMimeTypeCondition();
|
||||||
|
if (mimeTypeCondition != null) {
|
||||||
|
this.mimeTypeComboBox.setSelectedItem(mimeTypeCondition.getMimeType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets whether or not the OK button should be enabled based upon other UI
|
* Sets whether or not the OK button should be enabled based upon other UI
|
||||||
* elements
|
* elements
|
||||||
*/
|
*/
|
||||||
private void setOkButton() {
|
private void setOkButton() {
|
||||||
if (this.okButton != null) {
|
if (this.okButton != null) {
|
||||||
if (!(this.fileSizeCheck.isSelected() || this.mimeCheck.isSelected()
|
this.okButton.setEnabled(this.fileSizeCheck.isSelected() || this.mimeCheck.isSelected()
|
||||||
|| this.nameCheck.isSelected() || this.pathCheck.isSelected())) {
|
|| this.nameCheck.isSelected() || this.pathCheck.isSelected());
|
||||||
this.okButton.setEnabled(false);
|
|
||||||
} else {
|
|
||||||
this.okButton.setEnabled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -177,7 +184,7 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
|
|||||||
* @param ok The ok button
|
* @param ok The ok button
|
||||||
* @param cancel The cancel button
|
* @param cancel The cancel button
|
||||||
*/
|
*/
|
||||||
public void setButtons(JButton ok, JButton cancel) {
|
private void setButtons(JButton ok, JButton cancel) {
|
||||||
this.okButton = ok;
|
this.okButton = ok;
|
||||||
this.cancelButton = cancel;
|
this.cancelButton = cancel;
|
||||||
okButton.addActionListener(new ActionListener() {
|
okButton.addActionListener(new ActionListener() {
|
||||||
@ -207,13 +214,13 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
|
|||||||
FilesSet.Rule.MetaTypeCondition typeCondition = rule.getMetaTypeCondition();
|
FilesSet.Rule.MetaTypeCondition typeCondition = rule.getMetaTypeCondition();
|
||||||
switch (typeCondition.getMetaType()) {
|
switch (typeCondition.getMetaType()) {
|
||||||
case FILES:
|
case FILES:
|
||||||
this.filesRadio.setSelected(true);
|
this.filesRadioButton.setSelected(true);
|
||||||
break;
|
break;
|
||||||
case DIRECTORIES:
|
case DIRECTORIES:
|
||||||
this.dirsRadio.setSelected(true);
|
this.dirsRadioButton.setSelected(true);
|
||||||
break;
|
break;
|
||||||
case FILES_AND_DIRECTORIES:
|
case FILES_AND_DIRECTORIES:
|
||||||
this.filesAndDirsRadio.setSelected(true);
|
this.filesAndDirsRadioButton.setSelected(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -418,14 +425,10 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
|
|||||||
FilesSet.Rule.FileSizeCondition getFileSizeCondition() {
|
FilesSet.Rule.FileSizeCondition getFileSizeCondition() {
|
||||||
FilesSet.Rule.FileSizeCondition condition = null;
|
FilesSet.Rule.FileSizeCondition condition = null;
|
||||||
if ((Integer) this.fileSizeSpinner.getValue() != 0) {
|
if ((Integer) this.fileSizeSpinner.getValue() != 0) {
|
||||||
try {
|
|
||||||
FilesSet.Rule.FileSizeCondition.COMPARATOR comparator = FilesSet.Rule.FileSizeCondition.COMPARATOR.fromSymbol((String) this.equalitySymbolComboBox.getSelectedItem());
|
FilesSet.Rule.FileSizeCondition.COMPARATOR comparator = FilesSet.Rule.FileSizeCondition.COMPARATOR.fromSymbol((String) this.equalitySymbolComboBox.getSelectedItem());
|
||||||
FilesSet.Rule.FileSizeCondition.SIZE_UNIT unit = FilesSet.Rule.FileSizeCondition.SIZE_UNIT.fromName((String) this.fileSizeComboBox.getSelectedItem());
|
FilesSet.Rule.FileSizeCondition.SIZE_UNIT unit = FilesSet.Rule.FileSizeCondition.SIZE_UNIT.fromName((String) this.fileSizeComboBox.getSelectedItem());
|
||||||
int fileSizeValue = (Integer) this.fileSizeSpinner.getValue();
|
int fileSizeValue = (Integer) this.fileSizeSpinner.getValue();
|
||||||
condition = new FilesSet.Rule.FileSizeCondition(comparator, unit, fileSizeValue);
|
condition = new FilesSet.Rule.FileSizeCondition(comparator, unit, fileSizeValue);
|
||||||
} catch (IllegalArgumentException ex) {
|
|
||||||
//Swallowing up exception because if invalid data is given, this should return null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return condition;
|
return condition;
|
||||||
}
|
}
|
||||||
@ -437,9 +440,9 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
|
|||||||
* @return A type condition.
|
* @return A type condition.
|
||||||
*/
|
*/
|
||||||
FilesSet.Rule.MetaTypeCondition getMetaTypeCondition() {
|
FilesSet.Rule.MetaTypeCondition getMetaTypeCondition() {
|
||||||
if (this.filesRadio.isSelected()) {
|
if (this.filesRadioButton.isSelected()) {
|
||||||
return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
|
return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES);
|
||||||
} else if (this.dirsRadio.isSelected()) {
|
} else if (this.dirsRadioButton.isSelected()) {
|
||||||
return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.DIRECTORIES);
|
return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.DIRECTORIES);
|
||||||
} else {
|
} else {
|
||||||
return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES_AND_DIRECTORIES);
|
return new FilesSet.Rule.MetaTypeCondition(FilesSet.Rule.MetaTypeCondition.Type.FILES_AND_DIRECTORIES);
|
||||||
@ -509,7 +512,7 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
|
|||||||
* state of the UI components in the type button group.
|
* state of the UI components in the type button group.
|
||||||
*/
|
*/
|
||||||
private void setComponentsForSearchType() {
|
private void setComponentsForSearchType() {
|
||||||
if (!this.filesRadio.isSelected()) {
|
if (!this.filesRadioButton.isSelected()) {
|
||||||
this.fullNameRadioButton.setSelected(true);
|
this.fullNameRadioButton.setSelected(true);
|
||||||
this.extensionRadioButton.setEnabled(false);
|
this.extensionRadioButton.setEnabled(false);
|
||||||
this.mimeTypeComboBox.setEnabled(false);
|
this.mimeTypeComboBox.setEnabled(false);
|
||||||
@ -560,9 +563,9 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
|
|||||||
pathCheck = new javax.swing.JCheckBox();
|
pathCheck = new javax.swing.JCheckBox();
|
||||||
mimeCheck = new javax.swing.JCheckBox();
|
mimeCheck = new javax.swing.JCheckBox();
|
||||||
fileSizeCheck = new javax.swing.JCheckBox();
|
fileSizeCheck = new javax.swing.JCheckBox();
|
||||||
filesRadio = new javax.swing.JRadioButton();
|
filesRadioButton = new javax.swing.JRadioButton();
|
||||||
dirsRadio = new javax.swing.JRadioButton();
|
dirsRadioButton = new javax.swing.JRadioButton();
|
||||||
filesAndDirsRadio = new javax.swing.JRadioButton();
|
filesAndDirsRadioButton = new javax.swing.JRadioButton();
|
||||||
|
|
||||||
org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.ruleNameLabel.text")); // NOI18N
|
org.openide.awt.Mnemonics.setLocalizedText(ruleNameLabel, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.ruleNameLabel.text")); // NOI18N
|
||||||
|
|
||||||
@ -581,6 +584,11 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
|
|||||||
nameButtonGroup.add(fullNameRadioButton);
|
nameButtonGroup.add(fullNameRadioButton);
|
||||||
org.openide.awt.Mnemonics.setLocalizedText(fullNameRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.fullNameRadioButton.text")); // NOI18N
|
org.openide.awt.Mnemonics.setLocalizedText(fullNameRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.fullNameRadioButton.text")); // NOI18N
|
||||||
fullNameRadioButton.setEnabled(false);
|
fullNameRadioButton.setEnabled(false);
|
||||||
|
fullNameRadioButton.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
|
fullNameRadioButtonActionPerformed(evt);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
nameButtonGroup.add(extensionRadioButton);
|
nameButtonGroup.add(extensionRadioButton);
|
||||||
org.openide.awt.Mnemonics.setLocalizedText(extensionRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.extensionRadioButton.text")); // NOI18N
|
org.openide.awt.Mnemonics.setLocalizedText(extensionRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.extensionRadioButton.text")); // NOI18N
|
||||||
@ -604,11 +612,6 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
|
|||||||
mimeTypeComboBox.setEditable(true);
|
mimeTypeComboBox.setEditable(true);
|
||||||
mimeTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] {""}));
|
mimeTypeComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] {""}));
|
||||||
mimeTypeComboBox.setEnabled(false);
|
mimeTypeComboBox.setEnabled(false);
|
||||||
mimeTypeComboBox.addActionListener(new java.awt.event.ActionListener() {
|
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
|
||||||
mimeTypeComboBoxActionPerformed(evt);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
equalitySymbolComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] { "=", ">", "≥", "<", "≤" }));
|
equalitySymbolComboBox.setModel(new javax.swing.DefaultComboBoxModel<String>(new String[] { "=", ">", "≥", "<", "≤" }));
|
||||||
equalitySymbolComboBox.setEnabled(false);
|
equalitySymbolComboBox.setEnabled(false);
|
||||||
@ -647,27 +650,27 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
typeButtonGroup.add(filesRadio);
|
typeButtonGroup.add(filesRadioButton);
|
||||||
org.openide.awt.Mnemonics.setLocalizedText(filesRadio, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.filesRadio.text")); // NOI18N
|
org.openide.awt.Mnemonics.setLocalizedText(filesRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.filesRadioButton.text")); // NOI18N
|
||||||
filesRadio.addActionListener(new java.awt.event.ActionListener() {
|
filesRadioButton.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
filesRadioActionPerformed(evt);
|
filesRadioButtonActionPerformed(evt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
typeButtonGroup.add(dirsRadio);
|
typeButtonGroup.add(dirsRadioButton);
|
||||||
org.openide.awt.Mnemonics.setLocalizedText(dirsRadio, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.dirsRadio.text")); // NOI18N
|
org.openide.awt.Mnemonics.setLocalizedText(dirsRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.dirsRadioButton.text")); // NOI18N
|
||||||
dirsRadio.addActionListener(new java.awt.event.ActionListener() {
|
dirsRadioButton.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
dirsRadioActionPerformed(evt);
|
dirsRadioButtonActionPerformed(evt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
typeButtonGroup.add(filesAndDirsRadio);
|
typeButtonGroup.add(filesAndDirsRadioButton);
|
||||||
org.openide.awt.Mnemonics.setLocalizedText(filesAndDirsRadio, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.filesAndDirsRadio.text")); // NOI18N
|
org.openide.awt.Mnemonics.setLocalizedText(filesAndDirsRadioButton, org.openide.util.NbBundle.getMessage(FilesSetRulePanel.class, "FilesSetRulePanel.filesAndDirsRadioButton.text")); // NOI18N
|
||||||
filesAndDirsRadio.addActionListener(new java.awt.event.ActionListener() {
|
filesAndDirsRadioButton.addActionListener(new java.awt.event.ActionListener() {
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
filesAndDirsRadioActionPerformed(evt);
|
filesAndDirsRadioButtonActionPerformed(evt);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -690,11 +693,11 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
|
|||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addComponent(jLabel1)
|
.addComponent(jLabel1)
|
||||||
.addGap(65, 65, 65)
|
.addGap(65, 65, 65)
|
||||||
.addComponent(filesRadio)
|
.addComponent(filesRadioButton)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(dirsRadio)
|
.addComponent(dirsRadioButton)
|
||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addComponent(filesAndDirsRadio)))
|
.addComponent(filesAndDirsRadioButton)))
|
||||||
.addGap(0, 0, Short.MAX_VALUE))))
|
.addGap(0, 0, Short.MAX_VALUE))))
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
@ -743,9 +746,9 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
|
|||||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(jLabel1)
|
.addComponent(jLabel1)
|
||||||
.addComponent(filesRadio)
|
.addComponent(filesRadioButton)
|
||||||
.addComponent(dirsRadio)
|
.addComponent(dirsRadioButton)
|
||||||
.addComponent(filesAndDirsRadio))
|
.addComponent(filesAndDirsRadioButton))
|
||||||
.addGap(5, 5, 5)
|
.addGap(5, 5, 5)
|
||||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||||
.addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
|
.addComponent(nameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||||
@ -839,32 +842,32 @@ final class FilesSetRulePanel extends javax.swing.JPanel {
|
|||||||
this.setOkButton();
|
this.setOkButton();
|
||||||
}//GEN-LAST:event_fileSizeCheckActionPerformed
|
}//GEN-LAST:event_fileSizeCheckActionPerformed
|
||||||
|
|
||||||
private void mimeTypeComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_mimeTypeComboBoxActionPerformed
|
private void filesRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filesRadioButtonActionPerformed
|
||||||
|
|
||||||
|
this.setComponentsForSearchType();
|
||||||
|
}//GEN-LAST:event_filesRadioButtonActionPerformed
|
||||||
|
|
||||||
|
private void dirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dirsRadioButtonActionPerformed
|
||||||
|
this.setComponentsForSearchType();
|
||||||
|
}//GEN-LAST:event_dirsRadioButtonActionPerformed
|
||||||
|
|
||||||
|
private void filesAndDirsRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filesAndDirsRadioButtonActionPerformed
|
||||||
|
this.setComponentsForSearchType();
|
||||||
|
}//GEN-LAST:event_filesAndDirsRadioButtonActionPerformed
|
||||||
|
|
||||||
|
private void fullNameRadioButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_fullNameRadioButtonActionPerformed
|
||||||
// TODO add your handling code here:
|
// TODO add your handling code here:
|
||||||
}//GEN-LAST:event_mimeTypeComboBoxActionPerformed
|
}//GEN-LAST:event_fullNameRadioButtonActionPerformed
|
||||||
|
|
||||||
private void filesRadioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filesRadioActionPerformed
|
|
||||||
|
|
||||||
this.setComponentsForSearchType();
|
|
||||||
}//GEN-LAST:event_filesRadioActionPerformed
|
|
||||||
|
|
||||||
private void dirsRadioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_dirsRadioActionPerformed
|
|
||||||
this.setComponentsForSearchType();
|
|
||||||
}//GEN-LAST:event_dirsRadioActionPerformed
|
|
||||||
|
|
||||||
private void filesAndDirsRadioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filesAndDirsRadioActionPerformed
|
|
||||||
this.setComponentsForSearchType();
|
|
||||||
}//GEN-LAST:event_filesAndDirsRadioActionPerformed
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JRadioButton dirsRadio;
|
private javax.swing.JRadioButton dirsRadioButton;
|
||||||
private javax.swing.JComboBox<String> equalitySymbolComboBox;
|
private javax.swing.JComboBox<String> equalitySymbolComboBox;
|
||||||
private javax.swing.JRadioButton extensionRadioButton;
|
private javax.swing.JRadioButton extensionRadioButton;
|
||||||
private javax.swing.JCheckBox fileSizeCheck;
|
private javax.swing.JCheckBox fileSizeCheck;
|
||||||
private javax.swing.JComboBox<String> fileSizeComboBox;
|
private javax.swing.JComboBox<String> fileSizeComboBox;
|
||||||
private javax.swing.JSpinner fileSizeSpinner;
|
private javax.swing.JSpinner fileSizeSpinner;
|
||||||
private javax.swing.JRadioButton filesAndDirsRadio;
|
private javax.swing.JRadioButton filesAndDirsRadioButton;
|
||||||
private javax.swing.JRadioButton filesRadio;
|
private javax.swing.JRadioButton filesRadioButton;
|
||||||
private javax.swing.JRadioButton fullNameRadioButton;
|
private javax.swing.JRadioButton fullNameRadioButton;
|
||||||
private javax.swing.JLabel jLabel1;
|
private javax.swing.JLabel jLabel1;
|
||||||
private javax.swing.JLabel jLabel5;
|
private javax.swing.JLabel jLabel5;
|
||||||
|
@ -32,11 +32,6 @@ import java.util.Observable;
|
|||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.regex.PatternSyntaxException;
|
import java.util.regex.PatternSyntaxException;
|
||||||
import javax.persistence.PersistenceException;
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
|
||||||
import javax.xml.parsers.ParserConfigurationException;
|
|
||||||
import org.openide.util.Exceptions;
|
|
||||||
import org.openide.util.io.NbObjectInputStream;
|
import org.openide.util.io.NbObjectInputStream;
|
||||||
import org.openide.util.io.NbObjectOutputStream;
|
import org.openide.util.io.NbObjectOutputStream;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
@ -97,7 +92,7 @@ final class InterestingItemDefsManager extends Observable {
|
|||||||
* @return A map of interesting files set names to interesting file sets,
|
* @return A map of interesting files set names to interesting file sets,
|
||||||
* possibly empty.
|
* possibly empty.
|
||||||
*/
|
*/
|
||||||
synchronized Map<String, FilesSet> getInterestingFilesSets() {
|
synchronized Map<String, FilesSet> getInterestingFilesSets() throws InterestingItemDefsManagerException {
|
||||||
return FilesSetXML.readDefinitionsFile(DEFAULT_FILE_SET_DEFS_PATH);
|
return FilesSetXML.readDefinitionsFile(DEFAULT_FILE_SET_DEFS_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,7 +103,7 @@ final class InterestingItemDefsManager extends Observable {
|
|||||||
* @param filesSets A mapping of interesting files set names to files sets,
|
* @param filesSets A mapping of interesting files set names to files sets,
|
||||||
* used to enforce unique files set names.
|
* used to enforce unique files set names.
|
||||||
*/
|
*/
|
||||||
synchronized void setInterestingFilesSets(Map<String, FilesSet> filesSets) {
|
synchronized void setInterestingFilesSets(Map<String, FilesSet> filesSets) throws InterestingItemDefsManagerException {
|
||||||
FilesSetXML.writeDefinitionsFile(INTERESTING_FILES_SET_DEFS_SERIALIZATION_PATH, filesSets);
|
FilesSetXML.writeDefinitionsFile(INTERESTING_FILES_SET_DEFS_SERIALIZATION_PATH, filesSets);
|
||||||
this.setChanged();
|
this.setChanged();
|
||||||
this.notifyObservers();
|
this.notifyObservers();
|
||||||
@ -139,21 +134,6 @@ final class InterestingItemDefsManager extends Observable {
|
|||||||
private static final String TYPE_FILTER_VALUE_FILES = "file"; //NON-NLS
|
private static final String TYPE_FILTER_VALUE_FILES = "file"; //NON-NLS
|
||||||
private static final String TYPE_FILTER_VALUE_DIRS = "dir"; //NON-NLS
|
private static final String TYPE_FILTER_VALUE_DIRS = "dir"; //NON-NLS
|
||||||
|
|
||||||
// The following tags and attributes are currently specific to the
|
|
||||||
// Autopsy implementation of interesting files set definitions. Autopsy
|
|
||||||
// definitions that use these will not be able to be used by TSK
|
|
||||||
// Framework. However, Autopsy can accept TSK Framework definitions:
|
|
||||||
//
|
|
||||||
// 1. Rules do not have names in the TSK Framework schema, but rules do
|
|
||||||
// have names in the Autopsy schema. Names will be synthesized as needed
|
|
||||||
// to allow Autopsy to use TSK Framework interesting files set
|
|
||||||
// definitions.
|
|
||||||
// 2. The TSK Framework has an interesting files module that supports
|
|
||||||
// simple globbing with "*" characters. Name rules and path conditions with
|
|
||||||
// "*" characters will be converted to regexes to allow Autopsy to use
|
|
||||||
// TSK Framework interesting files set definitions.
|
|
||||||
// 3. Type conditions are required by Autopsy, but not by TSK Frmaework.
|
|
||||||
// Missing type conditions will defualt to "files" conditions.
|
|
||||||
private static final String REGEX_ATTR = "regex"; //NON-NLS
|
private static final String REGEX_ATTR = "regex"; //NON-NLS
|
||||||
private static final String PATH_REGEX_ATTR = "pathRegex"; //NON-NLS
|
private static final String PATH_REGEX_ATTR = "pathRegex"; //NON-NLS
|
||||||
private static final String TYPE_FILTER_VALUE_FILES_AND_DIRS = "files_and_dirs"; //NON-NLS
|
private static final String TYPE_FILTER_VALUE_FILES_AND_DIRS = "files_and_dirs"; //NON-NLS
|
||||||
@ -170,10 +150,10 @@ final class InterestingItemDefsManager extends Observable {
|
|||||||
// Note: This method takes a file path to support the possibility of
|
// Note: This method takes a file path to support the possibility of
|
||||||
// multiple intersting files set definition files, e.g., one for
|
// multiple intersting files set definition files, e.g., one for
|
||||||
// definitions that ship with Autopsy and one for user definitions.
|
// definitions that ship with Autopsy and one for user definitions.
|
||||||
static Map<String, FilesSet> readDefinitionsFile(String filePath) {
|
static Map<String, FilesSet> readDefinitionsFile(String filePath) throws InterestingItemDefsManagerException {
|
||||||
Map<String, FilesSet> filesSets = new HashMap<>();
|
Map<String, FilesSet> filesSets = new HashMap<>();
|
||||||
|
|
||||||
// Check if the file exists.
|
// Check if the legacy xml file exists.
|
||||||
File defsFile = new File(filePath);
|
File defsFile = new File(filePath);
|
||||||
if (!defsFile.exists()) {
|
if (!defsFile.exists()) {
|
||||||
return readSerializedDefinitions();
|
return readSerializedDefinitions();
|
||||||
@ -207,8 +187,9 @@ final class InterestingItemDefsManager extends Observable {
|
|||||||
return filesSets;
|
return filesSets;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Map<String, FilesSet> readSerializedDefinitions() {
|
private static Map<String, FilesSet> readSerializedDefinitions() throws InterestingItemDefsManagerException {
|
||||||
String filePath = INTERESTING_FILES_SET_DEFS_SERIALIZATION_PATH;
|
throw new InterestingItemDefsManagerException("Test");
|
||||||
|
/*String filePath = INTERESTING_FILES_SET_DEFS_SERIALIZATION_PATH;
|
||||||
File fileSetFile = new File(filePath);
|
File fileSetFile = new File(filePath);
|
||||||
if (fileSetFile.exists()) {
|
if (fileSetFile.exists()) {
|
||||||
try {
|
try {
|
||||||
@ -217,11 +198,11 @@ final class InterestingItemDefsManager extends Observable {
|
|||||||
return filesSetsSettings.getFilesSets();
|
return filesSetsSettings.getFilesSets();
|
||||||
}
|
}
|
||||||
} catch (IOException | ClassNotFoundException ex) {
|
} catch (IOException | ClassNotFoundException ex) {
|
||||||
throw new PersistenceException(String.format("Failed to read settings from %s", filePath), ex);
|
throw new InterestingItemDefsManagerException(String.format("Failed to read settings from %s", filePath), ex);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return new HashMap<String, FilesSet>();
|
return new HashMap<String, FilesSet>();
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -524,11 +505,11 @@ final class InterestingItemDefsManager extends Observable {
|
|||||||
// Note: This method takes a file path to support the possibility of
|
// Note: This method takes a file path to support the possibility of
|
||||||
// multiple intersting files set definition files, e.g., one for
|
// multiple intersting files set definition files, e.g., one for
|
||||||
// definitions that ship with Autopsy and one for user definitions.
|
// definitions that ship with Autopsy and one for user definitions.
|
||||||
static boolean writeDefinitionsFile(String filePath, Map<String, FilesSet> interestingFilesSets) {
|
static boolean writeDefinitionsFile(String filePath, Map<String, FilesSet> interestingFilesSets) throws InterestingItemDefsManagerException {
|
||||||
try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(filePath))) {
|
try (NbObjectOutputStream out = new NbObjectOutputStream(new FileOutputStream(filePath))) {
|
||||||
out.writeObject(new InterestingItemsFilesSetSettings(interestingFilesSets));
|
out.writeObject(new InterestingItemsFilesSetSettings(interestingFilesSets));
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
throw new PersistenceException(String.format("Failed to write settings to %s", filePath), ex);
|
throw new InterestingItemDefsManagerException(String.format("Failed to write settings to %s", filePath), ex);
|
||||||
}
|
}
|
||||||
File xmlFile = new File(DEFAULT_FILE_SET_DEFS_PATH);
|
File xmlFile = new File(DEFAULT_FILE_SET_DEFS_PATH);
|
||||||
if (xmlFile.exists()) {
|
if (xmlFile.exists()) {
|
||||||
@ -538,4 +519,19 @@ final class InterestingItemDefsManager extends Observable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static class InterestingItemDefsManagerException extends Exception {
|
||||||
|
InterestingItemDefsManagerException() {
|
||||||
|
|
||||||
|
}
|
||||||
|
InterestingItemDefsManagerException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
InterestingItemDefsManagerException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
InterestingItemDefsManagerException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ import org.sleuthkit.autopsy.ingest.IngestModuleGlobalSettingsPanel;
|
|||||||
import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector;
|
import org.sleuthkit.autopsy.modules.filetypeid.FileTypeDetector;
|
||||||
import org.apache.tika.mime.MediaType;
|
import org.apache.tika.mime.MediaType;
|
||||||
import org.apache.tika.mime.MimeTypes;
|
import org.apache.tika.mime.MimeTypes;
|
||||||
|
import org.openide.util.Exceptions;
|
||||||
import org.sleuthkit.autopsy.coreutils.Logger;
|
import org.sleuthkit.autopsy.coreutils.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -121,7 +122,11 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void saveSettings() {
|
public void saveSettings() {
|
||||||
|
try {
|
||||||
InterestingItemDefsManager.getInstance().setInterestingFilesSets(this.filesSets);
|
InterestingItemDefsManager.getInstance().setInterestingFilesSets(this.filesSets);
|
||||||
|
} catch (InterestingItemDefsManager.InterestingItemDefsManagerException ex) {
|
||||||
|
MessageNotifyUtil.Message.error("Test Error");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -139,9 +144,13 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp
|
|||||||
public void load() {
|
public void load() {
|
||||||
this.resetComponents();
|
this.resetComponents();
|
||||||
|
|
||||||
|
try {
|
||||||
// Get a working copy of the interesting files set definitions and sort
|
// Get a working copy of the interesting files set definitions and sort
|
||||||
// by set name.
|
// by set name.
|
||||||
this.filesSets = new TreeMap<>(InterestingItemDefsManager.getInstance().getInterestingFilesSets());
|
this.filesSets = new TreeMap<>(InterestingItemDefsManager.getInstance().getInterestingFilesSets());
|
||||||
|
} catch (InterestingItemDefsManager.InterestingItemDefsManagerException ex) {
|
||||||
|
MessageNotifyUtil.Message.error("Test error");
|
||||||
|
}
|
||||||
|
|
||||||
// Populate the list model for the interesting files sets list
|
// Populate the list model for the interesting files sets list
|
||||||
// component.
|
// component.
|
||||||
@ -369,12 +378,11 @@ final class InterestingItemDefsPanel extends IngestModuleGlobalSettingsPanel imp
|
|||||||
FilesSetRulePanel panel;
|
FilesSetRulePanel panel;
|
||||||
if (selectedRule != null) {
|
if (selectedRule != null) {
|
||||||
// Editing an existing rule definition.
|
// Editing an existing rule definition.
|
||||||
panel = new FilesSetRulePanel(selectedRule);
|
panel = new FilesSetRulePanel(selectedRule, okButton, cancelButton);
|
||||||
} else {
|
} else {
|
||||||
// Creating a new rule definition.
|
// Creating a new rule definition.
|
||||||
panel = new FilesSetRulePanel();
|
panel = new FilesSetRulePanel(okButton, cancelButton);
|
||||||
}
|
}
|
||||||
panel.setButtons(okButton, cancelButton);
|
|
||||||
// Do a dialog box with the files set panel until the user either enters
|
// Do a dialog box with the files set panel until the user either enters
|
||||||
// a valid definition or cancels. Note that the panel gives the user
|
// a valid definition or cancels. Note that the panel gives the user
|
||||||
// feedback when isValidDefinition() is called.
|
// feedback when isValidDefinition() is called.
|
||||||
|
@ -20,8 +20,10 @@ package org.sleuthkit.autopsy.modules.interestingitems;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import org.openide.util.Exceptions;
|
||||||
import org.openide.util.NbBundle;
|
import org.openide.util.NbBundle;
|
||||||
import org.openide.util.lookup.ServiceProvider;
|
import org.openide.util.lookup.ServiceProvider;
|
||||||
|
import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
|
||||||
import org.sleuthkit.autopsy.coreutils.Version;
|
import org.sleuthkit.autopsy.coreutils.Version;
|
||||||
import org.sleuthkit.autopsy.ingest.FileIngestModule;
|
import org.sleuthkit.autopsy.ingest.FileIngestModule;
|
||||||
import org.sleuthkit.autopsy.ingest.IngestModuleFactory;
|
import org.sleuthkit.autopsy.ingest.IngestModuleFactory;
|
||||||
@ -76,9 +78,13 @@ final public class InterestingItemsIngestModuleFactory extends IngestModuleFacto
|
|||||||
// definitions independent of the rules that make up the defintions.
|
// definitions independent of the rules that make up the defintions.
|
||||||
// Doing so also keeps the serialization simple.
|
// Doing so also keeps the serialization simple.
|
||||||
List<String> enabledFilesSetNames = new ArrayList<>();
|
List<String> enabledFilesSetNames = new ArrayList<>();
|
||||||
|
try {
|
||||||
for (String name : InterestingItemDefsManager.getInstance().getInterestingFilesSets().keySet()) {
|
for (String name : InterestingItemDefsManager.getInstance().getInterestingFilesSets().keySet()) {
|
||||||
enabledFilesSetNames.add(name);
|
enabledFilesSetNames.add(name);
|
||||||
}
|
}
|
||||||
|
} catch (InterestingItemDefsManager.InterestingItemDefsManagerException ex) {
|
||||||
|
MessageNotifyUtil.Message.error("Test Error");
|
||||||
|
}
|
||||||
return new FilesIdentifierIngestJobSettings(enabledFilesSetNames);
|
return new FilesIdentifierIngestJobSettings(enabledFilesSetNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user