private static Set<String> ACTIONS = Sets.newHashSet("Index", "Search", "Remove");
public static void main(final String[] args) throws Exception {
if (args.length == 0 || !ACTIONS.contains(args[0])) {
for (final String action : ACTIONS) {
final CmdLineParser parser = new CmdLineParser(Class.forName("fr.inra.lipm.jezlucene.action." + action).newInstance());
System.out.println(action);
parser.setUsageWidth(120);
parser.printUsage(System.out);
}
System.exit(2);
}
final String[] parameters = Arrays.copyOfRange(args, 1, args.length);
final Main main = new Main();
if (args[0].equalsIgnoreCase("index")) {
final Index indexer = new Index();
main.parseParameters(indexer, parameters);
indexer.index();
}
else if (args[0].equalsIgnoreCase("search")) {
final Search searcher = new Search();
main.parseParameters(searcher, parameters);
System.out.println(searcher.search());
}
else if (args[0].equalsIgnoreCase("remove")) {
final Remove remove = new Remove();
main.parseParameters(remove, parameters);
remove.remove();
}
else if (args[0].equalsIgnoreCase("test")) {
final File dir = new File("/home/llegrand/Documents/personnel/Dropbox/Camera Uploads");
for (final File file : dir.listFiles()) {
final org.apache.tika.parser.Parser parser = new AutoDetectParser();
final BodyContentHandler handler = new BodyContentHandler();
final Metadata metadata = new Metadata();
try {
parser.parse(new FileInputStream(file), handler, metadata, new ParseContext());
}
catch (final IOException e) {
System.out.println("Unable to open input file: " + e.getMessage());
}
catch (SAXException | TikaException e) {