19 package org.sleuthkit.autopsy.datamodel;
21 import java.beans.PropertyChangeEvent;
22 import java.beans.PropertyChangeListener;
23 import java.lang.ref.WeakReference;
24 import java.util.ArrayList;
25 import java.util.List;
26 import org.apache.commons.lang3.tuple.Pair;
27 import org.openide.util.NbBundle.Messages;
46 class GetSCOTask
implements Runnable {
48 private final WeakReference<AbstractContentNode<?>> weakNodeRef;
49 private final PropertyChangeListener listener;
51 GetSCOTask(WeakReference<AbstractContentNode<?>> weakContentRef, PropertyChangeListener listener) {
52 this.weakNodeRef = weakContentRef;
53 this.listener = listener;
56 @Messages({
"GetSCOTask.occurrences.defaultDescription=No correlation properties found",
57 "GetSCOTask.occurrences.multipleProperties=Multiple different correlation properties exist for this result"})
60 AbstractContentNode<?> contentNode = weakNodeRef.get();
63 if (contentNode == null || UserPreferences.getHideSCOColumns()) {
67 List<Tag> tags = contentNode.getAllTagsFromDatabase();
68 Pair<Score, String> scoreAndDescription;
69 DataResultViewerTable.HasCommentStatus comment;
70 Pair<Long, String> countAndDescription = null;
72 scoreAndDescription = contentNode.getScorePropertyAndDescription(tags);
75 String description = Bundle.GetSCOTask_occurrences_defaultDescription();
76 List<CorrelationAttributeInstance> listOfPossibleAttributes =
new ArrayList<>();
77 Content contentFromNode = contentNode.getContent();
78 if (contentFromNode instanceof AbstractFile) {
79 listOfPossibleAttributes.addAll(CorrelationAttributeUtil.makeCorrAttrsForSearch((AbstractFile) contentFromNode));
80 }
else if (contentFromNode instanceof AnalysisResult) {
81 listOfPossibleAttributes.addAll(CorrelationAttributeUtil.makeCorrAttrsForSearch((AnalysisResult) contentFromNode));
82 }
else if (contentFromNode instanceof DataArtifact) {
83 listOfPossibleAttributes.addAll(CorrelationAttributeUtil.makeCorrAttrsForSearch((DataArtifact) contentFromNode));
87 comment = contentNode.getCommentProperty(tags, listOfPossibleAttributes);
88 CorrelationAttributeInstance corInstance = null;
89 if (CentralRepository.isEnabled()) {
90 if (listOfPossibleAttributes.size() > 1) {
92 description = Bundle.GetSCOTask_occurrences_multipleProperties();
93 }
else if (!listOfPossibleAttributes.isEmpty()) {
95 corInstance = listOfPossibleAttributes.get(0);
97 countAndDescription = contentNode.getCountPropertyAndDescription(corInstance, description);
100 if(Thread.currentThread().isInterrupted()) {
105 if (listener != null) {
106 listener.propertyChange(
new PropertyChangeEvent(
107 AutopsyEvent.SourceType.LOCAL.toString(),
108 AbstractAbstractFileNode.NodeSpecificEvents.SCO_AVAILABLE.toString(),
109 null,
new SCOData(scoreAndDescription, comment, countAndDescription)));