19 package org.sleuthkit.autopsy.commandlineingest;
22 import java.util.HashSet;
25 import java.util.logging.Level;
27 import org.netbeans.api.sendopts.CommandException;
28 import org.netbeans.spi.sendopts.Env;
29 import org.netbeans.spi.sendopts.Option;
30 import org.netbeans.spi.sendopts.OptionProcessor;
31 import org.openide.util.lookup.ServiceProvider;
36 @ServiceProvider(service = OptionProcessor.class)
40 private final Option pathToDataSourceOption = Option.optionalArgument(
'l',
"inputPath");
41 private final Option caseNameOption = Option.optionalArgument(
'2',
"caseName");
42 private final Option runFromCommandLineOption = Option.optionalArgument(
'3',
"runFromCommandLine");
45 private boolean runFromCommandLine =
false;
49 Set<Option> set =
new HashSet<>();
50 set.add(pathToDataSourceOption);
51 set.add(caseNameOption);
52 set.add(runFromCommandLineOption);
57 protected void process(Env env, Map<Option, String[]> values) throws CommandException {
58 logger.log(Level.INFO,
"Processing Autopsy command line options");
59 System.out.println(
"Processing Autopsy command line options");
60 if (values.containsKey(pathToDataSourceOption) && values.containsKey(caseNameOption) && values.containsKey(runFromCommandLineOption)) {
65 if (values.size() < 3) {
66 logger.log(Level.SEVERE,
"Insufficient number of input arguments to run command line ingest");
67 System.out.println(
"Insufficient number of input arguments to run command line ingest");
68 this.runFromCommandLine =
false;
71 String[] argDirs = values.get(pathToDataSourceOption);
72 if (argDirs.length < 1) {
73 logger.log(Level.SEVERE,
"Missing argument 'inputPath'");
74 System.out.println(
"Missing argument 'inputPath'");
75 this.runFromCommandLine =
false;
78 inputPath = argDirs[0];
80 argDirs = values.get(caseNameOption);
81 if (argDirs.length < 1) {
82 logger.log(Level.SEVERE,
"Missing argument 'caseName'");
83 System.out.println(
"Missing argument 'caseName'");
84 this.runFromCommandLine =
false;
87 inputCaseName = argDirs[0];
89 argDirs = values.get(runFromCommandLineOption);
90 if (argDirs.length < 1) {
91 logger.log(Level.SEVERE,
"Missing argument 'runFromCommandLine'");
92 System.out.println(
"Missing argument 'runFromCommandLine'");
93 this.runFromCommandLine =
false;
96 modeString = argDirs[0];
99 if (modeString == null || modeString.isEmpty()) {
100 this.runFromCommandLine =
false;
101 System.out.println(
"runFromCommandLine argument is empty");
105 if (modeString.equalsIgnoreCase(
"true")) {
106 this.runFromCommandLine =
true;
109 System.out.println(
"runFromCommandLine = " + this.runFromCommandLine);
113 if (inputPath == null || inputPath.isEmpty() || !(
new File(inputPath).exists())) {
114 logger.log(Level.SEVERE,
"Input file {0} doesn''t exist", inputPath);
115 System.out.println(
"Input file " + inputPath +
" doesn't exist");
116 this.runFromCommandLine =
false;
120 if (inputCaseName == null || inputCaseName.isEmpty()) {
121 logger.log(Level.SEVERE,
"Case name argument is empty");
122 System.out.println(
"Case name argument is empty");
123 this.runFromCommandLine =
false;
128 this.pathToDataSource = inputPath;
129 this.baseCaseName = inputCaseName;
130 logger.log(Level.INFO,
"Input file = {0}",
this.pathToDataSource);
131 logger.log(Level.INFO,
"Case name = {0}",
this.baseCaseName);
132 logger.log(Level.INFO,
"runFromCommandLine = {0}",
this.runFromCommandLine);
133 System.out.println(
"Input file = " + this.pathToDataSource);
134 System.out.println(
"Case name = " + this.baseCaseName);
135 System.out.println(
"runFromCommandLine = " + this.runFromCommandLine);
137 System.out.println(
"Missing input arguments to run command line ingest");
138 logger.log(Level.SEVERE,
"Missing input arguments to run command line ingest");
147 String getPathToDataSource() {
148 return pathToDataSource;
156 String getBaseCaseName() {
166 return runFromCommandLine;
boolean isRunFromCommandLine()
synchronized static Logger getLogger(String name)
Set< Option > getOptions()
void process(Env env, Map< Option, String[]> values)