Autopsy  4.5.0
Graphical digital forensics platform for The Sleuth Kit and other tools.
AddFileExtensionAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-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.modules.fileextmismatch;
20 
21 import java.awt.event.ActionEvent;
22 import java.util.HashMap;
23 import java.util.Set;
24 import java.util.logging.Level;
25 import javax.swing.AbstractAction;
26 import javax.swing.JOptionPane;
27 import org.openide.util.NbBundle;
28 import org.openide.util.NbBundle.Messages;
30 
35 class AddFileExtensionAction extends AbstractAction {
36 
37  private static final long serialVersionUID = 1L;
38  private static final Logger logger = Logger.getLogger(AddFileExtensionAction.class.getName());
39  private final String extStr;
40  private final String mimeTypeStr;
41  private final FileExtMismatchSettings settings;
42 
43  AddFileExtensionAction(String menuItemStr, String extStr, String mimeTypeStr, FileExtMismatchSettings settings) {
44  super(menuItemStr);
45  this.mimeTypeStr = mimeTypeStr;
46  this.extStr = extStr;
47  this.settings = settings;
48  }
49 
50  @Override
51  @Messages({"AddFileExtensionAction.writeError.message=Could not write file extension settings."})
52  public void actionPerformed(ActionEvent event) {
53  HashMap<String, Set<String>> editableMap;
54  editableMap = settings.getMimeTypeToExtsMap();
55  Set<String> editedExtensions = editableMap.get(mimeTypeStr);
56  editedExtensions.add(extStr);
57 
58  try {
59  FileExtMismatchSettings.writeSettings(new FileExtMismatchSettings(editableMap));
60  } catch (FileExtMismatchSettings.FileExtMismatchSettingsException ex) {
61  //error
62  JOptionPane.showMessageDialog(null,
63  Bundle.AddFileExtensionAction_writeError_message(),
64  NbBundle.getMessage(this.getClass(), "AddFileExtensionAction.msgDlg.title"),
65  JOptionPane.ERROR_MESSAGE);
66  logger.log(Level.SEVERE, "Could not write file extension settings.", ex);
67  }
68  }
69 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

Copyright © 2012-2016 Basis Technology. Generated on: Tue Feb 20 2018
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.