19 package org.sleuthkit.autopsy.communications.relationships;
21 import java.util.ArrayList;
22 import java.util.List;
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;
46 final class ContactNode
extends BlackboardArtifactNode {
48 private static final Logger logger = Logger.getLogger(ContactNode.class.getName());
51 "ContactNode_Name=Name",
52 "ContactNode_Phone=Phone Number",
53 "ContactNode_Email=Email Address",
54 "ContactNode_Mobile_Number=Mobile Number",
55 "ContactNode_Office_Number=Office Number",
56 "ContactNode_URL=URL",
57 "ContactNode_Home_Number=Home Number",})
59 ContactNode(BlackboardArtifact artifact) {
62 String name = getAttributeDisplayString(artifact, TSK_NAME);
63 if (name == null || name.trim().isEmpty()) {
65 name = getAttributeDisplayString(artifact, TSK_NAME_PERSON);
71 protected Sheet createSheet() {
72 Sheet sheet =
new Sheet();
75 BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(artifact.getArtifactTypeID());
76 if (fromID != TSK_CONTACT) {
80 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
81 if (sheetSet == null) {
82 sheetSet = Sheet.createPropertiesSet();
91 List<BlackboardAttribute> phoneNumList =
new ArrayList<>();
92 List<BlackboardAttribute> emailList =
new ArrayList<>();
93 List<BlackboardAttribute> nameList =
new ArrayList<>();
94 List<BlackboardAttribute> otherList =
new ArrayList<>();
95 for (BlackboardAttribute bba : artifact.getAttributes()) {
96 if (bba.getAttributeType().getTypeName().startsWith(
"TSK_PHONE")) {
97 phoneNumList.add(bba);
98 }
else if (bba.getAttributeType().getTypeName().startsWith(
"TSK_EMAIL")) {
100 }
else if (bba.getAttributeType().getTypeName().startsWith(
"TSK_NAME")) {
107 addPropertiesToSheet(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_NAME.getLabel(),
109 addPropertiesToSheet(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER.getLabel(),
110 sheetSet, phoneNumList);
111 addPropertiesToSheet(BlackboardAttribute.ATTRIBUTE_TYPE.TSK_EMAIL.getLabel(),
112 sheetSet, emailList);
114 for (BlackboardAttribute bba : otherList) {
115 sheetSet.put(
new NodeProperty<>(bba.getAttributeType().getTypeName(), bba.getAttributeType().getDisplayName(),
"", bba.getDisplayString()));
118 List<Content> children = artifact.getChildren();
119 if (children != null) {
121 String imageLabelPrefix =
"Image";
122 for (Content child : children) {
123 if (child instanceof AbstractFile) {
124 String imageLabel = imageLabelPrefix;
126 imageLabel = imageLabelPrefix +
"-" + count;
128 sheetSet.put(
new NodeProperty<>(imageLabel, imageLabel, imageLabel, child.getName()));
133 }
catch (TskCoreException ex) {
134 logger.log(Level.WARNING,
"Error getting attribute values.", ex);
140 private void addPropertiesToSheet(String propertyID, Sheet.Set sheetSet, List<BlackboardAttribute> attributeList) {
142 for (BlackboardAttribute bba : attributeList) {
144 if (bba.getAttributeType().getTypeName().startsWith(
"TSK_PHONE")) {
145 String phoneNumCountry = PhoneNumUtil.getCountryCode(bba.getValueString());
146 if (phoneNumCountry.equals(
"")) {
147 sheetSet.put(
new NodeProperty<>(propertyID +
"_" + count, bba.getAttributeType().getDisplayName(),
"", bba.getDisplayString()));
149 sheetSet.put(
new NodeProperty<>(propertyID +
"_" + count, bba.getAttributeType().getDisplayName(),
"", bba.getDisplayString() +
" [" + phoneNumCountry +
"]"));
152 sheetSet.put(
new NodeProperty<>(propertyID +
"_" + count, bba.getAttributeType().getDisplayName(),
"", bba.getDisplayString()));
155 if (bba.getAttributeType().getTypeName().startsWith(
"TSK_PHONE")) {
156 String phoneNumCountry = PhoneNumUtil.getCountryCode(bba.getValueString());
157 if (phoneNumCountry.equals(
"")) {
158 sheetSet.put(
new NodeProperty<>(propertyID, bba.getAttributeType().getDisplayName(),
"", bba.getDisplayString()));
160 sheetSet.put(
new NodeProperty<>(propertyID, bba.getAttributeType().getDisplayName(),
"", bba.getDisplayString() +
" [" + phoneNumCountry +
"]"));
163 sheetSet.put(
new NodeProperty<>(propertyID, bba.getAttributeType().getDisplayName(),
"", bba.getDisplayString()));
169 private static String getAttributeDisplayString(
final BlackboardArtifact artifact,
final BlackboardAttribute.ATTRIBUTE_TYPE attributeType) {
171 BlackboardAttribute attribute = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(attributeType.getTypeID())));
172 if (attribute == null) {
174 }
else if (attributeType.getValueType() == DATETIME) {
175 return TimeUtilities.epochToTime(attribute.getValueLong(),
176 TimeZone.getTimeZone(Utils.getUserPreferredZoneId()));
178 return attribute.getDisplayString();
180 }
catch (TskCoreException tskCoreException) {
181 logger.log(Level.WARNING,
"Error getting attribute value.", tskCoreException);
193 public String getSourceName() {
194 return getDisplayName();
BlackboardArtifact getArtifact()