From 4f89d62ef39eb4a7f87ff3764bc21bf314fd96a5 Mon Sep 17 00:00:00 2001 From: Andrew Ziehl Date: Tue, 17 Apr 2018 17:00:18 -0700 Subject: [PATCH] merge cleanup # Conflicts: # Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesMetaDataBuilder.java --- .../autopsy/commonfilesearch/AllDataSources.java | 4 ++-- .../commonfilesearch/CommonFilesMetaDataBuilder.java | 11 +++++++---- .../autopsy/commonfilesearch/SingleDataSource.java | 6 ++---- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/AllDataSources.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/AllDataSources.java index 162cb6b63a..563ea0e582 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/AllDataSources.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/AllDataSources.java @@ -32,14 +32,14 @@ final class AllDataSources extends CommonFilesMetaDataBuilder { * Implements the algorithm for getting common files across all data sources. * @param dataSourceIdMap a map of obj_id to datasource name */ - public AllDataSources(Map dataSourceIdMap, boolean filterByMediaMimeType, boolean filterByDocMimeType) { + AllDataSources(Map dataSourceIdMap, boolean filterByMediaMimeType, boolean filterByDocMimeType) { super(dataSourceIdMap, filterByMediaMimeType, filterByDocMimeType); } @Override protected String buildSqlSelectStatement() { - Object[] args = new String[] {CommonFilesMetaDataBuilder.SELECT_PREFIX, determineMimeTypeFilter()}; + Object[] args = new String[] {SELECT_PREFIX, determineMimeTypeFilter()}; return String.format(WHERE_CLAUSE, args); } } diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesMetaDataBuilder.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesMetaDataBuilder.java index a5492ba1ac..e686cb6660 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesMetaDataBuilder.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesMetaDataBuilder.java @@ -22,8 +22,8 @@ package org.sleuthkit.autopsy.commonfilesearch; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashMap; +import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; @@ -115,7 +115,7 @@ abstract class CommonFilesMetaDataBuilder { *
  • If you do not use this string, you must use at least the columns selected below, in that order.
  • * */ - protected static String SELECT_PREFIX = "SELECT obj_id, md5, data_source_obj_id from tsk_files where"; + static final String SELECT_PREFIX = "SELECT obj_id, md5, data_source_obj_id from tsk_files where"; /** * Should build a SQL SELECT statement to be passed to @@ -168,7 +168,7 @@ abstract class CommonFilesMetaDataBuilder { } String determineMimeTypeFilter() { - StringBuilder mimeTypeFilter = new StringBuilder(); + Set mimeTypesToFilterOn = new HashSet<>(); String mimeTypeString = ""; if(filterByMedia) { @@ -177,12 +177,15 @@ abstract class CommonFilesMetaDataBuilder { if(filterByDoc) { mimeTypesToFilterOn.addAll(TEXT_FILES_MIME_TYPES); } + StringBuilder mimeTypeFilter = new StringBuilder(mimeTypesToFilterOn.size()); if(mimeTypesToFilterOn.size() > 0) { for (String mimeType : mimeTypesToFilterOn) { - mimeTypeFilter.append("\"" + mimeType + "\","); + mimeTypeFilter.append("\"").append(mimeType).append("\","); } mimeTypeString = mimeTypeFilter.toString().substring(0, mimeTypeFilter.length() - 1); } return String.format(filterByMimeTypesWhereClause, new Object[]{mimeTypeString}); } + + } diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/SingleDataSource.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/SingleDataSource.java index 4cecee4ad4..75d333efd0 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/SingleDataSource.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/SingleDataSource.java @@ -19,9 +19,7 @@ */ package org.sleuthkit.autopsy.commonfilesearch; -import java.util.HashSet; import java.util.Map; -import java.util.Set; /** * Provides logic for selecting common files from a single data source. @@ -37,14 +35,14 @@ final class SingleDataSource extends CommonFilesMetaDataBuilder { * @param dataSourceId data source id for which common files must appear at least once * @param dataSourceIdMap map of obj_id to data source name */ - public SingleDataSource(Long dataSourceId, Map dataSourceIdMap, boolean filterByMediaMimeType, boolean filterByDocMimeType) { + SingleDataSource(Long dataSourceId, Map dataSourceIdMap, boolean filterByMediaMimeType, boolean filterByDocMimeType) { super(dataSourceIdMap, filterByMediaMimeType, filterByDocMimeType); this.selectedDataSourceId = dataSourceId; } @Override protected String buildSqlSelectStatement() { - Object[] args = new String[]{CommonFilesMetaDataBuilder.SELECT_PREFIX, Long.toString(this.selectedDataSourceId), determineMimeTypeFilter()}; + Object[] args = new String[]{SELECT_PREFIX, Long.toString(this.selectedDataSourceId), determineMimeTypeFilter()}; return String.format(SingleDataSource.WHERE_CLAUSE, args); } }