5661 address some codacy complaints

This commit is contained in:
William Schaefer 2019-12-09 16:06:57 -05:00
parent 685a3f1b81
commit c16198cd48
19 changed files with 271 additions and 148 deletions

View File

@ -81,13 +81,45 @@ class DataSourceModulesWrapper {
if (hashModuleRun && fileTypeModuleRun && exifModuleRun) {
return;
}
if (!hashModuleRun && moduleInfo.getDisplayName().equals(HashLookupModuleFactory.getModuleName())) {
hashModuleRun = true;
} else if (!fileTypeModuleRun && moduleInfo.getDisplayName().equals(FileTypeIdModuleFactory.getModuleName())) {
fileTypeModuleRun = true;
} else if (!exifModuleRun && moduleInfo.getDisplayName().equals(ExifParserModuleFactory.getModuleName())) {
exifModuleRun = true;
}
updateHashModuleStatus(moduleInfo);
updateFileTypeStatus(moduleInfo);
updateExifStatus(moduleInfo);
}
}
/**
* Update whether the Hash Lookup module was run for this data source.
*
* @param moduleInfo Information regarding a module which was run on this
* data source.
*/
private void updateHashModuleStatus(IngestModuleInfo moduleInfo) {
if (!hashModuleRun && moduleInfo.getDisplayName().equals(HashLookupModuleFactory.getModuleName())) {
hashModuleRun = true;
}
}
/**
* Update whether the File Type ID module was run for this data source.
*
* @param moduleInfo Information regarding a module which was run on this
* data source.
*/
private void updateFileTypeStatus(IngestModuleInfo moduleInfo) {
if (!fileTypeModuleRun && moduleInfo.getDisplayName().equals(FileTypeIdModuleFactory.getModuleName())) {
fileTypeModuleRun = true;
}
}
/**
* Update whether the Exif module was run for this data source.
*
* @param moduleInfo Information regarding a module which was run on this
* data source.
*/
private void updateExifStatus(IngestModuleInfo moduleInfo) {
if (!exifModuleRun && moduleInfo.getDisplayName().equals(ExifParserModuleFactory.getModuleName())) {
exifModuleRun = true;
}
}
}

View File

