19 package org.sleuthkit.autopsy.communications.relationships;
21 import java.util.TimeZone;
22 import java.util.logging.Level;
23 import javax.swing.Action;
24 import org.apache.commons.lang3.StringUtils;
25 import org.openide.nodes.Sheet;
26 import org.openide.util.NbBundle.Messages;
31 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME;
32 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_SENT;
33 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START;
34 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_FROM;
35 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_TO;
36 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM;
37 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
38 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SUBJECT;
39 import static org.
sleuthkit.datamodel.BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DATETIME;
48 class MessageNode
extends BlackboardArtifactNode {
50 public static final String UNTHREADED_ID =
"<UNTHREADED>";
52 private static final Logger logger = Logger.getLogger(MessageNode.class.getName());
54 private final String threadID;
56 private final Action preferredAction;
58 MessageNode(BlackboardArtifact artifact, String threadID, Action preferredAction) {
61 this.preferredAction = preferredAction;
63 final String stripEnd = StringUtils.stripEnd(artifact.getDisplayName(),
"s");
64 String removeEndIgnoreCase = StringUtils.removeEndIgnoreCase(stripEnd,
"message");
65 setDisplayName(removeEndIgnoreCase.isEmpty() ? stripEnd : removeEndIgnoreCase);
67 this.threadID = threadID;
71 "MessageNode_Node_Property_Type=Type",
72 "MessageNode_Node_Property_From=From",
73 "MessageNode_Node_Property_To=To",
74 "MessageNode_Node_Property_Date=Date",
75 "MessageNode_Node_Property_Subject=Subject",
76 "MessageNode_Node_Property_Attms=Attachments"
80 protected Sheet createSheet() {
81 Sheet sheet = super.createSheet();
82 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
83 if (sheetSet == null) {
84 sheetSet = Sheet.createPropertiesSet();
88 sheetSet.put(
new NodeProperty<>(
"Type", Bundle.MessageNode_Node_Property_Type(),
"", getDisplayName()));
92 BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID());
97 sheetSet.put(
new NodeProperty<>(
"From", Bundle.MessageNode_Node_Property_From(),
"",
98 StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_FROM),
" \t\n;")));
99 sheetSet.put(
new NodeProperty<>(
"To", Bundle.MessageNode_Node_Property_To(),
"",
100 StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_TO),
" \t\n;")));
101 sheetSet.put(
new NodeProperty<>(
"Date", Bundle.MessageNode_Node_Property_Date(),
"",
102 getAttributeDisplayString(artifact, TSK_DATETIME_SENT)));
103 sheetSet.put(
new NodeProperty<>(
"Subject", Bundle.MessageNode_Node_Property_Subject(),
"",
104 getAttributeDisplayString(artifact, TSK_SUBJECT)));
106 sheetSet.put(
new NodeProperty<>(
"Attms", Bundle.MessageNode_Node_Property_Attms(),
"", artifact.getChildrenCount()));
107 }
catch (TskCoreException ex) {
108 logger.log(Level.WARNING,
"Error loading attachment count for " + artifact, ex);
111 sheetSet.put(
new NodeProperty<>(
"ThreadID",
"ThreadID",
"",threadID == null ?
"" : threadID));
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)));
121 sheetSet.put(
new NodeProperty<>(
"Subject", Bundle.MessageNode_Node_Property_Subject(),
"",
122 getAttributeDisplayString(artifact, TSK_SUBJECT)));
124 sheetSet.put(
new NodeProperty<>(
"Attms", Bundle.MessageNode_Node_Property_Attms(),
"", artifact.getChildrenCount()));
125 }
catch (TskCoreException ex) {
126 logger.log(Level.WARNING,
"Error loading attachment count for " + artifact, ex);
130 sheetSet.put(
new NodeProperty<>(
"From", Bundle.MessageNode_Node_Property_From(),
"",
131 getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM)));
132 sheetSet.put(
new NodeProperty<>(
"To", Bundle.MessageNode_Node_Property_To(),
"",
133 getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO)));
134 sheetSet.put(
new NodeProperty<>(
"Date", Bundle.MessageNode_Node_Property_Date(),
"",
135 getAttributeDisplayString(artifact, TSK_DATETIME_START)));
156 private static String getAttributeDisplayString(
final BlackboardArtifact artifact,
final BlackboardAttribute.ATTRIBUTE_TYPE attributeType) {
158 BlackboardAttribute attribute = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attributeType.getTypeID())));
159 if (attribute == null) {
161 }
else if (attributeType.getValueType() == DATETIME) {
162 return TimeUtilities.epochToTime(attribute.getValueLong(),
163 TimeZone.getTimeZone(Utils.getUserPreferredZoneId()));
165 return attribute.getDisplayString();
167 }
catch (TskCoreException tskCoreException) {
168 logger.log(Level.WARNING,
"Error getting attribute value.", tskCoreException);
180 public String getSourceName() {
181 return getDisplayName();
184 String getThreadID() {
189 public Action getPreferredAction() {
190 return preferredAction;
BlackboardArtifact getArtifact()