19 package org.sleuthkit.autopsy.communications.relationships;
21 import java.util.HashMap;
22 import java.util.List;
24 import java.util.TimeZone;
25 import java.util.logging.Level;
26 import org.openide.nodes.Sheet;
27 import org.openide.util.NbBundle.Messages;
32 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_CONTACT;
34 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME;
35 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME_PERSON;
36 import static org.
sleuthkit.datamodel.BlackboardAttribute.TSK_BLACKBOARD_ATTRIBUTE_VALUE_TYPE.DATETIME;
47 final class ContactNode
extends BlackboardArtifactNode {
49 private static final Logger logger = Logger.getLogger(ContactNode.class.getName());
52 "ContactNode_Name=Name",
53 "ContactNode_Phone=Phone Number",
54 "ContactNode_Email=Email Address",
55 "ContactNode_Mobile_Number=Mobile Number",
56 "ContactNode_Office_Number=Office Number",
57 "ContactNode_URL=URL",
58 "ContactNode_Home_Number=Home Number",})
60 ContactNode(BlackboardArtifact artifact) {
63 String name = getAttributeDisplayString(artifact, TSK_NAME);
64 if (name == null || name.trim().isEmpty()) {
66 name = getAttributeDisplayString(artifact, TSK_NAME_PERSON);
72 protected Sheet createSheet() {
73 Sheet sheet = super.createSheet();
76 BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID());
77 if (fromID != TSK_CONTACT) {
81 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
82 if (sheetSet == null) {
83 sheetSet = Sheet.createPropertiesSet();
92 HashMap<String, BlackboardAttribute> phoneNumMap =
new HashMap<>();
93 HashMap<String, BlackboardAttribute> emailMap =
new HashMap<>();
94 HashMap<String, BlackboardAttribute> nameMap =
new HashMap<>();
95 HashMap<String, BlackboardAttribute> otherMap =
new HashMap<>();
96 for (BlackboardAttribute bba : artifact.getAttributes()) {
97 if (bba.getAttributeType().getTypeName().startsWith(
"TSK_PHONE")) {
98 phoneNumMap.put(bba.getDisplayString(), bba);
99 }
else if (bba.getAttributeType().getTypeName().startsWith(
"TSK_EMAIL")) {
100 emailMap.put(bba.getDisplayString(), bba);
101 }
else if (bba.getAttributeType().getTypeName().startsWith(
"TSK_NAME")) {
102 nameMap.put(bba.getDisplayString(), bba);
104 otherMap.put(bba.getDisplayString(), bba);
108 addPropertiesToSheet(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME.getLabel(),
110 addPropertiesToSheet(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER.getLabel(),
111 sheetSet, phoneNumMap);
112 addPropertiesToSheet(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL.getLabel(),
115 for (BlackboardAttribute bba : otherMap.values()) {
116 sheetSet.put(
new NodeProperty<>(bba.getAttributeType().getTypeName(), bba.getAttributeType().getDisplayName(),
"", bba.getDisplayString()));
120 sheetSet.remove(
"S");
121 sheetSet.remove(
"C");
123 List<Content> children = artifact.getChildren();
124 if(children != null) {
126 String imageLabelPrefix =
"Image";
127 for(Content child: children) {
128 if(child instanceof AbstractFile) {
129 String imageLabel = imageLabelPrefix;
131 imageLabel = imageLabelPrefix +
"-" + count;
133 sheetSet.put(
new NodeProperty<>(imageLabel, imageLabel, imageLabel, child.getName()));
138 }
catch (TskCoreException ex) {
139 logger.log(Level.WARNING,
"Error getting attribute values.", ex);
145 private void addPropertiesToSheet(String propertyID, Sheet.Set sheetSet, Map<String, BlackboardAttribute> attributeMap) {
147 for (BlackboardAttribute bba : attributeMap.values()) {
149 sheetSet.put(
new NodeProperty<>(propertyID +
"_" + count, bba.getAttributeType().getDisplayName(),
"", bba.getDisplayString()));
151 sheetSet.put(
new NodeProperty<>(propertyID, bba.getAttributeType().getDisplayName(),
"", bba.getDisplayString()));
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();
BlackboardArtifact getArtifact()