Autopsy  4.15.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
MessageDataContent.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2017-18 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.communications.relationships;
20 
21 import java.beans.PropertyChangeEvent;
22 import java.util.List;
23 import java.util.logging.Level;
24 import org.openide.explorer.ExplorerManager;
25 import org.openide.nodes.Node;
31 import org.sleuthkit.datamodel.AbstractFile;
32 import org.sleuthkit.datamodel.BlackboardArtifact;
33 import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_ASSOCIATED_OBJECT;
34 import org.sleuthkit.datamodel.BlackboardAttribute;
35 import org.sleuthkit.datamodel.SleuthkitCase;
36 import org.sleuthkit.datamodel.TskCoreException;
37 
47 final class MessageDataContent extends MessageArtifactViewer implements DataContent, ExplorerManager.Provider {
48 
49  private static final Logger LOGGER = Logger.getLogger(MessageDataContent.class.getName());
50 
51  private static final long serialVersionUID = 1L;
52  final private ExplorerManager explorerManager = new ExplorerManager();
53 
54  @Override
55  public void propertyChange(final PropertyChangeEvent evt) {
56  throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
57  }
58 
59  @Override
60  public ExplorerManager getExplorerManager() {
61  return explorerManager;
62  }
63 
64  @Override
65  public void setNode(Node node) {
66  BlackboardArtifact artifact = null;
67  if (node != null) {
68  artifact = getNodeArtifact(node);
69  }
70  setArtifact(artifact);
71  }
72 
85  private BlackboardArtifact getNodeArtifact(Node node) {
86  BlackboardArtifact nodeArtifact = node.getLookup().lookup(BlackboardArtifact.class);
87 
88  if (nodeArtifact == null) {
89  try {
90  SleuthkitCase tskCase = Case.getCurrentCaseThrows().getSleuthkitCase();
91  AbstractFile file = node.getLookup().lookup(AbstractFile.class);
92  if (file != null) {
93  List<BlackboardArtifact> artifactsList = tskCase.getBlackboardArtifacts(TSK_ASSOCIATED_OBJECT, file.getId());
94 
95  for (BlackboardArtifact fileArtifact : artifactsList) {
96  BlackboardAttribute associatedArtifactAttribute = fileArtifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_ASSOCIATED_ARTIFACT));
97  if (associatedArtifactAttribute != null) {
98  BlackboardArtifact associatedArtifact = fileArtifact.getSleuthkitCase().getBlackboardArtifact(associatedArtifactAttribute.getValueLong());
99  if (isMessageArtifact(associatedArtifact)) {
100  nodeArtifact = associatedArtifact;
101  }
102  }
103  }
104  }
105  } catch (NoCurrentCaseException | TskCoreException ex) {
106  LOGGER.log(Level.SEVERE, "Failed to get file for selected node.", ex); //NON-NLS
107  }
108  }
109 
110  return nodeArtifact;
111  }
112 }

Copyright © 2012-2020 Basis Technology. Generated on: Mon Jul 6 2020
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.