Add support for 'path id' attribute

This commit is contained in:
Dick Fickling 2012-04-06 09:33:49 -04:00
parent a2267f34f5
commit abc449f8bc
3 changed files with 45 additions and 5 deletions

View File

@ -18,8 +18,9 @@
*/ */
package org.sleuthkit.autopsy.datamodel; package org.sleuthkit.autopsy.datamodel;
import java.sql.SQLException; import java.text.SimpleDateFormat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -27,7 +28,6 @@ import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.openide.nodes.AbstractNode; import org.openide.nodes.AbstractNode;
import org.openide.nodes.Children; import org.openide.nodes.Children;
import org.openide.nodes.Node;
import org.openide.nodes.Sheet; import org.openide.nodes.Sheet;
import org.openide.util.Lookup; import org.openide.util.Lookup;
import org.openide.util.lookup.Lookups; import org.openide.util.lookup.Lookups;
@ -101,7 +101,9 @@ public class BlackboardArtifactNode extends AbstractNode implements DisplayableI
public static void fillPropertyMap(Map<Integer, Object> map, BlackboardArtifact artifact) { public static void fillPropertyMap(Map<Integer, Object> map, BlackboardArtifact artifact) {
try { try {
for(BlackboardAttribute attribute : artifact.getAttributes()){ for(BlackboardAttribute attribute : artifact.getAttributes()){
switch(attribute.getValueType()){ if(attribute.getAttributeTypeID() == ATTRIBUTE_TYPE.TSK_PATH_ID.getTypeID())
continue;
else switch(attribute.getValueType()){
case STRING: case STRING:
map.put(attribute.getAttributeTypeID(), attribute.getValueString()); map.put(attribute.getAttributeTypeID(), attribute.getValueString());
break; break;
@ -109,7 +111,12 @@ public class BlackboardArtifactNode extends AbstractNode implements DisplayableI
map.put(attribute.getAttributeTypeID(), attribute.getValueInt()); map.put(attribute.getAttributeTypeID(), attribute.getValueInt());
break; break;
case LONG: 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; break;
case DOUBLE: case DOUBLE:
map.put(attribute.getAttributeTypeID(), attribute.getValueDouble()); map.put(attribute.getAttributeTypeID(), attribute.getValueDouble());

View File

@ -50,7 +50,10 @@ import org.sleuthkit.autopsy.datamodel.KeywordHits.KeywordHitsRootNode;
import org.sleuthkit.autopsy.datamodel.RecentFilesFilterNode; import org.sleuthkit.autopsy.datamodel.RecentFilesFilterNode;
import org.sleuthkit.autopsy.datamodel.RecentFilesNode; import org.sleuthkit.autopsy.datamodel.RecentFilesNode;
import org.sleuthkit.autopsy.datamodel.SearchFiltersNode; 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.Content;
import org.sleuthkit.datamodel.TskException;
/** /**
@ -178,7 +181,10 @@ public class DataResultFilterNode extends FilterNode{
public List<Action> visit(BlackboardArtifactNode ba) { public List<Action> visit(BlackboardArtifactNode ba) {
List<Action> actions = new ArrayList<Action>(); List<Action> actions = new ArrayList<Action>();
//actions.add(new ViewAssociatedContentAction("View Associated Content", ba)); //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; return actions;
} }
@ -187,6 +193,28 @@ public class DataResultFilterNode extends FilterNode{
return new ArrayList<Action>(); return new ArrayList<Action>();
} }
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<AbstractAction>{ private class GetPreferredActionsDisplayableItemNodeVisitor extends DisplayableItemNodeVisitor.Default<AbstractAction>{

View File

@ -66,6 +66,11 @@ class ViewContextAction extends AbstractAction {
super(title); super(title);
this.content = node.getLookup().lookup(Content.class); this.content = node.getLookup().lookup(Content.class);
} }
public ViewContextAction(String title, Content content) {
super(title);
this.content = content;
}
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {