diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/ICommonFilesMetadataBuilder.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/AbstractCommonFilesMetadataBuilder.java similarity index 75% rename from Core/src/org/sleuthkit/autopsy/commonfilesearch/ICommonFilesMetadataBuilder.java rename to Core/src/org/sleuthkit/autopsy/commonfilesearch/AbstractCommonFilesMetadataBuilder.java index 19a41f5652..9190ac1a73 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/ICommonFilesMetadataBuilder.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/AbstractCommonFilesMetadataBuilder.java @@ -27,20 +27,44 @@ import java.util.Set; import java.util.TreeMap; import java.util.stream.Collectors; import java.util.stream.Stream; +import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.datamodel.TskCoreException; -/** - * - * @author bsweeney - */ -abstract class ICommonFilesMetadataBuilder { +abstract class AbstractCommonFilesMetadataBuilder { + + boolean filterByMedia; + boolean filterByDoc; abstract CommonFilesMetadata findFiles() throws TskCoreException, NoCurrentCaseException, SQLException, Exception; + @NbBundle.Messages({ + "AbstractCommonFilesMetadataBuilder.buildTabTitle.titleIntraAll=Common Files (All Data Sources, %s)", + "AbstractCommonFilesMetadataBuilder.buildTabTitle.titleIntraSingle=Common Files (Data Source: %s, %s)", + "AbstractCommonFilesMetadataBuilder.buildTabTitle.titleInterAll=Common Files (All Central Repository Cases, %s)", + "AbstractCommonFilesMetadataBuilder.buildTabTitle.titleInterSingle=Common Files (Central Repository Case: %s, %s)", + }) abstract String buildTabTitle(); - abstract String buildCategorySelectionString(); + @NbBundle.Messages({ + "AbstractCommonFilesMetadataBuilder.buildCategorySelectionString.doc=Documents", + "AbstractCommonFilesMetadataBuilder.buildCategorySelectionString.media=Media", + "AbstractCommonFilesMetadataBuilder.buildCategorySelectionString.all=All File Categories" + }) + protected String buildCategorySelectionString() { + if (!this.filterByDoc && !this.filterByMedia) { + return Bundle.AbstractCommonFilesMetadataBuilder_buildCategorySelectionString_all(); + } else { + List filters = new ArrayList<>(); + if (this.filterByDoc) { + filters.add(Bundle.AbstractCommonFilesMetadataBuilder_buildCategorySelectionString_doc()); + } + if (this.filterByMedia) { + filters.add(Bundle.AbstractCommonFilesMetadataBuilder_buildCategorySelectionString_media()); + } + return String.join(", ", filters); + } + } static Map> collateMatchesByNumberOfInstances(Map commonFiles) { //collate matches by number of matching instances - doing this in sql doesnt seem efficient diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/AllCasesEamDbCommonFilesAlgorithm.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/AllCasesEamDbCommonFilesAlgorithm.java index 63c5525097..f7d1c65b41 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/AllCasesEamDbCommonFilesAlgorithm.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/AllCasesEamDbCommonFilesAlgorithm.java @@ -50,8 +50,10 @@ public class AllCasesEamDbCommonFilesAlgorithm extends InterCaseCommonFilesMetad } @Override - String buildCategorySelectionString() { - //TODO - return ""; + String buildTabTitle() { + final String buildCategorySelectionString = this.buildCategorySelectionString(); + final String titleTemplate = Bundle.AbstractCommonFilesMetadataBuilder_buildTabTitle_titleInterAll(); + return String.format(titleTemplate, new Object[]{buildCategorySelectionString}); } + } diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/AllDataSourcesCommonFilesAlgorithm.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/AllDataSourcesCommonFilesAlgorithm.java index 931c307453..e330ddc05e 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/AllDataSourcesCommonFilesAlgorithm.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/AllDataSourcesCommonFilesAlgorithm.java @@ -51,7 +51,7 @@ final public class AllDataSourcesCommonFilesAlgorithm extends IntraCaseCommonFil @Override protected String buildTabTitle() { final String buildCategorySelectionString = this.buildCategorySelectionString(); - final String titleTemplate = Bundle.CommonFilesMetadataBuilder_buildTabTitle_titleAll(); + final String titleTemplate = Bundle.AbstractCommonFilesMetadataBuilder_buildTabTitle_titleIntraAll(); return String.format(titleTemplate, new Object[]{buildCategorySelectionString}); } } diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesPanel.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesPanel.java index a5ea73065e..38cf65c656 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesPanel.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/CommonFilesPanel.java @@ -30,7 +30,6 @@ import javax.swing.SwingUtilities; import javax.swing.SwingWorker; import org.netbeans.api.progress.ProgressHandle; import org.openide.explorer.ExplorerManager; -import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; @@ -58,9 +57,6 @@ public final class CommonFilesPanel extends javax.swing.JPanel { private static final Long NO_DATA_SOURCE_SELECTED = -1L; private static final Logger LOGGER = Logger.getLogger(CommonFilesPanel.class.getName()); - - private boolean singleDataSource = false; - private String selectedDataSource = ""; private boolean pictureViewCheckboxState; private boolean documentsCheckboxState; @@ -74,9 +70,6 @@ public final class CommonFilesPanel extends javax.swing.JPanel { initComponents(); this.errorText.setVisible(false); - - this.intraCasePanel.setParent(this); - this.setupDataSources(); if (CommonFilesPanel.isEamDbAvailable()) { @@ -141,7 +134,7 @@ public final class CommonFilesPanel extends javax.swing.JPanel { Long dataSourceId = intraCasePanel.getSelectedDataSourceId(); Integer caseId = interCasePanel.getSelectedCaseId(); - IntraCaseCommonFilesMetadataBuilder builder; + AbstractCommonFilesMetadataBuilder builder; CommonFilesMetadata metadata; boolean filterByMedia = false; @@ -173,8 +166,6 @@ public final class CommonFilesPanel extends javax.swing.JPanel { setTitleForSingleSource(dataSourceId); } } - - //TODO set title from one method rather than two (or more) overloads metadata = builder.findFiles(); this.tabTitle = builder.buildTabTitle(); diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/InterCaseCommonFilesMetadataBuilder.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/InterCaseCommonFilesMetadataBuilder.java index 539c15fd6a..a4b71bf950 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/InterCaseCommonFilesMetadataBuilder.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/InterCaseCommonFilesMetadataBuilder.java @@ -34,7 +34,7 @@ import org.sleuthkit.datamodel.HashUtility; * Provides logic for selecting common files from all data sources and all cases * in the Central Repo. */ -public abstract class InterCaseCommonFilesMetadataBuilder extends ICommonFilesMetadataBuilder { +public abstract class InterCaseCommonFilesMetadataBuilder extends AbstractCommonFilesMetadataBuilder { //CONSIDER: we should create an interface which specifies the findFiles feature // instead of an abstract class and then have two abstract classes: // inter- and intra- which implement the interface and then 4 subclasses @@ -52,7 +52,8 @@ public abstract class InterCaseCommonFilesMetadataBuilder extends ICommonFilesMe * @throws EamDbException */ InterCaseCommonFilesMetadataBuilder(boolean filterByMediaMimeType, boolean filterByDocMimeType) throws EamDbException { - //TODO these two boolean variables are unused for the intercase feature at the moment + filterByMedia = filterByMediaMimeType; + filterByDoc = filterByDocMimeType; dbManager = EamDb.getInstance(); } @@ -105,13 +106,6 @@ public abstract class InterCaseCommonFilesMetadataBuilder extends ICommonFilesMe return instanceCollatedCommonFiles; } - @Override - String buildTabTitle() { - final String buildCategorySelectionString = this.buildCategorySelectionString(); - final String titleTemplate = Bundle.CommonFilesMetadataBuilder_buildTabTitle_titleEamDb(); - return String.format(titleTemplate, new Object[]{buildCategorySelectionString}); - } - protected CorrelationCase getCorrelationCaseFromId(int correlationCaseId) throws EamDbException, Exception { for (CorrelationCase cCase : this.dbManager.getCases()) { if (cCase.getID() == correlationCaseId) { diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/IntraCaseCommonFilesMetadataBuilder.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/IntraCaseCommonFilesMetadataBuilder.java index e1a35c0c2f..89f011c425 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/IntraCaseCommonFilesMetadataBuilder.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/IntraCaseCommonFilesMetadataBuilder.java @@ -27,7 +27,6 @@ import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException; import org.sleuthkit.datamodel.AbstractFile; @@ -45,11 +44,9 @@ import org.sleuthkit.datamodel.TskCoreException; * This entire thing runs on a background thread where exceptions are handled. */ @SuppressWarnings("PMD.AbstractNaming") -public abstract class IntraCaseCommonFilesMetadataBuilder extends ICommonFilesMetadataBuilder { +public abstract class IntraCaseCommonFilesMetadataBuilder extends AbstractCommonFilesMetadataBuilder { private final Map dataSourceIdToNameMap; - private final boolean filterByMedia; - private final boolean filterByDoc; private static final String FILTER_BY_MIME_TYPES_WHERE_CLAUSE = " and mime_type in (%s)"; //NON-NLS // where %s is csv list of mime_types to filter on /** @@ -100,6 +97,7 @@ public abstract class IntraCaseCommonFilesMetadataBuilder extends ICommonFilesMe * @throws NoCurrentCaseException * @throws SQLException */ + @Override public CommonFilesMetadata findFiles() throws TskCoreException, NoCurrentCaseException, SQLException, Exception { //TODO do we need all those exceptions or can we differentiate when they are caught? Map commonFiles = new HashMap<>(); @@ -173,24 +171,5 @@ public abstract class IntraCaseCommonFilesMetadataBuilder extends ICommonFilesMe } return mimeTypeString; } - - @NbBundle.Messages({ - "CommonFilesMetadataBuilder.buildCategorySelectionString.doc=Documents", - "CommonFilesMetadataBuilder.buildCategorySelectionString.media=Media", - "CommonFilesMetadataBuilder.buildCategorySelectionString.all=All File Categories" - }) - protected String buildCategorySelectionString() { - if (!this.filterByDoc && !this.filterByMedia) { - return Bundle.CommonFilesMetadataBuilder_buildCategorySelectionString_all(); - } else { - List filters = new ArrayList<>(); - if (this.filterByDoc) { - filters.add(Bundle.CommonFilesMetadataBuilder_buildCategorySelectionString_doc()); - } - if (this.filterByMedia) { - filters.add(Bundle.CommonFilesMetadataBuilder_buildCategorySelectionString_media()); - } - return String.join(", ", filters); - } - } + } diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/Md5Node.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/Md5Node.java index b22e3e35e7..45edc96c39 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/Md5Node.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/Md5Node.java @@ -19,21 +19,16 @@ */ package org.sleuthkit.autopsy.commonfilesearch; -import java.util.HashMap; import java.util.List; -import java.util.Map; import org.openide.nodes.ChildFactory; import org.openide.nodes.Children; import org.openide.nodes.Node; import org.openide.nodes.Sheet; import org.openide.util.NbBundle; -import org.sleuthkit.autopsy.commonfilesearch.FileInstanceNodeGenerator; -import org.sleuthkit.autopsy.commonfilesearch.Md5Metadata; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.datamodel.DisplayableItemNode; import org.sleuthkit.autopsy.datamodel.DisplayableItemNodeVisitor; import org.sleuthkit.autopsy.datamodel.NodeProperty; -import org.sleuthkit.datamodel.AbstractFile; /** * Represents a common files match - two or more files which appear to be the diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/SingleCaseEamDbCommonFilesAlgorithm.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/SingleCaseEamDbCommonFilesAlgorithm.java index 7d31517478..0cd96eb1ee 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/SingleCaseEamDbCommonFilesAlgorithm.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/SingleCaseEamDbCommonFilesAlgorithm.java @@ -36,6 +36,7 @@ import org.sleuthkit.datamodel.TskCoreException; public class SingleCaseEamDbCommonFilesAlgorithm extends InterCaseCommonFilesMetadataBuilder { private final int corrleationCaseId; + private String correlationCaseName; /** * @@ -48,6 +49,7 @@ public class SingleCaseEamDbCommonFilesAlgorithm extends InterCaseCommonFilesMet super(filterByMediaMimeType, filterByDocMimeType); this.corrleationCaseId = correlationCaseId; + this.correlationCaseName = ""; } /** @@ -66,7 +68,7 @@ public class SingleCaseEamDbCommonFilesAlgorithm extends InterCaseCommonFilesMet public CommonFilesMetadata findFiles() throws TskCoreException, NoCurrentCaseException, SQLException, EamDbException, Exception { CorrelationCase cCase = this.getCorrelationCaseFromId(this.corrleationCaseId); - + correlationCaseName = cCase.getDisplayName(); return this.findFiles(cCase); } @@ -80,10 +82,12 @@ public class SingleCaseEamDbCommonFilesAlgorithm extends InterCaseCommonFilesMet return new CommonFilesMetadata(interCaseCommonFiles); } - + @Override - String buildCategorySelectionString() { - //TODO - return ""; + String buildTabTitle() { + final String buildCategorySelectionString = this.buildCategorySelectionString(); + final String titleTemplate = Bundle.AbstractCommonFilesMetadataBuilder_buildTabTitle_titleInterSingle(); + return String.format(titleTemplate, new Object[]{correlationCaseName, buildCategorySelectionString}); } + } diff --git a/Core/src/org/sleuthkit/autopsy/commonfilesearch/SingleDataSourceCommonFilesAlgorithm.java b/Core/src/org/sleuthkit/autopsy/commonfilesearch/SingleDataSourceCommonFilesAlgorithm.java index a6594eb664..c97b15ae0b 100644 --- a/Core/src/org/sleuthkit/autopsy/commonfilesearch/SingleDataSourceCommonFilesAlgorithm.java +++ b/Core/src/org/sleuthkit/autopsy/commonfilesearch/SingleDataSourceCommonFilesAlgorithm.java @@ -56,7 +56,7 @@ final public class SingleDataSourceCommonFilesAlgorithm extends IntraCaseCommonF @Override public String buildTabTitle() { final String buildCategorySelectionString = this.buildCategorySelectionString(); - final String titleTemplate = Bundle.CommonFilesMetadataBuilder_buildTabTitle_titleSingle(); + final String titleTemplate = Bundle.AbstractCommonFilesMetadataBuilder_buildTabTitle_titleIntraSingle(); return String.format(titleTemplate, new Object[]{this.dataSourceName, buildCategorySelectionString}); } }