Autopsy 4.22.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 */
19package org.sleuthkit.autopsy.actions;
20
21import org.sleuthkit.autopsy.coreutils.Desktop;
22import java.awt.event.ActionEvent;
23import java.awt.event.ActionListener;
24import java.io.File;
25import java.io.IOException;
26import java.util.logging.Level;
27import org.openide.DialogDisplayer;
28import org.openide.NotifyDescriptor;
29import org.openide.awt.ActionID;
30import org.openide.awt.ActionReference;
31import org.openide.awt.ActionRegistration;
32import org.openide.modules.Places;
33import org.openide.util.NbBundle;
34import org.sleuthkit.autopsy.casemodule.Case;
35import org.sleuthkit.autopsy.casemodule.NoCurrentCaseException;
36import org.sleuthkit.autopsy.coreutils.Logger;
37
46@ActionRegistration(displayName = "#CTL_OpenLogFolder", iconInMenu = true)
47@ActionReference(path = "Menu/Help", position = 2000)
48@ActionID(id = "org.sleuthkit.autopsy.actions.OpenLogFolderAction", category = "Help")
49public 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}
synchronized static Logger getLogger(String name)
Definition Logger.java:124

Copyright © 2012-2024 Sleuth Kit Labs. Generated on:
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.