19 package org.sleuthkit.autopsy.communications.relationships;
 
   21 import java.util.logging.Level;
 
   22 import org.apache.commons.lang.StringUtils;
 
   23 import org.openide.nodes.Sheet;
 
   44 final class CallLogNode 
extends BlackboardArtifactNode {
 
   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);
 
   56     protected Sheet createSheet() {
 
   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)) {
 
  172     public String getSourceName() {
 
  173         return getDisplayName();
 
BlackboardArtifact getArtifact()