19package org.sleuthkit.autopsy.communications.relationships;
21import java.util.logging.Level;
22import org.apache.commons.lang.StringUtils;
23import org.openide.nodes.Sheet;
24import org.sleuthkit.autopsy.communications.Utils;
25import static org.sleuthkit.autopsy.communications.relationships.RelationshipsNodeUtilities.getAttributeDisplayString;
26import org.sleuthkit.autopsy.coreutils.Logger;
27import org.sleuthkit.autopsy.datamodel.BlackboardArtifactNode;
28import org.sleuthkit.autopsy.datamodel.NodeProperty;
29import org.sleuthkit.datamodel.Account;
30import org.sleuthkit.datamodel.BlackboardArtifact;
31import static org.sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_CALLLOG;
32import org.sleuthkit.datamodel.BlackboardAttribute;
33import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START;
34import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_END;
35import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM;
36import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
37import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DIRECTION;
38import static org.sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER;
39import org.sleuthkit.datamodel.TskCoreException;
46 private static final Logger logger = Logger.getLogger(CallLogNode.class.getName());
48 final static String DURATION_PROP =
"duration";
50 CallLogNode(BlackboardArtifact
artifact, String deviceID) {
51 super(
artifact, Utils.getIconFilePath(Account.Type.PHONE));
52 setDisplayName(deviceID);
57 Sheet sheet = super.createSheet();
58 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
59 if (sheetSet ==
null) {
60 sheetSet = Sheet.createPropertiesSet();
66 BlackboardArtifact.ARTIFACT_TYPE fromID = BlackboardArtifact.ARTIFACT_TYPE.fromID(
artifact.getArtifactTypeID());
67 if (
null != fromID && fromID != TSK_CALLLOG) {
73 duration = getCallDuration(
artifact);
74 }
catch(TskCoreException ex) {
75 logger.log(Level.WARNING, String.format(
"Unable to get calllog duration for artifact: %d",
artifact.getArtifactID()), ex);
78 sheetSet.put(createNode(TSK_DATETIME_START,
artifact));
79 sheetSet.put(createNode(TSK_DIRECTION,
artifact));
81 String phoneNumber = getPhoneNumber(
artifact);
82 Account account =
null;
84 account =
artifact.getSleuthkitCase().getCommunicationsManager().getAccount(Account.Type.PHONE, phoneNumber);
85 }
catch (TskCoreException ex) {
86 logger.log(Level.SEVERE,
"Failed to get instance of communications manager", ex);
89 sheetSet.put(
new AccountNodeProperty<>(TSK_PHONE_NUMBER.getLabel(), TSK_PHONE_NUMBER.getDisplayName(), phoneNumber, account));
91 sheetSet.put(
new NodeProperty<>(
"duration",
"Duration",
"", Long.toString(duration)));
97 NodeProperty<?> createNode(BlackboardAttribute.ATTRIBUTE_TYPE type, BlackboardArtifact
artifact) {
98 return new NodeProperty<>(type.getLabel(), type.getDisplayName(), type.getDisplayName(), getAttributeDisplayString(
artifact, type));
101 long getCallDuration(BlackboardArtifact
artifact)
throws TskCoreException {
102 BlackboardAttribute startAttribute =
artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(TSK_DATETIME_START.getTypeID())));
103 BlackboardAttribute endAttribute =
artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(TSK_DATETIME_END.getTypeID())));
105 if(startAttribute ==
null || endAttribute ==
null) {
109 return endAttribute.getValueLong() - startAttribute.getValueLong();
121 private String getPhoneNumber(BlackboardArtifact
artifact) {
122 String direction = getAttributeDisplayString(
artifact, TSK_DIRECTION);
124 String phoneNumberToReturn;
125 String fromPhoneNumber = getAttributeDisplayString(
artifact, TSK_PHONE_NUMBER_FROM);
126 String toPhoneNumber = getAttributeDisplayString(
artifact, TSK_PHONE_NUMBER_TO);
127 String phoneNumber = getAttributeDisplayString(
artifact, TSK_PHONE_NUMBER);
128 switch (direction.toLowerCase()) {
130 phoneNumberToReturn = getFirstNonBlank(fromPhoneNumber, phoneNumber, toPhoneNumber);
133 phoneNumberToReturn = getFirstNonBlank(toPhoneNumber, phoneNumber, fromPhoneNumber);
136 phoneNumberToReturn = getFirstNonBlank(toPhoneNumber, fromPhoneNumber, phoneNumber );
140 return phoneNumberToReturn;
154 private String getFirstNonBlank(String string1, String string2, String string3 ) {
156 if (!StringUtils.isBlank(string1)) {
158 }
else if (!StringUtils.isBlank(string2)) {
160 }
else if (!StringUtils.isBlank(string3)) {
173 return getDisplayName();
BlackboardArtifact getArtifact()
final BlackboardArtifact artifact