19 package org.sleuthkit.autopsy.casemodule;
21 import java.awt.event.ActionEvent;
23 import java.util.logging.Level;
24 import javax.swing.AbstractAction;
25 import javax.swing.SwingUtilities;
26 import org.openide.util.NbBundle;
35 final class OpenMultiUserCaseAction
extends AbstractAction {
37 private static final long serialVersionUID = 1L;
38 private static final Logger logger = Logger.getLogger(OpenMultiUserCaseAction.class.getName());
39 private final CaseNodeData caseNodeData;
50 "OpenMultiUserCaseAction.menuItemText=Open Case"
52 OpenMultiUserCaseAction(CaseNodeData caseNodeData) {
53 super(Bundle.OpenMultiUserCaseAction_menuItemText());
54 this.caseNodeData = caseNodeData;
58 "# {0} - caseErrorMessage",
"OpenMultiUserCaseAction.caseOpeningErrorErrorMsg=Failed to open case: {0}"
61 public void actionPerformed(ActionEvent event) {
62 StartupWindowProvider.getInstance().close();
63 OpenMultiUserCaseDialog.getInstance().setVisible(
false);
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();
75 if (caseMetadataFilePath != null) {
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);
82 SwingUtilities.invokeLater(() -> {
83 MessageNotifyUtil.Message.error(Bundle.OpenMultiUserCaseAction_caseOpeningErrorErrorMsg(ex.getLocalizedMessage()));
84 StartupWindowProvider.getInstance().open();
85 OpenMultiUserCaseDialog.getInstance().setVisible(
true);
89 SwingUtilities.invokeLater(() -> {
90 MessageNotifyUtil.Message.error(Bundle.OpenMultiUserCaseAction_caseOpeningErrorErrorMsg(
"Could not locate case metadata file."));
97 public OpenMultiUserCaseAction clone() throws CloneNotSupportedException {
98 throw new CloneNotSupportedException();