Autopsy  4.19.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-2020 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.Sheet;
28 import org.openide.util.NbBundle;
29 import org.openide.util.NbBundle.Messages;
30 import org.openide.util.lookup.Lookups;
34 import org.sleuthkit.datamodel.AbstractFile;
35 import org.sleuthkit.datamodel.BlackboardArtifact;
36 import org.sleuthkit.datamodel.BlackboardArtifactTag;
37 import org.sleuthkit.datamodel.TskCoreException;
38 import static org.sleuthkit.autopsy.datamodel.Bundle.*;
39 
47 public class BlackboardArtifactTagNode extends TagNode {
48 
49  private static final Logger LOGGER = Logger.getLogger(BlackboardArtifactTagNode.class.getName());
50  private static final String ICON_PATH = "org/sleuthkit/autopsy/images/green-tag-icon-16.png"; //NON-NLS
51  private final BlackboardArtifactTag tag;
52 
53  public BlackboardArtifactTagNode(BlackboardArtifactTag tag) {
54  super(Lookups.fixed(tag, tag.getArtifact(), tag.getContent()), tag.getContent());
55  super.setName(tag.getContent().getName());
56  super.setDisplayName(tag.getContent().getName());
57  this.setIconBaseWithExtension(ICON_PATH);
58  this.tag = tag;
59  }
60 
61  @Messages({"BlackboardArtifactTagNode.createSheet.userName.text=User Name"})
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  addOriginalNameProp(properties);
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  properties.put(new NodeProperty<>(
100  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.userName.text"),
101  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.userName.text"),
102  "",
103  tag.getUserName()));
104  return propertySheet;
105  }
106 
107  @NbBundle.Messages("BlackboardArtifactTagNode.viewSourceArtifact.text=View Source Result")
108  @Override
109  public Action[] getActions(boolean context) {
110  List<Action> actions = new ArrayList<>();
111  actions.addAll(Arrays.asList(super.getActions(context)));
112  BlackboardArtifact artifact = getLookup().lookup(BlackboardArtifact.class);
113  //if this artifact has a time stamp add the action to view it in the timeline
114  try {
116  actions.add(new ViewArtifactInTimelineAction(artifact));
117  }
118  } catch (TskCoreException ex) {
119  LOGGER.log(Level.SEVERE, MessageFormat.format("Error getting arttribute(s) from blackboard artifact{0}.", artifact.getArtifactID()), ex); //NON-NLS
120  }
121 
122  // if the artifact links to another file, add an action to go to that file
123  try {
124  AbstractFile c = findLinked(artifact);
125  if (c != null) {
127  }
128  } catch (TskCoreException ex) {
129  LOGGER.log(Level.SEVERE, MessageFormat.format("Error getting linked file from blackboard artifact{0}.", artifact.getArtifactID()), ex); //NON-NLS
130  }
131  //if this artifact has associated content, add the action to view the content in the timeline
132  AbstractFile file = getLookup().lookup(AbstractFile.class);
133  if (null != file) {
135  }
136  actions.add(new ViewTaggedArtifactAction(BlackboardArtifactTagNode_viewSourceArtifact_text(), artifact));
137  actions.addAll(DataModelActionsFactory.getActions(tag, true));
138 
139  return actions.toArray(new Action[0]);
140  }
141 
142  @Override
143  public <T> T accept(DisplayableItemNodeVisitor<T> visitor) {
144  return visitor.visit(this);
145  }
146 
147  @Override
148  public String getItemType() {
149  return getClass().getName();
150  }
151 }
static List< Action > getActions(File file, boolean isArtifactSource)
static ViewFileInTimelineAction createViewSourceFileAction(AbstractFile file)
synchronized static Logger getLogger(String name)
Definition: Logger.java:124
static ViewFileInTimelineAction createViewFileAction(AbstractFile file)

Copyright © 2012-2021 Basis Technology. Generated on: Fri Aug 6 2021
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.