Autopsy  4.10.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
BlackboardArtifactTagNode.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013-2018 Basis Technology Corp.
5  * Contact: carrier <at> sleuthkit <dot> org
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19 package org.sleuthkit.autopsy.datamodel;
20 
21 import java.text.MessageFormat;
22 import java.util.ArrayList;
23 import java.util.Arrays;
24 import java.util.List;
25 import java.util.logging.Level;
26 import javax.swing.Action;
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;
36 import org.sleuthkit.datamodel.AbstractFile;
37 import org.sleuthkit.datamodel.BlackboardArtifact;
38 import org.sleuthkit.datamodel.BlackboardArtifactTag;
39 import org.sleuthkit.datamodel.TskCoreException;
40 import static org.sleuthkit.autopsy.datamodel.Bundle.*;
41 
50 
51  private static final Logger LOGGER = Logger.getLogger(BlackboardArtifactTagNode.class.getName());
52  private static final String ICON_PATH = "org/sleuthkit/autopsy/images/green-tag-icon-16.png"; //NON-NLS
53  private final BlackboardArtifactTag tag;
54 
55  public BlackboardArtifactTagNode(BlackboardArtifactTag tag) {
56  super(Children.LEAF, Lookups.fixed(tag, tag.getArtifact(), tag.getContent()));
57  super.setName(tag.getContent().getName());
58  super.setDisplayName(tag.getContent().getName());
59  this.setIconBaseWithExtension(ICON_PATH);
60  this.tag = tag;
61  }
62 
63  @Messages({"BlackboardArtifactTagNode.createSheet.userName.text=User Name"})
64  @Override
65  protected Sheet createSheet() {
66  Sheet propertySheet = super.createSheet();
67  Sheet.Set properties = propertySheet.get(Sheet.PROPERTIES);
68  if (properties == null) {
69  properties = Sheet.createPropertiesSet();
70  propertySheet.put(properties);
71  }
72 
73  properties.put(new NodeProperty<>(
74  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.srcFile.text"),
75  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.srcFile.text"),
76  "",
77  tag.getContent().getName()));
78  String contentPath;
79  try {
80  contentPath = tag.getContent().getUniquePath();
81  } catch (TskCoreException ex) {
82  Logger.getLogger(ContentTagNode.class.getName()).log(Level.SEVERE, "Failed to get path for content (id = " + tag.getContent().getId() + ")", ex); //NON-NLS
83  contentPath = NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.unavail.text");
84  }
85 
86  properties.put(new NodeProperty<>(
87  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.srcFilePath.text"),
88  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.srcFilePath.text"),
89  "",
90  contentPath));
91  properties.put(new NodeProperty<>(
92  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.resultType.text"),
93  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.resultType.text"),
94  "",
95  tag.getArtifact().getDisplayName()));
96  properties.put(new NodeProperty<>(
97  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.comment.text"),
98  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.comment.text"),
99  "",
100  tag.getComment()));
101  properties.put(new NodeProperty<>(
102  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.userName.text"),
103  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.userName.text"),
104  "",
105  tag.getUserName()));
106  return propertySheet;
107  }
108 
109  @NbBundle.Messages("BlackboardArtifactTagNode.viewSourceArtifact.text=View Source Result")
110  @Override
111  public Action[] getActions(boolean context) {
112  List<Action> actions = new ArrayList<>();
113  actions.addAll(Arrays.asList(super.getActions(context)));
114  BlackboardArtifact artifact = getLookup().lookup(BlackboardArtifact.class);
115  //if this artifact has a time stamp add the action to view it in the timeline
116  try {
118  actions.add(new ViewArtifactInTimelineAction(artifact));
119  }
120  } catch (TskCoreException ex) {
121  LOGGER.log(Level.SEVERE, MessageFormat.format("Error getting arttribute(s) from blackboard artifact{0}.", artifact.getArtifactID()), ex); //NON-NLS
122  MessageNotifyUtil.Notify.error(Bundle.BlackboardArtifactNode_getAction_errorTitle(), Bundle.BlackboardArtifactNode_getAction_resultErrorMessage());
123  }
124 
125  // if the artifact links to another file, add an action to go to that file
126  try {
127  AbstractFile c = findLinked(artifact);
128  if (c != null) {
130  }
131  } catch (TskCoreException ex) {
132  LOGGER.log(Level.SEVERE, MessageFormat.format("Error getting linked file from blackboard artifact{0}.", artifact.getArtifactID()), ex); //NON-NLS
133  MessageNotifyUtil.Notify.error(Bundle.BlackboardArtifactNode_getAction_errorTitle(), Bundle.BlackboardArtifactNode_getAction_linkedFileMessage());
134  }
135  //if this artifact has associated content, add the action to view the content in the timeline
136  AbstractFile file = getLookup().lookup(AbstractFile.class);
137  if (null != file) {
139  }
140  actions.add(new ViewTaggedArtifactAction(BlackboardArtifactTagNode_viewSourceArtifact_text(), artifact));
141  actions.addAll(DataModelActionsFactory.getActions(tag, true));
142 
143  return actions.toArray(new Action[0]);
144  }
145 
146  @Override
147  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
148  return visitor.visit(this);
149  }
150 
151  @Override
152  public boolean isLeafTypeNode() {
153  return true;
154  }
155 
156  @Override
157  public String getItemType() {
158  return getClass().getName();
159  }
160 }
static List< Action > getActions(File file, boolean isArtifactSource)
static ViewFileInTimelineAction createViewSourceFileAction(AbstractFile file)
static void error(String title, String message)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static ViewFileInTimelineAction createViewFileAction(AbstractFile file)

Copyright © 2012-2018 Basis Technology. Generated on: Fri Mar 22 2019
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.