Autopsy  4.6.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-2016 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.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  @Override
64  protected Sheet createSheet() {
65  Sheet propertySheet = super.createSheet();
66  Sheet.Set properties = propertySheet.get(Sheet.PROPERTIES);
67  if (properties == null) {
68  properties = Sheet.createPropertiesSet();
69  propertySheet.put(properties);
70  }
71 
72  properties.put(new NodeProperty<>(
73  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.srcFile.text"),
74  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.srcFile.text"),
75  "",
76  tag.getContent().getName()));
77  String contentPath;
78  try {
79  contentPath = tag.getContent().getUniquePath();
80  } catch (TskCoreException ex) {
81  Logger.getLogger(ContentTagNode.class.getName()).log(Level.SEVERE, "Failed to get path for content (id = " + tag.getContent().getId() + ")", ex); //NON-NLS
82  contentPath = NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.unavail.text");
83  }
84  properties.put(new NodeProperty<>(
85  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.srcFilePath.text"),
86  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.srcFilePath.text"),
87  "",
88  contentPath));
89  properties.put(new NodeProperty<>(
90  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.resultType.text"),
91  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.resultType.text"),
92  "",
93  tag.getArtifact().getDisplayName()));
94  properties.put(new NodeProperty<>(
95  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.comment.text"),
96  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.comment.text"),
97  "",
98  tag.getComment()));
99 
100  return propertySheet;
101  }
102 
103  @NbBundle.Messages("BlackboardArtifactTagNode.viewSourceArtifact.text=View Source Result")
104  @Override
105  public Action[] getActions(boolean context) {
106  List<Action> actions = new ArrayList<>();
107  actions.addAll(Arrays.asList(super.getActions(context)));
108  BlackboardArtifact artifact = getLookup().lookup(BlackboardArtifact.class);
109  //if this artifact has a time stamp add the action to view it in the timeline
110  try {
112  actions.add(new ViewArtifactInTimelineAction(artifact));
113  }
114  } catch (TskCoreException ex) {
115  LOGGER.log(Level.SEVERE, MessageFormat.format("Error getting arttribute(s) from blackboard artifact{0}.", artifact.getArtifactID()), ex); //NON-NLS
116  MessageNotifyUtil.Notify.error(Bundle.BlackboardArtifactNode_getAction_errorTitle(), Bundle.BlackboardArtifactNode_getAction_resultErrorMessage());
117  }
118 
119  // if the artifact links to another file, add an action to go to that file
120  try {
121  AbstractFile c = findLinked(artifact);
122  if (c != null) {
124  }
125  } catch (TskCoreException ex) {
126  LOGGER.log(Level.SEVERE, MessageFormat.format("Error getting linked file from blackboard artifact{0}.", artifact.getArtifactID()), ex); //NON-NLS
127  MessageNotifyUtil.Notify.error(Bundle.BlackboardArtifactNode_getAction_errorTitle(), Bundle.BlackboardArtifactNode_getAction_linkedFileMessage());
128  }
129  //if this artifact has associated content, add the action to view the content in the timeline
130  AbstractFile file = getLookup().lookup(AbstractFile.class);
131  if (null != file) {
133  }
134  actions.add(new ViewTaggedArtifactAction(BlackboardArtifactTagNode_viewSourceArtifact_text(), artifact));
135  actions.addAll(DataModelActionsFactory.getActions(tag.getContent(), true));
137  return actions.toArray(new Action[0]);
138  }
139 
140  @Override
141  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
142  return visitor.visit(this);
143  }
144 
145  @Override
146  public boolean isLeafTypeNode() {
147  return true;
148  }
149 
150  @Override
151  public String getItemType() {
152  return getClass().getName();
153  }
154 }
static List< Action > getActions(File file, boolean isArtifactSource)
static synchronized DeleteBlackboardArtifactTagAction getInstance()
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-2016 Basis Technology. Generated on: Mon May 7 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.