From c16198cd48053928db167ac8f6e63dc077bb97cc Mon Sep 17 00:00:00 2001 From: William Schaefer Date: Mon, 9 Dec 2019 16:06:57 -0500 Subject: [PATCH] 5661 address some codacy complaints --- .../filequery/DataSourceModulesWrapper.java | 46 +++++++++-- ...ryEvents.java => DiscoveryEventUtils.java} | 4 +- .../filequery/DiscoveryTopComponent.form | 6 ++ .../filequery/DiscoveryTopComponent.java | 28 +++---- .../autopsy/filequery/FileSearch.java | 64 ++++++++++----- .../autopsy/filequery/FileSearchData.java | 4 +- .../filequery/FileSearchFiltering.java | 79 +++++++++++-------- .../autopsy/filequery/FileSearchPanel.form | 50 ++++++++++++ .../autopsy/filequery/FileSearchPanel.java | 45 ++++------- .../autopsy/filequery/GroupListPanel.form | 2 + .../autopsy/filequery/GroupListPanel.java | 11 ++- .../filequery/ImageThumbnailPanel.java | 3 +- .../filequery/OpenFileDiscoveryAction.java | 53 +++++++------ .../autopsy/filequery/PageWorker.java | 2 +- .../autopsy/filequery/ResultsPanel.form | 4 + .../autopsy/filequery/ResultsPanel.java | 9 +-- .../autopsy/filequery/SearchResults.java | 2 +- .../autopsy/filequery/SearchWorker.java | 4 +- .../filequery/VideoThumbnailPanel.java | 3 +- 19 files changed, 271 insertions(+), 148 deletions(-) rename Core/src/org/sleuthkit/autopsy/filequery/{DiscoveryEvents.java => DiscoveryEventUtils.java} (99%) diff --git a/Core/src/org/sleuthkit/autopsy/filequery/DataSourceModulesWrapper.java b/Core/src/org/sleuthkit/autopsy/filequery/DataSourceModulesWrapper.java index 9466c33192..53cabedfb3 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/DataSourceModulesWrapper.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/DataSourceModulesWrapper.java @@ -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; } } } diff --git a/Core/src/org/sleuthkit/autopsy/filequery/DiscoveryEvents.java b/Core/src/org/sleuthkit/autopsy/filequery/DiscoveryEventUtils.java similarity index 99% rename from Core/src/org/sleuthkit/autopsy/filequery/DiscoveryEvents.java rename to Core/src/org/sleuthkit/autopsy/filequery/DiscoveryEventUtils.java index d3dad4b24f..f73cf4171e 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/DiscoveryEvents.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/DiscoveryEventUtils.java @@ -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() { } /** diff --git a/Core/src/org/sleuthkit/autopsy/filequery/DiscoveryTopComponent.form b/Core/src/org/sleuthkit/autopsy/filequery/DiscoveryTopComponent.form index 172b156616..b8486b8ae6 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/DiscoveryTopComponent.form +++ b/Core/src/org/sleuthkit/autopsy/filequery/DiscoveryTopComponent.form @@ -174,6 +174,10 @@ + + + + @@ -218,6 +222,8 @@ + + diff --git a/Core/src/org/sleuthkit/autopsy/filequery/DiscoveryTopComponent.java b/Core/src/org/sleuthkit/autopsy/filequery/DiscoveryTopComponent.java index fadb54dfba..6e6fcf7cec 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/DiscoveryTopComponent.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/DiscoveryTopComponent.java @@ -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 diff --git a/Core/src/org/sleuthkit/autopsy/filequery/FileSearch.java b/Core/src/org/sleuthkit/autopsy/filequery/FileSearch.java index c960d22f60..648eb6457a 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/FileSearch.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/FileSearch.java @@ -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 currentFiles = new ArrayList<>(); - Set 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 files, + EamDb centralRepoDb) { + List currentFiles = new ArrayList<>(); + Set 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); + } } /** diff --git a/Core/src/org/sleuthkit/autopsy/filequery/FileSearchData.java b/Core/src/org/sleuthkit/autopsy/filequery/FileSearchData.java index 9221f36229..93d17b21bb 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/FileSearchData.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/FileSearchData.java @@ -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 mediaTypes; - private FileType(int value, String displayName, Collection mediaTypes) { + FileType(int value, String displayName, Collection mediaTypes) { this.ranking = value; this.displayName = displayName; this.mediaTypes = mediaTypes; diff --git a/Core/src/org/sleuthkit/autopsy/filequery/FileSearchFiltering.java b/Core/src/org/sleuthkit/autopsy/filequery/FileSearchFiltering.java index 920f7983c1..b35434be0e 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/FileSearchFiltering.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/FileSearchFiltering.java @@ -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 resultList = new ArrayList<>(); - - logger.log(Level.INFO, "Running SQL query: {0}", combinedQuery); - List 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 getResultList(List filters, String combinedQuery, SleuthkitCase caseDb, EamDb centralRepoDb) throws TskCoreException, FileSearchException { + // Get all matching abstract files + List resultList = new ArrayList<>(); + + logger.log(Level.INFO, "Running SQL query: {0}", combinedQuery); + List 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({ diff --git a/Core/src/org/sleuthkit/autopsy/filequery/FileSearchPanel.form b/Core/src/org/sleuthkit/autopsy/filequery/FileSearchPanel.form index 4f28aa9b3e..c8a68294e2 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/FileSearchPanel.form +++ b/Core/src/org/sleuthkit/autopsy/filequery/FileSearchPanel.form @@ -102,6 +102,10 @@ + + + + @@ -114,6 +118,10 @@ + + + + @@ -368,6 +376,10 @@ + + + + @@ -691,6 +703,10 @@ + + + + @@ -732,6 +748,10 @@ + + + + @@ -763,6 +783,8 @@ + + @@ -781,6 +803,10 @@ + + + + @@ -837,6 +863,10 @@ + + + + @@ -912,6 +942,10 @@ + + + + @@ -919,6 +953,10 @@ + + + + @@ -926,6 +964,10 @@ + + + + @@ -958,6 +1000,10 @@ + + + + @@ -965,6 +1011,10 @@ + + + + diff --git a/Core/src/org/sleuthkit/autopsy/filequery/FileSearchPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/FileSearchPanel.java index 25bcfb2893..d751911379 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/FileSearchPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/FileSearchPanel.java @@ -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 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 groupByCombobox; - private javax.swing.JLabel groupByLabel; private javax.swing.JComboBox groupSortingComboBox; private javax.swing.JCheckBox hashSetCheckbox; private javax.swing.JList 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 interestingItemsList; private javax.swing.JScrollPane interestingItemsScrollPane; @@ -1928,14 +1922,10 @@ final class FileSearchPanel extends javax.swing.JPanel implements ActionListener private javax.swing.JList objectsList; private javax.swing.JScrollPane objectsScrollPane; private javax.swing.JComboBox 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 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 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 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 tagsList; diff --git a/Core/src/org/sleuthkit/autopsy/filequery/GroupListPanel.form b/Core/src/org/sleuthkit/autopsy/filequery/GroupListPanel.form index e774a0fac7..9df241e5ab 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/GroupListPanel.form +++ b/Core/src/org/sleuthkit/autopsy/filequery/GroupListPanel.form @@ -34,6 +34,8 @@ + + diff --git a/Core/src/org/sleuthkit/autopsy/filequery/GroupListPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/GroupListPanel.java index ba1ed23388..374c079590 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/GroupListPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/GroupListPanel.java @@ -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 { // //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 groupKeyList; - private javax.swing.JScrollPane groupListScrollPane; // End of variables declaration//GEN-END:variables /** diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java index ac1b7daf4a..a1d04c9621 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ImageThumbnailPanel.java @@ -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); } diff --git a/Core/src/org/sleuthkit/autopsy/filequery/OpenFileDiscoveryAction.java b/Core/src/org/sleuthkit/autopsy/filequery/OpenFileDiscoveryAction.java index c22e6c8a6b..d315b85956 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/OpenFileDiscoveryAction.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/OpenFileDiscoveryAction.java @@ -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 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 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. * diff --git a/Core/src/org/sleuthkit/autopsy/filequery/PageWorker.java b/Core/src/org/sleuthkit/autopsy/filequery/PageWorker.java index 348e4c5947..f90d11bd32 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/PageWorker.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/PageWorker.java @@ -96,7 +96,7 @@ final class PageWorker extends SwingWorker { 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)); } } diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ResultsPanel.form b/Core/src/org/sleuthkit/autopsy/filequery/ResultsPanel.form index 4bc750ee57..c21dca33e5 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ResultsPanel.form +++ b/Core/src/org/sleuthkit/autopsy/filequery/ResultsPanel.form @@ -45,6 +45,10 @@ + + + + diff --git a/Core/src/org/sleuthkit/autopsy/filequery/ResultsPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/ResultsPanel.java index b0a80ca543..27086c731c 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/ResultsPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/ResultsPanel.java @@ -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 { // //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 instancesList; private javax.swing.JButton nextPageButton; private javax.swing.JComboBox pageSizeComboBox; - private javax.swing.JPanel pagingPanel; private javax.swing.JButton previousPageButton; private javax.swing.JPanel resultsViewerPanel; // End of variables declaration//GEN-END:variables diff --git a/Core/src/org/sleuthkit/autopsy/filequery/SearchResults.java b/Core/src/org/sleuthkit/autopsy/filequery/SearchResults.java index c7521c8f46..7cc9b8a596 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/SearchResults.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/SearchResults.java @@ -39,7 +39,7 @@ class SearchResults { private final Map groupMap = new HashMap<>(); private List 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 diff --git a/Core/src/org/sleuthkit/autopsy/filequery/SearchWorker.java b/Core/src/org/sleuthkit/autopsy/filequery/SearchWorker.java index be9d7a56a0..279a470f3a 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/SearchWorker.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/SearchWorker.java @@ -78,9 +78,9 @@ final class SearchWorker extends SwingWorker { @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)); } } } diff --git a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java index f2956cc8c8..72296f7ce8 100644 --- a/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java +++ b/Core/src/org/sleuthkit/autopsy/filequery/VideoThumbnailPanel.java @@ -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); }