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;
34 import org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE;
35 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME;
36 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_SENT;
37 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START;
38 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_FROM;
39 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL_TO;
40 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM;
41 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
42 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_SUBJECT;
43 import static org.
sleuthkit.datamodel.BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DATETIME;
51 final class RelationshipNode
extends BlackboardArtifactNode {
53 private static final Logger logger = Logger.getLogger(RelationshipNode.class.getName());
55 RelationshipNode(BlackboardArtifact artifact) {
57 final String stripEnd = StringUtils.stripEnd(artifact.getDisplayName(),
"s");
58 String removeEndIgnoreCase = StringUtils.removeEndIgnoreCase(stripEnd,
"message");
59 setDisplayName(removeEndIgnoreCase.isEmpty() ? stripEnd : removeEndIgnoreCase);
63 protected Sheet createSheet() {
64 Sheet sheet =
new Sheet();
66 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
67 if (sheetSet == null) {
68 sheetSet = Sheet.createPropertiesSet();
72 sheetSet.put(
new NodeProperty<>(
"Type",
"Type",
"Type", getDisplayName()));
76 CorrelationAttributeInstance correlationAttribute = null;
77 if (EamDbUtil.useCentralRepo() && UserPreferences.hideCentralRepoCommentsAndOccurrences()==
false) {
82 if (EamDbUtil.useCentralRepo() && UserPreferences.hideCentralRepoCommentsAndOccurrences()==
false) {
86 BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(
getArtifact().getArtifactTypeID());
91 sheetSet.put(
new NodeProperty<>(
"From",
"From",
"From",
92 StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_FROM),
" \t\n;")));
93 sheetSet.put(
new NodeProperty<>(
"To",
"To",
"To",
94 StringUtils.strip(getAttributeDisplayString(artifact, TSK_EMAIL_TO),
" \t\n;")));
95 sheetSet.put(
new NodeProperty<>(
"Date",
"Date",
"Date",
96 getAttributeDisplayString(artifact, TSK_DATETIME_SENT)));
97 sheetSet.put(
new NodeProperty<>(
"Subject",
"Subject",
"Subject",
98 getAttributeDisplayString(artifact, TSK_SUBJECT)));
100 sheetSet.put(
new NodeProperty<>(
"Attms",
"Attms",
"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",
"From",
"From",
108 getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM)));
109 sheetSet.put(
new NodeProperty<>(
"To",
"To",
"To",
110 getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO)));
111 sheetSet.put(
new NodeProperty<>(
"Date",
"Date",
"Date",
112 getAttributeDisplayString(artifact, TSK_DATETIME)));
113 sheetSet.put(
new NodeProperty<>(
"Subject",
"Subject",
"Subject",
114 getAttributeDisplayString(artifact, TSK_SUBJECT)));
116 sheetSet.put(
new NodeProperty<>(
"Attms",
"Attms",
"Attms", artifact.getChildrenCount()));
117 }
catch (TskCoreException ex) {
118 logger.log(Level.WARNING,
"Error loading attachment count for " + artifact, ex);
122 sheetSet.put(
new NodeProperty<>(
"From",
"From",
"From",
123 getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM)));
124 sheetSet.put(
new NodeProperty<>(
"To",
"To",
"To",
125 getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO)));
126 sheetSet.put(
new NodeProperty<>(
"Date",
"Date",
"Date",
127 getAttributeDisplayString(artifact, TSK_DATETIME_START)));
148 private static String getAttributeDisplayString(
final BlackboardArtifact artifact,
final ATTRIBUTE_TYPE attributeType) {
150 BlackboardAttribute attribute = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attributeType.getTypeID())));
151 if (attribute == null) {
153 }
else if (attributeType.getValueType() == DATETIME) {
154 return TimeUtilities.epochToTime(attribute.getValueLong(),
155 TimeZone.getTimeZone(Utils.getUserPreferredZoneId()));
157 return attribute.getDisplayString();
159 }
catch (TskCoreException tskCoreException) {
160 logger.log(Level.WARNING,
"Error getting attribute value.", tskCoreException);
172 public String getSourceName() {
173 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()