19 package org.sleuthkit.autopsy.communications;
21 import java.util.TimeZone;
22 import java.util.logging.Level;
23 import org.apache.commons.lang3.StringUtils;
24 import org.openide.nodes.Sheet;
30 import org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
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;
46 final class RelationshipNode
extends BlackboardArtifactNode {
48 private static final Logger logger = Logger.getLogger(RelationshipNode.class.getName());
50 RelationshipNode(BlackboardArtifact artifact) {
52 final String stripEnd = StringUtils.stripEnd(artifact.getDisplayName(),
"s");
53 String removeEndIgnoreCase = StringUtils.removeEndIgnoreCase(stripEnd,
"message");
54 setDisplayName(removeEndIgnoreCase.isEmpty() ? stripEnd : removeEndIgnoreCase);
58 protected Sheet createSheet() {
59 Sheet sheet =
new Sheet();
60 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
61 if (sheetSet == null) {
62 sheetSet = Sheet.createPropertiesSet();
66 sheetSet.put(
new NodeProperty<>(
"Type",
"Type",
"Type", getDisplayName()));
69 BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(
getArtifact().getArtifactTypeID());
74 sheetSet.put(
new NodeProperty<>(
"From",
"From",
"From",
75 StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_FROM),
" \t\n;")));
76 sheetSet.put(
new NodeProperty<>(
"To",
"To",
"To",
77 StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_TO),
" \t\n;")));
78 sheetSet.put(
new NodeProperty<>(
"Date",
"Date",
"Date",
79 getAttributeDisplayString(artifact, TSK_DATETIME_SENT)));
80 sheetSet.put(
new NodeProperty<>(
"Subject",
"Subject",
"Subject",
81 getAttributeDisplayString(artifact, TSK_SUBJECT)));
83 sheetSet.put(
new NodeProperty<>(
"Attms",
"Attms",
"Attms", artifact.getChildrenCount()));
84 }
catch (TskCoreException ex) {
85 logger.log(Level.WARNING,
"Error loading attachment count for " + artifact, ex);
90 sheetSet.put(
new NodeProperty<>(
"From",
"From",
"From",
91 getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM)));
92 sheetSet.put(
new NodeProperty<>(
"To",
"To",
"To",
93 getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO)));
94 sheetSet.put(
new NodeProperty<>(
"Date",
"Date",
"Date",
95 getAttributeDisplayString(artifact, TSK_DATETIME)));
96 sheetSet.put(
new NodeProperty<>(
"Subject",
"Subject",
"Subject",
97 getAttributeDisplayString(artifact, TSK_SUBJECT)));
99 sheetSet.put(
new NodeProperty<>(
"Attms",
"Attms",
"Attms", artifact.getChildrenCount()));
100 }
catch (TskCoreException ex) {
101 logger.log(Level.WARNING,
"Error loading attachment count for " + artifact, ex);
105 sheetSet.put(
new NodeProperty<>(
"From",
"From",
"From",
106 getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM)));
107 sheetSet.put(
new NodeProperty<>(
"To",
"To",
"To",
108 getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO)));
109 sheetSet.put(
new NodeProperty<>(
"Date",
"Date",
"Date",
110 getAttributeDisplayString(artifact, TSK_DATETIME_START)));
133 private static String getAttributeDisplayString(
final BlackboardArtifact artifact,
final ATTRIBUTE_TYPE attributeType) {
135 BlackboardAttribute attribute = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attributeType.getTypeID())));
136 if (attribute == null) {
138 }
else if (attributeType.getValueType() == DATETIME) {
139 return TimeUtilities.epochToTime(attribute.getValueLong(),
140 TimeZone.getTimeZone(Utils.getUserPreferredZoneId()));
142 return attribute.getDisplayString();
144 }
catch (TskCoreException tskCoreException) {
145 logger.log(Level.WARNING,
"Error getting attribute value.", tskCoreException);
157 public String getSourceName() {
158 return getDisplayName();
void addTagProperty(Sheet.Set sheetSet)
BlackboardArtifact getArtifact()