Autopsy  4.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;
36 
45 @ActionRegistration(displayName = "#CTL_OpenLogFolder", iconInMenu = true)
46 @ActionReference(path = "Menu/Help", position = 1750)
47 @ActionID(id = "org.sleuthkit.autopsy.actions.OpenLogFolderAction", category = "Help")
48 public final class OpenLogFolderAction implements ActionListener {
49 
50  private static final Logger logger = Logger.getLogger(OpenLogFolderAction.class.getName());
51 
52  @Override
53  public void actionPerformed(ActionEvent e) {
54  File logDir;
55  if (Case.isCaseOpen()) {
56  try {
57  /*
58  * Open the log directory for the case.
59  */
60  Case currentCase = Case.getCurrentCase();
61  logDir = new File(currentCase.getLogDirectoryPath());
62  } catch (IllegalStateException ex) {
63  /*
64  * There is no open case, open the application level log
65  * directory.
66  */
67  logDir = new File(Places.getUserDirectory().getAbsolutePath() + File.separator + "var" + File.separator + "log");
68  }
69  } else {
70  logDir = new File(Places.getUserDirectory().getAbsolutePath() + File.separator + "var" + File.separator + "log");
71  }
72 
73  try {
74  if (logDir.exists()) {
75  Desktop.getDesktop().open(logDir);
76  } else {
77  logger.log(Level.SEVERE, String.format("The log directory %s does not exist", logDir));
78  NotifyDescriptor notifyDescriptor = new NotifyDescriptor.Message(
79  NbBundle.getMessage(this.getClass(), "OpenLogFolder.error1", logDir.getAbsolutePath()),
80  NotifyDescriptor.ERROR_MESSAGE);
81  DialogDisplayer.getDefault().notify(notifyDescriptor);
82  }
83  } catch (IOException ex) {
84  logger.log(Level.SEVERE, String.format("Could not open log directory %s", logDir), ex);
85  NotifyDescriptor notifyDescriptor = new NotifyDescriptor.Message(
86  NbBundle.getMessage(this.getClass(), "OpenLogFolder.CouldNotOpenLogFolder", logDir.getAbsolutePath()),
87  NotifyDescriptor.ERROR_MESSAGE);
88  DialogDisplayer.getDefault().notify(notifyDescriptor);
89  }
90  }
91 
92 }
synchronized static Logger getLogger(String name)
Definition: Logger.java:161
void open(Path caseMetadataFilePath)
Definition: Case.java:1777

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.