19 package org.sleuthkit.autopsy.datamodel;
21 import java.util.ArrayList;
22 import java.util.Arrays;
23 import java.util.List;
24 import java.util.logging.Level;
25 import javax.swing.Action;
26 import org.apache.commons.lang3.StringUtils;
27 import org.openide.nodes.Children;
28 import org.openide.nodes.Sheet;
29 import org.openide.util.NbBundle;
30 import org.openide.util.NbBundle.Messages;
31 import org.openide.util.lookup.Lookups;
45 class ContentTagNode
extends DisplayableItemNode {
47 private static final Logger LOGGER = Logger.getLogger(ContentTagNode.class.getName());
49 private static final String ICON_PATH =
"org/sleuthkit/autopsy/images/blue-tag-icon-16.png";
50 private final ContentTag tag;
52 public ContentTagNode(ContentTag tag) {
53 super(Children.LEAF, Lookups.fixed(tag, tag.getContent()));
54 super.setName(tag.getContent().getName());
55 super.setDisplayName(tag.getContent().getName());
56 this.setIconBaseWithExtension(ICON_PATH);
61 "ContentTagNode.createSheet.artifactMD5.displayName=MD5 Hash",
62 "ContentTagNode.createSheet.artifactMD5.name=MD5 Hash",
63 "ContentTagNode.createSheet.userName.text=User Name"})
65 protected Sheet createSheet() {
66 Content content = tag.getContent();
69 contentPath = content.getUniquePath();
70 }
catch (TskCoreException ex) {
71 LOGGER.log(Level.SEVERE,
"Failed to get path for content (id = " + content.getId() +
")", ex);
72 contentPath = NbBundle.getMessage(this.getClass(),
"ContentTagNode.createSheet.unavail.path");
74 AbstractFile file = content instanceof AbstractFile ? (AbstractFile) content : null;
76 Sheet propertySheet = super.createSheet();
77 Sheet.Set properties = propertySheet.get(Sheet.PROPERTIES);
78 if (properties == null) {
79 properties = Sheet.createPropertiesSet();
80 propertySheet.put(properties);
82 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.file.name"),
83 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.file.displayName"),
86 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.filePath.name"),
87 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.filePath.displayName"),
90 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.comment.name"),
91 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.comment.displayName"),
94 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileModifiedTime.name"),
95 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileModifiedTime.displayName"),
97 file != null ? ContentUtils.getStringTime(file.getMtime(), file) :
""));
98 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileChangedTime.name"),
99 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileChangedTime.displayName"),
101 file != null ? ContentUtils.getStringTime(file.getCtime(), file) :
""));
102 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileAccessedTime.name"),
103 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileAccessedTime.displayName"),
105 file != null ? ContentUtils.getStringTime(file.getAtime(), file) :
""));
106 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileCreatedTime.name"),
107 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileCreatedTime.displayName"),
109 file != null ? ContentUtils.getStringTime(file.getCrtime(), file) :
""));
110 properties.put(
new NodeProperty<>(NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileSize.name"),
111 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.fileSize.displayName"),
114 properties.put(
new NodeProperty<>(Bundle.ContentTagNode_createSheet_artifactMD5_name(),
115 Bundle.ContentTagNode_createSheet_artifactMD5_displayName(),
117 file != null ? StringUtils.defaultString(file.getMd5Hash()) :
""));
118 properties.put(
new NodeProperty<>(
119 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.userName.text"),
120 NbBundle.getMessage(
this.getClass(),
"ContentTagNode.createSheet.userName.text"),
123 return propertySheet;
127 public Action[] getActions(
boolean context) {
128 List<Action> actions =
new ArrayList<>();
129 actions.addAll(Arrays.asList(super.getActions(context)));
131 AbstractFile file = getLookup().lookup(AbstractFile.class
134 actions.add(ViewFileInTimelineAction.createViewFileAction(file));
137 actions.addAll(DataModelActionsFactory.getActions(tag,
false));
139 return actions.toArray(
new Action[actions.size()]);
143 public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
144 return visitor.visit(
this);
148 public boolean isLeafTypeNode() {
153 public String getItemType() {
154 return getClass().getName();