19 package org.sleuthkit.autopsy.communications;
21 import java.util.List;
22 import java.util.TimeZone;
23 import java.util.logging.Level;
24 import org.apache.commons.lang3.StringUtils;
25 import org.openide.nodes.Sheet;
33 import org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
34 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME;
35 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_SENT;
36 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START;
37 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_FROM;
38 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_TO;
39 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM;
40 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
41 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SUBJECT;
42 import static org.
sleuthkit.datamodel.BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DATETIME;
50 final class RelationshipNode
extends BlackboardArtifactNode {
52 private static final Logger logger = Logger.getLogger(RelationshipNode.class.getName());
54 RelationshipNode(BlackboardArtifact artifact) {
56 final String stripEnd = StringUtils.stripEnd(artifact.getDisplayName(),
"s");
57 String removeEndIgnoreCase = StringUtils.removeEndIgnoreCase(stripEnd,
"message");
58 setDisplayName(removeEndIgnoreCase.isEmpty() ? stripEnd : removeEndIgnoreCase);
62 protected Sheet createSheet() {
63 Sheet sheet =
new Sheet();
65 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
66 if (sheetSet == null) {
67 sheetSet = Sheet.createPropertiesSet();
71 sheetSet.put(
new NodeProperty<>(
"Type",
"Type",
"Type", getDisplayName()));
75 CorrelationAttributeInstance correlationAttribute = null;
76 if (UserPreferences.hideCentralRepoCommentsAndOccurrences()==
false) {
81 if (UserPreferences.hideCentralRepoCommentsAndOccurrences()==
false) {
85 BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(
getArtifact().getArtifactTypeID());
90 sheetSet.put(
new NodeProperty<>(
"From",
"From",
"From",
91 StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_FROM),
" \t\n;")));
92 sheetSet.put(
new NodeProperty<>(
"To",
"To",
"To",
93 StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_TO),
" \t\n;")));
94 sheetSet.put(
new NodeProperty<>(
"Date",
"Date",
"Date",
95 getAttributeDisplayString(artifact, TSK_DATETIME_SENT)));
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);
106 sheetSet.put(
new NodeProperty<>(
"From",
"From",
"From",
107 getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM)));
108 sheetSet.put(
new NodeProperty<>(
"To",
"To",
"To",
109 getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO)));
110 sheetSet.put(
new NodeProperty<>(
"Date",
"Date",
"Date",
111 getAttributeDisplayString(artifact, TSK_DATETIME)));
112 sheetSet.put(
new NodeProperty<>(
"Subject",
"Subject",
"Subject",
113 getAttributeDisplayString(artifact, TSK_SUBJECT)));
115 sheetSet.put(
new NodeProperty<>(
"Attms",
"Attms",
"Attms", artifact.getChildrenCount()));
116 }
catch (TskCoreException ex) {
117 logger.log(Level.WARNING,
"Error loading attachment count for " + artifact, ex);
121 sheetSet.put(
new NodeProperty<>(
"From",
"From",
"From",
122 getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM)));
123 sheetSet.put(
new NodeProperty<>(
"To",
"To",
"To",
124 getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO)));
125 sheetSet.put(
new NodeProperty<>(
"Date",
"Date",
"Date",
126 getAttributeDisplayString(artifact, TSK_DATETIME_START)));
147 private static String getAttributeDisplayString(
final BlackboardArtifact artifact,
final ATTRIBUTE_TYPE attributeType) {
149 BlackboardAttribute attribute = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attributeType.getTypeID())));
150 if (attribute == null) {
152 }
else if (attributeType.getValueType() == DATETIME) {
153 return TimeUtilities.epochToTime(attribute.getValueLong(),
154 TimeZone.getTimeZone(Utils.getUserPreferredZoneId()));
156 return attribute.getDisplayString();
158 }
catch (TskCoreException tskCoreException) {
159 logger.log(Level.WARNING,
"Error getting attribute value.", tskCoreException);
171 public String getSourceName() {
172 return getDisplayName();
final void addScoreProperty(Sheet.Set sheetSet, List< Tag > tags)
final List< Tag > getAllTagsFromDatabase()
final void addCommentProperty(Sheet.Set sheetSet, List< Tag > tags, CorrelationAttributeInstance attribute)
final CorrelationAttributeInstance getCorrelationAttributeInstance()
final void addCountProperty(Sheet.Set sheetSet, CorrelationAttributeInstance attribute)
BlackboardArtifact getArtifact()