19package org.sleuthkit.autopsy.communications.relationships;
21import java.beans.PropertyChangeEvent;
23import java.util.concurrent.ExecutionException;
24import java.util.logging.Level;
25import javax.swing.SwingWorker;
26import org.openide.explorer.ExplorerManager;
27import org.openide.nodes.Node;
28import org.openide.util.Exceptions;
29import org.sleuthkit.autopsy.casemodule.Case;
30import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
31import org.sleuthkit.autopsy.contentviewers.artifactviewers.MessageArtifactViewer;
32import org.sleuthkit.autopsy.corecomponentinterfaces.DataContent;
33import org.sleuthkit.autopsy.coreutils.Logger;
34import org.sleuthkit.datamodel.AbstractFile;
35import org.sleuthkit.datamodel.BlackboardArtifact;
36import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_ASSOCIATED_OBJECT;
37import org.sleuthkit.datamodel.BlackboardAttribute;
38import org.sleuthkit.datamodel.SleuthkitCase;
39import org.sleuthkit.datamodel.TskCoreException;
52 private static final Logger LOGGER = Logger.getLogger(MessageDataContent.class.getName());
54 private static final long serialVersionUID = 1L;
55 final private ExplorerManager explorerManager =
new ExplorerManager();
60 public void propertyChange(
final PropertyChangeEvent evt) {
61 throw new UnsupportedOperationException(
"Not supported yet.");
65 public ExplorerManager getExplorerManager() {
66 return explorerManager;
70 public void setNode(Node node) {
97 private BlackboardArtifact getNodeArtifact(Node node) {
98 BlackboardArtifact nodeArtifact = node.getLookup().lookup(BlackboardArtifact.class);
100 if (nodeArtifact ==
null) {
102 SleuthkitCase tskCase = Case.getCurrentCaseThrows().getSleuthkitCase();
103 AbstractFile file = node.getLookup().lookup(AbstractFile.class);
105 List<BlackboardArtifact> artifactsList = tskCase.getBlackboardArtifacts(TSK_ASSOCIATED_OBJECT, file.getId());
107 for (BlackboardArtifact fileArtifact : artifactsList) {
108 BlackboardAttribute associatedArtifactAttribute = fileArtifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT));
109 if (associatedArtifactAttribute !=
null) {
110 BlackboardArtifact associatedArtifact = fileArtifact.getSleuthkitCase().getBlackboardArtifact(associatedArtifactAttribute.getValueLong());
112 nodeArtifact = associatedArtifact;
117 }
catch (NoCurrentCaseException | TskCoreException ex) {
118 LOGGER.log(Level.SEVERE,
"Failed to get file for selected node.", ex);
125 private class ArtifactFetcher
extends SwingWorker<BlackboardArtifact, Void> {
128 ArtifactFetcher(Node
node) {
134 return getNodeArtifact(
node);
145 }
catch (InterruptedException | ExecutionException ex) {
146 LOGGER.log(Level.SEVERE,
"Failed to get node for artifact.", ex);
BlackboardArtifact doInBackground()
static boolean isMessageArtifact(BlackboardArtifact nodeArtifact)
void setArtifact(BlackboardArtifact artifact)