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