19 package org.sleuthkit.autopsy.communications.relationships;
21 import java.util.HashMap;
23 import java.util.TimeZone;
24 import java.util.logging.Level;
25 import org.openide.nodes.Sheet;
26 import org.openide.util.NbBundle.Messages;
31 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_CONTACT;
33 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME;
34 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME_PERSON;
35 import static org.
sleuthkit.datamodel.BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DATETIME;
44 final class ContactNode
extends BlackboardArtifactNode {
46 private static final Logger logger = Logger.getLogger(ContactNode.class.getName());
49 "ContactNode_Name=Name",
50 "ContactNode_Phone=Phone Number",
51 "ContactNode_Email=Email Address",
52 "ContactNode_Mobile_Number=Mobile Number",
53 "ContactNode_Office_Number=Office Number",
54 "ContactNode_URL=URL",
55 "ContactNode_Home_Number=Home Number",})
57 ContactNode(BlackboardArtifact artifact) {
60 String name = getAttributeDisplayString(artifact, TSK_NAME);
61 if (name == null || name.trim().isEmpty()) {
63 name = getAttributeDisplayString(artifact, TSK_NAME_PERSON);
69 protected Sheet createSheet() {
70 Sheet sheet = super.createSheet();
73 BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID());
74 if (fromID != TSK_CONTACT) {
78 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
79 if (sheetSet == null) {
80 sheetSet = Sheet.createPropertiesSet();
89 HashMap<String, BlackboardAttribute> phoneNumMap =
new HashMap<>();
90 HashMap<String, BlackboardAttribute> emailMap =
new HashMap<>();
91 HashMap<String, BlackboardAttribute> nameMap =
new HashMap<>();
92 HashMap<String, BlackboardAttribute> otherMap =
new HashMap<>();
93 for (BlackboardAttribute bba : artifact.getAttributes()) {
94 if (bba.getAttributeType().getTypeName().startsWith(
"TSK_PHONE")) {
95 phoneNumMap.put(bba.getDisplayString(), bba);
96 }
else if (bba.getAttributeType().getTypeName().startsWith(
"TSK_EMAIL")) {
97 emailMap.put(bba.getDisplayString(), bba);
98 }
else if (bba.getAttributeType().getTypeName().startsWith(
"TSK_NAME")) {
99 nameMap.put(bba.getDisplayString(), bba);
101 otherMap.put(bba.getDisplayString(), bba);
105 addPropertiesToSheet(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME.getLabel(),
107 addPropertiesToSheet(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER.getLabel(),
108 sheetSet, phoneNumMap);
109 addPropertiesToSheet(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL.getLabel(),
112 for (BlackboardAttribute bba : otherMap.values()) {
113 sheetSet.put(
new NodeProperty<>(bba.getAttributeType().getTypeName(), bba.getAttributeType().getDisplayName(),
"", bba.getDisplayString()));
116 }
catch (TskCoreException ex) {
117 logger.log(Level.WARNING,
"Error getting attribute values.", ex);
123 private void addPropertiesToSheet(String propertyID, Sheet.Set sheetSet, Map<String, BlackboardAttribute> attributeMap) {
125 for (BlackboardAttribute bba : attributeMap.values()) {
127 sheetSet.put(
new NodeProperty<>(propertyID +
"_" + count, bba.getAttributeType().getDisplayName(),
"", bba.getDisplayString()));
129 sheetSet.put(
new NodeProperty<>(propertyID, bba.getAttributeType().getDisplayName(),
"", bba.getDisplayString()));
134 private static String getAttributeDisplayString(
final BlackboardArtifact artifact,
final BlackboardAttribute.ATTRIBUTE_TYPE attributeType) {
136 BlackboardAttribute attribute = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attributeType.getTypeID())));
137 if (attribute == null) {
139 }
else if (attributeType.getValueType() == DATETIME) {
140 return TimeUtilities.epochToTime(attribute.getValueLong(),
141 TimeZone.getTimeZone(Utils.getUserPreferredZoneId()));
143 return attribute.getDisplayString();
145 }
catch (TskCoreException tskCoreException) {
146 logger.log(Level.WARNING,
"Error getting attribute value.", tskCoreException);
158 public String getSourceName() {
159 return getDisplayName();
BlackboardArtifact getArtifact()