New tags API extended to properly handle blackboard artifact and content nodes

This commit is contained in:
Richard Cordovano 2013-10-15 16:10:11 -04:00
parent cf4c996f53
commit d74fa2e894
3 changed files with 26 additions and 15 deletions

View File

@ -201,7 +201,7 @@ public class TagsManager implements Closeable {
* @throws TskCoreException * @throws TskCoreException
*/ */
public void addBlackboardArtifactTag(BlackboardArtifact artifact, TagName tagName, String comment) throws TskCoreException { public void addBlackboardArtifactTag(BlackboardArtifact artifact, TagName tagName, String comment) throws TskCoreException {
tskCase.addBlackboardArtifactTag(new BlackboardArtifactTag(artifact, tagName, comment)); tskCase.addBlackboardArtifactTag(new BlackboardArtifactTag(artifact, tskCase.getContentById(artifact.getObjectID()), tagName, comment));
} }
void deleteBlackboardArtifactTag(BlackboardArtifactTag tag) throws TskCoreException { void deleteBlackboardArtifactTag(BlackboardArtifactTag tag) throws TskCoreException {

View File

@ -18,10 +18,13 @@
*/ */
package org.sleuthkit.autopsy.datamodel; package org.sleuthkit.autopsy.datamodel;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.nodes.Children; import org.openide.nodes.Children;
import org.openide.nodes.Sheet; import org.openide.nodes.Sheet;
import org.openide.util.lookup.Lookups; import org.openide.util.lookup.Lookups;
import org.sleuthkit.datamodel.BlackboardArtifactTag; import org.sleuthkit.datamodel.BlackboardArtifactTag;
import org.sleuthkit.datamodel.TskCoreException;
/** /**
* Instances of this class wrap BlackboardArtifactTag objects. In the Autopsy * Instances of this class wrap BlackboardArtifactTag objects. In the Autopsy
@ -31,18 +34,19 @@ import org.sleuthkit.datamodel.BlackboardArtifactTag;
* either content or blackboard artifact tag nodes. * either content or blackboard artifact tag nodes.
*/ */
public class BlackboardArtifactTagNode extends DisplayableItemNode { public class BlackboardArtifactTagNode extends DisplayableItemNode {
private static final String ICON_PATH = "org/sleuthkit/autopsy/images/tag-folder-blue-icon-16.png"; // RJCTODO: Want better icons? private static final String ICON_PATH = "org/sleuthkit/autopsy/images/tag-folder-blue-icon-16.png";
private final BlackboardArtifactTag tag;
public BlackboardArtifactTagNode(BlackboardArtifactTag tag) { public BlackboardArtifactTagNode(BlackboardArtifactTag tag) {
super(Children.LEAF, Lookups.fixed(tag, tag.getArtifact())); super(Children.LEAF, Lookups.fixed(tag, tag.getArtifact(), tag.getContent()));
super.setName(tag.getArtifact().getDisplayName()); super.setName(tag.getContent().getName());
super.setDisplayName(tag.getArtifact().getDisplayName()); super.setDisplayName(tag.getContent().getName());
this.setIconBaseWithExtension(ICON_PATH); this.setIconBaseWithExtension(ICON_PATH);
this.tag = tag;
} }
@Override @Override
protected Sheet createSheet() { protected Sheet createSheet() {
// RJCTODO: Make additional properties as needed for DataResultViewers
Sheet propertySheet = super.createSheet(); Sheet propertySheet = super.createSheet();
Sheet.Set properties = propertySheet.get(Sheet.PROPERTIES); Sheet.Set properties = propertySheet.get(Sheet.PROPERTIES);
if (properties == null) { if (properties == null) {
@ -50,15 +54,23 @@ public class BlackboardArtifactTagNode extends DisplayableItemNode {
propertySheet.put(properties); propertySheet.put(properties);
} }
properties.put(new NodeProperty("Name", "Name", "", getName())); properties.put(new NodeProperty("Source File", "Source File", "", tag.getContent().getName()));
String contentPath;
try {
contentPath = tag.getContent().getUniquePath();
}
catch (TskCoreException ex) {
Logger.getLogger(ContentTagNode.class.getName()).log(Level.SEVERE, "Failed to get path for content (id = " + tag.getContent().getId() + ")", ex);
contentPath = "Unavailable";
}
properties.put(new NodeProperty("Source File Path", "Source File Path", "", contentPath));
properties.put(new NodeProperty("Result Type", "Result Type", "", tag.getArtifact().getDisplayName()));
return propertySheet; return propertySheet;
} }
@Override @Override
public <T> T accept(DisplayableItemNodeVisitor<T> v) { public <T> T accept(DisplayableItemNodeVisitor<T> v) {
// See classes derived from DisplayableItemNodeVisitor<AbstractNode>
// for behavior added using the Visitor pattern.
return v.visit(this); return v.visit(this);
} }

View File

@ -19,6 +19,8 @@
package org.sleuthkit.autopsy.datamodel; package org.sleuthkit.autopsy.datamodel;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.openide.nodes.Children; import org.openide.nodes.Children;
import org.openide.nodes.Sheet; import org.openide.nodes.Sheet;
import org.openide.util.lookup.Lookups; import org.openide.util.lookup.Lookups;
@ -45,7 +47,6 @@ public class ContentTagNode extends DisplayableItemNode {
@Override @Override
protected Sheet createSheet() { protected Sheet createSheet() {
// RJCTODO: Make additional properties as needed for DataResultViewers
Sheet propertySheet = super.createSheet(); Sheet propertySheet = super.createSheet();
Sheet.Set properties = propertySheet.get(Sheet.PROPERTIES); Sheet.Set properties = propertySheet.get(Sheet.PROPERTIES);
if (properties == null) { if (properties == null) {
@ -53,13 +54,13 @@ public class ContentTagNode extends DisplayableItemNode {
propertySheet.put(properties); propertySheet.put(properties);
} }
properties.put(new NodeProperty("Source File", "Source File", "", getName())); properties.put(new NodeProperty("Source File", "Source File", "", tag.getContent().getName()));
String contentPath; String contentPath;
try { try {
contentPath = tag.getContent().getUniquePath(); contentPath = tag.getContent().getUniquePath();
} }
catch (TskCoreException ex) { catch (TskCoreException ex) {
// RJCTODO: Add to log Logger.getLogger(ContentTagNode.class.getName()).log(Level.SEVERE, "Failed to get path for content (id = " + tag.getContent().getId() + ")", ex);
contentPath = "Unavailable"; contentPath = "Unavailable";
} }
properties.put(new NodeProperty("Source File Path", "Source File Path", "", contentPath)); properties.put(new NodeProperty("Source File Path", "Source File Path", "", contentPath));
@ -69,8 +70,6 @@ public class ContentTagNode extends DisplayableItemNode {
@Override @Override
public <T> T accept(DisplayableItemNodeVisitor<T> v) { public <T> T accept(DisplayableItemNodeVisitor<T> v) {
// See classes derived from DisplayableItemNodeVisitor<AbstractNode>
// for behavior added using the Visitor pattern.
return v.visit(this); return v.visit(this);
} }