@ -28,7 +28,7 @@ import org.sleuthkit.autopsy.filequery.FileSearchData.FileType;
/**
* Class to handle event bus and events for file discovery tool.
*/
final class DiscoveryEvents {
final class DiscoveryEventUtils {
private final static EventBus discoveryEventBus = new EventBus();
@ -41,7 +41,7 @@ final class DiscoveryEvents {
return discoveryEventBus;
}
private DiscoveryEvents() {
private DiscoveryEventUtils() {
}
/**

View File

@ -174,6 +174,10 @@
<ResourceString bundle="org/sleuthkit/autopsy/filequery/Bundle.properties" key="DiscoveryTopComponent.stepOneLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
<Component class="javax.swing.JButton" name="videosButton">
<Properties>
@ -218,6 +222,8 @@
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.HorizontalStrut"/>
</AuxValues>
</Component>

View File

@ -127,19 +127,19 @@ public final class DiscoveryTopComponent extends TopComponent {
public void componentOpened() {
super.componentOpened();
WindowManager.getDefault().setTopComponentFloating(this, true);
DiscoveryEvents.getDiscoveryEventBus().register(this);
DiscoveryEvents.getDiscoveryEventBus().register(resultsPanel);
DiscoveryEvents.getDiscoveryEventBus().register(groupListPanel);
DiscoveryEvents.getDiscoveryEventBus().register(fileSearchPanel);
DiscoveryEventUtils.getDiscoveryEventBus().register(this);
DiscoveryEventUtils.getDiscoveryEventBus().register(resultsPanel);
DiscoveryEventUtils.getDiscoveryEventBus().register(groupListPanel);
DiscoveryEventUtils.getDiscoveryEventBus().register(fileSearchPanel);
}
@Override
protected void componentClosed() {
fileSearchPanel.cancelSearch();
DiscoveryEvents.getDiscoveryEventBus().unregister(this);
DiscoveryEvents.getDiscoveryEventBus().unregister(fileSearchPanel);
DiscoveryEvents.getDiscoveryEventBus().unregister(groupListPanel);
DiscoveryEvents.getDiscoveryEventBus().unregister(resultsPanel);
DiscoveryEventUtils.getDiscoveryEventBus().unregister(this);
DiscoveryEventUtils.getDiscoveryEventBus().unregister(fileSearchPanel);
DiscoveryEventUtils.getDiscoveryEventBus().unregister(groupListPanel);
DiscoveryEventUtils.getDiscoveryEventBus().unregister(resultsPanel);
super.componentClosed();
}
@ -158,9 +158,9 @@ public final class DiscoveryTopComponent extends TopComponent {
javax.swing.JPanel toolBarPanel = new javax.swing.JPanel();
javax.swing.JToolBar toolBar = new javax.swing.JToolBar();
imagesButton = new javax.swing.JButton();
stepOneLabel = new javax.swing.JLabel();
javax.swing.JLabel stepOneLabel = new javax.swing.JLabel();
videosButton = new javax.swing.JButton();
filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(62, 0), new java.awt.Dimension(62, 0), new java.awt.Dimension(62, 32767));
javax.swing.Box.Filler filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(62, 0), new java.awt.Dimension(62, 0), new java.awt.Dimension(62, 32767));
setPreferredSize(new java.awt.Dimension(1400, 900));
setLayout(new java.awt.BorderLayout());
@ -282,7 +282,7 @@ public final class DiscoveryTopComponent extends TopComponent {
* @param searchCancelledEvent The SearchCancelledEvent received.
*/
@Subscribe
void handleSearchCancelledEvent(DiscoveryEvents.SearchCancelledEvent searchCancelledEvent) {
void handleSearchCancelledEvent(DiscoveryEventUtils.SearchCancelledEvent searchCancelledEvent) {
SwingUtilities.invokeLater(() -> {
if (fileSearchPanel.getSelectedType() == FileType.VIDEO) {
imagesButton.setEnabled(true);
@ -298,7 +298,7 @@ public final class DiscoveryTopComponent extends TopComponent {
* @param searchCompletedEvent The SearchCompletedEvent received.
*/
@Subscribe
void handleSearchCompletedEvent(DiscoveryEvents.SearchCompleteEvent searchCompletedEvent) {
void handleSearchCompletedEvent(DiscoveryEventUtils.SearchCompleteEvent searchCompletedEvent) {
SwingUtilities.invokeLater(() -> {
if (fileSearchPanel.getSelectedType() == FileType.VIDEO) {
imagesButton.setEnabled(true);
@ -325,7 +325,7 @@ public final class DiscoveryTopComponent extends TopComponent {
* @param searchStartedEvent The SearchStartedEvent received.
*/
@Subscribe
void handleSearchStartedEvent(DiscoveryEvents.SearchStartedEvent searchStartedEvent) {
void handleSearchStartedEvent(DiscoveryEventUtils.SearchStartedEvent searchStartedEvent) {
SwingUtilities.invokeLater(() -> {
imagesButton.setEnabled(false);
videosButton.setEnabled(false);
@ -333,11 +333,9 @@ public final class DiscoveryTopComponent extends TopComponent {
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.Box.Filler filler1;
private javax.swing.JButton imagesButton;
private javax.swing.JSplitPane leftSplitPane;
private javax.swing.JSplitPane rightSplitPane;
private javax.swing.JLabel stepOneLabel;
private javax.swing.JButton videosButton;
// End of variables declaration//GEN-END:variables

View File

@ -803,6 +803,16 @@ class FileSearch {
parent = null;
}
}
setParentPathAndID(parent, file);
}
/**
* Helper method to set the parent path and parent ID.
*
* @param parent The parent content object.
* @param file The ResultFile object.
*/
private void setParentPathAndID(Content parent, ResultFile file) {
if (parent != null) {
try {
parentPath = parent.getUniquePath();
@ -1207,29 +1217,41 @@ class FileSearch {
}
}
} else {
// Set frequency in batches
List<ResultFile> currentFiles = new ArrayList<>();
Set<String> hashesToLookUp = new HashSet<>();
for (ResultFile file : files) {
if (file.getFirstInstance().getKnown() == TskData.FileKnown.KNOWN) {
file.setFrequency(Frequency.KNOWN);
}
if (file.getFrequency() == Frequency.UNKNOWN
&& file.getFirstInstance().getMd5Hash() != null
&& !file.getFirstInstance().getMd5Hash().isEmpty()) {
hashesToLookUp.add(file.getFirstInstance().getMd5Hash());
currentFiles.add(file);
}
if (hashesToLookUp.size() >= BATCH_SIZE) {
computeFrequency(hashesToLookUp, currentFiles, centralRepoDb);
hashesToLookUp.clear();
currentFiles.clear();
}
}
computeFrequency(hashesToLookUp, currentFiles, centralRepoDb);
processResultFilesForCR(files, centralRepoDb);
}
}
/**
* Private helper method for adding Frequency attribute when CR is
* enabled.
*
* @param files The list of ResultFiles to caluclate frequency
* for.
* @param centralRepoDb The central repository currently in use.
*/
private void processResultFilesForCR(List<ResultFile> files,
EamDb centralRepoDb) {
List<ResultFile> currentFiles = new ArrayList<>();
Set<String> hashesToLookUp = new HashSet<>();
for (ResultFile file : files) {
if (file.getFirstInstance().getKnown() == TskData.FileKnown.KNOWN) {
file.setFrequency(Frequency.KNOWN);
}
if (file.getFrequency() == Frequency.UNKNOWN
&& file.getFirstInstance().getMd5Hash() != null
&& !file.getFirstInstance().getMd5Hash().isEmpty()) {
hashesToLookUp.add(file.getFirstInstance().getMd5Hash());
currentFiles.add(file);
}
if (hashesToLookUp.size() >= BATCH_SIZE) {
computeFrequency(hashesToLookUp, currentFiles, centralRepoDb);
hashesToLookUp.clear();
currentFiles.clear();
}
}
computeFrequency(hashesToLookUp, currentFiles, centralRepoDb);
}
}
/**

View File

@ -29,7 +29,7 @@ import org.sleuthkit.autopsy.coreutils.FileTypeUtils;
/**
* Utility enums for FileSearch
*/
class FileSearchData {
final class FileSearchData {
private final static long BYTES_PER_MB = 1000000;
@ -293,7 +293,7 @@ class FileSearchData {
private final String displayName;
private final Collection<String> mediaTypes;
private FileType(int value, String displayName, Collection<String> mediaTypes) {
FileType(int value, String displayName, Collection<String> mediaTypes) {
this.ranking = value;
this.displayName = displayName;
this.mediaTypes = mediaTypes;

View File

@ -88,42 +88,57 @@ class FileSearchFiltering {
// The file search filter is required, so this should never be empty.
throw new FileSearchException("Selected filters do not include a case database query");
}
try {
// Get all matching abstract files
List<ResultFile> resultList = new ArrayList<>();
logger.log(Level.INFO, "Running SQL query: {0}", combinedQuery);
List<AbstractFile> sqlResults = caseDb.findAllFilesWhere(combinedQuery);
// If there are no results, return now
if (sqlResults.isEmpty()) {
return resultList;
}
// Wrap each result in a ResultFile
for (AbstractFile abstractFile : sqlResults) {
resultList.add(new ResultFile(abstractFile));
}
// Now run any non-SQL filters.
for (FileFilter filter : filters) {
if (filter.useAlternateFilter()) {
resultList = filter.applyAlternateFilter(resultList, caseDb, centralRepoDb);
}
// There are no matches for the filters run so far, so return
if (resultList.isEmpty()) {
return resultList;
}
}
return resultList;
return getResultList(filters, combinedQuery, caseDb, centralRepoDb);
} catch (TskCoreException ex) {
throw new FileSearchException("Error querying case database", ex); // NON-NLS
}
}
/**
* Private helper method for runQueries method to get the ResultFile list.
*
* @param filters The filters to run.
* @param combinedQuery The query to get results files for.
* @param caseDb The case database.
* @param crDb The central repo. Can be null as long as no filters
* need it.
*
* @return An ArrayList of ResultFiles returned by the query.
*
* @throws TskCoreException
* @throws FileSearchException
*/
private static List<ResultFile> getResultList(List<FileFilter> filters, String combinedQuery, SleuthkitCase caseDb, EamDb centralRepoDb) throws TskCoreException, FileSearchException {
// Get all matching abstract files
List<ResultFile> resultList = new ArrayList<>();
logger.log(Level.INFO, "Running SQL query: {0}", combinedQuery);
List<AbstractFile> sqlResults = caseDb.findAllFilesWhere(combinedQuery);
// If there are no results, return now
if (sqlResults.isEmpty()) {
return resultList;
}
// Wrap each result in a ResultFile
for (AbstractFile abstractFile : sqlResults) {
resultList.add(new ResultFile(abstractFile));
}
// Now run any non-SQL filters.
for (FileFilter filter : filters) {
if (filter.useAlternateFilter()) {
resultList = filter.applyAlternateFilter(resultList, caseDb, centralRepoDb);
}
// There are no matches for the filters run so far, so return
if (resultList.isEmpty()) {
return resultList;
}
}
return resultList;
}
/**
* Base class for the filters.
*/
@ -857,11 +872,9 @@ class FileSearchFiltering {
@Override
String getWhereClause() {
String queryStr = "(obj_id IN (SELECT obj_id from blackboard_artifacts WHERE artifact_id IN "
return "(obj_id IN (SELECT obj_id from blackboard_artifacts WHERE artifact_id IN "
+ "(SELECT artifact_id FROM blackboard_attributes WHERE artifact_type_id = "
+ BlackboardArtifact.ARTIFACT_TYPE.TSK_METADATA_EXIF.getTypeID() + ")))";
return queryStr;
}
@NbBundle.Messages({

View File

@ -102,6 +102,10 @@
<Dimension value="[309, 400]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
@ -114,6 +118,10 @@
<Dimension value="[280, 540]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout"/>
<SubComponents>
@ -368,6 +376,10 @@
<ResourceString bundle="org/sleuthkit/autopsy/filequery/Bundle.properties" key="FileSearchPanel.parentLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="8" gridWidth="1" gridHeight="1" fill="0" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="6" insetsBottom="4" insetsRight="0" anchor="23" weightX="0.0" weightY="0.0"/>
@ -691,6 +703,10 @@
</Constraints>
</Component>
<Container class="javax.swing.JPanel" name="fullRadioPanel">
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="9" gridWidth="2" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
@ -732,6 +748,10 @@
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="includeRadioPanel">
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="0" gridY="10" gridWidth="2" gridHeight="1" fill="1" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="0" insetsBottom="0" insetsRight="0" anchor="10" weightX="1.0" weightY="0.0"/>
@ -763,6 +783,8 @@
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="classDetails" type="java.lang.String" value="Box.Filler.Glue"/>
</AuxValues>
</Component>
@ -781,6 +803,10 @@
</SubComponents>
</Container>
<Container class="javax.swing.JPanel" name="parentTextPanel">
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout" value="org.netbeans.modules.form.compat2.layouts.DesignGridBagLayout$GridBagConstraintsDescription">
<GridBagConstraints gridX="1" gridY="11" gridWidth="2" gridHeight="1" fill="2" ipadX="0" ipadY="0" insetsTop="0" insetsLeft="4" insetsBottom="4" insetsRight="0" anchor="10" weightX="1.5" weightY="0.0"/>
@ -837,6 +863,10 @@
<Dimension value="[345, 112]"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
@ -912,6 +942,10 @@
<ResourceString bundle="org/sleuthkit/autopsy/filequery/Bundle.properties" key="FileSearchPanel.orderGroupsByLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="orderByLabel">
<Properties>
@ -919,6 +953,10 @@
<ResourceString bundle="org/sleuthkit/autopsy/filequery/Bundle.properties" key="FileSearchPanel.orderByLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="groupByLabel">
<Properties>
@ -926,6 +964,10 @@
<ResourceString bundle="org/sleuthkit/autopsy/filequery/Bundle.properties" key="FileSearchPanel.groupByLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
<Component class="javax.swing.JComboBox" name="groupSortingComboBox">
<AuxValues>
@ -958,6 +1000,10 @@
<ResourceString bundle="org/sleuthkit/autopsy/filequery/Bundle.properties" key="FileSearchPanel.stepTwoLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="stepThreeLabel">
<Properties>
@ -965,6 +1011,10 @@
<ResourceString bundle="org/sleuthkit/autopsy/filequery/Bundle.properties" key="FileSearchPanel.stepThreeLabel.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
</Component>
</SubComponents>
</Form>

View File

@ -1075,8 +1075,8 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
javax.swing.ButtonGroup parentPathButtonGroup = new javax.swing.ButtonGroup();
javax.swing.ButtonGroup parentIncludeButtonGroup = new javax.swing.ButtonGroup();
filtersScrollPane = new javax.swing.JScrollPane();
filtersPanel = new javax.swing.JPanel();
javax.swing.JScrollPane filtersScrollPane = new javax.swing.JScrollPane();
javax.swing.JPanel filtersPanel = new javax.swing.JPanel();
sizeCheckbox = new javax.swing.JCheckBox();
dataSourceCheckbox = new javax.swing.JCheckBox();
crFrequencyCheckbox = new javax.swing.JCheckBox();
@ -1093,7 +1093,7 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
crFrequencyList = new javax.swing.JList<>();
keywordScrollPane = new javax.swing.JScrollPane();
keywordList = new javax.swing.JList<>();
parentLabel = new javax.swing.JLabel();
javax.swing.JLabel parentLabel = new javax.swing.JLabel();
parentScrollPane = new javax.swing.JScrollPane();
parentList = new javax.swing.JList<>();
hashSetCheckbox = new javax.swing.JCheckBox();
@ -1115,25 +1115,25 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
scoreList = new javax.swing.JList<>();
excludeRadioButton = new javax.swing.JRadioButton();
knownFilesCheckbox = new javax.swing.JCheckBox();
fullRadioPanel = new javax.swing.JPanel();
javax.swing.JPanel fullRadioPanel = new javax.swing.JPanel();
fullRadioButton = new javax.swing.JRadioButton();
includeRadioPanel = new javax.swing.JPanel();
filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767));
javax.swing.JPanel includeRadioPanel = new javax.swing.JPanel();
javax.swing.Box.Filler filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(32767, 32767));
includeRadioButton = new javax.swing.JRadioButton();
parentTextPanel = new javax.swing.JPanel();
javax.swing.JPanel parentTextPanel = new javax.swing.JPanel();
parentTextField = new javax.swing.JTextField();
searchButton = new javax.swing.JButton();
sortingPanel = new javax.swing.JPanel();
javax.swing.JPanel sortingPanel = new javax.swing.JPanel();
groupByCombobox = new javax.swing.JComboBox<>();
orderByCombobox = new javax.swing.JComboBox<>();
orderGroupsByLabel = new javax.swing.JLabel();
orderByLabel = new javax.swing.JLabel();
groupByLabel = new javax.swing.JLabel();
javax.swing.JLabel orderGroupsByLabel = new javax.swing.JLabel();
javax.swing.JLabel orderByLabel = new javax.swing.JLabel();
javax.swing.JLabel groupByLabel = new javax.swing.JLabel();
groupSortingComboBox = new javax.swing.JComboBox<>();
errorLabel = new javax.swing.JLabel();
cancelButton = new javax.swing.JButton();
stepTwoLabel = new javax.swing.JLabel();
stepThreeLabel = new javax.swing.JLabel();
javax.swing.JLabel stepTwoLabel = new javax.swing.JLabel();
javax.swing.JLabel stepThreeLabel = new javax.swing.JLabel();
setMinimumSize(new java.awt.Dimension(10, 0));
setPreferredSize(new java.awt.Dimension(321, 400));
@ -1740,7 +1740,7 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
// Get the selected filters
List<FileSearchFiltering.FileFilter> filters = getFilters();
enableSearch(false);
DiscoveryEvents.getDiscoveryEventBus().post(new DiscoveryEvents.SearchStartedEvent(fileType));
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.SearchStartedEvent(fileType));
// Get the grouping attribute and group sorting method
FileSearch.AttributeType groupingAttr = getGroupingAttribute();
@ -1792,7 +1792,7 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
* @param searchCancelledEvent The SearchCancelledEvent which was received.
*/
@Subscribe
void handleSearchCancelledEvent(DiscoveryEvents.SearchCancelledEvent searchCancelledEvent) {
void handleSearchCancelledEvent(DiscoveryEventUtils.SearchCancelledEvent searchCancelledEvent) {
SwingUtilities.invokeLater(() -> {
enableSearch(true);
});
@ -1804,7 +1804,7 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
* @param searchCompleteEvent The SearchCompleteEvent which was received.
*/
@Subscribe
void handleSearchCompleteEvent(DiscoveryEvents.SearchCompleteEvent searchCompleteEvent) {
void handleSearchCompleteEvent(DiscoveryEventUtils.SearchCompleteEvent searchCompleteEvent) {
SwingUtilities.invokeLater(() -> {
enableSearch(true);
});
@ -1903,19 +1903,13 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
private javax.swing.JLabel errorLabel;
private javax.swing.JRadioButton excludeRadioButton;
private javax.swing.JCheckBox exifCheckbox;
private javax.swing.Box.Filler filler2;
private javax.swing.JPanel filtersPanel;
private javax.swing.JScrollPane filtersScrollPane;
private javax.swing.JRadioButton fullRadioButton;
private javax.swing.JPanel fullRadioPanel;
private javax.swing.JComboBox<GroupingAttributeType> groupByCombobox;
private javax.swing.JLabel groupByLabel;
private javax.swing.JComboBox<GroupSortingAlgorithm> groupSortingComboBox;
private javax.swing.JCheckBox hashSetCheckbox;
private javax.swing.JList<String> hashSetList;
private javax.swing.JScrollPane hashSetScrollPane;
private javax.swing.JRadioButton includeRadioButton;
private javax.swing.JPanel includeRadioPanel;
private javax.swing.JCheckBox interestingItemsCheckbox;
private javax.swing.JList<String> interestingItemsList;
private javax.swing.JScrollPane interestingItemsScrollPane;
@ -1928,14 +1922,10 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
private javax.swing.JList<String> objectsList;
private javax.swing.JScrollPane objectsScrollPane;
private javax.swing.JComboBox<SortingMethod> orderByCombobox;
private javax.swing.JLabel orderByLabel;
private javax.swing.JLabel orderGroupsByLabel;
private javax.swing.JCheckBox parentCheckbox;
private javax.swing.JLabel parentLabel;
private javax.swing.JList<ParentSearchTerm> parentList;
private javax.swing.JScrollPane parentScrollPane;
private javax.swing.JTextField parentTextField;
private javax.swing.JPanel parentTextPanel;
private javax.swing.JCheckBox scoreCheckbox;
private javax.swing.JList<Score> scoreList;
private javax.swing.JScrollPane scoreScrollPane;
@ -1943,9 +1933,6 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener
private javax.swing.JCheckBox sizeCheckbox;
private javax.swing.JList<FileSize> sizeList;
private javax.swing.JScrollPane sizeScrollPane;
private javax.swing.JPanel sortingPanel;
private javax.swing.JLabel stepThreeLabel;
private javax.swing.JLabel stepTwoLabel;
private javax.swing.JRadioButton substringRadioButton;
private javax.swing.JCheckBox tagsCheckbox;
private javax.swing.JList<TagName> tagsList;

View File

@ -34,6 +34,8 @@
<SubComponents>
<Container class="javax.swing.JScrollPane" name="groupListScrollPane">
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>

View File

@ -56,7 +56,7 @@ class GroupListPanel extends javax.swing.JPanel {
* @param searchStartedEvent the SearchStartedEvent which was received
*/
@Subscribe
void handleSearchStartedEvent(DiscoveryEvents.SearchStartedEvent searchStartedEvent) {
void handleSearchStartedEvent(DiscoveryEventUtils.SearchStartedEvent searchStartedEvent) {
resultType = searchStartedEvent.getType();
groupKeyList.setListData(new GroupKey[0]);
}
@ -70,7 +70,7 @@ class GroupListPanel extends javax.swing.JPanel {
* @param searchCompleteEvent the SearchCompleteEvent which was received
*/
@Subscribe
void handleSearchCompleteEvent(DiscoveryEvents.SearchCompleteEvent searchCompleteEvent) {
void handleSearchCompleteEvent(DiscoveryEventUtils.SearchCompleteEvent searchCompleteEvent) {
groupMap = searchCompleteEvent.getGroupMap();
searchfilters = searchCompleteEvent.getFilters();
groupingAttribute = searchCompleteEvent.getGroupingAttr();
@ -96,7 +96,7 @@ class GroupListPanel extends javax.swing.JPanel {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
groupListScrollPane = new javax.swing.JScrollPane();
javax.swing.JScrollPane groupListScrollPane = new javax.swing.JScrollPane();
groupKeyList = new javax.swing.JList<>();
groupKeyList.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(GroupListPanel.class, "GroupListPanel.groupKeyList.border.title"))); // NOI18N
@ -145,20 +145,19 @@ class GroupListPanel extends javax.swing.JPanel {
for (GroupKey groupKey : groupMap.keySet()) {
if (selectedGroup.equals(groupKey)) {
selectedGroupKey = groupKey;
DiscoveryEvents.getDiscoveryEventBus().post(new DiscoveryEvents.GroupSelectedEvent(
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.GroupSelectedEvent(
searchfilters, groupingAttribute, groupSort, fileSortMethod, selectedGroupKey, groupMap.get(selectedGroupKey), resultType));
break;
}
}
} else {
DiscoveryEvents.getDiscoveryEventBus().post(new DiscoveryEvents.NoResultsEvent());
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.NoResultsEvent());
}
}
}//GEN-LAST:event_groupSelected
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JList<GroupKey> groupKeyList;
private javax.swing.JScrollPane groupListScrollPane;
// End of variables declaration//GEN-END:variables
/**

View File

@ -160,7 +160,7 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR
case INTERESTING_SCORE:
scoreLabel.setIcon(INTERESTING_SCORE_ICON);
break;
case NO_SCORE:
case NO_SCORE: // empty case - this is interpreted as an intentional fall-through
default:
scoreLabel.setIcon(null);
break;
@ -210,6 +210,7 @@ public class ImageThumbnailPanel extends javax.swing.JPanel implements ListCellR
break;
default:
units = Bundle.ImageThumbnailPanel_bytes_text();
break;
}
return Bundle.ImageThumbnailPanel_sizeLabel_text(size, units);
}

View File

@ -80,28 +80,7 @@ public final class OpenFileDiscoveryAction extends CallableSystemAction implemen
if (tc.isOpened() == false) {
tc.open();
tc.updateSearchSettings();
//check if modules run and assemble message
try {
SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase();
Map<Long, DataSourceModulesWrapper> dataSourceIngestModules = new HashMap<>();
for (DataSource dataSource : skCase.getDataSources()) {
dataSourceIngestModules.put(dataSource.getId(), new DataSourceModulesWrapper(dataSource.getName()));
}
for (IngestJobInfo jobInfo : skCase.getIngestJobs()) {
dataSourceIngestModules.get(jobInfo.getObjectId()).updateModulesRun(jobInfo);
}
String message = "";
for (DataSourceModulesWrapper dsmodulesWrapper : dataSourceIngestModules.values()) {
message += dsmodulesWrapper.getMessage();
}
if (!message.isEmpty()) {
JOptionPane.showMessageDialog(tc, message, Bundle.OpenFileDiscoveryAction_resultsIncomplete_text(), JOptionPane.INFORMATION_MESSAGE);
}
} catch (NoCurrentCaseException | TskCoreException ex) {
logger.log(Level.WARNING, "Exception while determining which modules have been run for File Discovery", ex);
}
displayErrorMessage(tc);
}
tc.toFront();
tc.requestActive();
@ -109,6 +88,36 @@ public final class OpenFileDiscoveryAction extends CallableSystemAction implemen
}
}
/**
* Private helper method to display an error message when the results of the
* File Discovery Top component may be incomplete.
*
* @param tc The File Discovery Top component.
*/
private void displayErrorMessage(DiscoveryTopComponent tc) {
//check if modules run and assemble message
try {
SleuthkitCase skCase = Case.getCurrentCaseThrows().getSleuthkitCase();
Map<Long, DataSourceModulesWrapper> dataSourceIngestModules = new HashMap<>();
for (DataSource dataSource : skCase.getDataSources()) {
dataSourceIngestModules.put(dataSource.getId(), new DataSourceModulesWrapper(dataSource.getName()));
}
for (IngestJobInfo jobInfo : skCase.getIngestJobs()) {
dataSourceIngestModules.get(jobInfo.getObjectId()).updateModulesRun(jobInfo);
}
String message = "";
for (DataSourceModulesWrapper dsmodulesWrapper : dataSourceIngestModules.values()) {
message += dsmodulesWrapper.getMessage();
}
if (!message.isEmpty()) {
JOptionPane.showMessageDialog(tc, message, Bundle.OpenFileDiscoveryAction_resultsIncomplete_text(), JOptionPane.INFORMATION_MESSAGE);
}
} catch (NoCurrentCaseException | TskCoreException ex) {
logger.log(Level.WARNING, "Exception while determining which modules have been run for File Discovery", ex);
}
}
/**
* Returns the toolbar component of this action.
*

View File

@ -96,7 +96,7 @@ final class PageWorker extends SwingWorker<Void, Void> {
protected void done() {
if (!isCancelled()) {
int currentPage = startingEntry / pageSize; //integer division should round down to get page number correctly
DiscoveryEvents.getDiscoveryEventBus().post(new DiscoveryEvents.PageRetrievedEvent(resultType, currentPage, results));
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.PageRetrievedEvent(resultType, currentPage, results));
}
}

View File

@ -45,6 +45,10 @@
</Border>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_VariableLocal" type="java.lang.Boolean" value="true"/>
<AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="0"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">

View File

@ -190,7 +190,7 @@ public class ResultsPanel extends javax.swing.JPanel {
* @param pageRetrievedEvent The PageRetrievedEvent received.
*/
@Subscribe
void handlePageRetrievedEvent(DiscoveryEvents.PageRetrievedEvent pageRetrievedEvent) {
void handlePageRetrievedEvent(DiscoveryEventUtils.PageRetrievedEvent pageRetrievedEvent) {
SwingUtilities.invokeLater(() -> {
populateInstancesList();
currentPage = pageRetrievedEvent.getPageNumber();
@ -264,7 +264,7 @@ public class ResultsPanel extends javax.swing.JPanel {
* @param groupSelectedEvent The GroupSelectedEvent received.
*/
@Subscribe
void handleGroupSelectedEvent(DiscoveryEvents.GroupSelectedEvent groupSelectedEvent) {
void handleGroupSelectedEvent(DiscoveryEventUtils.GroupSelectedEvent groupSelectedEvent) {
SwingUtilities.invokeLater(() -> {
searchFilters = groupSelectedEvent.getFilters();
groupingAttribute = groupSelectedEvent.getGroupingAttr();
@ -284,7 +284,7 @@ public class ResultsPanel extends javax.swing.JPanel {
* @param noResultsEvent the NoResultsEvent received.
*/
@Subscribe
void handleNoResultsEvent(DiscoveryEvents.NoResultsEvent noResultsEvent) {
void handleNoResultsEvent(DiscoveryEventUtils.NoResultsEvent noResultsEvent) {
SwingUtilities.invokeLater(() -> {
groupSize = 0;
currentPage = 0;
@ -349,7 +349,7 @@ public class ResultsPanel extends javax.swing.JPanel {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
pagingPanel = new javax.swing.JPanel();
javax.swing.JPanel pagingPanel = new javax.swing.JPanel();
previousPageButton = new javax.swing.JButton();
currentPageLabel = new javax.swing.JLabel();
nextPageButton = new javax.swing.JButton();
@ -611,7 +611,6 @@ public class ResultsPanel extends javax.swing.JPanel {
private javax.swing.JList<AbstractFile> instancesList;
private javax.swing.JButton nextPageButton;
private javax.swing.JComboBox<Integer> pageSizeComboBox;
private javax.swing.JPanel pagingPanel;
private javax.swing.JButton previousPageButton;
private javax.swing.JPanel resultsViewerPanel;
// End of variables declaration//GEN-END:variables

View File

@ -39,7 +39,7 @@ class SearchResults {
private final Map<FileSearch.GroupKey, FileGroup> groupMap = new HashMap<>();
private List<FileGroup> groupList = new ArrayList<>();
private final long MAX_OUTPUT_FILES = 2000; // For debug UI - maximum number of lines to print
private static final long MAX_OUTPUT_FILES = 2000; // For debug UI - maximum number of lines to print
/**
* Create an empty SearchResults object

View File

@ -78,9 +78,9 @@ final class SearchWorker extends SwingWorker<Void, Void> {
@Override
protected void done() {
if (isCancelled()) {
DiscoveryEvents.getDiscoveryEventBus().post(new DiscoveryEvents.SearchCancelledEvent());
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.SearchCancelledEvent());
} else {
DiscoveryEvents.getDiscoveryEventBus().post(new DiscoveryEvents.SearchCompleteEvent(results, filters, groupingAttr, groupSortAlgorithm, fileSort));
DiscoveryEventUtils.getDiscoveryEventBus().post(new DiscoveryEventUtils.SearchCompleteEvent(results, filters, groupingAttr, groupSortAlgorithm, fileSort));
}
}
}

View File

@ -193,7 +193,7 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe
case INTERESTING_SCORE:
scoreLabel.setIcon(INTERESTING_SCORE_ICON);
break;
case NO_SCORE:
case NO_SCORE: // empty case - this is interpreted as an intentional fall-through
default:
scoreLabel.setIcon(null);
break;
@ -242,6 +242,7 @@ final class VideoThumbnailPanel extends javax.swing.JPanel implements ListCellRe
break;
default:
units = Bundle.VideoThumbnailPanel_bytes_text();
break;
}
return Bundle.VideoThumbnailPanel_sizeLabel_text(size, units);
}