List of usage examples for java.lang Exception getMessage
public String getMessage()
From source file:alluxio.cli.AlluxioFrameworkIntegrationTest.java
/** * @param args arguments/*from ww w . jav a 2 s.co m*/ * @throws Exception if an exception occurs */ public static void main(String[] args) throws Exception { AlluxioFrameworkIntegrationTest test = new AlluxioFrameworkIntegrationTest(); JCommander jc = new JCommander(test); jc.setProgramName(AlluxioFrameworkIntegrationTest.class.getName()); try { jc.parse(args); } catch (Exception e) { LOG.error(e.getMessage()); jc.usage(); System.exit(1); } if (test.mHelp) { jc.usage(); } else { test.run(); } }
From source file:com.gordcorp.jira2db.App.java
public static void main(String[] args) throws Exception { File log4jFile = new File("log4j.xml"); if (log4jFile.exists()) { DOMConfigurator.configure("log4j.xml"); }/*from ww w.ja v a 2s . c om*/ Option help = new Option("h", "help", false, "print this message"); @SuppressWarnings("static-access") Option project = OptionBuilder.withLongOpt("project").withDescription("Only sync Jira project PROJECT") .hasArg().withArgName("PROJECT").create(); @SuppressWarnings("static-access") Option property = OptionBuilder.withArgName("property=value").hasArgs(2).withValueSeparator() .withDescription("use value for given property").create("D"); @SuppressWarnings("static-access") Option testJira = OptionBuilder.withLongOpt("test-jira") .withDescription("Test the connection to Jira and print the results").create(); @SuppressWarnings("static-access") Option forever = OptionBuilder.withLongOpt("forever") .withDescription("Will continue polling Jira and syncing forever").create(); Options options = new Options(); options.addOption(help); options.addOption(project); options.addOption(property); options.addOption(testJira); options.addOption(forever); CommandLineParser parser = new GnuParser(); try { CommandLine line = parser.parse(options, args); if (line.hasOption(help.getOpt())) { printHelp(options); return; } // Overwrite the properties file with command line arguments if (line.hasOption("D")) { String[] values = line.getOptionValues("D"); for (int i = 0; i < values.length; i = i + 2) { String key = values[i]; // If user does not provide a value for this property, use // an empty string String value = ""; if (i + 1 < values.length) { value = values[i + 1]; } log.info("Setting key=" + key + " value=" + value); PropertiesWrapper.set(key, value); } } if (line.hasOption("test-jira")) { testJira(); } else { JiraSynchroniser jira = new JiraSynchroniser(); if (line.hasOption("project")) { jira.setProjects(Arrays.asList(new String[] { line.getOptionValue("project") })); } if (line.hasOption("forever")) { jira.syncForever(); } else { jira.syncAll(); } } } catch (ParseException exp) { log.error("Parsing failed: " + exp.getMessage()); } catch (Exception e) { log.error(e.getMessage(), e); } }
From source file:com.aerospike.examples.Main.java
/** * Main entry point.// w w w . j ava 2 s . co m */ public static void main(String[] args) { try { Options options = new Options(); options.addOption("h", "host", true, "Server hostname (default: localhost)"); options.addOption("p", "port", true, "Server port (default: 3000)"); options.addOption("U", "user", true, "User name"); options.addOption("P", "password", true, "Password"); options.addOption("n", "namespace", true, "Namespace (default: test)"); options.addOption("s", "set", true, "Set name. Use 'empty' for empty set (default: demoset)"); options.addOption("g", "gui", false, "Invoke GUI to selectively run tests."); options.addOption("d", "debug", false, "Run in debug mode."); options.addOption("u", "usage", false, "Print usage."); CommandLineParser parser = new PosixParser(); CommandLine cl = parser.parse(options, args, false); if (args.length == 0 || cl.hasOption("u")) { logUsage(options); return; } Parameters params = parseParameters(cl); String[] exampleNames = cl.getArgs(); if ((exampleNames.length == 0) && (!cl.hasOption("g"))) { logUsage(options); return; } // Check for all. for (String exampleName : exampleNames) { if (exampleName.equalsIgnoreCase("all")) { exampleNames = ExampleNames; break; } } if (cl.hasOption("d")) { Log.setLevel(Level.DEBUG); } if (cl.hasOption("g")) { GuiDisplay.startGui(params); } else { Console console = new Console(); runExamples(console, params, exampleNames); } } catch (Exception ex) { System.out.println(ex.getMessage()); ex.printStackTrace(); } }
From source file:fedora.client.Uploader.java
/** * Test this class by uploading the given file three times. First, with the * provided credentials, as an InputStream. Second, with the provided * credentials, as a File. Third, with bogus credentials, as a File. */// w w w . j a v a 2s . c o m public static void main(String[] args) { try { if (args.length == 5 || args.length == 6) { String protocol = args[0]; int port = Integer.parseInt(args[1]); String user = args[2]; String password = args[3]; String fileName = args[4]; String context = Constants.FEDORA_DEFAULT_APP_CONTEXT; if (args.length == 6 && !args[5].equals("")) { context = args[5]; } Uploader uploader = new Uploader(protocol, port, context, user, password); File f = new File(fileName); System.out.println(uploader.upload(new FileInputStream(f))); System.out.println(uploader.upload(f)); uploader = new Uploader(protocol, port, context, user + "test", password); System.out.println(uploader.upload(f)); } else { System.err.println("Usage: Uploader host port user password file [context]"); } } catch (Exception e) { System.err.println("ERROR: " + e.getMessage()); } }
From source file:edu.msu.cme.rdp.framebot.stat.TaxonAbundance.java
/** * this class group the nearest matches by phylum/class, or by match * @param args/* ww w .j a va2s . com*/ * @throws Exception */ public static void main(String[] args) throws Exception { HashMap<String, Double> coveragetMap = null; double identity = 0.0; try { CommandLine line = new PosixParser().parse(options, args); if (line.hasOption("seqCoverage")) { String coveragefile = line.getOptionValue("seqCoverage"); coveragetMap = parseKmerCoverage(coveragefile); } if (line.hasOption("identity")) { identity = Double.parseDouble(line.getOptionValue("identity")); if (identity < 0 || identity > 100) { throw new IllegalArgumentException("identity cutoff should be in the range of 0 and 100"); } } args = line.getArgs(); if (args.length != 3) { throw new Exception(""); } } catch (Exception e) { System.out.println("Command Error: " + e.getMessage()); new HelpFormatter().printHelp(80, "[options] <FrameBot Alignment file or Dir> <seqLineage> <out file> ", "", options, "seqLineage: a tab-delimited file with ref seqID and lineage, or fasta of ref seq with lineage as the descrption" + "\nframeBot alignment file or Dir: frameBot alignment files " + "\noutfile: output with the nearest match count group by phylum/class; and by match name"); } TaxonAbundance.mapAbundance(new File(args[0]), new File(args[1]), args[2], coveragetMap, identity); }
From source file:edu.msu.cme.rdp.probematch.cli.PrimerMatch.java
public static void main(String[] args) throws Exception { PrintStream out = new PrintStream(System.out); int maxDist = Integer.MAX_VALUE; try {/*from www .ja va 2 s.c o m*/ CommandLine line = new PosixParser().parse(options, args); if (line.hasOption("outFile")) { out = new PrintStream(new File(line.getOptionValue("outFile"))); } if (line.hasOption("maxDist")) { maxDist = Integer.valueOf(line.getOptionValue("maxDist")); } args = line.getArgs(); if (args.length != 2) { throw new Exception("Unexpected number of command line arguments"); } } catch (Exception e) { System.err.println("Error: " + e.getMessage()); new HelpFormatter().printHelp("PrimerMatch <primer_list | primer_file> <seq_file>", options); return; } List<PatternBitMask64> primers = new ArrayList(); if (new File(args[0]).exists()) { File primerFile = new File(args[0]); SequenceFormat seqformat = SeqUtils.guessFileFormat(primerFile); if (seqformat.equals(SequenceFormat.FASTA)) { SequenceReader reader = new SequenceReader(primerFile); Sequence seq; while ((seq = reader.readNextSequence()) != null) { primers.add(new PatternBitMask64(seq.getSeqString(), true, seq.getSeqName())); } reader.close(); } else { BufferedReader reader = new BufferedReader(new FileReader(args[0])); String line; while ((line = reader.readLine()) != null) { line = line.trim(); if (!line.equals("")) { primers.add(new PatternBitMask64(line, true)); } } reader.close(); } } else { for (String primer : args[0].split(",")) { primers.add(new PatternBitMask64(primer, true)); } } SeqReader seqReader = new SequenceReader(new File(args[1])); Sequence seq; String primerRegion; out.println("#seqname\tdesc\tprimer_index\tprimer_name\tposition\tmismatches\tseq_primer_region"); while ((seq = seqReader.readNextSequence()) != null) { for (int index = 0; index < primers.size(); index++) { PatternBitMask64 primer = primers.get(index); BitVector64Result results = BitVector64.process(seq.getSeqString().toCharArray(), primer, maxDist); for (BitVector64Match result : results.getResults()) { primerRegion = seq.getSeqString().substring( Math.max(0, result.getPosition() - primer.getPatternLength()), result.getPosition()); if (result.getPosition() < primer.getPatternLength()) { for (int pad = result.getPosition(); pad < primer.getPatternLength(); pad++) { primerRegion = "x" + primerRegion; } } out.println(seq.getSeqName() + "\t" + seq.getDesc() + "\t" + (index + 1) + "\t" + primer.getPrimerName() + "\t" + result.getPosition() + "\t" + result.getScore() + "\t" + primerRegion); } } } out.close(); seqReader.close(); }
From source file:com.yahoo.athenz.example.zts.tls.client.ZTSAWSCredsClient.java
public static void main(String[] args) { // parse our command line to retrieve required input CommandLine cmd = parseCommandLine(args); final String domainName = cmd.getOptionValue("domain").toLowerCase(); final String roleName = cmd.getOptionValue("role").toLowerCase(); final String ztsUrl = cmd.getOptionValue("ztsurl"); final String keyPath = cmd.getOptionValue("key"); final String certPath = cmd.getOptionValue("cert"); final String trustStorePath = cmd.getOptionValue("trustStorePath"); final String trustStorePassword = cmd.getOptionValue("trustStorePassword"); // we are going to setup our service private key and // certificate into a ssl context that we can use with // our zts client try {//from w w w . j av a2 s . c om KeyRefresher keyRefresher = Utils.generateKeyRefresher(trustStorePath, trustStorePassword, certPath, keyPath); SSLContext sslContext = Utils.buildSSLContext(keyRefresher.getKeyManagerProxy(), keyRefresher.getTrustManagerProxy()); // obtain temporary credential provider for our domain and role AWSCredentialsProviderImpl awsCredProvider = new AWSCredentialsProviderImpl(ztsUrl, sslContext, domainName, roleName); // retrieve and display aws temporary creds. Typically you just pass // the AWSCredentialsProvider object to any AWS api that requires it. // for example, when creating an AWS S3 client // AmazonS3 s3client = AmazonS3ClientBuilder.standard() // .withCredentials(awsCredProvider).withClientConfiguration(cltConf) // .withRegion(getRegion()).build(); retrieveAWSTempCreds(awsCredProvider); // once we're done with our api and we no longer need our // provider we need to make sure to close it awsCredProvider.close(); } catch (Exception ex) { System.out.println("Exception: " + ex.getMessage()); ex.printStackTrace(); System.exit(1); } }
From source file:genql.CLIRunner.java
public static void main(String[] args) { Options options = setupOptions();/*w ww.ja va 2s . c om*/ CommandLineParser parser = new BasicParser(); try { // for (int i = 0; i < args.length; i++) { // System.out.println(args[i]); // } CommandLine line = parser.parse(options, args); if (line.hasOption('e')) { isEval = true; } if (line.hasOption('g')) { isGen = true; } if (line.hasOption('d')) { corpusDir = line.getOptionValue('d'); } if (line.hasOption('n')) { qcount = Integer.parseInt(line.getOptionValue('n')); } else { qcount = 10; } if (line.hasOption('o')) { outputFile = line.getOptionValue('o'); } if (line.hasOption('g')) { groundTruthQueryFile = line.getOptionValue('g'); } if (line.hasOption('q')) { generatedQueryFile = line.getOptionValue('q'); } if (line.hasOption('m')) { min_query_len = Integer.parseInt(line.getOptionValue('m')); } else { min_query_len = 2; } if (line.hasOption('x')) { max_query_len = Integer.parseInt(line.getOptionValue('x')); } else { max_query_len = 7; } if (line.hasOption('h')) { printHelpAndExit(options); } if (isGen) { MainApp.gen(corpusDir, outputFile, qcount, min_query_len, max_query_len); } else if (isEval) { final String intermediateResults = corpusDir + "/temp"; new File(intermediateResults).mkdir(); MainApp.eval(corpusDir, generatedQueryFile, groundTruthQueryFile, intermediateResults, min_query_len, max_query_len); } } catch (Exception ex) { ex.printStackTrace(); System.err.println("Unexpected exception: " + ex.getMessage()); System.exit(1); } }
From source file:com.genentech.chemistry.openEye.apps.SDFALogP.java
/** * @param args//from www . ja v a2 s.c om */ public static void main(String... args) throws IOException { // create command line Options object Options options = new Options(); Option opt = new Option(OPT_INFILE, true, "input file oe-supported Use .sdf|.smi to specify the file type."); opt.setRequired(true); options.addOption(opt); opt = new Option(OPT_OUTFILE, true, "output file oe-supported. Use .sdf|.smi to specify the file type."); opt.setRequired(true); options.addOption(opt); opt = new Option(OPT_SMARTS_FILE, true, "Optional: to overwrite atom type definition file."); opt.setRequired(false); options.addOption(opt); opt = new Option(OPT_PRINT_COUNTS, false, "If set the count of each atom type is added to the output file."); opt.setRequired(false); options.addOption(opt); opt = new Option(OPT_VALIDATE_ASSIGNMENT, false, "Print warning if no atomtype matches an atom in a candidte molecule."); opt.setRequired(false); options.addOption(opt); opt = new Option(OPT_SUPRESS_ZERO, false, "If given atom type counts with count=0 will not be added."); opt.setRequired(false); options.addOption(opt); opt = new Option(OPT_NEUTRALIZE, true, "y|n to neutralize molecule if possible (default=y)"); opt.setRequired(false); options.addOption(opt); CommandLineParser parser = new PosixParser(); CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (Exception e) { System.err.println(e.getMessage()); exitWithHelp(options); } args = cmd.getArgs(); if (cmd.hasOption("d")) { System.err.println("Start debugger and press return:"); new BufferedReader(new InputStreamReader(System.in)).readLine(); } String inFile = cmd.getOptionValue(OPT_INFILE); String outFile = cmd.getOptionValue(OPT_OUTFILE); String smartsFile = cmd.getOptionValue(OPT_SMARTS_FILE); boolean outputCount = cmd.hasOption(OPT_PRINT_COUNTS); boolean outputZero = !cmd.hasOption(OPT_SUPRESS_ZERO); boolean neutralize = !"n".equalsIgnoreCase(cmd.getOptionValue(OPT_NEUTRALIZE)); boolean ValidateAssignment = cmd.hasOption(OPT_VALIDATE_ASSIGNMENT); SDFALogP sdfALogP = new SDFALogP(smartsFile, outFile, outputZero, neutralize, ValidateAssignment); sdfALogP.run(inFile, outputCount); sdfALogP.close(); }
From source file:net.modelbased.proasense.storage.registry.StorageRegistrySensorDataTestClient.java
public static void main(String[] args) { // Get client properties from properties file // StorageRegistrySensorDataTestClient client = new StorageRegistrySensorDataTestClient(); // client.loadClientProperties(); // Hardcoded client properties (simple test client) String STORAGE_REGISTRY_SERVICE_URL = "http://192.168.84.34:8080/storage-registry"; // Default HTTP client and common properties for requests HttpClient client = new DefaultHttpClient(); StringBuilder requestUrl = null; List<NameValuePair> params = null; String queryString = null;/*from ww w .ja v a 2s . c o m*/ // Default HTTP response and common properties for responses HttpResponse response = null; ResponseHandler<String> handler = null; int status = 0; String body = null; // Query for sensor list requestUrl = new StringBuilder(STORAGE_REGISTRY_SERVICE_URL); requestUrl.append("/query/sensor/list"); try { HttpGet query21 = new HttpGet(requestUrl.toString()); query21.setHeader("Content-type", "application/json"); response = client.execute(query21); // Check status code status = response.getStatusLine().getStatusCode(); if (status != 200) { throw new RuntimeException("Failed! HTTP error code: " + status); } // Get body handler = new BasicResponseHandler(); body = handler.handleResponse(response); System.out.println("SENSOR LIST: " + body); } catch (Exception e) { System.out.println(e.getClass().getName() + ": " + e.getMessage()); } // Query for sensor properties requestUrl = new StringBuilder(STORAGE_REGISTRY_SERVICE_URL); requestUrl.append("/query/sensor/properties"); params = new LinkedList<NameValuePair>(); params.add(new BasicNameValuePair("sensorId", "visualInspection")); queryString = URLEncodedUtils.format(params, "utf-8"); requestUrl.append("?"); requestUrl.append(queryString); try { HttpGet query22 = new HttpGet(requestUrl.toString()); query22.setHeader("Content-type", "application/json"); response = client.execute(query22); // Check status code status = response.getStatusLine().getStatusCode(); if (status != 200) { throw new RuntimeException("Failed! HTTP error code: " + status); } // Get body handler = new BasicResponseHandler(); body = handler.handleResponse(response); System.out.println("SENSOR PROPERTIES: " + body); } catch (Exception e) { System.out.println(e.getClass().getName() + ": " + e.getMessage()); } }