diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/AddEditCentralRepoCommentAction.java b/Core/src/org/sleuthkit/autopsy/centralrepository/AddEditCentralRepoCommentAction.java index b1069ba5b9..1bef9719bb 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/AddEditCentralRepoCommentAction.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/AddEditCentralRepoCommentAction.java @@ -67,7 +67,7 @@ public final class AddEditCentralRepoCommentAction extends AbstractAction { addToDatabase = true; final List md5CorrelationAttr = CorrelationAttributeUtil.makeCorrAttrsForSearch(file); if (!md5CorrelationAttr.isEmpty()) { - //for an abstract file the 'list' of attributes will be a single attribute or empty and is returning a list for consistancy with other makeCorrAttrsForSearch methods per 7852 + //for an abstract file the 'list' of attributes will be a single attribute or empty and is returning a list for consistency with other makeCorrAttrsForSearch methods per 7852 correlationAttributeInstance = md5CorrelationAttr.get(0); } else { correlationAttributeInstance = null; diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepository.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepository.java index 289dfa476f..975ae93b46 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepository.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepository.java @@ -67,7 +67,7 @@ public interface CentralRepository { * are no in-use connections when you call this method. * * @throws CentralRepoException if there is a problem closing the connection - * pool. + * pool. */ void shutdownConnections() throws CentralRepoException; @@ -104,20 +104,20 @@ public interface CentralRepository { /** * Add a new name/value pair in the db_info table. * - * @param name Key to set + * @param name Key to set * @param value Value to set * * @throws CentralRepoException */ - public void newDbInfo(String name, String value) throws CentralRepoException; + void newDbInfo(String name, String value) throws CentralRepoException; /** * Set the data source object id for a specific entry in the data_sources * table * - * @param rowId - the row id for the data_sources table entry + * @param rowId - the row id for the data_sources table entry * @param dataSourceObjectId - the object id for the data source from the - * caseDb + * caseDb */ void addDataSourceObjectId(int rowId, long dataSourceObjectId) throws CentralRepoException; @@ -130,17 +130,17 @@ public interface CentralRepository { * * @throws CentralRepoException */ - public String getDbInfo(String name) throws CentralRepoException; + String getDbInfo(String name) throws CentralRepoException; /** * Update the value for a name in the name/value db_info table. * - * @param name Name to find + * @param name Name to find * @param value Value to assign to name. * * @throws CentralRepoException */ - public void updateDbInfo(String name, String value) throws CentralRepoException; + void updateDbInfo(String name, String value) throws CentralRepoException; /** * Creates new Case in the database @@ -170,9 +170,11 @@ public interface CentralRepository { * user is not found in the examiner table. * * @param examinerLoginName user name to look for. + * * @return CentralRepoExaminer for the given user name. + * * @throws CentralRepoException If there is an error in looking up or - * inserting the user in the examiners table. + * inserting the user in the examiners table. */ CentralRepoExaminer getOrInsertExaminer(String examinerLoginName) throws CentralRepoException; @@ -218,7 +220,7 @@ public interface CentralRepository { * @param eamDataSource the data source to add * * @return - A CorrelationDataSource object with data source's central - * repository id + * repository id */ CorrelationDataSource newDataSource(CorrelationDataSource eamDataSource) throws CentralRepoException; @@ -247,8 +249,8 @@ public interface CentralRepository { /** * Retrieves Data Source details based on data source device ID * - * @param correlationCase the current CorrelationCase used for ensuring - * uniqueness of DataSource + * @param correlationCase the current CorrelationCase used for ensuring + * uniqueness of DataSource * @param caseDbDataSourceId the data source device ID number * * @return The data source @@ -259,8 +261,8 @@ public interface CentralRepository { * Retrieves Data Source details based on data source ID * * @param correlationCase the current CorrelationCase used for ensuring - * uniqueness of DataSource - * @param dataSourceId the data source ID number + * uniqueness of DataSource + * @param dataSourceId the data source ID number * * @return The data source */ @@ -277,7 +279,7 @@ public interface CentralRepository { * Changes the name of a data source in the DB * * @param eamDataSource The data source - * @param newName The new name + * @param newName The new name * * @throws CentralRepoException */ @@ -295,12 +297,12 @@ public interface CentralRepository { * Retrieves eamArtifact instances from the database that are associated * with the eamArtifactType and eamArtifactValues of the given eamArtifact. * - * @param aType EamArtifact.Type to search for + * @param aType EamArtifact.Type to search for * @param values The list of correlation values to get - * CorrelationAttributeInstances for + * CorrelationAttributeInstances for * * @return List of artifact instances for a given type with the specified - * values + * values * * @throws CorrelationAttributeNormalizationException * @throws CentralRepoException @@ -326,14 +328,14 @@ public interface CentralRepository { * with the eamArtifactType and eamArtifactValues of the given eamArtifact * for the specified cases. * - * @param aType The type of the artifact - * @param values The list of correlation values to get - * CorrelationAttributeInstances for + * @param aType The type of the artifact + * @param values The list of correlation values to get + * CorrelationAttributeInstances for * @param caseIds The list of central repository case ids to get - * CorrelationAttributeInstances for + * CorrelationAttributeInstances for * * @return List of artifact instances for a given type with the specified - * values for the specified cases + * values for the specified cases * * @throws CorrelationAttributeNormalizationException * @throws CentralRepoException @@ -348,7 +350,7 @@ public interface CentralRepository { * @param value Value to search for * * @return Number of artifact instances having ArtifactType and - * ArtifactValue. + * ArtifactValue. */ Long getCountArtifactInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException; @@ -373,6 +375,22 @@ public interface CentralRepository { */ Long getCountUniqueCaseDataSourceTuplesHavingTypeValue(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException; + /** + * Gets the count of cases that have an instance of a given correlation + * attribute. + * + * This count will ignore the specified instance of the correlation + * attribute and any other instances of this correlation attribute existing + * on the same object. + * + * @param instance The instance having its cases with other occurrences + * counted. + * + * @return Number of cases with additional instances of this + * CorrelationAttributeInstance. + */ + Long getCountCasesWithOtherInstances(CorrelationAttributeInstance instance) throws CentralRepoException, CorrelationAttributeNormalizationException; + /** * Retrieves number of data sources in the database. * @@ -387,7 +405,7 @@ public interface CentralRepository { * @param correlationDataSource Data source to search for * * @return Number of artifact instances having caseDisplayName and - * dataSource + * dataSource */ Long getCountArtifactInstancesByCaseDataSource(CorrelationDataSource correlationDataSource) throws CentralRepoException; @@ -416,7 +434,7 @@ public interface CentralRepository { * in the associated CorrelationAttribute object. * * @param eamArtifact The correlation attribute whose database instance will - * be updated. + * be updated. * * @throws CentralRepoException */ @@ -429,11 +447,11 @@ public interface CentralRepository { * Method exists to support instances added using Central Repository version * 1,1 and older * - * @param type The type of instance. - * @param correlationCase The case tied to the instance. + * @param type The type of instance. + * @param correlationCase The case tied to the instance. * @param correlationDataSource The data source tied to the instance. - * @param value The value tied to the instance. - * @param filePath The file path tied to the instance. + * @param value The value tied to the instance. + * @param filePath The file path tied to the instance. * * @return The correlation attribute if it exists; otherwise null. * @@ -446,10 +464,11 @@ public interface CentralRepository { * Find a correlation attribute in the Central Repository database given the * instance type, case, data source, object id. * - * @param type The type of instance. - * @param correlationCase The case tied to the instance. + * @param type The type of instance. + * @param correlationCase The case tied to the instance. * @param correlationDataSource The data source tied to the instance. - * @param objectID The object id of the file tied to the instance. + * @param objectID The object id of the file tied to the + * instance. * * @return The correlation attribute if it exists; otherwise null. * @@ -485,7 +504,7 @@ public interface CentralRepository { * @param value Value to search for * * @return List of cases containing this artifact with instances marked as - * bad + * bad * * @throws CentralRepoException */ @@ -499,7 +518,7 @@ public interface CentralRepository { * @param value Value to search for * * @return List of cases containing this artifact with instances marked as - * bad + * bad * * @throws CentralRepoException */ @@ -512,7 +531,7 @@ public interface CentralRepository { * * @throws CentralRepoException */ - public void deleteReferenceSet(int referenceSetID) throws CentralRepoException; + void deleteReferenceSet(int referenceSetID) throws CentralRepoException; /** * Check whether a reference set with the given parameters exists in the @@ -527,7 +546,7 @@ public interface CentralRepository { * * @throws CentralRepoException */ - public boolean referenceSetIsValid(int referenceSetID, String referenceSetName, String version) throws CentralRepoException; + boolean referenceSetIsValid(int referenceSetID, String referenceSetName, String version) throws CentralRepoException; /** * Check whether a reference set with the given name/version is in the @@ -541,7 +560,7 @@ public interface CentralRepository { * * @throws CentralRepoException */ - public boolean referenceSetExists(String referenceSetName, String version) throws CentralRepoException; + boolean referenceSetExists(String referenceSetName, String version) throws CentralRepoException; /** * Check if the given file hash is in this reference set. Only searches the @@ -554,15 +573,15 @@ public interface CentralRepository { * * @throws CentralRepoException */ - public boolean isFileHashInReferenceSet(String hash, int referenceSetID) throws CentralRepoException, CorrelationAttributeNormalizationException; + boolean isFileHashInReferenceSet(String hash, int referenceSetID) throws CentralRepoException, CorrelationAttributeNormalizationException; /** * Retrieves the given file HashHitInfo if the given file hash is in this * reference set. Only searches the reference_files table. * - * @param hash The hash to find in a search. + * @param hash The hash to find in a search. * @param referenceSetID The referenceSetID within which the file should - * exist. + * exist. * * @return The HashHitInfo if found or null if not found. * @@ -580,7 +599,7 @@ public interface CentralRepository { * * @return true if the hash is found in the reference set */ - public boolean isValueInReferenceSet(String value, int referenceSetID, int correlationTypeID) throws CentralRepoException, CorrelationAttributeNormalizationException; + boolean isValueInReferenceSet(String value, int referenceSetID, int correlationTypeID) throws CentralRepoException, CorrelationAttributeNormalizationException; /** * Is the artifact known as bad according to the reference entries? @@ -638,7 +657,7 @@ public interface CentralRepository { * Update an existing organization. * * @param updatedOrganization the values the Organization with the same ID - * will be updated to in the database. + * will be updated to in the database. * * @throws CentralRepoException */ @@ -690,7 +709,8 @@ public interface CentralRepository { * Add a new reference instance * * @param eamGlobalFileInstance The reference instance to add - * @param correlationType Correlation Type that this Reference Instance is + * @param correlationType Correlation Type that this Reference + * Instance is * * @throws CentralRepoException */ @@ -700,8 +720,8 @@ public interface CentralRepository { * Insert the bulk collection of Global File Instances * * @param globalInstances a Set of EamGlobalFileInstances to insert into the - * db. - * @param contentType the Type of the global instances + * db. + * @param contentType the Type of the global instances * * @throws CentralRepoException */ @@ -710,7 +730,7 @@ public interface CentralRepository { /** * Get all reference entries having a given correlation type and value * - * @param aType Type to use for matching + * @param aType Type to use for matching * @param aValue Value to use for matching * * @return List of all global file instances with a type and value @@ -735,7 +755,7 @@ public interface CentralRepository { * used to correlate artifacts. * * @return List of EamArtifact.Type's. If none are defined in the database, - * the default list will be returned. + * the default list will be returned. * * @throws CentralRepoException */ @@ -746,7 +766,7 @@ public interface CentralRepository { * artifacts. * * @return List of enabled EamArtifact.Type's. If none are defined in the - * database, the default list will be returned. + * database, the default list will be returned. * * @throws CentralRepoException */ @@ -757,7 +777,7 @@ public interface CentralRepository { * correlate artifacts. * * @return List of supported EamArtifact.Type's. If none are defined in the - * database, the default list will be returned. + * database, the default list will be returned. * * @throws CentralRepoException */ @@ -788,7 +808,7 @@ public interface CentralRepository { * * @throws CentralRepoException */ - public void upgradeSchema() throws CentralRepoException, SQLException, IncompatibleCentralRepoException; + void upgradeSchema() throws CentralRepoException, SQLException, IncompatibleCentralRepoException; /** * Gets an exclusive lock (if applicable). Will return the lock if @@ -799,14 +819,14 @@ public interface CentralRepository { * @return the lock, or null if locking is not supported * * @throws CentralRepoException if the coordination service is running but - * we fail to get the lock + * we fail to get the lock */ - public CoordinationService.Lock getExclusiveMultiUserDbLock() throws CentralRepoException; + CoordinationService.Lock getExclusiveMultiUserDbLock() throws CentralRepoException; /** * Process the Artifact instance in the EamDb * - * @param type EamArtifact.Type to search for + * @param type EamArtifact.Type to search for * @param instanceTableCallback callback to process the instance * * @throws CentralRepoException @@ -816,9 +836,9 @@ public interface CentralRepository { /** * Process the Artifact instance in the EamDb * - * @param type EamArtifact.Type to search for + * @param type EamArtifact.Type to search for * @param instanceTableCallback callback to process the instance - * @param whereClause query string to execute + * @param whereClause query string to execute * * @throws CentralRepoException */ @@ -827,18 +847,18 @@ public interface CentralRepository { /** * Process a SELECT query * - * @param selectClause query string to execute + * @param selectClause query string to execute * @param instanceTableCallback callback to process the instance * * @throws CentralRepoException */ - public void processSelectClause(String selectClause, InstanceTableCallback instanceTableCallback) throws CentralRepoException; + void processSelectClause(String selectClause, InstanceTableCallback instanceTableCallback) throws CentralRepoException; /** * Executes an INSERT/UPDATE/DELETE sql as a prepared statement, on the * central repository database. * - * @param sql sql to execute. + * @param sql sql to execute. * @param params List of query params to use, may be empty. * * @throws CentralRepoException If there is an error. @@ -849,8 +869,8 @@ public interface CentralRepository { * Executes a SELECT query sql as a prepared statement, on the central * repository database. * - * @param sql sql to execute. - * @param params List of query params to use, may be empty. + * @param sql sql to execute. + * @param params List of query params to use, may be empty. * @param queryCallback Query callback to handle the result of the query. * * @throws CentralRepoException If there is an error. @@ -861,7 +881,9 @@ public interface CentralRepository { * Get account type by type name. * * @param accountTypeName account type name to look for + * * @return CR account type (if found) + * * @throws CentralRepoException */ Optional getAccountTypeByName(String accountTypeName) throws CentralRepoException; @@ -879,15 +901,17 @@ public interface CentralRepository { * Get an account from the accounts table matching the given type/ID. * Inserts a row if one doesn't exists. * - * @param crAccountType CR account type to look for or create + * @param crAccountType CR account type to look for or create * @param accountUniqueID type specific unique account id + * * @return CR account - * - * @throws CentralRepoException If there is an error accessing Central Repository. + * + * @throws CentralRepoException If there is an error accessing Central + * Repository. * @throws InvalidAccountIDException If the account identifier is not valid. */ CentralRepoAccount getOrCreateAccount(CentralRepoAccount.CentralRepoAccountType crAccountType, String accountUniqueID) throws InvalidAccountIDException, CentralRepoException; - + /** * Gets an account from the accounts table matching the given type/ID, if * one exists. @@ -897,7 +921,8 @@ public interface CentralRepository { * * @return CR account, if found, null otherwise. * - * @throws CentralRepoException If there is an error accessing Central Repository. + * @throws CentralRepoException If there is an error accessing Central + * Repository. * @throws InvalidAccountIDException If the account identifier is not valid. */ CentralRepoAccount getAccount(CentralRepoAccount.CentralRepoAccountType crAccountType, String accountUniqueID) throws InvalidAccountIDException, CentralRepoException; diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeUtil.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeUtil.java index 5e64e3994b..c8dfa81f7c 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeUtil.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CorrelationAttributeUtil.java @@ -617,7 +617,7 @@ public class CorrelationAttributeUtil { */ public static CorrelationAttributeInstance getCorrAttrForFile(AbstractFile file) { - if (!isSupportedAbstractFileType(file)) { + if (!CentralRepository.isEnabled() || !isSupportedAbstractFileType(file)) { return null; } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepo.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepo.java index e72bfa9359..9e079c69db 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepo.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/PostgresCentralRepo.java @@ -205,7 +205,7 @@ final class PostgresCentralRepo extends RdbmsCentralRepo { } } } - + @Override protected String getConflictClause() { return CONFLICT_CLAUSE; @@ -269,4 +269,5 @@ final class PostgresCentralRepo extends RdbmsCentralRepo { return columnExists; } + } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/RdbmsCentralRepo.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/RdbmsCentralRepo.java index 2e2dafbefd..1442a0ec62 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/RdbmsCentralRepo.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/RdbmsCentralRepo.java @@ -1,7 +1,7 @@ /* * Central Repository * - * Copyright 2015-2020 Basis Technology Corp. + * Copyright 2015-2021 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -212,8 +212,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting value for name.", ex); } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } @@ -505,8 +505,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting case details.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } @@ -565,8 +565,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting case details.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } @@ -602,8 +602,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting all cases.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } @@ -787,8 +787,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting data source.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } @@ -851,8 +851,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting data source.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } @@ -885,8 +885,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting all data sources.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } @@ -1090,7 +1090,7 @@ abstract class RdbmsCentralRepo implements CentralRepository { String insertSQL; switch (CentralRepoDbManager.getSavedDbChoice().getDbPlatform()) { case POSTGRESQL: - insertSQL = "INSERT INTO accounts (account_type_id, account_unique_identifier) VALUES (?, ?) " + getConflictClause(); //NON-NLS + insertSQL = "INSERT INTO accounts (account_type_id, account_unique_identifier) VALUES (?, ?) " + getConflictClause(); //NON-NLS break; case SQLITE: insertSQL = "INSERT OR IGNORE INTO accounts (account_type_id, account_unique_identifier) VALUES (?, ?) "; //NON-NLS @@ -1098,7 +1098,6 @@ abstract class RdbmsCentralRepo implements CentralRepository { default: throw new CentralRepoException(String.format("Cannot add account to currently selected CR database platform %s", CentralRepoDbManager.getSavedDbChoice().getDbPlatform())); //NON-NLS } - try (Connection connection = connect(); PreparedStatement preparedStatement = connection.prepareStatement(insertSQL);) { @@ -1193,7 +1192,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { * @return CentralRepoAccount for the give type/id. May return null if not * found. * - * @throws CentralRepoException If there is an error accessing Central Repository. + * @throws CentralRepoException If there is an error accessing Central + * Repository. * @throws InvalidAccountIDException If the account identifier is not valid. */ @Override @@ -1390,8 +1390,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting artifact instances by artifactType and artifactValue.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } return artifactInstances; @@ -1432,8 +1432,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting count of artifact instances by artifactType and artifactValue.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } @@ -1488,14 +1488,65 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error counting unique caseDisplayName/dataSource tuples having artifactType and artifactValue.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } return instanceCount; } + @Override + public Long getCountCasesWithOtherInstances(CorrelationAttributeInstance instance) throws CentralRepoException, CorrelationAttributeNormalizationException { + Long instanceCount = 0L; + if (instance != null) { + Long sourceObjID = instance.getFileObjectId(); + //The CorrelationAttributeInstance will have a CorrelationCase, however that correlation case's ID will be null if the case is not in the CR. + int correlationCaseId = instance.getCorrelationCase().getID(); + String normalizedValue = CorrelationAttributeNormalizer.normalize(instance.getCorrelationType(), instance.getCorrelationValue()); + Connection conn = connect(); + PreparedStatement preparedStatement = null; + String tableName = CentralRepoDbUtil.correlationTypeToInstanceTableName(instance.getCorrelationType()); + ResultSet resultSet = null; + try { + if (correlationCaseId > 0 && sourceObjID != null) { + //The CorrelationCase is in the Central repository. + String sql + = "SELECT count(*) FROM (SELECT DISTINCT case_id FROM " //Get distinct cases with a matching value in the corresponding table from the central repository. + + tableName + + " WHERE value=? AND NOT (file_obj_id=? AND case_id=?)) AS " //Check the file_obj_id AND case_id to ensure we ignore the currently selected instance. + + tableName + + "_other_case_count"; + preparedStatement = conn.prepareStatement(sql); + preparedStatement.setString(1, normalizedValue); + preparedStatement.setLong(2, sourceObjID); + preparedStatement.setInt(3, correlationCaseId); + } else { + //The CorrelationCase is NOT in the central repository. + String sql + = "SELECT count(*) FROM (SELECT DISTINCT case_id FROM " //Get all distinct cases with a matching value in the corresponding table from the central repository. + + tableName + + " WHERE value=? AS " + + tableName + + "_other_case_count"; + preparedStatement = conn.prepareStatement(sql); + preparedStatement.setString(1, normalizedValue); + } + resultSet = preparedStatement.executeQuery(); + resultSet.next(); + instanceCount = resultSet.getLong(1); + } catch (SQLException ex) { + throw new CentralRepoException("Error counting unique caseDisplayName/dataSource tuples having artifactType and artifactValue.", ex); // NON-NLS + } finally { + CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); + CentralRepoDbUtil.closeConnection(conn); + } + } + + return instanceCount; + } + @Override public Long getCountUniqueDataSources() throws CentralRepoException { Connection conn = connect(); @@ -1514,8 +1565,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error counting data sources.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } @@ -1561,8 +1612,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error counting artifact instances by caseName/dataSource.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } @@ -1888,8 +1939,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting notable artifact instances.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } @@ -1959,8 +2010,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting notable artifact instances.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } @@ -2046,9 +2097,9 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting/setting artifact instance knownStatus=" + knownStatus.getName(), ex); // NON-NLS } finally { + CentralRepoDbUtil.closeResultSet(resultSet); CentralRepoDbUtil.closeStatement(preparedUpdate); CentralRepoDbUtil.closeStatement(preparedQuery); - CentralRepoDbUtil.closeResultSet(resultSet); CentralRepoDbUtil.closeConnection(conn); } } @@ -2088,8 +2139,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting count of notable artifact instances.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } @@ -2143,8 +2194,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting notable artifact instances.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } @@ -2195,8 +2246,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting notable artifact instances.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } @@ -2339,8 +2390,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error determining if value (" + normalizeValued + ") is in reference set " + referenceSetID, ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } } @@ -2378,8 +2429,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error determining if value (" + normalizeValued + ") is in reference set " + referenceSetID, ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } @@ -2422,8 +2473,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error determining if artifact is notable by reference.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } @@ -2463,8 +2514,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting all artifact instances from instances table", ex); } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } } @@ -2509,8 +2560,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting all artifact instances from instances table", ex); } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } } @@ -2548,21 +2599,21 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error running query", ex); } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } } @Override public void executeCommand(String sql, List params) throws CentralRepoException { - + try (Connection conn = connect();) { - + PreparedStatement preparedStatement = conn.prepareStatement(sql); - - // Fill in the params - if (params != null) { + + // Fill in the params + if (params != null) { int paramIndex = 1; for (Object param : params) { preparedStatement.setObject(paramIndex, param); @@ -2582,10 +2633,9 @@ abstract class RdbmsCentralRepo implements CentralRepository { throw new CentralRepoException("Query callback is null"); } - - try ( Connection conn = connect();) { - PreparedStatement preparedStatement = conn.prepareStatement(sql); - + try (Connection conn = connect();) { + PreparedStatement preparedStatement = conn.prepareStatement(sql); + // fill in the params if (params != null) { int paramIndex = 1; @@ -2600,7 +2650,7 @@ abstract class RdbmsCentralRepo implements CentralRepository { } } catch (SQLException ex) { throw new CentralRepoException(String.format("Error executing prepared statement for SQL query %s", sql), ex); - } + } } @Override @@ -2635,8 +2685,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error inserting new organization.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(generatedKeys); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } } @@ -2668,8 +2718,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting all organizations.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } } @@ -2701,8 +2751,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting organization by id.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } } @@ -2853,9 +2903,9 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error executing query when attempting to delete organization by id.", ex); // NON-NLS } finally { + CentralRepoDbUtil.closeResultSet(resultSet); CentralRepoDbUtil.closeStatement(checkIfUsedStatement); CentralRepoDbUtil.closeStatement(deleteOrgStatement); - CentralRepoDbUtil.closeResultSet(resultSet); CentralRepoDbUtil.closeConnection(conn); } } @@ -2917,9 +2967,9 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error inserting new global set.", ex); // NON-NLS } finally { + CentralRepoDbUtil.closeResultSet(resultSet); CentralRepoDbUtil.closeStatement(preparedStatement1); CentralRepoDbUtil.closeStatement(preparedStatement2); - CentralRepoDbUtil.closeResultSet(resultSet); CentralRepoDbUtil.closeConnection(conn); } } @@ -2954,8 +3004,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting reference set by id.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement1); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement1); CentralRepoDbUtil.closeConnection(conn); } } @@ -2993,8 +3043,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting reference sets.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement1); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement1); CentralRepoDbUtil.closeConnection(conn); } return results; @@ -3071,8 +3121,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { throw new CentralRepoException("Error testing whether reference set exists (name: " + referenceSetName + " version: " + version, ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement1); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement1); CentralRepoDbUtil.closeConnection(conn); } } @@ -3162,8 +3212,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting reference instances by type and value.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement1); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement1); CentralRepoDbUtil.closeConnection(conn); } @@ -3243,9 +3293,9 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error inserting new correlation type.", ex); // NON-NLS } finally { + CentralRepoDbUtil.closeResultSet(resultSet); CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeStatement(preparedStatementQuery); - CentralRepoDbUtil.closeResultSet(resultSet); CentralRepoDbUtil.closeConnection(conn); } return typeId; @@ -3297,9 +3347,9 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error inserting new correlation type.", ex); // NON-NLS } finally { + CentralRepoDbUtil.closeResultSet(resultSet); CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeStatement(preparedStatementQuery); - CentralRepoDbUtil.closeResultSet(resultSet); CentralRepoDbUtil.closeConnection(conn); } return typeId; @@ -3345,8 +3395,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting enabled correlation types.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } } @@ -3380,8 +3430,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting supported correlation types.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } } @@ -3474,8 +3524,8 @@ abstract class RdbmsCentralRepo implements CentralRepository { } catch (SQLException ex) { throw new CentralRepoException("Error getting correlation type by id.", ex); // NON-NLS } finally { - CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeResultSet(resultSet); + CentralRepoDbUtil.closeStatement(preparedStatement); CentralRepoDbUtil.closeConnection(conn); } } diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepo.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepo.java index df0327469d..688266486b 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepo.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/SqliteCentralRepo.java @@ -624,6 +624,16 @@ final class SqliteCentralRepo extends RdbmsCentralRepo { releaseSharedLock(); } } + + @Override + public Long getCountCasesWithOtherInstances(CorrelationAttributeInstance instance) throws CentralRepoException, CorrelationAttributeNormalizationException { + try { + acquireSharedLock(); + return super.getCountCasesWithOtherInstances(instance); + } finally { + releaseSharedLock(); + } + } @Override public Long getCountUniqueDataSources() throws CentralRepoException { diff --git a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/CaseEventListener.java b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/CaseEventListener.java index 4fe5467bef..39d93bd76a 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/CaseEventListener.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/eventlisteners/CaseEventListener.java @@ -322,7 +322,7 @@ public final class CaseEventListener implements PropertyChangeListener { private void setContentKnownStatus(AbstractFile af, TskData.FileKnown knownStatus) { final List md5CorrelationAttr = CorrelationAttributeUtil.makeCorrAttrsForSearch(af); if (!md5CorrelationAttr.isEmpty()) { - //for an abstract file the 'list' of attributes will be a single attribute or empty and is returning a list for consistancy with other makeCorrAttrsForSearch methods per 7852 + //for an abstract file the 'list' of attributes will be a single attribute or empty and is returning a list for consistency with other makeCorrAttrsForSearch methods per 7852 // send update to Central Repository db try { dbManager.setAttributeInstanceKnownStatus(md5CorrelationAttr.get(0), knownStatus); @@ -436,7 +436,6 @@ public final class CaseEventListener implements PropertyChangeListener { } } catch (TskCoreException ex) { LOGGER.log(Level.SEVERE, "Failed to obtain tags manager for case.", ex); - return; } } @@ -569,9 +568,9 @@ public final class CaseEventListener implements PropertyChangeListener { if (!hasTagWithConflictingKnownStatus) { Content taggedContent = contentTag.getContent(); if (taggedContent instanceof AbstractFile) { - final List eamArtifact = CorrelationAttributeUtil.makeCorrAttrsForSearch((AbstractFile) taggedContent); + final List eamArtifact = CorrelationAttributeUtil.makeCorrAttrsForSearch(taggedContent); if (!eamArtifact.isEmpty()) { - //for an abstract file the 'list' of attributes will be a single attribute or empty and is returning a list for consistancy with other makeCorrAttrsForSearch methods per 7852 + //for an abstract file the 'list' of attributes will be a single attribute or empty and is returning a list for consistency with other makeCorrAttrsForSearch methods per 7852 CentralRepository.getInstance().setAttributeInstanceKnownStatus(eamArtifact.get(0), tagName.getKnownStatus()); } } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/AbstractAbstractFileNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/AbstractAbstractFileNode.java index 14534c3e3e..6081d0703c 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/AbstractAbstractFileNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/AbstractAbstractFileNode.java @@ -182,9 +182,13 @@ public abstract class AbstractAbstractFileNode extends A Pair scorePropAndDescr = getScorePropertyAndDescription(tags); Score value = scorePropAndDescr.getLeft(); String descr = scorePropAndDescr.getRight(); - CorrelationAttributeInstance attribute = getCorrelationAttributeInstance(); + List listWithJustFileAttr = new ArrayList<>(); + CorrelationAttributeInstance corrInstance = CorrelationAttributeUtil.getCorrAttrForFile(content); + if (corrInstance != null) { + listWithJustFileAttr.add(corrInstance); + } updateSheet(new NodeProperty<>(SCORE.toString(), SCORE.toString(), descr, value), - new NodeProperty<>(COMMENT.toString(), COMMENT.toString(), NO_DESCR, getCommentProperty(tags, attribute)) + new NodeProperty<>(COMMENT.toString(), COMMENT.toString(), NO_DESCR, getCommentProperty(tags, listWithJustFileAttr)) ); } } else if (eventType.equals(Case.Events.CONTENT_TAG_DELETED.toString())) { @@ -194,17 +198,25 @@ public abstract class AbstractAbstractFileNode extends A Pair scorePropAndDescr = getScorePropertyAndDescription(tags); Score value = scorePropAndDescr.getLeft(); String descr = scorePropAndDescr.getRight(); - CorrelationAttributeInstance attribute = getCorrelationAttributeInstance(); + List listWithJustFileAttr = new ArrayList<>(); + CorrelationAttributeInstance corrInstance = CorrelationAttributeUtil.getCorrAttrForFile(content); + if (corrInstance != null) { + listWithJustFileAttr.add(corrInstance); + } updateSheet(new NodeProperty<>(SCORE.toString(), SCORE.toString(), descr, value), - new NodeProperty<>(COMMENT.toString(), COMMENT.toString(), NO_DESCR, getCommentProperty(tags, attribute)) + new NodeProperty<>(COMMENT.toString(), COMMENT.toString(), NO_DESCR, getCommentProperty(tags, listWithJustFileAttr)) ); } } else if (eventType.equals(Case.Events.CR_COMMENT_CHANGED.toString())) { CommentChangedEvent event = (CommentChangedEvent) evt; if (event.getContentID() == content.getId()) { List tags = getAllTagsFromDatabase(); - CorrelationAttributeInstance attribute = getCorrelationAttributeInstance(); - updateSheet(new NodeProperty<>(COMMENT.toString(), COMMENT.toString(), NO_DESCR, getCommentProperty(tags, attribute))); + List listWithJustFileAttr = new ArrayList<>(); + CorrelationAttributeInstance corrInstance = CorrelationAttributeUtil.getCorrAttrForFile(content); + if (corrInstance != null) { + listWithJustFileAttr.add(corrInstance); + } + updateSheet(new NodeProperty<>(COMMENT.toString(), COMMENT.toString(), NO_DESCR, getCommentProperty(tags, listWithJustFileAttr))); } } else if (eventType.equals(NodeSpecificEvents.TRANSLATION_AVAILABLE.toString())) { this.setDisplayName(evt.getNewValue().toString()); @@ -411,16 +423,15 @@ public abstract class AbstractAbstractFileNode extends A "# {0} - occurrenceCount", "AbstractAbstractFileNode.createSheet.count.description=There were {0} datasource(s) found with occurrences of the MD5 correlation value"}) @Override - protected Pair getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, - String defaultDescription) { + protected Pair getCountPropertyAndDescription(CorrelationAttributeInstance attributeInstance, String defaultDescription) { Long count = -1L; //The column renderer will not display negative values, negative value used when count unavailble to preserve sorting String description = defaultDescription; try { //don't perform the query if there is no correlation value - if (attributeType != null && StringUtils.isNotBlank(attributeValue)) { - count = CentralRepository.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue(attributeType, attributeValue); + if (attributeInstance != null && StringUtils.isNotBlank(attributeInstance.getCorrelationValue())) { + count = CentralRepository.getInstance().getCountCasesWithOtherInstances(attributeInstance); description = Bundle.AbstractAbstractFileNode_createSheet_count_description(count); - } else if (attributeType != null) { + } else if (attributeInstance != null) { description = Bundle.AbstractAbstractFileNode_createSheet_count_hashLookupNotRun_description(); } } catch (CentralRepoException ex) { @@ -434,7 +445,7 @@ public abstract class AbstractAbstractFileNode extends A @NbBundle.Messages({ "AbstractAbstractFileNode.createSheet.comment.displayName=C"}) @Override - protected HasCommentStatus getCommentProperty(List tags, CorrelationAttributeInstance attribute) { + protected HasCommentStatus getCommentProperty(List tags, List attributes) { DataResultViewerTable.HasCommentStatus status = !tags.isEmpty() ? DataResultViewerTable.HasCommentStatus.TAG_NO_COMMENT : DataResultViewerTable.HasCommentStatus.NO_COMMENT; @@ -445,11 +456,16 @@ public abstract class AbstractAbstractFileNode extends A break; } } - if (attribute != null && !StringUtils.isBlank(attribute.getComment())) { - if (status == DataResultViewerTable.HasCommentStatus.TAG_COMMENT) { - status = DataResultViewerTable.HasCommentStatus.CR_AND_TAG_COMMENTS; - } else { - status = DataResultViewerTable.HasCommentStatus.CR_COMMENT; + if (attributes != null && !attributes.isEmpty()) { + for (CorrelationAttributeInstance attribute : attributes) { + if (attribute != null && !StringUtils.isBlank(attribute.getComment())) { + if (status == DataResultViewerTable.HasCommentStatus.TAG_COMMENT) { + status = DataResultViewerTable.HasCommentStatus.CR_AND_TAG_COMMENTS; + } else { + status = DataResultViewerTable.HasCommentStatus.CR_COMMENT; + } + break; + } } } return status; @@ -490,15 +506,6 @@ public abstract class AbstractAbstractFileNode extends A return new ArrayList<>(getContentTagsFromDatabase()); } - @Override - protected CorrelationAttributeInstance getCorrelationAttributeInstance() { - CorrelationAttributeInstance attribute = null; - if (CentralRepository.isEnabled() && !UserPreferences.getHideSCOColumns()) { - attribute = CorrelationAttributeUtil.getCorrAttrForFile(content); - } - return attribute; - } - static String getContentPath(AbstractFile file) { try { return file.getUniquePath(); diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/AbstractContentNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/AbstractContentNode.java index cb4bb9794c..2781c11ccc 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/AbstractContentNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/AbstractContentNode.java @@ -325,15 +325,6 @@ public abstract class AbstractContentNode extends ContentNode */ abstract protected List getAllTagsFromDatabase(); - /** - * Returns correlation attribute instance for the underlying content of the - * node. - * - * @return correlation attribute instance for the underlying content of the - * node. - */ - abstract protected CorrelationAttributeInstance getCorrelationAttributeInstance(); - /** * Returns Score property for the node. * @@ -352,7 +343,7 @@ public abstract class AbstractContentNode extends ContentNode } catch (TskCoreException ex) { logger.log(Level.WARNING, "Unable to get aggregate score for content with id: " + this.content.getId(), ex); } - + String significanceDisplay = score.getSignificance().getDisplayName(); String description = Bundle.AbstractContentNode_getScorePropertyAndDescription_description(significanceDisplay); return Pair.of(score, description); @@ -361,22 +352,30 @@ public abstract class AbstractContentNode extends ContentNode /** * Returns comment property for the node. * - * @param tags list of tags - * @param attribute correlation attribute instance + * Default implementation is a null implementation. + * + * @param tags The list of tags. + * @param attributes The list of correlation attribute instances. * * @return Comment property for the underlying content of the node. */ - abstract protected DataResultViewerTable.HasCommentStatus getCommentProperty(List tags, CorrelationAttributeInstance attribute); + protected DataResultViewerTable.HasCommentStatus getCommentProperty(List tags, List attributes) { + return DataResultViewerTable.HasCommentStatus.NO_COMMENT; + } /** * Returns occurrences/count property for the node. * - * @param attributeType the type of the attribute to count - * @param attributeValue the value of the attribute to count - * @param defaultDescription a description to use when none is determined by - * the getCountPropertyAndDescription method + * Default implementation is a null implementation. + * + * @param attribute The correlation attribute for which data will + * be retrieved. + * @param defaultDescription A description to use when none is determined by + * the getCountPropertyAndDescription method. * * @return count property for the underlying content of the node. */ - abstract protected Pair getCountPropertyAndDescription(Type attributeType, String attributeValue, String defaultDescription); + protected Pair getCountPropertyAndDescription(CorrelationAttributeInstance attribute, String defaultDescription) { + return Pair.of(-1L, NO_DESCR); + } } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java index fabb83bac0..64cece2956 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java @@ -54,9 +54,7 @@ import org.sleuthkit.autopsy.casemodule.events.CommentChangedEvent; import org.sleuthkit.autopsy.casemodule.events.ContentTagAddedEvent; import org.sleuthkit.autopsy.casemodule.events.ContentTagDeletedEvent; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance.Type; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeNormalizationException; -import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil; import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable; @@ -826,23 +824,6 @@ public class BlackboardArtifactNode extends AbstractContentNode tags, CorrelationAttributeInstance attribute) { + protected DataResultViewerTable.HasCommentStatus getCommentProperty(List tags, List attributes) { /* * Has a tag with a comment been applied to the artifact or its source @@ -877,50 +858,37 @@ public class BlackboardArtifactNode extends AbstractContentNode getCountPropertyAndDescription(Type corrAttrType, String attributeValue, String defaultDescription) { + protected Pair getCountPropertyAndDescription(CorrelationAttributeInstance attribute, String defaultDescription) { Long count = -1L; String description = defaultDescription; try { - if (corrAttrType != null && StringUtils.isNotBlank(attributeValue)) { - count = CentralRepository.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue(corrAttrType, attributeValue); - description = Bundle.BlackboardArtifactNode_createSheet_count_description(count, corrAttrType.getDisplayName()); - } else if (corrAttrType != null) { + if (attribute != null && StringUtils.isNotBlank(attribute.getCorrelationValue())) { + count = CentralRepository.getInstance().getCountCasesWithOtherInstances(attribute); + description = Bundle.BlackboardArtifactNode_createSheet_count_description(count, attribute.getCorrelationType().getDisplayName()); + } else if (attribute != null) { description = Bundle.BlackboardArtifactNode_createSheet_count_noCorrelationValues_description(); } } catch (CentralRepoException ex) { - logger.log(Level.SEVERE, MessageFormat.format("Error querying central repository for other occurences count (artifact objID={0}, corrAttrType={1}, corrAttrValue={2})", artifact.getId(), corrAttrType, attributeValue), ex); + logger.log(Level.SEVERE, MessageFormat.format("Error querying central repository for other occurences count (artifact objID={0}, corrAttrType={1}, corrAttrValue={2})", artifact.getId(), attribute.getCorrelationType(), attribute.getCorrelationValue()), ex); } catch (CorrelationAttributeNormalizationException ex) { - logger.log(Level.SEVERE, MessageFormat.format("Error normalizing correlation attribute for central repository query (artifact objID={0}, corrAttrType={2}, corrAttrValue={3})", artifact.getId(), corrAttrType, attributeValue), ex); + logger.log(Level.SEVERE, MessageFormat.format("Error normalizing correlation attribute for central repository query (artifact objID={0}, corrAttrType={2}, corrAttrValue={3})", artifact.getId(), attribute.getCorrelationType(), attribute.getCorrelationValue()), ex); } return Pair.of(count, description); } @@ -953,7 +921,7 @@ public class BlackboardArtifactNode extends AbstractContentNode countAndDescription = getCountPropertyAndDescription(attribute.getCorrelationType(), attribute.getCorrelationValue(), Bundle.BlackboardArtifactNode_createSheet_count_noCorrelationAttributes_description()); + Pair countAndDescription = getCountPropertyAndDescription(attribute, Bundle.BlackboardArtifactNode_createSheet_count_noCorrelationAttributes_description()); sheetSet.put(new NodeProperty<>(Bundle.BlackboardArtifactNode_createSheet_count_name(), Bundle.BlackboardArtifactNode_createSheet_count_displayName(), countAndDescription.getRight(), countAndDescription.getLeft())); } @@ -1333,7 +1301,9 @@ public class BlackboardArtifactNode extends AbstractContentNode tags, CorrelationAttributeInstance attribute) { - HasCommentStatus status = getCommentProperty(tags, attribute); + List attributes = new ArrayList<>(); + attributes.add(attribute); + HasCommentStatus status = getCommentProperty(tags, attributes); sheetSet.put(new NodeProperty<>(Bundle.BlackboardArtifactNode_createSheet_comment_name(), Bundle.BlackboardArtifactNode_createSheet_comment_displayName(), NO_DESCR, status)); } } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/GetSCOTask.java b/Core/src/org/sleuthkit/autopsy/datamodel/GetSCOTask.java index 64b8aa604f..c721fe9536 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/GetSCOTask.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/GetSCOTask.java @@ -24,12 +24,11 @@ import java.lang.ref.WeakReference; import java.util.List; import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance.Type; -import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil; import org.sleuthkit.autopsy.core.UserPreferences; import org.sleuthkit.autopsy.events.AutopsyEvent; import org.sleuthkit.datamodel.Tag; import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepository; +import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil; /** * Background task to get Score, Comment and Occurrences values for an Abstract @@ -58,27 +57,23 @@ class GetSCOTask implements Runnable { } // get the SCO column values List tags = contentNode.getAllTagsFromDatabase(); - SCOData scoData = new SCOData(); scoData.setScoreAndDescription(contentNode.getScorePropertyAndDescription(tags)); //getting the correlation attribute and setting the comment column is done before the eamdb isEnabled check - //because the Comment column will reflect the presence of comments in the CR when the CR is enabled, but reflect tag comments regardless - CorrelationAttributeInstance fileAttribute = contentNode.getCorrelationAttributeInstance(); - scoData.setComment(contentNode.getCommentProperty(tags, fileAttribute)); + //because the Comment column will reflect the presence of comments in the CR when the CR is enabled, but reflect tag comments regardless + String description = Bundle.GetSCOTask_occurrences_defaultDescription(); + List listOfPossibleAttributes = CorrelationAttributeUtil.makeCorrAttrsForSearch(contentNode.getContent()); + scoData.setComment(contentNode.getCommentProperty(tags, listOfPossibleAttributes)); + CorrelationAttributeInstance corInstance = null; if (CentralRepository.isEnabled()) { - Type type = null; - String value = null; - String description = Bundle.GetSCOTask_occurrences_defaultDescription(); - List listOfPossibleAttributes = CorrelationAttributeUtil.makeCorrAttrsForSearch(contentNode.getContent()); if (listOfPossibleAttributes.size() > 1) { //Don't display anything if there is more than 1 correlation property for an artifact but let the user know description = Bundle.GetSCOTask_occurrences_multipleProperties(); } else if (!listOfPossibleAttributes.isEmpty()) { //there should only be one item in the list - type = listOfPossibleAttributes.get(0).getCorrelationType(); - value = listOfPossibleAttributes.get(0).getCorrelationValue(); + corInstance = listOfPossibleAttributes.get(0); } - scoData.setCountAndDescription(contentNode.getCountPropertyAndDescription(type, value, description)); + scoData.setCountAndDescription(contentNode.getCountPropertyAndDescription(corInstance, description)); } // signal SCO data is available. diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/ImageNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/ImageNode.java index f5eed043fa..a7d458c805 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/ImageNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/ImageNode.java @@ -27,15 +27,12 @@ import java.util.List; import java.util.Set; import java.util.logging.Level; import javax.swing.Action; -import org.apache.commons.lang3.tuple.Pair; import org.openide.nodes.Sheet; import org.openide.util.NbBundle; import org.openide.util.NbBundle.Messages; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.DeleteDataSourceAction; import org.sleuthkit.autopsy.datasourcesummary.ui.ViewSummaryInformationAction; -import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.directorytree.ExplorerNodeActionVisitor; import org.sleuthkit.autopsy.directorytree.FileSearchAction; @@ -168,9 +165,9 @@ public class ImageNode extends AbstractContentNode { this.content.getTimeZone())); sheetSet.put(new NodeProperty<>(Bundle.ImageNode_createSheet_deviceId_name(), - Bundle.ImageNode_createSheet_deviceId_displayName(), - Bundle.ImageNode_createSheet_deviceId_desc(), - content.getDeviceId())); + Bundle.ImageNode_createSheet_deviceId_displayName(), + Bundle.ImageNode_createSheet_deviceId_desc(), + content.getDeviceId())); return sheet; } @@ -256,50 +253,4 @@ public class ImageNode extends AbstractContentNode { protected List getAllTagsFromDatabase() { return new ArrayList<>(); } - - /** - * Returns correlation attribute instance for the underlying content of the - * node. - * - * Null implementation of an abstract method. - * - * @return correlation attribute instance for the underlying content of the - * node. - */ - @Override - protected CorrelationAttributeInstance getCorrelationAttributeInstance() { - return null; - } - - /** - * Returns comment property for the node. - * - * Null implementation of an abstract method. - * - * @param tags list of tags - * @param attribute correlation attribute instance - * - * @return Comment property for the underlying content of the node. - */ - @Override - protected DataResultViewerTable.HasCommentStatus getCommentProperty(List tags, CorrelationAttributeInstance attribute) { - return DataResultViewerTable.HasCommentStatus.NO_COMMENT; - } - - /** - * Returns occurrences/count property for the node. - * - * Null implementation of an abstract method. - * - * @param attributeType the type of the attribute to count - * @param attributeValue the value of the attribute to coun - * @param defaultDescription a description to use when none is determined by - * the getCountPropertyAndDescription method - * - * @return count property for the underlying content of the node. - */ - @Override - protected Pair getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, String defaultDescription) { - return Pair.of(-1L, NO_DESCR); - } } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/OsAccounts.java b/Core/src/org/sleuthkit/autopsy/datamodel/OsAccounts.java index ade29e2cfa..5a34967ac8 100755 --- a/Core/src/org/sleuthkit/autopsy/datamodel/OsAccounts.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/OsAccounts.java @@ -30,7 +30,6 @@ import java.util.List; import java.util.Optional; import java.util.logging.Level; import javax.swing.Action; -import org.apache.commons.lang3.tuple.Pair; import org.openide.nodes.ChildFactory; import org.openide.nodes.Children; import org.openide.nodes.Node; @@ -40,8 +39,6 @@ import org.openide.util.NbBundle.Messages; import org.openide.util.WeakListeners; import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.events.OsAccountsUpdatedEvent; -import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable; import org.sleuthkit.autopsy.coreutils.Logger; import org.sleuthkit.autopsy.coreutils.TimeZoneUtils; import static org.sleuthkit.autopsy.datamodel.AbstractContentNode.backgroundTasksPool; @@ -335,21 +332,6 @@ public final class OsAccounts implements AutopsyVisitableItem { throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. } - @Override - protected CorrelationAttributeInstance getCorrelationAttributeInstance() { - return null; - } - - @Override - protected DataResultViewerTable.HasCommentStatus getCommentProperty(List tags, CorrelationAttributeInstance attribute) { - return DataResultViewerTable.HasCommentStatus.NO_COMMENT; - } - - @Override - protected Pair getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, String defaultDescription) { - return null; - } - @Override public T accept(ContentNodeVisitor visitor) { return visitor.visit(this); diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/PoolNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/PoolNode.java index 3050e25712..a2fe8c155c 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/PoolNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/PoolNode.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2019 Basis Technology Corp. + * Copyright 2019-2021 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -21,12 +21,8 @@ package org.sleuthkit.autopsy.datamodel; import java.util.ArrayList; import java.util.List; import javax.swing.Action; -import org.apache.commons.lang3.tuple.Pair; import org.openide.nodes.Sheet; import org.openide.util.NbBundle; -import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable; -import static org.sleuthkit.autopsy.datamodel.AbstractContentNode.NO_DESCR; import org.sleuthkit.datamodel.Pool; import org.sleuthkit.datamodel.Tag; @@ -141,50 +137,4 @@ public class PoolNode extends AbstractContentNode { protected List getAllTagsFromDatabase() { return new ArrayList<>(); } - - /** - * Returns correlation attribute instance for the underlying content of the - * node. - * - * Null implementation of an abstract method. - * - * @return correlation attribute instance for the underlying content of the - * node. - */ - @Override - protected CorrelationAttributeInstance getCorrelationAttributeInstance() { - return null; - } - - /** - * Returns comment property for the node. - * - * Null implementation of an abstract method. - * - * @param tags list of tags - * @param attribute correlation attribute instance - * - * @return Comment property for the underlying content of the node. - */ - @Override - protected DataResultViewerTable.HasCommentStatus getCommentProperty(List tags, CorrelationAttributeInstance attribute) { - return DataResultViewerTable.HasCommentStatus.NO_COMMENT; - } - - /** - * Returns occurrences/count property for the node. - * - * Null implementation of an abstract method. - * - * @param attributeType the type of the attribute to count - * @param attributeValue the value of the attribute to coun - * @param defaultDescription a description to use when none is determined by - * the getCountPropertyAndDescription method - * - * @return count property for the underlying content of the node. - */ - @Override - protected Pair getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, String defaultDescription) { - return Pair.of(-1L, NO_DESCR); - } } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/UnsupportedContentNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/UnsupportedContentNode.java index 6d4b9fe5c6..876f7cb8e6 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/UnsupportedContentNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/UnsupportedContentNode.java @@ -21,12 +21,8 @@ package org.sleuthkit.autopsy.datamodel; import java.util.ArrayList; import java.util.List; import javax.swing.Action; -import org.apache.commons.lang3.tuple.Pair; import org.openide.nodes.Sheet; import org.openide.util.NbBundle; -import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable; -import static org.sleuthkit.autopsy.datamodel.AbstractContentNode.NO_DESCR; import org.sleuthkit.datamodel.UnsupportedContent; import org.sleuthkit.datamodel.Tag; @@ -40,8 +36,7 @@ public class UnsupportedContentNode extends AbstractContentNode(); } - /** - * Returns correlation attribute instance for the underlying content of the - * node. - * - * Null implementation of an abstract method. - * - * @return correlation attribute instance for the underlying content of the - * node. - */ - @Override - protected CorrelationAttributeInstance getCorrelationAttributeInstance() { - return null; - } - - /** - * Returns comment property for the node. - * - * Null implementation of an abstract method. - * - * @param tags list of tags - * @param attribute correlation attribute instance - * - * @return Comment property for the underlying content of the node. - */ - @Override - protected DataResultViewerTable.HasCommentStatus getCommentProperty(List tags, CorrelationAttributeInstance attribute) { - return DataResultViewerTable.HasCommentStatus.NO_COMMENT; - } - - /** - * Returns occurrences/count property for the node. - * - * Null implementation of an abstract method. - * - * @param attributeType the type of the attribute to count - * @param attributeValue the value of the attribute to coun - * @param defaultDescription a description to use when none is determined by - * the getCountPropertyAndDescription method - * - * @return count property for the underlying content of the node. - */ - @Override - protected Pair getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, String defaultDescription) { - return Pair.of(-1L, NO_DESCR); - } } diff --git a/Core/src/org/sleuthkit/autopsy/datamodel/VolumeNode.java b/Core/src/org/sleuthkit/autopsy/datamodel/VolumeNode.java index 709c8375a9..1a30d4db8c 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/VolumeNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/VolumeNode.java @@ -1,7 +1,7 @@ /* * Autopsy Forensic Browser * - * Copyright 2011-2019 Basis Technology Corp. + * Copyright 2011-2021 Basis Technology Corp. * Contact: carrier sleuthkit org * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -26,14 +26,10 @@ import java.util.List; import java.util.Set; import java.util.logging.Level; import javax.swing.Action; -import org.apache.commons.lang3.tuple.Pair; import org.openide.nodes.Sheet; import org.openide.util.NbBundle; import org.sleuthkit.autopsy.casemodule.Case; -import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; -import org.sleuthkit.autopsy.corecomponents.DataResultViewerTable; import org.sleuthkit.autopsy.coreutils.Logger; -import static org.sleuthkit.autopsy.datamodel.AbstractContentNode.NO_DESCR; import org.sleuthkit.autopsy.datamodel.BaseChildFactory.NoSuchEventBusException; import org.sleuthkit.autopsy.directorytree.ExplorerNodeActionVisitor; import org.sleuthkit.autopsy.directorytree.NewWindowViewAction; @@ -74,21 +70,21 @@ public class VolumeNode extends AbstractContentNode { */ public VolumeNode(Volume vol) { super(vol); - + // set name, display name, and icon String volName = nameForVolume(vol); long end = vol.getStart() + (vol.getLength() - 1); String tempVolName = volName + " (" + vol.getDescription() + ": " + vol.getStart() + "-" + end + ")"; - + // If this is a pool volume use a custom display name try { - if (vol.getParent() != null && - vol.getParent().getParent() instanceof Pool) { + if (vol.getParent() != null + && vol.getParent().getParent() instanceof Pool) { // Pool volumes are not contiguous so printing a range of blocks is inaccurate tempVolName = volName + " (" + vol.getDescription() + ": " + vol.getStart() + ")"; } } catch (TskCoreException ex) { - logger.log(Level.WARNING, "Error looking up parent(s) of volume with obj ID = "+ vol.getId(), ex); + logger.log(Level.WARNING, "Error looking up parent(s) of volume with obj ID = " + vol.getId(), ex); } this.setDisplayName(tempVolName); @@ -244,49 +240,4 @@ public class VolumeNode extends AbstractContentNode { return new ArrayList<>(); } - /** - * Returns correlation attribute instance for the underlying content of the - * node. - * - * Null implementation of an abstract method. - * - * @return correlation attribute instance for the underlying content of the - * node. - */ - @Override - protected CorrelationAttributeInstance getCorrelationAttributeInstance() { - return null; - } - - /** - * Returns comment property for the node. - * - * Null implementation of an abstract method. - * - * @param tags list of tags - * @param attribute correlation attribute instance - * - * @return Comment property for the underlying content of the node. - */ - @Override - protected DataResultViewerTable.HasCommentStatus getCommentProperty(List tags, CorrelationAttributeInstance attribute) { - return DataResultViewerTable.HasCommentStatus.NO_COMMENT; - } - - /** - * Returns occurrences/count property for the node. - * - * Null implementation of an abstract method. - * - * @param attributeType the type of the attribute to count - * @param attributeValue the value of the attribute to coun - * @param defaultDescription a description to use when none is determined by - * the getCountPropertyAndDescription method - * - * @return count property for the underlying content of the node. - */ - @Override - protected Pair getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, String defaultDescription) { - return Pair.of(-1L, NO_DESCR); - } }