19 package org.sleuthkit.autopsy.modules.hashdatabase;
 
   21 import java.awt.event.ActionEvent;
 
   22 import java.awt.event.ActionListener;
 
   23 import java.util.Collection;
 
   24 import java.util.List;
 
   25 import java.util.logging.Level;
 
   26 import javax.swing.AbstractAction;
 
   27 import javax.swing.JMenu;
 
   28 import javax.swing.JMenuItem;
 
   29 import javax.swing.JOptionPane;
 
   30 import org.openide.util.NbBundle;
 
   31 import org.openide.util.Utilities;
 
   32 import org.openide.util.actions.Presenter;
 
   44 final class AddContentToHashDbAction 
extends AbstractAction implements Presenter.Popup {
 
   46     private static AddContentToHashDbAction instance;
 
   47     private final static String SINGLE_SELECTION_NAME = NbBundle.getMessage(AddContentToHashDbAction.class,
 
   48             "AddContentToHashDbAction.singleSelectionName");
 
   49     private final static String MULTIPLE_SELECTION_NAME = NbBundle.getMessage(AddContentToHashDbAction.class,
 
   50             "AddContentToHashDbAction.multipleSelectionName");
 
   58     public static synchronized AddContentToHashDbAction getInstance() {
 
   59         if (null == instance) {
 
   60             instance = 
new AddContentToHashDbAction();
 
   65     private AddContentToHashDbAction() {
 
   69     public JMenuItem getPopupPresenter() {
 
   70         return new AddContentToHashDbMenu();
 
   74     public void actionPerformed(ActionEvent event) {
 
   82             super(SINGLE_SELECTION_NAME);
 
   91             final Collection<? extends AbstractFile> selectedFiles = Utilities.actionsGlobalContext().lookupAll(
AbstractFile.class);
 
   92             if (selectedFiles.isEmpty()) {
 
   95             } 
else if (selectedFiles.size() > 1) {
 
   96                 setText(MULTIPLE_SELECTION_NAME);
 
  101                 if (null == file.getMd5Hash()) {
 
  111             if (!hashDatabases.isEmpty()) {
 
  112                 for (
final HashDb database : hashDatabases) {
 
  113                     JMenuItem databaseItem = add(database.getHashSetName());
 
  114                     databaseItem.addActionListener(
new ActionListener() {
 
  116                         public void actionPerformed(ActionEvent e) {
 
  122                 JMenuItem empty = 
new JMenuItem(
 
  123                         NbBundle.getMessage(
this.getClass(),
 
  124                         "AddContentToHashDbAction.ContentMenu.noHashDbsConfigd"));
 
  125                 empty.setEnabled(
false);
 
  133             JMenuItem newHashSetItem = 
new JMenuItem(NbBundle.getMessage(
this.getClass(),
 
  134                     "AddContentToHashDbAction.ContentMenu.createDbItem"));
 
  135             newHashSetItem.addActionListener(
new ActionListener() {
 
  137                 public void actionPerformed(ActionEvent e) {
 
  138                     HashDb hashDb = 
new HashDbCreateDatabaseDialog().getHashDatabase();
 
  139                     if (null != hashDb) {
 
  150                 String md5Hash = file.getMd5Hash();
 
  151                 if (null != md5Hash) {
 
  154                         Logger.
getLogger(AddContentToHashDbAction.class.getName()).log(Level.INFO, 
"Not adding " + file.getName() + 
" to database (empty content)"); 
 
  155                         JOptionPane.showMessageDialog(null,
 
  156                                 NbBundle.getMessage(
this.getClass(),
 
  157                                 "AddContentToHashDbAction.addFilesToHashSet.unableToAddFileEmptyMsg",
 
  159                                 NbBundle.getMessage(
this.getClass(),
 
  160                                                     "AddContentToHashDbAction.addFilesToHashSet.addToHashDbErr1.text"),
 
  161                                 JOptionPane.ERROR_MESSAGE);
 
  167                         Logger.
getLogger(AddContentToHashDbAction.class.getName()).log(Level.SEVERE, 
"Error adding to hash database", ex); 
 
  168                         JOptionPane.showMessageDialog(null,
 
  169                                 NbBundle.getMessage(
this.getClass(),
 
  170                                 "AddContentToHashDbAction.addFilesToHashSet.unableToAddFileMsg",
 
  172                                 NbBundle.getMessage(
this.getClass(),
 
  173                                                     "AddContentToHashDbAction.addFilesToHashSet.addToHashDbErr2.text"),
 
  174                                 JOptionPane.ERROR_MESSAGE);
 
  177                     JOptionPane.showMessageDialog(null,
 
  178                             NbBundle.getMessage(
this.getClass(),
 
  179                             "AddContentToHashDbAction.addFilesToHashSet.unableToAddFileSzMsg",
 
  180                             files.size() > 1 ? NbBundle
 
  181                             .getMessage(this.getClass(),
 
  182                             "AddContentToHashDbAction.addFilesToHashSet.files") : NbBundle
 
  183                             .getMessage(this.getClass(),
 
  184                             "AddContentToHashDbAction.addFilesToHashSet.file")),
 
  185                             NbBundle.getMessage(
this.getClass(),
 
  186                                                 "AddContentToHashDbAction.addFilesToHashSet.addToHashDbErr3.text"),
 
  187                             JOptionPane.ERROR_MESSAGE);
 
static boolean isNoDataMd5(String md5)
 
static synchronized IngestManager getInstance()
 
boolean isIngestRunning()
 
static synchronized HashDbManager getInstance()
 
void addHashes(Content content)
 
synchronized List< HashDb > getUpdateableHashSets()
 
static Logger getLogger(String name)