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;
 
   31 import static org.
sleuthkit.datamodel.BlackboardArtifact.ARTIFACT_TYPE.TSK_CALLLOG;
 
   33 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_START;
 
   34 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DATETIME_END;
 
   35 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_FROM;
 
   36 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER_TO;
 
   37 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_DIRECTION;
 
   38 import static org.
sleuthkit.datamodel.BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PHONE_NUMBER;
 
   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));
 
   80         sheetSet.put(
new NodeProperty<>(TSK_PHONE_NUMBER.getLabel(), TSK_PHONE_NUMBER.getDisplayName(), 
"", getPhoneNumber(artifact)));
 
   82             sheetSet.put(
new NodeProperty<>(
"duration", 
"Duration", 
"", Long.toString(duration)));
 
   88     NodeProperty<?> createNode(BlackboardAttribute.ATTRIBUTE_TYPE type, BlackboardArtifact artifact) {
 
   89         return new NodeProperty<>(type.getLabel(), type.getDisplayName(), type.getDisplayName(), getAttributeDisplayString(artifact, type));
 
   92     long getCallDuration(BlackboardArtifact artifact) 
throws TskCoreException {
 
   93         BlackboardAttribute startAttribute = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(TSK_DATETIME_START.getTypeID())));
 
   94         BlackboardAttribute endAttribute = artifact.getAttribute(
new BlackboardAttribute.Type(BlackboardAttribute.ATTRIBUTE_TYPE.fromID(TSK_DATETIME_END.getTypeID())));
 
   96         if(startAttribute == null || endAttribute == null) {
 
  100         return endAttribute.getValueLong() - startAttribute.getValueLong();
 
  112     private String getPhoneNumber(BlackboardArtifact artifact) {
 
  113         String direction = getAttributeDisplayString(artifact, TSK_DIRECTION);
 
  115         String phoneNumberToReturn;
 
  116         String fromPhoneNumber = getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_FROM);
 
  117         String toPhoneNumber = getAttributeDisplayString(artifact, TSK_PHONE_NUMBER_TO);
 
  118         String phoneNumber = getAttributeDisplayString(artifact, TSK_PHONE_NUMBER);
 
  119         switch (direction.toLowerCase()) {
 
  121                 phoneNumberToReturn = getFirstNonBlank(fromPhoneNumber, phoneNumber, toPhoneNumber);
 
  124                 phoneNumberToReturn = getFirstNonBlank(toPhoneNumber, phoneNumber, fromPhoneNumber);
 
  127                 phoneNumberToReturn = getFirstNonBlank(toPhoneNumber, fromPhoneNumber, phoneNumber );
 
  131         return phoneNumberToReturn;
 
  145     private String getFirstNonBlank(String string1, String string2, String string3 ) {
 
  147         if (!StringUtils.isBlank(string1)) {
 
  149         } 
else if (!StringUtils.isBlank(string2)) {
 
  151         } 
else if (!StringUtils.isBlank(string3)) {
 
  163     public String getSourceName() {
 
  164         return getDisplayName();
 
BlackboardArtifact getArtifact()