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 144d1830ca..3db1fea511 100755 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepository.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/CentralRepository.java @@ -109,7 +109,7 @@ public interface CentralRepository { * * @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 @@ -130,7 +130,7 @@ 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. @@ -140,7 +140,7 @@ public interface CentralRepository { * * @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 @@ -376,17 +376,20 @@ public interface CentralRepository { 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. + * 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 attribute type - * and value. + * @return Number of cases with additional instances of this + * CorrelationAttributeInstance. */ - public Long getCountCasesWithOtherInstances(CorrelationAttributeInstance instance) throws CentralRepoException, CorrelationAttributeNormalizationException; + Long getCountCasesWithOtherInstances(CorrelationAttributeInstance instance) throws CentralRepoException, CorrelationAttributeNormalizationException; /** * Retrieves number of data sources in the database. @@ -528,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 @@ -543,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 @@ -557,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 @@ -570,7 +573,7 @@ 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 @@ -596,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? @@ -805,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 @@ -818,7 +821,7 @@ public interface CentralRepository { * @throws CentralRepoException if the coordination service is running but * we fail to get the lock */ - public CoordinationService.Lock getExclusiveMultiUserDbLock() throws CentralRepoException; + CoordinationService.Lock getExclusiveMultiUserDbLock() throws CentralRepoException; /** * Process the Artifact instance in the EamDb @@ -849,7 +852,7 @@ public interface CentralRepository { * * @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 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/RdbmsCentralRepo.java b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/RdbmsCentralRepo.java index 6783377f2f..1442a0ec62 100644 --- a/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/RdbmsCentralRepo.java +++ b/Core/src/org/sleuthkit/autopsy/centralrepository/datamodel/RdbmsCentralRepo.java @@ -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); } @@ -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,8 +1488,8 @@ 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); } @@ -1501,7 +1501,7 @@ abstract class RdbmsCentralRepo implements CentralRepository { 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. + //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(); @@ -1510,12 +1510,11 @@ abstract class RdbmsCentralRepo implements CentralRepository { 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 + //The CorrelationCase is in the Central repository. String sql - = "SELECT count(*) FROM (SELECT DISTINCT case_id FROM " + = "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 " + + " 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); @@ -1523,10 +1522,9 @@ abstract class RdbmsCentralRepo implements CentralRepository { 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 + //The CorrelationCase is NOT in the central repository. String sql - = "SELECT count(*) FROM (SELECT DISTINCT case_id FROM " + = "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 @@ -1540,8 +1538,8 @@ 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); } } @@ -1567,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); } @@ -1614,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); } @@ -1941,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); } @@ -2012,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); } @@ -2099,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); } } @@ -2141,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); } @@ -2196,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); } @@ -2248,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); } @@ -2392,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); } } @@ -2431,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); } @@ -2475,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); } @@ -2516,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); } } @@ -2562,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); } } @@ -2601,8 +2599,8 @@ 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); } } @@ -2687,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); } } @@ -2720,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); } } @@ -2753,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); } } @@ -2905,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); } } @@ -2969,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); } } @@ -3006,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); } } @@ -3045,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; @@ -3123,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); } } @@ -3214,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); } @@ -3295,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; @@ -3349,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; @@ -3397,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); } } @@ -3432,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); } } @@ -3526,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/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 ad4f94e1ff..6081d0703c 100644 --- a/Core/src/org/sleuthkit/autopsy/datamodel/AbstractAbstractFileNode.java +++ b/Core/src/org/sleuthkit/autopsy/datamodel/AbstractAbstractFileNode.java @@ -183,7 +183,10 @@ public abstract class AbstractAbstractFileNode extends A Score value = scorePropAndDescr.getLeft(); String descr = scorePropAndDescr.getRight(); List listWithJustFileAttr = new ArrayList<>(); - listWithJustFileAttr.add(CorrelationAttributeUtil.getCorrAttrForFile(content)); + 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, listWithJustFileAttr)) ); @@ -196,7 +199,10 @@ public abstract class AbstractAbstractFileNode extends A Score value = scorePropAndDescr.getLeft(); String descr = scorePropAndDescr.getRight(); List listWithJustFileAttr = new ArrayList<>(); - listWithJustFileAttr.add(CorrelationAttributeUtil.getCorrAttrForFile(content)); + 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, listWithJustFileAttr)) ); @@ -206,7 +212,10 @@ public abstract class AbstractAbstractFileNode extends A if (event.getContentID() == content.getId()) { List tags = getAllTagsFromDatabase(); List listWithJustFileAttr = new ArrayList<>(); - listWithJustFileAttr.add(CorrelationAttributeUtil.getCorrAttrForFile(content)); + 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())) {