From abc449f8bcf32698c3624dc4c23deae28a441df0 Mon Sep 17 00:00:00 2001 From: Dick Fickling Date: Fri, 6 Apr 2012 09:33:49 -0400 Subject: [PATCH] Add support for 'path id' attribute --- .../datamodel/BlackboardArtifactNode.java | 15 +++++++--- .../directorytree/DataResultFilterNode.java | 30 ++++++++++++++++++- .../directorytree/ViewContextAction.java | 5 ++++ 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/DataModel/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java b/DataModel/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java index 4a21a6de90..f258183251 100644 --- a/DataModel/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java +++ b/DataModel/src/org/sleuthkit/autopsy/datamodel/BlackboardArtifactNode.java @@ -18,8 +18,9 @@ */ package org.sleuthkit.autopsy.datamodel; -import java.sql.SQLException; +import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Date; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -27,7 +28,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.openide.nodes.AbstractNode; import org.openide.nodes.Children; -import org.openide.nodes.Node; import org.openide.nodes.Sheet; import org.openide.util.Lookup; import org.openide.util.lookup.Lookups; @@ -101,7 +101,9 @@ public class BlackboardArtifactNode extends AbstractNode implements DisplayableI public static void fillPropertyMap(Map map, BlackboardArtifact artifact) { try { for(BlackboardAttribute attribute : artifact.getAttributes()){ - switch(attribute.getValueType()){ + if(attribute.getAttributeTypeID() == ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID()) + continue; + else switch(attribute.getValueType()){ case STRING: map.put(attribute.getAttributeTypeID(), attribute.getValueString()); break; @@ -109,7 +111,12 @@ public class BlackboardArtifactNode extends AbstractNode implements DisplayableI map.put(attribute.getAttributeTypeID(), attribute.getValueInt()); break; case LONG: - map.put(attribute.getAttributeTypeID(), attribute.getValueLong()); + if(attribute.getAttributeTypeID() == ATTRIBUTE_TYPE.TSK_DATETIME.getTypeID() || + attribute.getAttributeTypeID() == ATTRIBUTE_TYPE.TSK_LAST_ACCESSED.getTypeID()) { + SimpleDateFormat formatter = new SimpleDateFormat("MM-dd-yyyy HH:mm"); + map.put(attribute.getAttributeTypeID(), formatter.format(new Date(attribute.getValueLong()))); + } else + map.put(attribute.getAttributeTypeID(), attribute.getValueLong()); break; case DOUBLE: map.put(attribute.getAttributeTypeID(), attribute.getValueDouble()); diff --git a/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java b/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java index f3ec73c2f6..3a17c8844b 100644 --- a/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java +++ b/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/DataResultFilterNode.java @@ -50,7 +50,10 @@ import org.sleuthkit.autopsy.datamodel.KeywordHits.KeywordHitsRootNode; import org.sleuthkit.autopsy.datamodel.RecentFilesFilterNode; import org.sleuthkit.autopsy.datamodel.RecentFilesNode; import org.sleuthkit.autopsy.datamodel.SearchFiltersNode; +import org.sleuthkit.datamodel.BlackboardArtifact; +import org.sleuthkit.datamodel.BlackboardAttribute; import org.sleuthkit.datamodel.Content; +import org.sleuthkit.datamodel.TskException; /** @@ -178,7 +181,10 @@ public class DataResultFilterNode extends FilterNode{ public List visit(BlackboardArtifactNode ba) { List actions = new ArrayList(); //actions.add(new ViewAssociatedContentAction("View Associated Content", ba)); - actions.add(new ViewContextAction("View in Directory", ba)); + actions.add(new ViewContextAction("View Source in Directory", ba)); + Content c = findLinked(ba); + if(c != null) + actions.add(new ViewContextAction("View Linked in Directory", c)); return actions; } @@ -187,6 +193,28 @@ public class DataResultFilterNode extends FilterNode{ return new ArrayList(); } + private Content findLinked(BlackboardArtifactNode ba) { + BlackboardArtifact art = ba.getLookup().lookup(BlackboardArtifact.class); + Content c = null; + try { + for(BlackboardAttribute attr : art.getAttributes()) { + if(attr.getAttributeTypeID() == BlackboardAttribute.ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID()) { + switch(attr.getValueType()) { + case INTEGER: + c = art.getSleuthkitCase().getContentById(attr.getValueInt()); + break; + case LONG: + c = art.getSleuthkitCase().getContentById(attr.getValueLong()); + break; + } + } + } + } catch(TskException ex) { + Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "Error getting linked file"); + } + return c; + } + } private class GetPreferredActionsDisplayableItemNodeVisitor extends DisplayableItemNodeVisitor.Default{ diff --git a/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/ViewContextAction.java b/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/ViewContextAction.java index 7b9c014e2e..36fd7a776c 100644 --- a/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/ViewContextAction.java +++ b/DirectoryTree/src/org/sleuthkit/autopsy/directorytree/ViewContextAction.java @@ -66,6 +66,11 @@ class ViewContextAction extends AbstractAction { super(title); this.content = node.getLookup().lookup(Content.class); } + + public ViewContextAction(String title, Content content) { + super(title); + this.content = content; + } @Override public void actionPerformed(ActionEvent e) {