diff --git a/bindings/java/src/org/sleuthkit/datamodel/Blackboard.java b/bindings/java/src/org/sleuthkit/datamodel/Blackboard.java index 38c23733e4b0e75960348a06d6b92587c38a5556..b1ea67405a28197176e79583440f221d56b57994 100755 --- a/bindings/java/src/org/sleuthkit/datamodel/Blackboard.java +++ b/bindings/java/src/org/sleuthkit/datamodel/Blackboard.java @@ -1766,53 +1766,49 @@ private long getArtifactsCountHelper(int artifactTypeID, String whereClause) thr } } - /* - * Determine if an artifact of a given type exists for given content with a - * specific list of attributes. + /** + * Determines whether or not an artifact of a given type with a given set of + * attributes already exists for a given content. * - * @param content The content whose artifacts need to be looked at. @param - * artifactType The type of artifact to look for. @param attributesList The - * list of attributes to look for. + * @param content The content. + * @param artifactType The artifact type. + * @param attributes The attributes. * - * @return True if the specific artifact exists; otherwise false. + * @return True or false * - * @throws TskCoreException If there is a problem getting artifacts or - * attributes. + * @throws TskCoreException The exception is thrown if there is an issue + * querying the case database. */ - public boolean artifactExists(Content content, BlackboardArtifact.ARTIFACT_TYPE artifactType, - Collection<BlackboardAttribute> attributesList) throws TskCoreException { - - ArrayList<BlackboardArtifact> artifactsList; - - /* - * Get the content's artifacts. - */ - artifactsList = content.getArtifacts(artifactType); - if (artifactsList.isEmpty()) { - return false; - } - - /* - * Get each artifact's attributes and analyze them for matches. - */ - for (BlackboardArtifact artifact : artifactsList) { - if (attributesMatch(artifact.getAttributes(), attributesList)) { - /* - * The exact artifact exists, so we don't need to look any - * further. - */ + public boolean artifactExists(Content content, BlackboardArtifact.Type artifactType, Collection<BlackboardAttribute> attributes) throws TskCoreException { + List<BlackboardArtifact> existingArtifacts = content.getArtifacts(artifactType.getTypeID()); + for (BlackboardArtifact artifact : existingArtifacts) { + if (attributesMatch(artifact.getAttributes(), attributes)) { return true; } } - - /* - * None of the artifacts have the exact set of attribute type/value - * combinations. The provided content does not have the artifact being - * sought. - */ return false; } + /** + * Determines whether or not an artifact of a given type with a given set of + * attributes already exists for a given content. + * + * @param content The content. + * @param artifactType The artifact type. + * @param attributes The attributes. + * + * @return True or false + * + * @throws TskCoreException The exception is thrown if there is an issue + * querying the case database. + * @deprecated Use artifactExists(Content content, BlackboardArtifact.Type + * artifactType, Collection\<BlackboardAttribute\> attributes) instead. + */ + @Deprecated + public boolean artifactExists(Content content, BlackboardArtifact.ARTIFACT_TYPE artifactType, Collection<BlackboardAttribute> attributes) throws TskCoreException { + return artifactExists(content, getArtifactType(artifactType.getTypeID()), attributes); + } + /** * Determine if the expected attributes can all be found in the supplied * file attributes list. diff --git a/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/CommunicationArtifactsHelper.java b/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/CommunicationArtifactsHelper.java index 371cef2821b6a408666faaa1a08619a6d7c4847d..362fdb3235135600cf80936d3cdc89b79d9c0a09 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/CommunicationArtifactsHelper.java +++ b/bindings/java/src/org/sleuthkit/datamodel/blackboardutils/CommunicationArtifactsHelper.java @@ -946,7 +946,7 @@ public void addAttachments(BlackboardArtifact message, MessageAttachments attach assocObjectArtifacts.add(artifact); } } - + try { Optional<Long> ingestJobId = getIngestJobId(); getSleuthkitCase().getBlackboard().postArtifacts(assocObjectArtifacts, getModuleName(), ingestJobId.orElse(null));