19 package org.sleuthkit.autopsy.communications.relationships;
21 import java.util.logging.Level;
22 import javax.swing.Action;
23 import org.apache.commons.lang3.StringUtils;
24 import org.openide.nodes.Sheet;
25 import org.openide.util.NbBundle.Messages;
29 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME;
30 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_SENT;
31 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_FROM;
32 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_TO;
33 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM;
34 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
35 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SUBJECT;
39 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_EMAIL_MSG;
40 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_MESSAGE;
45 class MessageNode
extends BlackboardArtifactNode {
47 public static final String UNTHREADED_ID =
"<UNTHREADED>";
49 private static final Logger logger = Logger.getLogger(MessageNode.class.getName());
51 private final String threadID;
53 private final Action preferredAction;
55 MessageNode(BlackboardArtifact artifact, String threadID, Action preferredAction) {
58 this.preferredAction = preferredAction;
60 final String stripEnd = StringUtils.stripEnd(artifact.getDisplayName(),
"s");
61 String removeEndIgnoreCase = StringUtils.removeEndIgnoreCase(stripEnd,
"message");
62 setDisplayName(removeEndIgnoreCase.isEmpty() ? stripEnd : removeEndIgnoreCase);
64 this.threadID = threadID;
68 "MessageNode_Node_Property_Type=Type",
69 "MessageNode_Node_Property_From=From",
70 "MessageNode_Node_Property_To=To",
71 "MessageNode_Node_Property_Date=Date",
72 "MessageNode_Node_Property_Subject=Subject",
73 "MessageNode_Node_Property_Attms=Attachments"
77 protected Sheet createSheet() {
78 Sheet sheet = super.createSheet();
79 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
80 if (sheetSet == null) {
81 sheetSet = Sheet.createPropertiesSet();
85 sheetSet.put(
new NodeProperty<>(
"Type", Bundle.MessageNode_Node_Property_Type(),
"", getDisplayName()));
88 BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID());
91 (fromID != TSK_EMAIL_MSG &&
92 fromID != TSK_MESSAGE)) {
96 sheetSet.put(
new NodeProperty<>(
"ThreadID",
"ThreadID",
"",threadID == null ? UNTHREADED_ID : threadID));
97 sheetSet.put(
new NodeProperty<>(
"Subject", Bundle.MessageNode_Node_Property_Subject(),
"",
98 getAttributeDisplayString(artifact, TSK_SUBJECT)));
100 sheetSet.put(
new NodeProperty<>(
"Attms", Bundle.MessageNode_Node_Property_Attms(),
"", artifact.getChildrenCount()));
101 }
catch (TskCoreException ex) {
102 logger.log(Level.WARNING,
"Error loading attachment count for " + artifact, ex);
107 sheetSet.put(
new NodeProperty<>(
"From", Bundle.MessageNode_Node_Property_From(),
"",
108 StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_FROM),
" \t\n;")));
109 sheetSet.put(
new NodeProperty<>(
"To", Bundle.MessageNode_Node_Property_To(),
"",
110 StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_TO),
" \t\n;")));
111 sheetSet.put(
new NodeProperty<>(
"Date", Bundle.MessageNode_Node_Property_Date(),
"",
112 getAttributeDisplayString(artifact, TSK_DATETIME_SENT)));
115 sheetSet.put(
new NodeProperty<>(
"From", Bundle.MessageNode_Node_Property_From(),
"",
116 getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM)));
117 sheetSet.put(
new NodeProperty<>(
"To", Bundle.MessageNode_Node_Property_To(),
"",
118 getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO)));
119 sheetSet.put(
new NodeProperty<>(
"Date", Bundle.MessageNode_Node_Property_Date(),
"",
120 getAttributeDisplayString(artifact, TSK_DATETIME)));
135 public String getSourceName() {
136 return getDisplayName();
139 String getThreadID() {
144 public Action getPreferredAction() {
145 return preferredAction;
BlackboardArtifact getArtifact()