Autopsy  4.9.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
OpenLogFolderAction.java
Go to the documentation of this file.
1 /*
2  * Autopsy Forensic Browser
3  *
4  * Copyright 2011-2017 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.awt.Desktop;
22 import java.awt.event.ActionEvent;
23 import java.awt.event.ActionListener;
24 import java.io.File;
25 import java.io.IOException;
26 import java.util.logging.Level;
27 import org.openide.DialogDisplayer;
28 import org.openide.NotifyDescriptor;
29 import org.openide.awt.ActionID;
30 import org.openide.awt.ActionReference;
31 import org.openide.awt.ActionRegistration;
32 import org.openide.modules.Places;
33 import org.openide.util.NbBundle;
37 
46 @ActionRegistration(displayName = "#CTL_OpenLogFolder", iconInMenu = true)
47 @ActionReference(path = "Menu/Help", position = 1750)
48 @ActionID(id = "org.sleuthkit.autopsy.actions.OpenLogFolderAction", category = "Help")
49 public final class OpenLogFolderAction implements ActionListener {
50 
51  private static final Logger logger = Logger.getLogger(OpenLogFolderAction.class.getName());
52 
53  @Override
54  public void actionPerformed(ActionEvent e) {
55  File logDir;
56  if (Case.isCaseOpen()) {
57  try {
58  /*
59  * Open the log directory for the case.
60  */
61  Case currentCase = Case.getCurrentCaseThrows();
62  logDir = new File(currentCase.getLogDirectoryPath());
63  } catch (NoCurrentCaseException ex) {
64  /*
65  * There is no open case, open the application level log
66  * directory.
67  */
68  logDir = new File(Places.getUserDirectory().getAbsolutePath() + File.separator + "var" + File.separator + "log");
69  }
70  } else {
71  logDir = new File(Places.getUserDirectory().getAbsolutePath() + File.separator + "var" + File.separator + "log");
72  }
73 
74  try {
75  if (logDir.exists()) {
76  Desktop.getDesktop().open(logDir);
77  } else {
78  logger.log(Level.SEVERE, String.format("The log directory %s does not exist", logDir));
79  NotifyDescriptor notifyDescriptor = new NotifyDescriptor.Message(
80  NbBundle.getMessage(this.getClass(), "OpenLogFolder.error1", logDir.getAbsolutePath()),
81  NotifyDescriptor.ERROR_MESSAGE);
82  DialogDisplayer.getDefault().notify(notifyDescriptor);
83  }
84  } catch (IOException ex) {
85  logger.log(Level.SEVERE, String.format("Could not open log directory %s", logDir), ex);
86  NotifyDescriptor notifyDescriptor = new NotifyDescriptor.Message(
87  NbBundle.getMessage(this.getClass(), "OpenLogFolder.CouldNotOpenLogFolder", logDir.getAbsolutePath()),
88  NotifyDescriptor.ERROR_MESSAGE);
89  DialogDisplayer.getDefault().notify(notifyDescriptor);
90  }
91  }
92 
93 }
void open(boolean isNewCase)
Definition: Case.java:1791
synchronized static Logger getLogger(String name)
Definition: Logger.java:124

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