Autopsy  4.19.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
ThreadNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2019 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.util.logging.Level;
22 import javax.swing.Action;
23 import org.openide.nodes.AbstractNode;
24 import org.openide.nodes.Children;
25 import org.openide.nodes.Sheet;
28 import org.sleuthkit.datamodel.BlackboardArtifact;
29 import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE;
30 import org.sleuthkit.datamodel.BlackboardAttribute;
31 import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_TEXT;
32 import org.sleuthkit.datamodel.TskCoreException;
33 
39 final class ThreadNode extends AbstractNode{
40 
41  private static final Logger logger = Logger.getLogger(ThreadNode.class.getName());
42 
43  private final static int MAX_SUBJECT_LENGTH = 120;
44 
45  final private MessageNode messageNode;
46 
47  ThreadNode(BlackboardArtifact artifact, String threadID, Action preferredAction) {
48  super(Children.LEAF);
49  messageNode = new MessageNode(artifact, threadID, preferredAction);
50  this.setIconBaseWithExtension("org/sleuthkit/autopsy/communications/images/threaded.png" );
51  }
52 
53  @Override
54  protected Sheet createSheet() {
55  BlackboardArtifact artifact = messageNode.getArtifact();
56  if(artifact == null) {
57  return messageNode.createSheet() ;
58  }
59 
60  Sheet sheet = messageNode.createSheet();
61  BlackboardArtifact.ARTIFACT_TYPE artifactTypeID = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID());
62 
63  // If its a text message, replace the subject node which is probably
64  // an empty string with the firest 120 characters of the text message
65  if(artifactTypeID != null && artifactTypeID == TSK_MESSAGE) {
66  try {
67  BlackboardAttribute attribute = artifact.getAttribute(new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(TSK_TEXT.getTypeID())));
68  if(attribute != null) {
69  Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
70  sheetSet.remove("Subject");
71 
72  String msg = attribute.getDisplayString();
73  if(msg != null && msg.length() > MAX_SUBJECT_LENGTH) {
74  msg = msg.substring(0, MAX_SUBJECT_LENGTH) + "...";
75  }
76 
77  sheetSet.put(new NodeProperty<>("Subject", Bundle.MessageNode_Node_Property_Subject(), "", msg)); //NON-NLS
78  }
79  } catch (TskCoreException ex) {
80  logger.log(Level.WARNING, String.format("Unable to get the text message from message artifact %d", artifact.getId()), ex);
81  }
82  }
83 
84  return sheet;
85  }
86 
87  String getThreadID() {
88  return messageNode.getThreadID();
89  }
90 
91  @Override
92  public Action getPreferredAction() {
93  return messageNode.getPreferredAction();
94  }
95 
96  @Override
97  public String getDisplayName() {
98  return messageNode.getDisplayName();
99  }
100 }

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