Autopsy  4.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
AddBlackboardArtifactTagAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2013-2015 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.actions;
20 
21 import java.util.Collection;
22 import java.util.logging.Level;
23 import javax.swing.JOptionPane;
24 import javax.swing.SwingUtilities;
25 import org.openide.util.NbBundle;
26 import org.openide.util.Utilities;
29 import org.sleuthkit.datamodel.TagName;
30 import org.sleuthkit.datamodel.BlackboardArtifact;
31 import org.sleuthkit.datamodel.TskCoreException;
32 
36 public class AddBlackboardArtifactTagAction extends AddTagAction {
37 
38  // This class is a singleton to support multi-selection of nodes, since
39  // org.openide.nodes.NodeOp.findActions(Node[] nodes) will only pick up an Action if every
40  // node in the array returns a reference to the same action object from Node.getActions(boolean).
41 
43 
44  public static synchronized AddBlackboardArtifactTagAction getInstance() {
45  if (null == instance) {
46  instance = new AddBlackboardArtifactTagAction();
47  }
48  return instance;
49  }
50 
52  super("");
53  }
54 
55  @Override
56  protected String getActionDisplayName() {
57  String singularTagResult = NbBundle.getMessage(this.getClass(),
58  "AddBlackboardArtifactTagAction.singularTagResult");
59  String pluralTagResult = NbBundle.getMessage(this.getClass(),
60  "AddBlackboardArtifactTagAction.pluralTagResult");
61  return Utilities.actionsGlobalContext().lookupAll(BlackboardArtifact.class).size() > 1 ? pluralTagResult : singularTagResult;
62  }
63 
64  @Override
65  protected void addTag(TagName tagName, String comment) {
66  final Collection<? extends BlackboardArtifact> selectedArtifacts = Utilities.actionsGlobalContext().lookupAll(BlackboardArtifact.class);
67 
68  new Thread(() -> {
69  for (BlackboardArtifact artifact : selectedArtifacts) {
70  try {
71  Case.getCurrentCase().getServices().getTagsManager().addBlackboardArtifactTag(artifact, tagName, comment);
72  } catch (TskCoreException ex) {
73  Logger.getLogger(AddBlackboardArtifactTagAction.class.getName()).log(Level.SEVERE, "Error tagging result", ex); //NON-NLS
74  SwingUtilities.invokeLater(() -> {
75  JOptionPane.showMessageDialog(null,
76  NbBundle.getMessage(this.getClass(),
77  "AddBlackboardArtifactTagAction.unableToTag.msg",
78  artifact.getDisplayName()),
79  NbBundle.getMessage(this.getClass(),
80  "AddBlackboardArtifactTagAction.taggingErr"),
81  JOptionPane.ERROR_MESSAGE);
82  });
83  }
84  }
85  }).start();
86  }
87 }
static synchronized AddBlackboardArtifactTagAction getInstance()
BlackboardArtifactTag addBlackboardArtifactTag(BlackboardArtifact artifact, TagName tagName)
synchronized static Logger getLogger(String name)
Definition: Logger.java:166

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