7917 hopefully working SCO changes after 7852

This commit is contained in:
William Schaefer 2021-09-10 16:02:20 -04:00
parent d0b6ff4683
commit c296fbbdd2
13 changed files with 231 additions and 381 deletions

View File

@ -67,7 +67,7 @@ public interface CentralRepository {
* are no in-use connections when you call this method. * are no in-use connections when you call this method.
* *
* @throws CentralRepoException if there is a problem closing the connection * @throws CentralRepoException if there is a problem closing the connection
* pool. * pool.
*/ */
void shutdownConnections() throws CentralRepoException; void shutdownConnections() throws CentralRepoException;
@ -104,7 +104,7 @@ public interface CentralRepository {
/** /**
* Add a new name/value pair in the db_info table. * 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 * @param value Value to set
* *
* @throws CentralRepoException * @throws CentralRepoException
@ -115,9 +115,9 @@ public interface CentralRepository {
* Set the data source object id for a specific entry in the data_sources * Set the data source object id for a specific entry in the data_sources
* table * 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 * @param dataSourceObjectId - the object id for the data source from the
* caseDb * caseDb
*/ */
void addDataSourceObjectId(int rowId, long dataSourceObjectId) throws CentralRepoException; void addDataSourceObjectId(int rowId, long dataSourceObjectId) throws CentralRepoException;
@ -135,7 +135,7 @@ public interface CentralRepository {
/** /**
* Update the value for a name in the name/value db_info table. * 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. * @param value Value to assign to name.
* *
* @throws CentralRepoException * @throws CentralRepoException
@ -170,9 +170,11 @@ public interface CentralRepository {
* user is not found in the examiner table. * user is not found in the examiner table.
* *
* @param examinerLoginName user name to look for. * @param examinerLoginName user name to look for.
*
* @return CentralRepoExaminer for the given user name. * @return CentralRepoExaminer for the given user name.
*
* @throws CentralRepoException If there is an error in looking up or * @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; CentralRepoExaminer getOrInsertExaminer(String examinerLoginName) throws CentralRepoException;
@ -218,7 +220,7 @@ public interface CentralRepository {
* @param eamDataSource the data source to add * @param eamDataSource the data source to add
* *
* @return - A CorrelationDataSource object with data source's central * @return - A CorrelationDataSource object with data source's central
* repository id * repository id
*/ */
CorrelationDataSource newDataSource(CorrelationDataSource eamDataSource) throws CentralRepoException; CorrelationDataSource newDataSource(CorrelationDataSource eamDataSource) throws CentralRepoException;
@ -247,8 +249,8 @@ public interface CentralRepository {
/** /**
* Retrieves Data Source details based on data source device ID * Retrieves Data Source details based on data source device ID
* *
* @param correlationCase the current CorrelationCase used for ensuring * @param correlationCase the current CorrelationCase used for ensuring
* uniqueness of DataSource * uniqueness of DataSource
* @param caseDbDataSourceId the data source device ID number * @param caseDbDataSourceId the data source device ID number
* *
* @return The data source * @return The data source
@ -259,8 +261,8 @@ public interface CentralRepository {
* Retrieves Data Source details based on data source ID * Retrieves Data Source details based on data source ID
* *
* @param correlationCase the current CorrelationCase used for ensuring * @param correlationCase the current CorrelationCase used for ensuring
* uniqueness of DataSource * uniqueness of DataSource
* @param dataSourceId the data source ID number * @param dataSourceId the data source ID number
* *
* @return The data source * @return The data source
*/ */
@ -277,7 +279,7 @@ public interface CentralRepository {
* Changes the name of a data source in the DB * Changes the name of a data source in the DB
* *
* @param eamDataSource The data source * @param eamDataSource The data source
* @param newName The new name * @param newName The new name
* *
* @throws CentralRepoException * @throws CentralRepoException
*/ */
@ -295,12 +297,12 @@ public interface CentralRepository {
* Retrieves eamArtifact instances from the database that are associated * Retrieves eamArtifact instances from the database that are associated
* with the eamArtifactType and eamArtifactValues of the given eamArtifact. * 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 * @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 * @return List of artifact instances for a given type with the specified
* values * values
* *
* @throws CorrelationAttributeNormalizationException * @throws CorrelationAttributeNormalizationException
* @throws CentralRepoException * @throws CentralRepoException
@ -326,14 +328,14 @@ public interface CentralRepository {
* with the eamArtifactType and eamArtifactValues of the given eamArtifact * with the eamArtifactType and eamArtifactValues of the given eamArtifact
* for the specified cases. * for the specified cases.
* *
* @param aType The type of the artifact * @param aType The type of the artifact
* @param values The list of correlation values to get * @param values The list of correlation values to get
* CorrelationAttributeInstances for * CorrelationAttributeInstances for
* @param caseIds The list of central repository case ids to get * @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 * @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 CorrelationAttributeNormalizationException
* @throws CentralRepoException * @throws CentralRepoException
@ -348,7 +350,7 @@ public interface CentralRepository {
* @param value Value to search for * @param value Value to search for
* *
* @return Number of artifact instances having ArtifactType and * @return Number of artifact instances having ArtifactType and
* ArtifactValue. * ArtifactValue.
*/ */
Long getCountArtifactInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException; Long getCountArtifactInstancesByTypeValue(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException;
@ -373,6 +375,19 @@ public interface CentralRepository {
*/ */
Long getCountUniqueCaseDataSourceTuplesHavingTypeValue(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException; Long getCountUniqueCaseDataSourceTuplesHavingTypeValue(CorrelationAttributeInstance.Type aType, String value) throws CentralRepoException, CorrelationAttributeNormalizationException;
/**
* Retrieves number of unique cases which have correlation attributes other
* which are not associated with the specified file with the same type and
* value.
*
* @param instance The instance having its cases with other occurrences
* counted.
*
* @return Number of cases with additional instances of this attribute type
* and value.
*/
public Long getCountCasesWithOtherInstances(CorrelationAttributeInstance instance) throws CentralRepoException, CorrelationAttributeNormalizationException;
/** /**
* Retrieves number of data sources in the database. * Retrieves number of data sources in the database.
* *
@ -387,7 +402,7 @@ public interface CentralRepository {
* @param correlationDataSource Data source to search for * @param correlationDataSource Data source to search for
* *
* @return Number of artifact instances having caseDisplayName and * @return Number of artifact instances having caseDisplayName and
* dataSource * dataSource
*/ */
Long getCountArtifactInstancesByCaseDataSource(CorrelationDataSource correlationDataSource) throws CentralRepoException; Long getCountArtifactInstancesByCaseDataSource(CorrelationDataSource correlationDataSource) throws CentralRepoException;
@ -416,7 +431,7 @@ public interface CentralRepository {
* in the associated CorrelationAttribute object. * in the associated CorrelationAttribute object.
* *
* @param eamArtifact The correlation attribute whose database instance will * @param eamArtifact The correlation attribute whose database instance will
* be updated. * be updated.
* *
* @throws CentralRepoException * @throws CentralRepoException
*/ */
@ -429,11 +444,11 @@ public interface CentralRepository {
* Method exists to support instances added using Central Repository version * Method exists to support instances added using Central Repository version
* 1,1 and older * 1,1 and older
* *
* @param type The type of instance. * @param type The type of instance.
* @param correlationCase The case tied to the instance. * @param correlationCase The case tied to the instance.
* @param correlationDataSource The data source tied to the instance. * @param correlationDataSource The data source tied to the instance.
* @param value The value tied to the instance. * @param value The value tied to the instance.
* @param filePath The file path tied to the instance. * @param filePath The file path tied to the instance.
* *
* @return The correlation attribute if it exists; otherwise null. * @return The correlation attribute if it exists; otherwise null.
* *
@ -446,10 +461,11 @@ public interface CentralRepository {
* Find a correlation attribute in the Central Repository database given the * Find a correlation attribute in the Central Repository database given the
* instance type, case, data source, object id. * instance type, case, data source, object id.
* *
* @param type The type of instance. * @param type The type of instance.
* @param correlationCase The case tied to the instance. * @param correlationCase The case tied to the instance.
* @param correlationDataSource The data source 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. * @return The correlation attribute if it exists; otherwise null.
* *
@ -485,7 +501,7 @@ public interface CentralRepository {
* @param value Value to search for * @param value Value to search for
* *
* @return List of cases containing this artifact with instances marked as * @return List of cases containing this artifact with instances marked as
* bad * bad
* *
* @throws CentralRepoException * @throws CentralRepoException
*/ */
@ -499,7 +515,7 @@ public interface CentralRepository {
* @param value Value to search for * @param value Value to search for
* *
* @return List of cases containing this artifact with instances marked as * @return List of cases containing this artifact with instances marked as
* bad * bad
* *
* @throws CentralRepoException * @throws CentralRepoException
*/ */
@ -560,9 +576,9 @@ public interface CentralRepository {
* Retrieves the given file HashHitInfo if the given file hash is in this * Retrieves the given file HashHitInfo if the given file hash is in this
* reference set. Only searches the reference_files table. * 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 * @param referenceSetID The referenceSetID within which the file should
* exist. * exist.
* *
* @return The HashHitInfo if found or null if not found. * @return The HashHitInfo if found or null if not found.
* *
@ -638,7 +654,7 @@ public interface CentralRepository {
* Update an existing organization. * Update an existing organization.
* *
* @param updatedOrganization the values the Organization with the same ID * @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 * @throws CentralRepoException
*/ */
@ -690,7 +706,8 @@ public interface CentralRepository {
* Add a new reference instance * Add a new reference instance
* *
* @param eamGlobalFileInstance The reference instance to add * @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 * @throws CentralRepoException
*/ */
@ -700,8 +717,8 @@ public interface CentralRepository {
* Insert the bulk collection of Global File Instances * Insert the bulk collection of Global File Instances
* *
* @param globalInstances a Set of EamGlobalFileInstances to insert into the * @param globalInstances a Set of EamGlobalFileInstances to insert into the
* db. * db.
* @param contentType the Type of the global instances * @param contentType the Type of the global instances
* *
* @throws CentralRepoException * @throws CentralRepoException
*/ */
@ -710,7 +727,7 @@ public interface CentralRepository {
/** /**
* Get all reference entries having a given correlation type and value * 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 * @param aValue Value to use for matching
* *
* @return List of all global file instances with a type and value * @return List of all global file instances with a type and value
@ -735,7 +752,7 @@ public interface CentralRepository {
* used to correlate artifacts. * used to correlate artifacts.
* *
* @return List of EamArtifact.Type's. If none are defined in the database, * @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 * @throws CentralRepoException
*/ */
@ -746,7 +763,7 @@ public interface CentralRepository {
* artifacts. * artifacts.
* *
* @return List of enabled EamArtifact.Type's. If none are defined in the * @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 * @throws CentralRepoException
*/ */
@ -757,7 +774,7 @@ public interface CentralRepository {
* correlate artifacts. * correlate artifacts.
* *
* @return List of supported EamArtifact.Type's. If none are defined in the * @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 * @throws CentralRepoException
*/ */
@ -799,14 +816,14 @@ public interface CentralRepository {
* @return the lock, or null if locking is not supported * @return the lock, or null if locking is not supported
* *
* @throws CentralRepoException if the coordination service is running but * @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; public CoordinationService.Lock getExclusiveMultiUserDbLock() throws CentralRepoException;
/** /**
* Process the Artifact instance in the EamDb * 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 instanceTableCallback callback to process the instance
* *
* @throws CentralRepoException * @throws CentralRepoException
@ -816,9 +833,9 @@ public interface CentralRepository {
/** /**
* Process the Artifact instance in the EamDb * 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 instanceTableCallback callback to process the instance
* @param whereClause query string to execute * @param whereClause query string to execute
* *
* @throws CentralRepoException * @throws CentralRepoException
*/ */
@ -827,7 +844,7 @@ public interface CentralRepository {
/** /**
* Process a SELECT query * Process a SELECT query
* *
* @param selectClause query string to execute * @param selectClause query string to execute
* @param instanceTableCallback callback to process the instance * @param instanceTableCallback callback to process the instance
* *
* @throws CentralRepoException * @throws CentralRepoException
@ -838,7 +855,7 @@ public interface CentralRepository {
* Executes an INSERT/UPDATE/DELETE sql as a prepared statement, on the * Executes an INSERT/UPDATE/DELETE sql as a prepared statement, on the
* central repository database. * central repository database.
* *
* @param sql sql to execute. * @param sql sql to execute.
* @param params List of query params to use, may be empty. * @param params List of query params to use, may be empty.
* *
* @throws CentralRepoException If there is an error. * @throws CentralRepoException If there is an error.
@ -849,8 +866,8 @@ public interface CentralRepository {
* Executes a SELECT query sql as a prepared statement, on the central * Executes a SELECT query sql as a prepared statement, on the central
* repository database. * repository database.
* *
* @param sql sql to execute. * @param sql sql to execute.
* @param params List of query params to use, may be empty. * @param params List of query params to use, may be empty.
* @param queryCallback Query callback to handle the result of the query. * @param queryCallback Query callback to handle the result of the query.
* *
* @throws CentralRepoException If there is an error. * @throws CentralRepoException If there is an error.
@ -861,7 +878,9 @@ public interface CentralRepository {
* Get account type by type name. * Get account type by type name.
* *
* @param accountTypeName account type name to look for * @param accountTypeName account type name to look for
*
* @return CR account type (if found) * @return CR account type (if found)
*
* @throws CentralRepoException * @throws CentralRepoException
*/ */
Optional<CentralRepoAccountType> getAccountTypeByName(String accountTypeName) throws CentralRepoException; Optional<CentralRepoAccountType> getAccountTypeByName(String accountTypeName) throws CentralRepoException;
@ -879,15 +898,17 @@ public interface CentralRepository {
* Get an account from the accounts table matching the given type/ID. * Get an account from the accounts table matching the given type/ID.
* Inserts a row if one doesn't exists. * 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 * @param accountUniqueID type specific unique account id
*
* @return CR account * @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. * @throws InvalidAccountIDException If the account identifier is not valid.
*/ */
CentralRepoAccount getOrCreateAccount(CentralRepoAccount.CentralRepoAccountType crAccountType, String accountUniqueID) throws InvalidAccountIDException, CentralRepoException; CentralRepoAccount getOrCreateAccount(CentralRepoAccount.CentralRepoAccountType crAccountType, String accountUniqueID) throws InvalidAccountIDException, CentralRepoException;
/** /**
* Gets an account from the accounts table matching the given type/ID, if * Gets an account from the accounts table matching the given type/ID, if
* one exists. * one exists.
@ -897,7 +918,8 @@ public interface CentralRepository {
* *
* @return CR account, if found, null otherwise. * @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. * @throws InvalidAccountIDException If the account identifier is not valid.
*/ */
CentralRepoAccount getAccount(CentralRepoAccount.CentralRepoAccountType crAccountType, String accountUniqueID) throws InvalidAccountIDException, CentralRepoException; CentralRepoAccount getAccount(CentralRepoAccount.CentralRepoAccountType crAccountType, String accountUniqueID) throws InvalidAccountIDException, CentralRepoException;

View File

@ -205,7 +205,7 @@ final class PostgresCentralRepo extends RdbmsCentralRepo {
} }
} }
} }
@Override @Override
protected String getConflictClause() { protected String getConflictClause() {
return CONFLICT_CLAUSE; return CONFLICT_CLAUSE;
@ -269,4 +269,5 @@ final class PostgresCentralRepo extends RdbmsCentralRepo {
return columnExists; return columnExists;
} }
} }

View File

@ -1090,7 +1090,7 @@ abstract class RdbmsCentralRepo implements CentralRepository {
String insertSQL; String insertSQL;
switch (CentralRepoDbManager.getSavedDbChoice().getDbPlatform()) { switch (CentralRepoDbManager.getSavedDbChoice().getDbPlatform()) {
case POSTGRESQL: 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; break;
case SQLITE: case SQLITE:
insertSQL = "INSERT OR IGNORE INTO accounts (account_type_id, account_unique_identifier) VALUES (?, ?) "; //NON-NLS 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: default:
throw new CentralRepoException(String.format("Cannot add account to currently selected CR database platform %s", CentralRepoDbManager.getSavedDbChoice().getDbPlatform())); //NON-NLS throw new CentralRepoException(String.format("Cannot add account to currently selected CR database platform %s", CentralRepoDbManager.getSavedDbChoice().getDbPlatform())); //NON-NLS
} }
try (Connection connection = connect(); try (Connection connection = connect();
PreparedStatement preparedStatement = connection.prepareStatement(insertSQL);) { 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 * @return CentralRepoAccount for the give type/id. May return null if not
* found. * 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. * @throws InvalidAccountIDException If the account identifier is not valid.
*/ */
@Override @Override
@ -1496,6 +1496,59 @@ abstract class RdbmsCentralRepo implements CentralRepository {
return instanceCount; return instanceCount;
} }
@Override
public Long getCountCasesWithOtherInstances(CorrelationAttributeInstance instance) throws CentralRepoException, CorrelationAttributeNormalizationException {
Long instanceCount = 0L;
if (instance != null) {
Long sourceObjID = instance.getFileObjectId();
//We know that instances have a correlation case but that correlation case may have a null ID if it is not in the CR, although it should be.
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 current case is in the CR we can ignore this case source file to ensure we don't count the current item
//this will also work regardless of the instance itself being a database instance
String sql
= "SELECT count(*) FROM (SELECT DISTINCT case_id FROM "
+ tableName
+ " WHERE value=? AND NOT (file_obj_id=? AND case_id=?)) AS "
+ tableName
+ "_other_case_count";
preparedStatement = conn.prepareStatement(sql);
preparedStatement.setString(1, normalizedValue);
preparedStatement.setLong(2, sourceObjID);
preparedStatement.setInt(3, correlationCaseId);
} else {
//the current case is not in the CR so the current instance can't be so we can just count all other cases with the instance
//we won't know if it exists elsewhere in this case because this case is not in the CR
String sql
= "SELECT count(*) FROM (SELECT DISTINCT case_id FROM "
+ 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.closeStatement(preparedStatement);
CentralRepoDbUtil.closeResultSet(resultSet);
CentralRepoDbUtil.closeConnection(conn);
}
}
return instanceCount;
}
@Override @Override
public Long getCountUniqueDataSources() throws CentralRepoException { public Long getCountUniqueDataSources() throws CentralRepoException {
Connection conn = connect(); Connection conn = connect();
@ -2556,13 +2609,13 @@ abstract class RdbmsCentralRepo implements CentralRepository {
@Override @Override
public void executeCommand(String sql, List<Object> params) throws CentralRepoException { public void executeCommand(String sql, List<Object> params) throws CentralRepoException {
try (Connection conn = connect();) { try (Connection conn = connect();) {
PreparedStatement preparedStatement = conn.prepareStatement(sql); PreparedStatement preparedStatement = conn.prepareStatement(sql);
// Fill in the params // Fill in the params
if (params != null) { if (params != null) {
int paramIndex = 1; int paramIndex = 1;
for (Object param : params) { for (Object param : params) {
preparedStatement.setObject(paramIndex, param); preparedStatement.setObject(paramIndex, param);
@ -2582,10 +2635,9 @@ abstract class RdbmsCentralRepo implements CentralRepository {
throw new CentralRepoException("Query callback is null"); throw new CentralRepoException("Query callback is null");
} }
try (Connection conn = connect();) {
try ( Connection conn = connect();) { PreparedStatement preparedStatement = conn.prepareStatement(sql);
PreparedStatement preparedStatement = conn.prepareStatement(sql);
// fill in the params // fill in the params
if (params != null) { if (params != null) {
int paramIndex = 1; int paramIndex = 1;
@ -2600,7 +2652,7 @@ abstract class RdbmsCentralRepo implements CentralRepository {
} }
} catch (SQLException ex) { } catch (SQLException ex) {
throw new CentralRepoException(String.format("Error executing prepared statement for SQL query %s", sql), ex); throw new CentralRepoException(String.format("Error executing prepared statement for SQL query %s", sql), ex);
} }
} }
@Override @Override

View File

@ -624,6 +624,16 @@ final class SqliteCentralRepo extends RdbmsCentralRepo {
releaseSharedLock(); releaseSharedLock();
} }
} }
@Override
public Long getCountCasesWithOtherInstances(CorrelationAttributeInstance instance) throws CentralRepoException, CorrelationAttributeNormalizationException {
try {
acquireSharedLock();
return super.getCountCasesWithOtherInstances(instance);
} finally {
releaseSharedLock();
}
}
@Override @Override
public Long getCountUniqueDataSources() throws CentralRepoException { public Long getCountUniqueDataSources() throws CentralRepoException {

View File

@ -182,9 +182,9 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
Pair<Score, String> scorePropAndDescr = getScorePropertyAndDescription(tags); Pair<Score, String> scorePropAndDescr = getScorePropertyAndDescription(tags);
Score value = scorePropAndDescr.getLeft(); Score value = scorePropAndDescr.getLeft();
String descr = scorePropAndDescr.getRight(); String descr = scorePropAndDescr.getRight();
CorrelationAttributeInstance attribute = getCorrelationAttributeInstance(); CorrelationAttributeInstance corInstance = getFirstCorrelationAttributeInstance();
updateSheet(new NodeProperty<>(SCORE.toString(), SCORE.toString(), descr, value), 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, corInstance))
); );
} }
} else if (eventType.equals(Case.Events.CONTENT_TAG_DELETED.toString())) { } else if (eventType.equals(Case.Events.CONTENT_TAG_DELETED.toString())) {
@ -194,17 +194,17 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
Pair<Score, String> scorePropAndDescr = getScorePropertyAndDescription(tags); Pair<Score, String> scorePropAndDescr = getScorePropertyAndDescription(tags);
Score value = scorePropAndDescr.getLeft(); Score value = scorePropAndDescr.getLeft();
String descr = scorePropAndDescr.getRight(); String descr = scorePropAndDescr.getRight();
CorrelationAttributeInstance attribute = getCorrelationAttributeInstance(); CorrelationAttributeInstance corInstance = getFirstCorrelationAttributeInstance();
updateSheet(new NodeProperty<>(SCORE.toString(), SCORE.toString(), descr, value), 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, corInstance))
); );
} }
} else if (eventType.equals(Case.Events.CR_COMMENT_CHANGED.toString())) { } else if (eventType.equals(Case.Events.CR_COMMENT_CHANGED.toString())) {
CommentChangedEvent event = (CommentChangedEvent) evt; CommentChangedEvent event = (CommentChangedEvent) evt;
if (event.getContentID() == content.getId()) { if (event.getContentID() == content.getId()) {
List<Tag> tags = getAllTagsFromDatabase(); List<Tag> tags = getAllTagsFromDatabase();
CorrelationAttributeInstance attribute = getCorrelationAttributeInstance(); CorrelationAttributeInstance corInstance = getFirstCorrelationAttributeInstance();
updateSheet(new NodeProperty<>(COMMENT.toString(), COMMENT.toString(), NO_DESCR, getCommentProperty(tags, attribute))); updateSheet(new NodeProperty<>(COMMENT.toString(), COMMENT.toString(), NO_DESCR, getCommentProperty(tags, corInstance)));
} }
} else if (eventType.equals(NodeSpecificEvents.TRANSLATION_AVAILABLE.toString())) { } else if (eventType.equals(NodeSpecificEvents.TRANSLATION_AVAILABLE.toString())) {
this.setDisplayName(evt.getNewValue().toString()); this.setDisplayName(evt.getNewValue().toString());
@ -411,16 +411,15 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
"# {0} - occurrenceCount", "# {0} - occurrenceCount",
"AbstractAbstractFileNode.createSheet.count.description=There were {0} datasource(s) found with occurrences of the MD5 correlation value"}) "AbstractAbstractFileNode.createSheet.count.description=There were {0} datasource(s) found with occurrences of the MD5 correlation value"})
@Override @Override
protected Pair<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, protected Pair<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance attributeInstance, String defaultDescription) {
String defaultDescription) {
Long count = -1L; //The column renderer will not display negative values, negative value used when count unavailble to preserve sorting Long count = -1L; //The column renderer will not display negative values, negative value used when count unavailble to preserve sorting
String description = defaultDescription; String description = defaultDescription;
try { try {
//don't perform the query if there is no correlation value //don't perform the query if there is no correlation value
if (attributeType != null && StringUtils.isNotBlank(attributeValue)) { if (attributeInstance != null && StringUtils.isNotBlank(attributeInstance.getCorrelationValue())) {
count = CentralRepository.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue(attributeType, attributeValue); count = CentralRepository.getInstance().getCountCasesWithOtherInstances(attributeInstance);
description = Bundle.AbstractAbstractFileNode_createSheet_count_description(count); description = Bundle.AbstractAbstractFileNode_createSheet_count_description(count);
} else if (attributeType != null) { } else if (attributeInstance != null) {
description = Bundle.AbstractAbstractFileNode_createSheet_count_hashLookupNotRun_description(); description = Bundle.AbstractAbstractFileNode_createSheet_count_hashLookupNotRun_description();
} }
} catch (CentralRepoException ex) { } catch (CentralRepoException ex) {
@ -491,10 +490,13 @@ public abstract class AbstractAbstractFileNode<T extends AbstractFile> extends A
} }
@Override @Override
protected CorrelationAttributeInstance getCorrelationAttributeInstance() { protected CorrelationAttributeInstance getFirstCorrelationAttributeInstance() {
CorrelationAttributeInstance attribute = null; CorrelationAttributeInstance attribute = null;
if (CentralRepository.isEnabled() && !UserPreferences.getHideSCOColumns()) { if (CentralRepository.isEnabled() && !UserPreferences.getHideSCOColumns()) {
attribute = CorrelationAttributeUtil.getCorrAttrForFile(content); List<CorrelationAttributeInstance> listOfPossibleAttributes = CorrelationAttributeUtil.makeCorrAttrsForSearch(content);
if (!listOfPossibleAttributes.isEmpty()) {
attribute = listOfPossibleAttributes.get(0);
}
} }
return attribute; return attribute;
} }

View File

@ -326,13 +326,17 @@ public abstract class AbstractContentNode<T extends Content> extends ContentNode
abstract protected List<Tag> getAllTagsFromDatabase(); abstract protected List<Tag> getAllTagsFromDatabase();
/** /**
* Returns correlation attribute instance for the underlying content of the * Returns the first correlation attribute instance for the underlying
* node. * content of the node.
* *
* @return correlation attribute instance for the underlying content of the * Default implementation is a null implementation.
* node. *
* @return The first correlation attribute instance for the underlying
* content of the node.
*/ */
abstract protected CorrelationAttributeInstance getCorrelationAttributeInstance(); protected CorrelationAttributeInstance getFirstCorrelationAttributeInstance() {
return null;
}
/** /**
* Returns Score property for the node. * Returns Score property for the node.
@ -352,7 +356,7 @@ public abstract class AbstractContentNode<T extends Content> extends ContentNode
} catch (TskCoreException ex) { } catch (TskCoreException ex) {
logger.log(Level.WARNING, "Unable to get aggregate score for content with id: " + this.content.getId(), ex); logger.log(Level.WARNING, "Unable to get aggregate score for content with id: " + this.content.getId(), ex);
} }
String significanceDisplay = score.getSignificance().getDisplayName(); String significanceDisplay = score.getSignificance().getDisplayName();
String description = Bundle.AbstractContentNode_getScorePropertyAndDescription_description(significanceDisplay); String description = Bundle.AbstractContentNode_getScorePropertyAndDescription_description(significanceDisplay);
return Pair.of(score, description); return Pair.of(score, description);
@ -361,22 +365,30 @@ public abstract class AbstractContentNode<T extends Content> extends ContentNode
/** /**
* Returns comment property for the node. * Returns comment property for the node.
* *
* Default implementation is a null implementation.
*
* @param tags list of tags * @param tags list of tags
* @param attribute correlation attribute instance * @param attribute correlation attribute instance
* *
* @return Comment property for the underlying content of the node. * @return Comment property for the underlying content of the node.
*/ */
abstract protected DataResultViewerTable.HasCommentStatus getCommentProperty(List<Tag> tags, CorrelationAttributeInstance attribute); protected DataResultViewerTable.HasCommentStatus getCommentProperty(List<Tag> tags, CorrelationAttributeInstance attribute) {
return DataResultViewerTable.HasCommentStatus.NO_COMMENT;
}
/** /**
* Returns occurrences/count property for the node. * Returns occurrences/count property for the node.
* *
* @param attributeType the type of the attribute to count * Default implementation is a null implementation.
* @param attributeValue the value of the attribute to count *
* @param defaultDescription a description to use when none is determined by * @param attribute The correlation attribute for which data will
* the getCountPropertyAndDescription method * 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. * @return count property for the underlying content of the node.
*/ */
abstract protected Pair<Long, String> getCountPropertyAndDescription(Type attributeType, String attributeValue, String defaultDescription); protected Pair<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance attribute, String defaultDescription) {
return Pair.of(-1L, NO_DESCR);
}
} }

View File

@ -53,7 +53,6 @@ import org.sleuthkit.autopsy.casemodule.events.CommentChangedEvent;
import org.sleuthkit.autopsy.casemodule.events.ContentTagAddedEvent; import org.sleuthkit.autopsy.casemodule.events.ContentTagAddedEvent;
import org.sleuthkit.autopsy.casemodule.events.ContentTagDeletedEvent; import org.sleuthkit.autopsy.casemodule.events.ContentTagDeletedEvent;
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; 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.CorrelationAttributeNormalizationException;
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil; import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeUtil;
import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException; import org.sleuthkit.autopsy.centralrepository.datamodel.CentralRepoException;
@ -830,20 +829,21 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
} }
/** /**
* Gets the correlation attribute for the MD5 hash of the source file of the * Gets the first correlation attribute instance associated with the
* artifact represented by this node. The correlation attribute instance can * artifact this node represents.
* only be returned if the central repository is enabled and the source
* content is a file.
* *
* @return The correlation attribute instance, may be null. * @return The first correlation attribute instance, may be null.
*/ */
@Override @Override
protected final CorrelationAttributeInstance getCorrelationAttributeInstance() { protected CorrelationAttributeInstance getFirstCorrelationAttributeInstance() {
CorrelationAttributeInstance correlationAttribute = null; CorrelationAttributeInstance attribute = null;
if (CentralRepository.isEnabled() && srcContent instanceof AbstractFile) { if (CentralRepository.isEnabled() && !UserPreferences.getHideSCOColumns()) {
correlationAttribute = CorrelationAttributeUtil.getCorrAttrForFile((AbstractFile) srcContent); List<CorrelationAttributeInstance> listOfPossibleAttributes = CorrelationAttributeUtil.makeCorrAttrsForSearch(content);
if (!listOfPossibleAttributes.isEmpty()) {
attribute = listOfPossibleAttributes.get(0);
}
} }
return correlationAttribute; return attribute;
} }
/** /**
@ -856,7 +856,7 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
* repository. * repository.
* *
* @param tags The tags applied to the artifact and its source content. * @param tags The tags applied to the artifact and its source content.
* @param attribute A correlation attribute instance Ffor the central * @param attribute A correlation attribute instance for the central
* repository lookup. * repository lookup.
* *
* @return The value of the comment property. * @return The value of the comment property.
@ -891,39 +891,21 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
return status; return status;
} }
/**
* Computes the value of the other occurrences property ("O" in S, C, O) for
* the artifact represented by this node. The value of the other occurrences
* property is the number of other data sources this artifact appears in
* according to a correlation attribute instance lookup in the central
* repository, plus one for the data source for this instance of the
* artifact.
*
* @param corrAttrType The correlation attribute instance type to use
* for the central repsoitory lookup.
* @param attributeValue The correlation attribute instane value to use
* for the central repsoitory lookup.
* @param defaultDescription A default description.
*
* @return The value of the occurrences property as a data sources count and
* a description string.
*
*/
@Override @Override
protected Pair<Long, String> getCountPropertyAndDescription(Type corrAttrType, String attributeValue, String defaultDescription) { protected Pair<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance attribute, String defaultDescription) {
Long count = -1L; Long count = -1L;
String description = defaultDescription; String description = defaultDescription;
try { try {
if (corrAttrType != null && StringUtils.isNotBlank(attributeValue)) { if (attribute != null && StringUtils.isNotBlank(attribute.getCorrelationValue())) {
count = CentralRepository.getInstance().getCountUniqueCaseDataSourceTuplesHavingTypeValue(corrAttrType, attributeValue); count = CentralRepository.getInstance().getCountCasesWithOtherInstances(attribute);
description = Bundle.BlackboardArtifactNode_createSheet_count_description(count, corrAttrType.getDisplayName()); description = Bundle.BlackboardArtifactNode_createSheet_count_description(count, attribute.getCorrelationType().getDisplayName());
} else if (corrAttrType != null) { } else if (attribute != null) {
description = Bundle.BlackboardArtifactNode_createSheet_count_noCorrelationValues_description(); description = Bundle.BlackboardArtifactNode_createSheet_count_noCorrelationValues_description();
} }
} catch (CentralRepoException ex) { } 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) { } 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); return Pair.of(count, description);
} }
@ -956,7 +938,7 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
} }
/** /**
* Adds a "custom" property to the property sheet of this node, indepoendent * Adds a "custom" property to the property sheet of this node, independent
* of the artifact this node represents or its source content. * of the artifact this node represents or its source content.
* *
* @param property The custom property. * @param property The custom property.
@ -1171,7 +1153,7 @@ public class BlackboardArtifactNode extends AbstractContentNode<BlackboardArtifa
"BlackboardArtifactNode.createSheet.count.description=There were {0} datasource(s) found with occurrences of the correlation value of type {1}"}) "BlackboardArtifactNode.createSheet.count.description=There were {0} datasource(s) found with occurrences of the correlation value of type {1}"})
@Deprecated @Deprecated
protected final void addCountProperty(Sheet.Set sheetSet, CorrelationAttributeInstance attribute) { protected final void addCountProperty(Sheet.Set sheetSet, CorrelationAttributeInstance attribute) {
Pair<Long, String> countAndDescription = getCountPropertyAndDescription(attribute.getCorrelationType(), attribute.getCorrelationValue(), Bundle.BlackboardArtifactNode_createSheet_count_noCorrelationAttributes_description()); Pair<Long, String> 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())); sheetSet.put(new NodeProperty<>(Bundle.BlackboardArtifactNode_createSheet_count_name(), Bundle.BlackboardArtifactNode_createSheet_count_displayName(), countAndDescription.getRight(), countAndDescription.getLeft()));
} }

View File

@ -24,8 +24,6 @@ import java.lang.ref.WeakReference;
import java.util.List; import java.util.List;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.centralrepository.datamodel.CorrelationAttributeInstance; 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.core.UserPreferences;
import org.sleuthkit.autopsy.events.AutopsyEvent; import org.sleuthkit.autopsy.events.AutopsyEvent;
import org.sleuthkit.datamodel.Tag; import org.sleuthkit.datamodel.Tag;
@ -58,27 +56,15 @@ class GetSCOTask implements Runnable {
} }
// get the SCO column values // get the SCO column values
List<Tag> tags = contentNode.getAllTagsFromDatabase(); List<Tag> tags = contentNode.getAllTagsFromDatabase();
SCOData scoData = new SCOData(); SCOData scoData = new SCOData();
scoData.setScoreAndDescription(contentNode.getScorePropertyAndDescription(tags)); scoData.setScoreAndDescription(contentNode.getScorePropertyAndDescription(tags));
//getting the correlation attribute and setting the comment column is done before the eamdb isEnabled check //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 //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(); CorrelationAttributeInstance corInstance = contentNode.getFirstCorrelationAttributeInstance();
scoData.setComment(contentNode.getCommentProperty(tags, fileAttribute)); scoData.setComment(contentNode.getCommentProperty(tags, corInstance));
if (CentralRepository.isEnabled()) { if (CentralRepository.isEnabled()) {
Type type = null;
String value = null;
String description = Bundle.GetSCOTask_occurrences_defaultDescription(); String description = Bundle.GetSCOTask_occurrences_defaultDescription();
List<CorrelationAttributeInstance> listOfPossibleAttributes = CorrelationAttributeUtil.makeCorrAttrsForSearch(contentNode.getContent()); scoData.setCountAndDescription(contentNode.getCountPropertyAndDescription(corInstance, description));
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();
}
scoData.setCountAndDescription(contentNode.getCountPropertyAndDescription(type, value, description));
} }
// signal SCO data is available. // signal SCO data is available.

View File

@ -27,15 +27,12 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.logging.Level; import java.util.logging.Level;
import javax.swing.Action; import javax.swing.Action;
import org.apache.commons.lang3.tuple.Pair;
import org.openide.nodes.Sheet; import org.openide.nodes.Sheet;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.DeleteDataSourceAction; import org.sleuthkit.autopsy.casemodule.DeleteDataSourceAction;
import org.sleuthkit.autopsy.datasourcesummary.ui.ViewSummaryInformationAction; 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.coreutils.Logger;
import org.sleuthkit.autopsy.directorytree.ExplorerNodeActionVisitor; import org.sleuthkit.autopsy.directorytree.ExplorerNodeActionVisitor;
import org.sleuthkit.autopsy.directorytree.FileSearchAction; import org.sleuthkit.autopsy.directorytree.FileSearchAction;
@ -168,9 +165,9 @@ public class ImageNode extends AbstractContentNode<Image> {
this.content.getTimeZone())); this.content.getTimeZone()));
sheetSet.put(new NodeProperty<>(Bundle.ImageNode_createSheet_deviceId_name(), sheetSet.put(new NodeProperty<>(Bundle.ImageNode_createSheet_deviceId_name(),
Bundle.ImageNode_createSheet_deviceId_displayName(), Bundle.ImageNode_createSheet_deviceId_displayName(),
Bundle.ImageNode_createSheet_deviceId_desc(), Bundle.ImageNode_createSheet_deviceId_desc(),
content.getDeviceId())); content.getDeviceId()));
return sheet; return sheet;
} }
@ -256,50 +253,4 @@ public class ImageNode extends AbstractContentNode<Image> {
protected List<Tag> getAllTagsFromDatabase() { protected List<Tag> getAllTagsFromDatabase() {
return new ArrayList<>(); 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<Tag> 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<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, String defaultDescription) {
return Pair.of(-1L, NO_DESCR);
}
} }

View File

@ -30,7 +30,6 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.logging.Level; import java.util.logging.Level;
import javax.swing.Action; import javax.swing.Action;
import org.apache.commons.lang3.tuple.Pair;
import org.openide.nodes.ChildFactory; import org.openide.nodes.ChildFactory;
import org.openide.nodes.Children; import org.openide.nodes.Children;
import org.openide.nodes.Node; import org.openide.nodes.Node;
@ -40,8 +39,6 @@ import org.openide.util.NbBundle.Messages;
import org.openide.util.WeakListeners; import org.openide.util.WeakListeners;
import org.sleuthkit.autopsy.casemodule.Case; import org.sleuthkit.autopsy.casemodule.Case;
import org.sleuthkit.autopsy.casemodule.events.OsAccountsUpdatedEvent; 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.Logger;
import org.sleuthkit.autopsy.coreutils.TimeZoneUtils; import org.sleuthkit.autopsy.coreutils.TimeZoneUtils;
import static org.sleuthkit.autopsy.datamodel.AbstractContentNode.backgroundTasksPool; 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. 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<Tag> tags, CorrelationAttributeInstance attribute) {
return DataResultViewerTable.HasCommentStatus.NO_COMMENT;
}
@Override
protected Pair<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, String defaultDescription) {
return null;
}
@Override @Override
public <T> T accept(ContentNodeVisitor<T> visitor) { public <T> T accept(ContentNodeVisitor<T> visitor) {
return visitor.visit(this); return visitor.visit(this);

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2019 Basis Technology Corp. * Copyright 2019-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * 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.ArrayList;
import java.util.List; import java.util.List;
import javax.swing.Action; import javax.swing.Action;
import org.apache.commons.lang3.tuple.Pair;
import org.openide.nodes.Sheet; import org.openide.nodes.Sheet;
import org.openide.util.NbBundle; 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.Pool;
import org.sleuthkit.datamodel.Tag; import org.sleuthkit.datamodel.Tag;
@ -141,50 +137,4 @@ public class PoolNode extends AbstractContentNode<Pool> {
protected List<Tag> getAllTagsFromDatabase() { protected List<Tag> getAllTagsFromDatabase() {
return new ArrayList<>(); 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<Tag> 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<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, String defaultDescription) {
return Pair.of(-1L, NO_DESCR);
}
} }

View File

@ -21,12 +21,8 @@ package org.sleuthkit.autopsy.datamodel;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.swing.Action; import javax.swing.Action;
import org.apache.commons.lang3.tuple.Pair;
import org.openide.nodes.Sheet; import org.openide.nodes.Sheet;
import org.openide.util.NbBundle; 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.UnsupportedContent;
import org.sleuthkit.datamodel.Tag; import org.sleuthkit.datamodel.Tag;
@ -40,8 +36,7 @@ public class UnsupportedContentNode extends AbstractContentNode<UnsupportedConte
* @param unsupportedContent underlying Content instance * @param unsupportedContent underlying Content instance
*/ */
@NbBundle.Messages({ @NbBundle.Messages({
"UnsupportedContentNode.displayName=Unsupported Content", "UnsupportedContentNode.displayName=Unsupported Content",})
})
public UnsupportedContentNode(UnsupportedContent unsupportedContent) { public UnsupportedContentNode(UnsupportedContent unsupportedContent) {
super(unsupportedContent); super(unsupportedContent);
@ -67,14 +62,13 @@ public class UnsupportedContentNode extends AbstractContentNode<UnsupportedConte
} }
return actionsList.toArray(new Action[actionsList.size()]); return actionsList.toArray(new Action[actionsList.size()]);
} }
@NbBundle.Messages({ @NbBundle.Messages({
"UnsupportedContentNode.createSheet.name.name=Name", "UnsupportedContentNode.createSheet.name.name=Name",
"UnsupportedContentNode.createSheet.name.displayName=Name", "UnsupportedContentNode.createSheet.name.displayName=Name",
"UnsupportedContentNode.createSheet.name.desc=no description", "UnsupportedContentNode.createSheet.name.desc=no description",})
})
@Override @Override
protected Sheet createSheet() { protected Sheet createSheet() {
Sheet sheet = super.createSheet(); Sheet sheet = super.createSheet();
@ -124,49 +118,4 @@ public class UnsupportedContentNode extends AbstractContentNode<UnsupportedConte
return new ArrayList<>(); 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<Tag> 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<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, String defaultDescription) {
return Pair.of(-1L, NO_DESCR);
}
} }

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2011-2019 Basis Technology Corp. * Copyright 2011-2021 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * 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.Set;
import java.util.logging.Level; import java.util.logging.Level;
import javax.swing.Action; import javax.swing.Action;
import org.apache.commons.lang3.tuple.Pair;
import org.openide.nodes.Sheet; import org.openide.nodes.Sheet;
import org.openide.util.NbBundle; import org.openide.util.NbBundle;
import org.sleuthkit.autopsy.casemodule.Case; 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 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.datamodel.BaseChildFactory.NoSuchEventBusException;
import org.sleuthkit.autopsy.directorytree.ExplorerNodeActionVisitor; import org.sleuthkit.autopsy.directorytree.ExplorerNodeActionVisitor;
import org.sleuthkit.autopsy.directorytree.NewWindowViewAction; import org.sleuthkit.autopsy.directorytree.NewWindowViewAction;
@ -74,21 +70,21 @@ public class VolumeNode extends AbstractContentNode<Volume> {
*/ */
public VolumeNode(Volume vol) { public VolumeNode(Volume vol) {
super(vol); super(vol);
// set name, display name, and icon // set name, display name, and icon
String volName = nameForVolume(vol); String volName = nameForVolume(vol);
long end = vol.getStart() + (vol.getLength() - 1); long end = vol.getStart() + (vol.getLength() - 1);
String tempVolName = volName + " (" + vol.getDescription() + ": " + vol.getStart() + "-" + end + ")"; String tempVolName = volName + " (" + vol.getDescription() + ": " + vol.getStart() + "-" + end + ")";
// If this is a pool volume use a custom display name // If this is a pool volume use a custom display name
try { try {
if (vol.getParent() != null && if (vol.getParent() != null
vol.getParent().getParent() instanceof Pool) { && vol.getParent().getParent() instanceof Pool) {
// Pool volumes are not contiguous so printing a range of blocks is inaccurate // Pool volumes are not contiguous so printing a range of blocks is inaccurate
tempVolName = volName + " (" + vol.getDescription() + ": " + vol.getStart() + ")"; tempVolName = volName + " (" + vol.getDescription() + ": " + vol.getStart() + ")";
} }
} catch (TskCoreException ex) { } 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); this.setDisplayName(tempVolName);
@ -244,49 +240,4 @@ public class VolumeNode extends AbstractContentNode<Volume> {
return new ArrayList<>(); 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<Tag> 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<Long, String> getCountPropertyAndDescription(CorrelationAttributeInstance.Type attributeType, String attributeValue, String defaultDescription) {
return Pair.of(-1L, NO_DESCR);
}
} }