Autopsy  4.1
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.Arrays;
23 import java.util.List;
24 import java.util.logging.Level;
25 import javax.swing.Action;
26 import org.openide.nodes.Children;
27 import org.openide.nodes.Sheet;
28 import org.openide.util.NbBundle;
29 import org.openide.util.lookup.Lookups;
39 
48  private static final Logger LOGGER = Logger.getLogger(BlackboardArtifactTagNode.class.getName());
49  private static final String ICON_PATH = "org/sleuthkit/autopsy/images/green-tag-icon-16.png"; //NON-NLS
50  private final BlackboardArtifactTag tag;
51 
53  super(Children.LEAF, Lookups.fixed(tag, tag.getArtifact(), tag.getContent()));
54  super.setName(tag.getContent().getName());
55  super.setDisplayName(tag.getContent().getName());
56  this.setIconBaseWithExtension(ICON_PATH);
57  this.tag = tag;
58  }
59 
60  @Override
61  protected Sheet createSheet() {
62  Sheet propertySheet = super.createSheet();
63  Sheet.Set properties = propertySheet.get(Sheet.PROPERTIES);
64  if (properties == null) {
65  properties = Sheet.createPropertiesSet();
66  propertySheet.put(properties);
67  }
68 
69  properties.put(new NodeProperty<>(
70  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.srcFile.text"),
71  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.srcFile.text"),
72  "",
73  tag.getContent().getName()));
74  String contentPath;
75  try {
76  contentPath = tag.getContent().getUniquePath();
77  } catch (TskCoreException ex) {
78  Logger.getLogger(ContentTagNode.class.getName()).log(Level.SEVERE, "Failed to get path for content (id = " + tag.getContent().getId() + ")", ex); //NON-NLS
79  contentPath = NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.unavail.text");
80  }
81  properties.put(new NodeProperty<>(
82  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.srcFilePath.text"),
83  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.srcFilePath.text"),
84  "",
85  contentPath));
86  properties.put(new NodeProperty<>(
87  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.resultType.text"),
88  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.resultType.text"),
89  "",
90  tag.getArtifact().getDisplayName()));
91  properties.put(new NodeProperty<>(
92  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.comment.text"),
93  NbBundle.getMessage(this.getClass(), "BlackboardArtifactTagNode.createSheet.comment.text"),
94  "",
95  tag.getComment()));
96 
97  return propertySheet;
98  }
99 
100  @Override
101  public Action[] getActions(boolean context) {
102  List<Action> actions = DataModelActionsFactory.getActions(tag.getContent(), true);
103  actions.addAll(Arrays.asList(super.getActions(context)));
104 
105  BlackboardArtifact artifact = getLookup().lookup(BlackboardArtifact.class);
106  //if this artifact has a time stamp add the action to view it in the timeline
107  try {
109  actions.add(new ViewArtifactInTimelineAction(artifact));
110  }
111  } catch (TskCoreException ex) {
112  LOGGER.log(Level.SEVERE, MessageFormat.format("Error getting arttribute(s) from blackboard artifact{0}.", artifact.getArtifactID()), ex); //NON-NLS
113  MessageNotifyUtil.Notify.error(Bundle.BlackboardArtifactNode_getAction_errorTitle(), Bundle.BlackboardArtifactNode_getAction_resultErrorMessage());
114  }
115 
116  // if the artifact links to another file, add an action to go to that file
117  try {
118  AbstractFile c = findLinked(artifact);
119  if (c != null) {
121  }
122  } catch (TskCoreException ex) {
123  LOGGER.log(Level.SEVERE, MessageFormat.format("Error getting linked file from blackboard artifact{0}.", artifact.getArtifactID()), ex); //NON-NLS
124  MessageNotifyUtil.Notify.error(Bundle.BlackboardArtifactNode_getAction_errorTitle(), Bundle.BlackboardArtifactNode_getAction_linkedFileMessage());
125  }
126 
127  //if this artifact has associated content, add the action to view the content in the timeline
128  AbstractFile file = getLookup().lookup(AbstractFile.class);
129  if (null != file) {
130 
132  }
133 
135  return actions.toArray(new Action[0]);
136  }
137 
138  @Override
139  public <T> T accept(DisplayableItemNodeVisitor<T> v) {
140  return v.visit(this);
141  }
142 
143  @Override
144  public boolean isLeafTypeNode() {
145  return true;
146  }
147 
148  @Override
149  public String getItemType() {
150  return getClass().getName();
151  }
152 }
static List< Action > getActions(File file, boolean isArtifactSource)
static synchronized DeleteBlackboardArtifactTagAction getInstance()
static ViewFileInTimelineAction createViewSourceFileAction(AbstractFile file)
synchronized static Logger getLogger(String name)
Definition: Logger.java:161
static ViewFileInTimelineAction createViewFileAction(AbstractFile file)

Copyright © 2012-2016 Basis Technology. Generated on: Mon Apr 24 2017
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.