19 package org.sleuthkit.autopsy.casemodule;
21 import java.awt.Desktop;
22 import java.awt.event.ActionEvent;
23 import java.io.IOException;
24 import java.nio.file.Path;
25 import java.nio.file.Paths;
26 import java.util.ArrayList;
27 import java.util.List;
28 import java.util.logging.Level;
29 import javax.swing.AbstractAction;
30 import javax.swing.Action;
31 import javax.swing.JOptionPane;
32 import javax.swing.SwingUtilities;
33 import org.openide.nodes.AbstractNode;
34 import org.openide.nodes.ChildFactory;
35 import org.openide.nodes.Children;
36 import org.openide.nodes.Node;
37 import org.openide.nodes.Sheet;
38 import org.openide.util.NbBundle.Messages;
46 final class MultiUserNode
extends AbstractNode {
48 @Messages({
"CaseNode.column.name=Name",
49 "CaseNode.column.createdTime=Created Time",
50 "CaseNode.column.metadataFilePath=Path"})
51 private static final Logger LOGGER = Logger.getLogger(MultiUserNode.class.getName());
52 private static final String LOG_FILE_NAME =
"auto_ingest_log.txt";
59 MultiUserNode(List<CaseMetadata> caseList) {
60 super(Children.create(
new MultiUserNodeChildren(caseList),
true));
63 static class MultiUserNodeChildren
extends ChildFactory<CaseMetadata> {
65 private final List<CaseMetadata> caseList;
67 MultiUserNodeChildren(List<CaseMetadata> caseList) {
68 this.caseList = caseList;
72 protected boolean createKeys(List<CaseMetadata> list) {
73 if (caseList != null && caseList.size() > 0) {
74 list.addAll(caseList);
80 protected Node createNodeForKey(CaseMetadata key) {
81 return new MultiUserCaseNode(key);
89 static final class MultiUserCaseNode
extends AbstractNode {
91 private final String caseName;
92 private final String caseCreatedDate;
93 private final String caseMetadataFilePath;
94 private final Path caseLogFilePath;
96 MultiUserCaseNode(CaseMetadata multiUserCase) {
98 caseName = multiUserCase.getCaseDisplayName();
99 caseCreatedDate = multiUserCase.getCreatedDate();
100 super.setName(caseName);
102 setDisplayName(caseName);
103 caseMetadataFilePath = multiUserCase.getFilePath().toString();
104 caseLogFilePath = Paths.get(multiUserCase.getCaseDirectory(), LOG_FILE_NAME);
112 public Action getPreferredAction() {
113 return new OpenMultiUserCaseAction(caseMetadataFilePath);
117 protected Sheet createSheet() {
118 Sheet sheet = super.createSheet();
119 Sheet.Set sheetSet = sheet.get(Sheet.PROPERTIES);
120 if (sheetSet == null) {
121 sheetSet = Sheet.createPropertiesSet();
124 sheetSet.put(
new NodeProperty<>(Bundle.CaseNode_column_name(), Bundle.CaseNode_column_name(), Bundle.CaseNode_column_name(),
126 sheetSet.put(
new NodeProperty<>(Bundle.CaseNode_column_createdTime(), Bundle.CaseNode_column_createdTime(), Bundle.CaseNode_column_createdTime(),
128 sheetSet.put(
new NodeProperty<>(Bundle.CaseNode_column_metadataFilePath(), Bundle.CaseNode_column_metadataFilePath(), Bundle.CaseNode_column_metadataFilePath(),
129 caseMetadataFilePath));
134 public Action[] getActions(
boolean context) {
135 List<Action> actions =
new ArrayList<>();
136 actions.add(
new OpenMultiUserCaseAction(caseMetadataFilePath));
137 actions.add(
new OpenCaseLogAction(caseLogFilePath));
138 return actions.toArray(
new Action[actions.size()]);
142 @Messages({
"MultiUserNode.OpenMultiUserCaseAction.text=Open Case"})
149 private static final long serialVersionUID = 1L;
154 super(Bundle.MultiUserNode_OpenMultiUserCaseAction_text());
155 caseMetadataFilePath = path;
161 MultiUserCasesDialog.getInstance().setVisible(
false);
168 LOGGER.log(Level.SEVERE, String.format(
"Error opening case with metadata file path %s", caseMetadataFilePath), ex);
171 SwingUtilities.invokeLater(() -> {
174 MultiUserCasesDialog.getInstance().setVisible(
true);
182 public Object
clone() throws CloneNotSupportedException {
183 return super.clone();
187 @Messages({
"MultiUserNode.OpenCaseLogAction.text=Open Log File"})
194 private static final long serialVersionUID = 1L;
199 super(Bundle.MultiUserNode_OpenCaseLogAction_text());
200 pathToLog = caseLogFilePath;
201 this.setEnabled(caseLogFilePath != null && caseLogFilePath.toFile().exists());
207 if (pathToLog != null) {
209 if (pathToLog.toFile().exists()) {
210 Desktop.getDesktop().edit(pathToLog.toFile());
213 JOptionPane.showMessageDialog(MultiUserCasesDialog.getInstance(),
org.openide.util.NbBundle.getMessage(MultiUserNode.class,
"DisplayLogDialog.cannotFindLog"),
214 org.openide.util.NbBundle.getMessage(MultiUserNode.class,
"DisplayLogDialog.unableToShowLogFile"), JOptionPane.ERROR_MESSAGE);
216 }
catch (IOException ex) {
217 LOGGER.log(Level.SEVERE, String.format(
"Error attempting to open case auto ingest log file %s", pathToLog), ex);
218 JOptionPane.showMessageDialog(MultiUserCasesDialog.getInstance(),
219 org.openide.util.NbBundle.getMessage(MultiUserNode.class,
"DisplayLogDialog.cannotOpenLog"),
220 org.openide.util.NbBundle.getMessage(MultiUserNode.class,
"DisplayLogDialog.unableToShowLogFile"),
221 JOptionPane.PLAIN_MESSAGE);
227 public Object
clone() throws CloneNotSupportedException {
228 return super.clone();
void actionPerformed(ActionEvent e)
final String caseMetadataFilePath
void actionPerformed(ActionEvent e)
static void openAsCurrentCase(String caseMetadataFilePath)
static StartupWindowProvider getInstance()
static void error(String message)