List of usage examples for org.apache.commons.cli Options Options
Options
From source file:mecard.MetroService.java
public static void main(String[] args) { // First get the valid options Options options = new Options(); // add t option c to config directory true=arg required. options.addOption("c", true, "configuration file directory path, include all sys dependant dir seperators like '/'."); // add t option c to config directory true=arg required. options.addOption("v", false, "Metro server version information."); try {//w ww .j ava 2s . c o m // parse the command line. CommandLineParser parser = new BasicParser(); CommandLine cmd; cmd = parser.parse(options, args); if (cmd.hasOption("v")) { System.out.println("Metro (MeCard) server version " + PropertyReader.VERSION); } // get c option value String configDirectory = cmd.getOptionValue("c"); PropertyReader.setConfigDirectory(configDirectory); } catch (ParseException ex) { // Logger.getLogger(MetroService.class.getName()).log(Level.SEVERE, null, ex); System.out.println( new Date() + "Unable to parse command line option. Please check your service configuration."); System.exit(799); } Properties properties = PropertyReader.getProperties(ConfigFileTypes.ENVIRONMENT); String portString = properties.getProperty(LibraryPropertyTypes.METRO_PORT.toString(), defaultPort); try { int port = Integer.parseInt(portString); serverSocket = new ServerSocket(port); } catch (IOException ex) { String msg = " Could not listen on port: " + portString; // Logger.getLogger(MetroService.class.getName()).log(Level.SEVERE, msg, ex); System.out.println(new Date() + msg + ex.getMessage()); } catch (NumberFormatException ex) { String msg = "Could not parse port number defined in configuration file."; // Logger.getLogger(MetroService.class.getName()).log(Level.SEVERE, msg, ex); System.out.println(new Date() + msg + ex.getMessage()); } while (listening) { try { new SocketThread(serverSocket.accept()).start(); } catch (IOException ex) { String msg = "unable to start server socket; either accept or start failed."; // Logger.getLogger(MetroService.class.getName()).log(Level.SEVERE, msg, ex); System.out.println(new Date() + msg); } } try { serverSocket.close(); } catch (IOException ex) { String msg = "failed to close the server socket."; // Logger.getLogger(MetroService.class.getName()).log(Level.SEVERE, msg, ex); System.out.println(new Date() + msg); } }
From source file:eu.annocultor.utils.XmlUtils.java
public static void main(String... args) throws Exception { // Handling command line parameters with Apache Commons CLI Options options = new Options(); options.addOption(OptionBuilder.withArgName(OPT_FN).hasArg().isRequired() .withDescription("XML file name to be pretty-printed").create(OPT_FN)); // now lets parse the input CommandLineParser parser = new BasicParser(); CommandLine cmd;/*from w ww. jav a 2 s . co m*/ try { cmd = parser.parse(options, Utils.getCommandLineFromANNOCULTOR_ARGS(args)); } catch (ParseException pe) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("pretty", options); return; } List<File> files = Utils.expandFileTemplateFrom(new File("."), cmd.getOptionValue(OPT_FN)); for (File file : files) { // XML pretty print System.out.println("Pretty-print for file " + file); if (file.exists()) prettyPrintXmlFileSAX(file.getCanonicalPath()); else throw new Exception("File not found: " + file.getCanonicalPath()); } }
From source file:dhtaccess.tools.Put.java
public static void main(String[] args) { byte[] secret = null; int ttl = 3600; // parse properties Properties prop = System.getProperties(); String gateway = prop.getProperty("dhtaccess.gateway"); if (gateway == null || gateway.length() <= 0) { gateway = DEFAULT_GATEWAY;//w ww .j ava 2 s. c o m } // parse options Options options = new Options(); options.addOption("h", "help", false, "print help"); options.addOption("g", "gateway", true, "gateway URI, list at http://opendht.org/servers.txt"); options.addOption("s", "secret", true, "can be used to remove the value later"); options.addOption("t", "ttl", true, "how long (in seconds) to store the value"); CommandLineParser parser = new PosixParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (ParseException e) { System.out.println("There is an invalid option."); e.printStackTrace(); System.exit(1); } String optVal; if (cmd.hasOption('h')) { usage(COMMAND); System.exit(1); } optVal = cmd.getOptionValue('g'); if (optVal != null) { gateway = optVal; } optVal = cmd.getOptionValue('s'); if (optVal != null) { try { secret = optVal.getBytes(ENCODE); } catch (UnsupportedEncodingException e) { // NOTREACHED } } optVal = cmd.getOptionValue('t'); if (optVal != null) { ttl = Integer.parseInt(optVal); } args = cmd.getArgs(); // parse arguments if (args.length < 2) { usage(COMMAND); System.exit(1); } for (int index = 0; index + 1 < args.length; index += 2) { byte[] key = null, value = null; try { key = args[index].getBytes(ENCODE); value = args[index + 1].getBytes(ENCODE); } catch (UnsupportedEncodingException e1) { // NOTREACHED } // prepare for RPC DHTAccessor accessor = null; try { accessor = new DHTAccessor(gateway); } catch (MalformedURLException e) { e.printStackTrace(); System.exit(1); } // RPC int res = accessor.put(key, value, ttl, secret); String resultString; switch (res) { case 0: resultString = "Success"; break; case 1: resultString = "Capacity"; break; case 2: resultString = "Again"; break; default: resultString = "???"; } System.out.println(resultString + ": " + args[index] + ", " + args[index + 1]); } }
From source file:mx.unam.fesa.isoo.msp.MSPMain.java
/** * @param args/* www .ja v a 2 s . c o m*/ * @throws Exception */ @SuppressWarnings("static-access") public static void main(String[] args) { // // creating options // Options options = new Options(); // help option // options.addOption( OptionBuilder.withDescription("Prints this message.").withLongOpt("help").create(OPT_HELP)); // server option // options.addOption(OptionBuilder.withDescription("The server this MineSweeperPlayer will connect to.") .hasArg().withArgName("SERVER").withLongOpt("server").create(OPT_SERVER)); // port option // options.addOption(OptionBuilder.withDescription("The port this MineSweeperPlayer will connect to.").hasArg() .withType(new Integer(0)).withArgName("PORT").withLongOpt("port").create(OPT_PORT)); // parsing options // String hostname = DEFAULT_SERVER; int port = DEFAULT_PORT; try { // using GNU standard // CommandLine line = new GnuParser().parse(options, args); if (line.hasOption(OPT_HELP)) { new HelpFormatter().printHelp("msc [options]", options); return; } if (line.hasOption(OPT_PORT)) { try { port = (Integer) line.getOptionObject(OPT_PORT); } catch (Exception e) { } } if (line.hasOption(OPT_SERVER)) { hostname = line.getOptionValue(OPT_PORT); } } catch (ParseException e) { System.err.println("Could not parse command line options correctly: " + e.getMessage()); return; } // // configuring logging services // try { LogManager.getLogManager() .readConfiguration(ClassLoader.getSystemResourceAsStream(DEFAULT_LOGGING_CONFIG_FILE)); } catch (Exception e) { throw new Error("Could not load logging properties file.", e); } // // setting up Mine Sweeper client // try { new MSClient(hostname, port); } catch (Exception e) { System.err.println("Could not execute MineSweeper client: " + e.getMessage()); } }
From source file:com.khubla.jvmbasic.jvmbasicwww.JVMBASICWWW.java
public static void main(String[] args) { try {//from ww w . ja v a2 s. co m System.out.println("khubla.com jvmBasic www server"); /* * options */ final Options options = new Options(); Option oo = Option.builder().argName(SOURCEDIR_OPTION).longOpt(SOURCEDIR_OPTION).type(String.class) .hasArg().required(false).desc("source dir").build(); options.addOption(oo); oo = Option.builder().argName(CLASSDIR_OPTION).longOpt(CLASSDIR_OPTION).type(String.class).hasArg() .required(false).desc("class dir").build(); options.addOption(oo); oo = Option.builder().argName(PORT_OPTION).longOpt(PORT_OPTION).type(String.class).hasArg() .required(false).desc("TCP port").build(); options.addOption(oo); /* * parse */ final CommandLineParser parser = new DefaultParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (final Exception e) { final HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("posix", options); System.exit(0); } /* * input dir */ final String sourceDir = cmd.getOptionValue(SOURCEDIR_OPTION, SOURCEDIR_DEFAULT); /* * class dir */ final String classdir = cmd.getOptionValue(CLASSDIR_OPTION, CLASSDIR_DEFAULT); /* * port */ int port = Integer.parseInt(cmd.getOptionValue(PORT_OPTION, PORT_DEFAULT)); /* * output the config */ System.out.println("Source directory: " + sourceDir); System.out.println("Class directory: " + classdir); System.out.println("HTTP port: " + port); /* * configuration */ final ServerConfiguration serverConfiguration = new ServerConfiguration(sourceDir, classdir, port); /* * server */ final JVMBasicWebServer jvmBasicWebServer = new JVMBasicWebServer(serverConfiguration); jvmBasicWebServer.listen(); } catch (final Exception e) { e.printStackTrace(); } }
From source file:hyperloglog.tools.HyperLogLogCLI.java
public static void main(String[] args) { Options options = new Options(); addOptions(options);/*from www.j a va 2 s . c om*/ CommandLineParser parser = new BasicParser(); CommandLine cli = null; long n = 0; long seed = 123; EncodingType enc = EncodingType.SPARSE; int p = 14; int hb = 64; boolean bitPack = true; boolean noBias = true; int unique = -1; String filePath = null; BufferedReader br = null; String outFile = null; String inFile = null; FileOutputStream fos = null; DataOutputStream out = null; FileInputStream fis = null; DataInputStream in = null; try { cli = parser.parse(options, args); if (!(cli.hasOption('n') || cli.hasOption('f') || cli.hasOption('d'))) { System.out.println("Example usage: hll -n 1000 " + "<OR> hll -f /tmp/input.txt " + "<OR> hll -d -i /tmp/out.hll"); usage(options); return; } if (cli.hasOption('n')) { n = Long.parseLong(cli.getOptionValue('n')); } if (cli.hasOption('e')) { String value = cli.getOptionValue('e'); if (value.equals(EncodingType.DENSE.name())) { enc = EncodingType.DENSE; } } if (cli.hasOption('p')) { p = Integer.parseInt(cli.getOptionValue('p')); if (p < 4 && p > 16) { System.out.println("Warning! Out-of-range value specified for p. Using to p=14."); p = 14; } } if (cli.hasOption('h')) { hb = Integer.parseInt(cli.getOptionValue('h')); } if (cli.hasOption('c')) { noBias = Boolean.parseBoolean(cli.getOptionValue('c')); } if (cli.hasOption('b')) { bitPack = Boolean.parseBoolean(cli.getOptionValue('b')); } if (cli.hasOption('f')) { filePath = cli.getOptionValue('f'); br = new BufferedReader(new FileReader(new File(filePath))); } if (filePath != null && cli.hasOption('n')) { System.out.println("'-f' (input file) specified. Ignoring -n."); } if (cli.hasOption('s')) { if (cli.hasOption('o')) { outFile = cli.getOptionValue('o'); fos = new FileOutputStream(new File(outFile)); out = new DataOutputStream(fos); } else { System.err.println("Specify output file. Example usage: hll -s -o /tmp/out.hll"); usage(options); return; } } if (cli.hasOption('d')) { if (cli.hasOption('i')) { inFile = cli.getOptionValue('i'); fis = new FileInputStream(new File(inFile)); in = new DataInputStream(fis); } else { System.err.println("Specify input file. Example usage: hll -d -i /tmp/in.hll"); usage(options); return; } } // return after deserialization if (fis != null && in != null) { long start = System.currentTimeMillis(); HyperLogLog deserializedHLL = HyperLogLogUtils.deserializeHLL(in); long end = System.currentTimeMillis(); System.out.println(deserializedHLL.toString()); System.out.println("Count after deserialization: " + deserializedHLL.count()); System.out.println("Deserialization time: " + (end - start) + " ms"); return; } // construct hll and serialize it if required HyperLogLog hll = HyperLogLog.builder().enableBitPacking(bitPack).enableNoBias(noBias).setEncoding(enc) .setNumHashBits(hb).setNumRegisterIndexBits(p).build(); if (br != null) { Set<String> hashset = new HashSet<String>(); String line; while ((line = br.readLine()) != null) { hll.addString(line); hashset.add(line); } n = hashset.size(); } else { Random rand = new Random(seed); for (int i = 0; i < n; i++) { if (unique < 0) { hll.addLong(rand.nextLong()); } else { int val = rand.nextInt(unique); hll.addLong(val); } } } long estCount = hll.count(); System.out.println("Actual count: " + n); System.out.println(hll.toString()); System.out.println("Relative error: " + HyperLogLogUtils.getRelativeError(n, estCount) + "%"); if (fos != null && out != null) { long start = System.currentTimeMillis(); HyperLogLogUtils.serializeHLL(out, hll); long end = System.currentTimeMillis(); System.out.println("Serialized hyperloglog to " + outFile); System.out.println("Serialized size: " + out.size() + " bytes"); System.out.println("Serialization time: " + (end - start) + " ms"); out.close(); } } catch (ParseException e) { System.err.println("Invalid parameter."); usage(options); } catch (NumberFormatException e) { System.err.println("Invalid type for parameter."); usage(options); } catch (FileNotFoundException e) { System.err.println("Specified file not found."); usage(options); } catch (IOException e) { System.err.println("Exception occured while reading file."); usage(options); } }
From source file:fr.inria.atlanmod.kyanos.benchmarks.CdoQueryList.java
public static void main(String[] args) { Options options = new Options(); Option inputOpt = OptionBuilder.create(IN); inputOpt.setArgName("INPUT"); inputOpt.setDescription("Input CDO resource directory"); inputOpt.setArgs(1);/*from w ww .j a va2s .com*/ inputOpt.setRequired(true); Option inClassOpt = OptionBuilder.create(EPACKAGE_CLASS); inClassOpt.setArgName("CLASS"); inClassOpt.setDescription("FQN of EPackage implementation class"); inClassOpt.setArgs(1); inClassOpt.setRequired(true); Option repoOpt = OptionBuilder.create(REPO_NAME); repoOpt.setArgName("REPO_NAME"); repoOpt.setDescription("CDO Repository name"); repoOpt.setArgs(1); repoOpt.setRequired(true); options.addOption(inputOpt); options.addOption(inClassOpt); options.addOption(repoOpt); CommandLineParser parser = new PosixParser(); try { CommandLine commandLine = parser.parse(options, args); String repositoryDir = commandLine.getOptionValue(IN); String repositoryName = commandLine.getOptionValue(REPO_NAME); Class<?> inClazz = CdoQueryList.class.getClassLoader() .loadClass(commandLine.getOptionValue(EPACKAGE_CLASS)); inClazz.getMethod("init").invoke(null); EmbeddedCDOServer server = new EmbeddedCDOServer(repositoryDir, repositoryName); try { server.run(); CDOSession session = server.openSession(); CDOTransaction transaction = session.openTransaction(); Resource resource = transaction.getRootResource(); { LOG.log(Level.INFO, "Start query"); long begin = System.currentTimeMillis(); EList<MethodDeclaration> list = JavaQueries.getUnusedMethodsList(resource); long end = System.currentTimeMillis(); LOG.log(Level.INFO, "End query"); LOG.log(Level.INFO, MessageFormat.format("Query result (list) contains {0} elements", list.size())); LOG.log(Level.INFO, MessageFormat.format("Time spent: {0}", MessageUtil.formatMillis(end - begin))); } transaction.close(); session.close(); } finally { server.stop(); } } catch (ParseException e) { MessageUtil.showError(e.toString()); MessageUtil.showError("Current arguments: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar <this-file.jar>", options, true); } catch (Throwable e) { MessageUtil.showError(e.toString()); } }
From source file:fr.inria.atlanmod.kyanos.benchmarks.CdoQueryLoop.java
public static void main(String[] args) { Options options = new Options(); Option inputOpt = OptionBuilder.create(IN); inputOpt.setArgName("INPUT"); inputOpt.setDescription("Input CDO resource directory"); inputOpt.setArgs(1);//w w w . j a v a 2s . c om inputOpt.setRequired(true); Option inClassOpt = OptionBuilder.create(EPACKAGE_CLASS); inClassOpt.setArgName("CLASS"); inClassOpt.setDescription("FQN of EPackage implementation class"); inClassOpt.setArgs(1); inClassOpt.setRequired(true); Option repoOpt = OptionBuilder.create(REPO_NAME); repoOpt.setArgName("REPO_NAME"); repoOpt.setDescription("CDO Repository name"); repoOpt.setArgs(1); repoOpt.setRequired(true); options.addOption(inputOpt); options.addOption(inClassOpt); options.addOption(repoOpt); CommandLineParser parser = new PosixParser(); try { CommandLine commandLine = parser.parse(options, args); String repositoryDir = commandLine.getOptionValue(IN); String repositoryName = commandLine.getOptionValue(REPO_NAME); Class<?> inClazz = CdoQueryLoop.class.getClassLoader() .loadClass(commandLine.getOptionValue(EPACKAGE_CLASS)); inClazz.getMethod("init").invoke(null); EmbeddedCDOServer server = new EmbeddedCDOServer(repositoryDir, repositoryName); try { server.run(); CDOSession session = server.openSession(); CDOTransaction transaction = session.openTransaction(); Resource resource = transaction.getRootResource(); { LOG.log(Level.INFO, "Start query"); long begin = System.currentTimeMillis(); EList<MethodDeclaration> list = JavaQueries.getUnusedMethodsLoop(resource); long end = System.currentTimeMillis(); LOG.log(Level.INFO, "End query"); LOG.log(Level.INFO, MessageFormat.format("Query result (loops) contains {0} elements", list.size())); LOG.log(Level.INFO, MessageFormat.format("Time spent: {0}", MessageUtil.formatMillis(end - begin))); } transaction.close(); session.close(); } finally { server.stop(); } } catch (ParseException e) { MessageUtil.showError(e.toString()); MessageUtil.showError("Current arguments: " + Arrays.toString(args)); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar <this-file.jar>", options, true); } catch (Throwable e) { MessageUtil.showError(e.toString()); } }
From source file:com.genentech.chemistry.tool.SDF2HtmlTab.java
public static void main(String[] args) throws ParseException, JDOMException, IOException { long start = System.currentTimeMillis(); // create command line Options object Options options = new Options(); Option opt = new Option("in", true, "input sd file"); opt.setRequired(true);/*www. j a v a 2 s . c o m*/ options.addOption(opt); CommandLineParser parser = new BasicParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (Exception e) { System.err.println(e.getMessage()); exitWithHelp(options); } args = cmd.getArgs(); String inFile = cmd.getOptionValue("in"); args = cmd.getArgs(); if (args.length > 0) { exitWithHelp(options); } oemolistream ifs; Set<String> tagSet = getTagSet(inFile); System.out.println( "<html xmlns:v='urn:schemas-microsoft-com:vml' xmlns:o='urn:schemas-microsoft-com:office:office'>"); System.out.println("<head>"); System.out.println("<BASE href='" + BASEUrl + "'/>"); System.out.println( "<link href='/" + Settings.SERVLET_CONTEXT + "/css/Aestel.css' rel='stylesheet' type='text/css'/>"); System.out.println("<style type='text/css'>"); System.out.println("td.stru { width: " + (IMGWidth + 2) + "px; height: " + (IMGHeigth + 4) + "px; vertical-align: top; }"); System.out.println("table.grid tr.first { border-top: 3px solid black; }"); // for tables in tables System.out.println("table.grid table td { border: 0px; text-align: right;}"); System.out.println("table.grid table td:first-child { text-align: left;}"); System.out.println("th.head { border-left: 1px solid black; border-bottom: 2px solid black;\n" + " empty-cells: show; background-color: #6297ff; color: #000000;\n" + " padding: 0em .3em 0em .3em; vertical-align: middle; }"); System.out.println("</style>"); System.out.println("</head>"); System.out.println("<body>"); System.out.println("<table class='grid'><tr>"); System.out.println("<th class='head'>Structure</th>"); for (String tag : tagSet) System.out.println("<th class='head'>" + tag + "</th>"); System.out.println("</tr>"); OEGraphMol mol = new OEGraphMol(); ifs = new oemolistream(inFile); int iCounter = 0; while (oechem.OEReadMolecule(ifs, mol)) { iCounter++; System.out.println("<tr>"); String smi = OETools.molToCanSmi(mol, true); String img = DepictHelper.DEFAULT.getExcelSmilesImageElement(BASEUrl, 120, 120, ImageType.PNG, smi, null); System.out.print(" <td class='stru'>"); System.out.print(img); System.out.println("</td>"); for (String tag : tagSet) { String val = oechem.OEGetSDData(mol, tag); System.out.print(" <td>"); System.out.print(val); System.out.println("</td>"); } System.out.println("</tr>"); } System.out.println("</table></body></html>"); System.err.printf("SDF2HtmlTab: Exported %d structures in %dsec\n", iCounter, (System.currentTimeMillis() - start) / 1000); }
From source file:com.hortonworks.registries.storage.tool.sql.TablesInitializer.java
public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption(Option.builder("s").numberOfArgs(1).longOpt(OPTION_SCRIPT_ROOT_PATH) .desc("Root directory of script path").build()); options.addOption(Option.builder("c").numberOfArgs(1).longOpt(OPTION_CONFIG_FILE_PATH) .desc("Config file path").build()); options.addOption(Option.builder("m").numberOfArgs(1).longOpt(OPTION_MYSQL_JAR_URL_PATH) .desc("Mysql client jar url to download").build()); options.addOption(Option.builder().hasArg(false).longOpt(SchemaMigrationOption.CREATE.toString()) .desc("Run sql migrations from scatch").build()); options.addOption(Option.builder().hasArg(false).longOpt(SchemaMigrationOption.DROP.toString()) .desc("Drop all the tables in the target database").build()); options.addOption(Option.builder().hasArg(false).longOpt(SchemaMigrationOption.CHECK_CONNECTION.toString()) .desc("Check the connection for configured data source").build()); options.addOption(Option.builder().hasArg(false).longOpt(SchemaMigrationOption.MIGRATE.toString()) .desc("Execute schema migration from last check point").build()); options.addOption(Option.builder().hasArg(false).longOpt(SchemaMigrationOption.INFO.toString()) .desc("Show the status of the schema migration compared to the target database").build()); options.addOption(Option.builder().hasArg(false).longOpt(SchemaMigrationOption.VALIDATE.toString()) .desc("Validate the target database changes with the migration scripts").build()); options.addOption(Option.builder().hasArg(false).longOpt(SchemaMigrationOption.REPAIR.toString()).desc( "Repairs the DATABASE_CHANGE_LOG by removing failed migrations and correcting checksum of existing migration script") .build());/*from w w w . ja va 2 s . c o m*/ options.addOption(Option.builder().hasArg(false).longOpt(DISABLE_VALIDATE_ON_MIGRATE) .desc("Disable flyway validation checks while running migrate").build()); CommandLineParser parser = new BasicParser(); CommandLine commandLine = parser.parse(options, args); if (!commandLine.hasOption(OPTION_CONFIG_FILE_PATH) || !commandLine.hasOption(OPTION_SCRIPT_ROOT_PATH)) { usage(options); System.exit(1); } boolean isSchemaMigrationOptionSpecified = false; SchemaMigrationOption schemaMigrationOptionSpecified = null; for (SchemaMigrationOption schemaMigrationOption : SchemaMigrationOption.values()) { if (commandLine.hasOption(schemaMigrationOption.toString())) { if (isSchemaMigrationOptionSpecified) { System.out.println( "Only one operation can be execute at once, please select one of 'create', ',migrate', 'validate', 'info', 'drop', 'repair', 'check-connection'."); System.exit(1); } isSchemaMigrationOptionSpecified = true; schemaMigrationOptionSpecified = schemaMigrationOption; } } if (!isSchemaMigrationOptionSpecified) { System.out.println( "One of the option 'create', ',migrate', 'validate', 'info', 'drop', 'repair', 'check-connection' must be specified to execute."); System.exit(1); } String confFilePath = commandLine.getOptionValue(OPTION_CONFIG_FILE_PATH); String scriptRootPath = commandLine.getOptionValue(OPTION_SCRIPT_ROOT_PATH); String mysqlJarUrl = commandLine.getOptionValue(OPTION_MYSQL_JAR_URL_PATH); StorageProviderConfiguration storageProperties; Map<String, Object> conf; try { conf = Utils.readConfig(confFilePath); StorageProviderConfigurationReader confReader = new StorageProviderConfigurationReader(); storageProperties = confReader.readStorageConfig(conf); } catch (IOException e) { System.err.println("Error occurred while reading config file: " + confFilePath); System.exit(1); throw new IllegalStateException("Shouldn't reach here"); } String bootstrapDirPath = null; try { bootstrapDirPath = System.getProperty("bootstrap.dir"); Proxy proxy = Proxy.NO_PROXY; String httpProxyUrl = (String) conf.get(HTTP_PROXY_URL); String httpProxyUsername = (String) conf.get(HTTP_PROXY_USERNAME); String httpProxyPassword = (String) conf.get(HTTP_PROXY_PASSWORD); if ((httpProxyUrl != null) && !httpProxyUrl.isEmpty()) { URL url = new URL(httpProxyUrl); proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(url.getHost(), url.getPort())); if ((httpProxyUsername != null) && !httpProxyUsername.isEmpty()) { Authenticator.setDefault(getBasicAuthenticator(url.getHost(), url.getPort(), httpProxyUsername, httpProxyPassword)); } } MySqlDriverHelper.downloadMySQLJarIfNeeded(storageProperties, bootstrapDirPath, mysqlJarUrl, proxy); } catch (Exception e) { System.err.println("Error occurred while downloading MySQL jar. bootstrap dir: " + bootstrapDirPath); System.exit(1); throw new IllegalStateException("Shouldn't reach here"); } boolean disableValidateOnMigrate = commandLine.hasOption(DISABLE_VALIDATE_ON_MIGRATE); if (disableValidateOnMigrate) { System.out.println("Disabling validation on schema migrate"); } SchemaMigrationHelper schemaMigrationHelper = new SchemaMigrationHelper( SchemaFlywayFactory.get(storageProperties, scriptRootPath, !disableValidateOnMigrate)); try { schemaMigrationHelper.execute(schemaMigrationOptionSpecified); System.out .println(String.format("\"%s\" option successful", schemaMigrationOptionSpecified.toString())); } catch (Exception e) { System.err.println( String.format("\"%s\" option failed : %s", schemaMigrationOptionSpecified.toString(), e)); System.exit(1); } }