Autopsy 4.22.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
OpenMultiUserCaseAction.java
Go to the documentation of this file.
1/*
2 * Autopsy Forensic Browser
3 *
4 * Copyright 2017-2019 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.casemodule;
20
21import java.awt.event.ActionEvent;
22import java.io.File;
23import java.util.logging.Level;
24import javax.swing.AbstractAction;
25import javax.swing.SwingUtilities;
26import org.openide.util.NbBundle;
27import org.sleuthkit.autopsy.casemodule.multiusercases.CaseNodeData;
28import org.sleuthkit.autopsy.coreutils.Logger;
29import org.sleuthkit.autopsy.coreutils.MessageNotifyUtil;
30
35final class OpenMultiUserCaseAction extends AbstractAction {
36
37 private static final long serialVersionUID = 1L;
38 private static final Logger logger = Logger.getLogger(OpenMultiUserCaseAction.class.getName());
39 private final CaseNodeData caseNodeData;
40
49 @NbBundle.Messages({
50 "OpenMultiUserCaseAction.menuItemText=Open Case"
51 })
52 OpenMultiUserCaseAction(CaseNodeData caseNodeData) {
53 super(Bundle.OpenMultiUserCaseAction_menuItemText());
54 this.caseNodeData = caseNodeData;
55 }
56
57 @NbBundle.Messages({
58 "# {0} - caseErrorMessage", "OpenMultiUserCaseAction.caseOpeningErrorErrorMsg=Failed to open case: {0}"
59 })
60 @Override
61 public void actionPerformed(ActionEvent event) {
62 StartupWindowProvider.getInstance().close();
63 OpenMultiUserCaseDialog.getInstance().setVisible(false);
64 new Thread(() -> {
65 String caseMetadataFilePath = null;
66 File caseDirectory = caseNodeData.getDirectory().toFile();
67 File[] filesInDirectory = caseDirectory.listFiles();
68 if (filesInDirectory != null) {
69 for (File file : filesInDirectory) {
70 if (file.getName().toLowerCase().endsWith(CaseMetadata.getFileExtension()) && file.isFile()) {
71 caseMetadataFilePath = file.getPath();
72 }
73 }
74 }
75 if (caseMetadataFilePath != null) {
76 try {
77 Case.openAsCurrentCase(caseMetadataFilePath);
78 } catch (CaseActionException ex) {
79 if (null != ex.getCause() && !(ex.getCause() instanceof CaseActionCancelledException)) {
80 logger.log(Level.SEVERE, String.format("Error opening case with metadata file path %s", caseMetadataFilePath), ex); //NON-NLS
81 }
82 SwingUtilities.invokeLater(() -> {
83 MessageNotifyUtil.Message.error(Bundle.OpenMultiUserCaseAction_caseOpeningErrorErrorMsg(ex.getLocalizedMessage()));
84 StartupWindowProvider.getInstance().open();
85 OpenMultiUserCaseDialog.getInstance().setVisible(true);
86 });
87 }
88 } else {
89 SwingUtilities.invokeLater(() -> {
90 MessageNotifyUtil.Message.error(Bundle.OpenMultiUserCaseAction_caseOpeningErrorErrorMsg("Could not locate case metadata file."));
91 });
92 }
93 }).start();
94 }
95
96 @Override
97 public OpenMultiUserCaseAction clone() throws CloneNotSupportedException {
98 throw new CloneNotSupportedException();
99 }
100
101}

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