19 package org.sleuthkit.autopsy.commandlineingest;
22 import java.nio.file.Paths;
23 import java.util.logging.Level;
32 class CommandLineManager {
34 private static final Logger LOGGER = Logger.
getLogger(CommandLineOpenCaseManager.class.getName());
43 Case openCase(String casePath)
throws CaseActionException {
45 String metadataFilePath;
46 if (casePath.endsWith(
".aut") && (
new File(casePath)).isFile()) {
47 LOGGER.log(Level.INFO,
"Opening case {0}", casePath);
48 metadataFilePath = casePath;
50 LOGGER.log(Level.INFO,
"Opening case in directory {0}", casePath);
51 metadataFilePath = findAutFile(casePath);
53 Case.openAsCurrentCase(metadataFilePath);
55 Case newCase = Case.getCurrentCase();
56 LOGGER.log(Level.INFO,
"Opened case {0}", newCase.getName());
70 private String findAutFile(String caseDirectory)
throws CaseActionException {
71 File caseFolder = Paths.get(caseDirectory).toFile();
72 if (caseFolder.exists()) {
76 File[] fileArray = caseFolder.listFiles();
77 if (fileArray == null) {
78 throw new CaseActionException(
"No files found in case directory");
80 String autFilePath = null;
81 for (File file : fileArray) {
82 String name = file.getName().toLowerCase();
83 if (autFilePath == null && name.endsWith(getFileExtension())) {
84 return file.getAbsolutePath();
87 throw new CaseActionException(
"No .aut files found in case directory");
89 throw new CaseActionException(
"Case directory was not found");
synchronized static Logger getLogger(String name)