Example usage for java.lang Exception getMessage

List of usage examples for java.lang Exception getMessage

Introduction

In this page you can find the example usage for java.lang Exception getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:search.java

public static void main(String argv[]) {
    int optind;//from   ww w  .j  ava  2s .c  o  m

    String subject = null;
    String from = null;
    boolean or = false;
    boolean today = false;

    for (optind = 0; optind < argv.length; optind++) {
        if (argv[optind].equals("-T")) {
            protocol = argv[++optind];
        } else if (argv[optind].equals("-H")) {
            host = argv[++optind];
        } else if (argv[optind].equals("-U")) {
            user = argv[++optind];
        } else if (argv[optind].equals("-P")) {
            password = argv[++optind];
        } else if (argv[optind].equals("-or")) {
            or = true;
        } else if (argv[optind].equals("-D")) {
            debug = true;
        } else if (argv[optind].equals("-f")) {
            mbox = argv[++optind];
        } else if (argv[optind].equals("-L")) {
            url = argv[++optind];
        } else if (argv[optind].equals("-subject")) {
            subject = argv[++optind];
        } else if (argv[optind].equals("-from")) {
            from = argv[++optind];
        } else if (argv[optind].equals("-today")) {
            today = true;
        } else if (argv[optind].equals("--")) {
            optind++;
            break;
        } else if (argv[optind].startsWith("-")) {
            System.out.println("Usage: search [-D] [-L url] [-T protocol] [-H host] "
                    + "[-U user] [-P password] [-f mailbox] "
                    + "[-subject subject] [-from from] [-or] [-today]");
            System.exit(1);
        } else {
            break;
        }
    }

    try {

        if ((subject == null) && (from == null) && !today) {
            System.out.println("Specify either -subject, -from or -today");
            System.exit(1);
        }

        // Get a Properties object
        Properties props = System.getProperties();

        // Get a Session object
        Session session = Session.getInstance(props, null);
        session.setDebug(debug);

        // Get a Store object
        Store store = null;
        if (url != null) {
            URLName urln = new URLName(url);
            store = session.getStore(urln);
            store.connect();
        } else {
            if (protocol != null)
                store = session.getStore(protocol);
            else
                store = session.getStore();

            // Connect
            if (host != null || user != null || password != null)
                store.connect(host, user, password);
            else
                store.connect();
        }

        // Open the Folder

        Folder folder = store.getDefaultFolder();
        if (folder == null) {
            System.out.println("Cant find default namespace");
            System.exit(1);
        }

        folder = folder.getFolder(mbox);
        if (folder == null) {
            System.out.println("Invalid folder");
            System.exit(1);
        }

        folder.open(Folder.READ_ONLY);
        SearchTerm term = null;

        if (subject != null)
            term = new SubjectTerm(subject);
        if (from != null) {
            FromStringTerm fromTerm = new FromStringTerm(from);
            if (term != null) {
                if (or)
                    term = new OrTerm(term, fromTerm);
                else
                    term = new AndTerm(term, fromTerm);
            } else
                term = fromTerm;
        }
        if (today) {
            ReceivedDateTerm dateTerm = new ReceivedDateTerm(ComparisonTerm.EQ, new Date());
            if (term != null) {
                if (or)
                    term = new OrTerm(term, dateTerm);
                else
                    term = new AndTerm(term, dateTerm);
            } else
                term = dateTerm;
        }

        Message[] msgs = folder.search(term);
        System.out.println("FOUND " + msgs.length + " MESSAGES");
        if (msgs.length == 0) // no match
            System.exit(1);

        // Use a suitable FetchProfile
        FetchProfile fp = new FetchProfile();
        fp.add(FetchProfile.Item.ENVELOPE);
        folder.fetch(msgs, fp);

        for (int i = 0; i < msgs.length; i++) {
            System.out.println("--------------------------");
            System.out.println("MESSAGE #" + (i + 1) + ":");
            dumpPart(msgs[i]);
        }

        folder.close(false);
        store.close();
    } catch (Exception ex) {
        System.out.println("Oops, got exception! " + ex.getMessage());
        ex.printStackTrace();
    }

    System.exit(1);
}

From source file:com.netscape.cmstools.CMCSharedToken.java

public static void main(String args[]) throws Exception {
    boolean isVerificationMode = false; // developer debugging only

    Options options = createOptions();//w  w  w  .  ja va2 s . c om
    CommandLine cmd = null;

    try {
        CommandLineParser parser = new PosixParser();
        cmd = parser.parse(options, args);

    } catch (Exception e) {
        printError(e.getMessage());
        System.exit(1);
    }

    if (cmd.hasOption("help")) {
        printHelp();
        System.exit(0);
    }

    boolean verbose = cmd.hasOption("v");

    String databaseDir = cmd.getOptionValue("d", ".");
    String passphrase = cmd.getOptionValue("s");
    if (passphrase == null) {
        printError("Missing passphrase");
        System.exit(1);
    }
    if (verbose) {
        System.out.println("passphrase String = " + passphrase);
        System.out.println("passphrase UTF-8 bytes = ");
        System.out.println(Arrays.toString(passphrase.getBytes("UTF-8")));
    }
    String tokenName = cmd.getOptionValue("h");
    String tokenPassword = cmd.getOptionValue("p");

    String issuanceProtCertFilename = cmd.getOptionValue("b");
    String issuanceProtCertNick = cmd.getOptionValue("n");
    String output = cmd.getOptionValue("o");

    try {
        CryptoManager.initialize(databaseDir);

        CryptoManager manager = CryptoManager.getInstance();

        CryptoToken token = CryptoUtil.getKeyStorageToken(tokenName);
        tokenName = token.getName();
        manager.setThreadToken(token);

        Password password = new Password(tokenPassword.toCharArray());
        token.login(password);

        X509Certificate issuanceProtCert = null;
        if (issuanceProtCertFilename != null) {
            if (verbose)
                System.out.println("Loading issuance protection certificate");
            String encoded = new String(Files.readAllBytes(Paths.get(issuanceProtCertFilename)));
            byte[] issuanceProtCertData = Cert.parseCertificate(encoded);

            issuanceProtCert = manager.importCACertPackage(issuanceProtCertData);
            if (verbose)
                System.out.println("issuance protection certificate imported");
        } else {
            // must have issuance protection cert nickname if file not provided
            if (verbose)
                System.out.println("Getting cert by nickname: " + issuanceProtCertNick);
            if (issuanceProtCertNick == null) {
                System.out.println(
                        "Invallid command: either nickname or PEM file must be provided for Issuance Protection Certificate");
                System.exit(1);
            }
            issuanceProtCert = getCertificate(tokenName, issuanceProtCertNick);
        }

        EncryptionAlgorithm encryptAlgorithm = EncryptionAlgorithm.AES_128_CBC_PAD;
        KeyWrapAlgorithm wrapAlgorithm = KeyWrapAlgorithm.RSA;

        if (verbose)
            System.out.println("Generating session key");
        SymmetricKey sessionKey = CryptoUtil.generateKey(token, KeyGenAlgorithm.AES, 128, null, true);

        if (verbose)
            System.out.println("Encrypting passphrase");
        byte iv[] = { 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1 };
        byte[] secret_data = CryptoUtil.encryptUsingSymmetricKey(token, sessionKey,
                passphrase.getBytes("UTF-8"), encryptAlgorithm, new IVParameterSpec(iv));

        if (verbose)
            System.out.println("Wrapping session key with issuance protection cert");
        byte[] issuanceProtWrappedSessionKey = CryptoUtil.wrapUsingPublicKey(token,
                issuanceProtCert.getPublicKey(), sessionKey, wrapAlgorithm);

        // final_data takes this format:
        // SEQUENCE {
        //     encryptedSession OCTET STRING,
        //     encryptedPrivate OCTET STRING
        // }

        DerOutputStream tmp = new DerOutputStream();

        tmp.putOctetString(issuanceProtWrappedSessionKey);
        tmp.putOctetString(secret_data);
        DerOutputStream out = new DerOutputStream();
        out.write(DerValue.tag_Sequence, tmp);

        byte[] final_data = out.toByteArray();
        String final_data_b64 = Utils.base64encode(final_data, true);
        if (final_data_b64 != null) {
            System.out.println("\nEncrypted Secret Data:");
            System.out.println(final_data_b64);
        } else
            System.out.println("Failed to produce final data");

        if (output != null) {
            System.out.println("\nStoring Base64 secret data into " + output);
            try (FileWriter fout = new FileWriter(output)) {
                fout.write(final_data_b64);
            }
        }

        if (isVerificationMode) { // developer use only
            PrivateKey wrappingKey = null;
            if (issuanceProtCertNick != null)
                wrappingKey = (org.mozilla.jss.crypto.PrivateKey) getPrivateKey(tokenName,
                        issuanceProtCertNick);
            else
                wrappingKey = CryptoManager.getInstance().findPrivKeyByCert(issuanceProtCert);

            System.out.println("\nVerification begins...");
            byte[] wrapped_secret_data = Utils.base64decode(final_data_b64);
            DerValue wrapped_val = new DerValue(wrapped_secret_data);
            // val.tag == DerValue.tag_Sequence
            DerInputStream wrapped_in = wrapped_val.data;
            DerValue wrapped_dSession = wrapped_in.getDerValue();
            byte wrapped_session[] = wrapped_dSession.getOctetString();
            System.out.println("wrapped session key retrieved");
            DerValue wrapped_dPassphrase = wrapped_in.getDerValue();
            byte wrapped_passphrase[] = wrapped_dPassphrase.getOctetString();
            System.out.println("wrapped passphrase retrieved");

            SymmetricKey ver_session = CryptoUtil.unwrap(token, SymmetricKey.AES, 128,
                    SymmetricKey.Usage.UNWRAP, wrappingKey, wrapped_session, wrapAlgorithm);
            byte[] ver_passphrase = CryptoUtil.decryptUsingSymmetricKey(token, new IVParameterSpec(iv),
                    wrapped_passphrase, ver_session, encryptAlgorithm);

            String ver_spassphrase = new String(ver_passphrase, "UTF-8");

            CryptoUtil.obscureBytes(ver_passphrase, "random");

            System.out.println("ver_passphrase String = " + ver_spassphrase);
            System.out.println("ver_passphrase UTF-8 bytes = ");
            System.out.println(Arrays.toString(ver_spassphrase.getBytes("UTF-8")));

            if (ver_spassphrase.equals(passphrase))
                System.out.println("Verification success!");
            else
                System.out.println("Verification failure! ver_spassphrase=" + ver_spassphrase);
        }

    } catch (Exception e) {
        if (verbose)
            e.printStackTrace();
        printError(e.getMessage());
        System.exit(1);
    }
}

From source file:chibi.gemmaanalysis.ExperimentMetaDataExtractorCli.java

public static void main(String[] args) {
    ExperimentMetaDataExtractorCli s = new ExperimentMetaDataExtractorCli();
    try {//w w w .j a va  2  s .c  o m
        Exception ex = s.doWork(args);
        if (ex != null) {
            ex.printStackTrace();
        }

        System.exit(0);
    } catch (Exception e) {
        // throw new RuntimeException( e );
        log.error(e.getMessage(), e);
        System.exit(1);
    }
}

From source file:de.interactive_instruments.ShapeChange.Target.FeatureCatalogue.XsltWriter.java

/**
 * Parameter identifiers have a leading "-". Parameter values are separated
 * from the parameter identifier via a single space.
 * <ul>/*from ww w .ja v  a 2 s .co  m*/
 * <li>Parameter {@value #PARAM_xslTransformerFactory}: fully qualified name
 * of the XSLT processor implementation; NOTE: this parameter may not be
 * provided if the default implementation shall be used.</li>
 * <li>Parameter {@value #PARAM_hrefMappings}: list of key-value pairs
 * defining href mappings, structured using URL query syntax (i.e. using '='
 * to separate the key from the value, using '&' to separate pairs, and with
 * URL-encoded value (with UTF-8 character encoding); NOTE: this parameter
 * may not be provided if href mappings are not needed.</li>
 * <li>Parameter {@value #PARAM_transformationParameters}: list of key-value
 * pairs defining the transformation parameters, structured using URL query
 * syntax (i.e. using '=' to separate the key from the value, using '&' to
 * separate pairs, and with URL-encoded value (with UTF-8 character
 * encoding); NOTE: this parameter may not be provided if transformation
 * parameters are not needed.</li>
 * <li>Parameter {@value #PARAM_transformationSourcePath}: path to the
 * transformation source file (may be a relative path); NOTE: this is a
 * required parameter.</li>
 * <li>Parameter {@value #PARAM_xsltMainFileUri}: String representation of
 * the URI to the main XSLT file; NOTE: this is a required parameter.</li>
 * <li>Parameter {@value #PARAM_transformationTargetPath}: path to the
 * transformation target file (may be a relative path); NOTE: this is a
 * required parameter.</li>
 * </ul>
 */
public static void main(String[] args) {

    String xslTransformerFactory = null;
    String hrefMappingsString = null;
    String transformationParametersString = null;
    String transformationSourcePath = null;
    String xsltMainFileUriString = null;
    String transformationTargetPath = null;

    // identify parameters
    String arg = null;

    for (int i = 0; i < args.length; i++) {

        arg = args[i];

        if (arg.equals(PARAM_xslTransformerFactory)) {

            if (i + 1 == args.length || args[i + 1].startsWith("-")) {
                System.err.println("No value provided for invocation parameter " + PARAM_xslTransformerFactory);
                return;
            } else {
                xslTransformerFactory = args[i + 1];
                i++;
            }

        } else if (arg.equals(PARAM_hrefMappings)) {

            if (i + 1 == args.length || args[i + 1].startsWith("-")) {
                System.err.println("No value provided for invocation parameter " + PARAM_hrefMappings);
                return;
            } else {
                hrefMappingsString = args[i + 1];
                i++;
            }

        } else if (arg.equals(PARAM_transformationParameters)) {

            if (i + 1 == args.length || args[i + 1].startsWith("-")) {
                System.err.println(
                        "No value provided for invocation parameter " + PARAM_transformationParameters);
                return;
            } else {
                transformationParametersString = args[i + 1];
                i++;
            }

        } else if (arg.equals(PARAM_transformationSourcePath)) {

            if (i + 1 == args.length || args[i + 1].startsWith("-")) {
                System.err.println(
                        "No value provided for invocation parameter " + PARAM_transformationSourcePath);
                return;
            } else {
                transformationSourcePath = args[i + 1];
                i++;
            }

        } else if (arg.equals(PARAM_transformationTargetPath)) {

            if (i + 1 == args.length || args[i + 1].startsWith("-")) {
                System.err.println(
                        "No value provided for invocation parameter " + PARAM_transformationTargetPath);
                return;
            } else {
                transformationTargetPath = args[i + 1];
                i++;
            }

        } else if (arg.equals(PARAM_xsltMainFileUri)) {

            if (i + 1 == args.length || args[i + 1].startsWith("-")) {
                System.err.println("No value provided for invocation parameter " + PARAM_xsltMainFileUri);
                return;
            } else {
                xsltMainFileUriString = args[i + 1];
                i++;
            }
        }
    }

    try {

        // parse parameter values
        Map<String, URI> hrefMappings = new HashMap<String, URI>();

        List<NameValuePair> hrefMappingsList = URLEncodedUtils.parse(hrefMappingsString, ENCODING_CHARSET);
        for (NameValuePair nvp : hrefMappingsList) {

            hrefMappings.put(nvp.getName(), new URI(nvp.getValue()));
        }

        Map<String, String> transformationParameters = new HashMap<String, String>();

        List<NameValuePair> transParamList = URLEncodedUtils.parse(transformationParametersString,
                ENCODING_CHARSET);
        for (NameValuePair nvp : transParamList) {
            transformationParameters.put(nvp.getName(), nvp.getValue());
        }

        boolean invalidParameters = false;

        if (transformationSourcePath == null) {
            invalidParameters = true;
            System.err.println("Path to transformation source file was not provided.");
        }
        if (xsltMainFileUriString == null) {
            invalidParameters = true;
            System.err.println("Path to main XSLT file was not provided.");
        }
        if (transformationTargetPath == null) {
            invalidParameters = true;
            System.err.println("Path to transformation target file was not provided.");
        }

        if (!invalidParameters) {

            // set up and execute XSL transformation
            XsltWriter writer = new XsltWriter(xslTransformerFactory, hrefMappings, transformationParameters,
                    null);

            File transformationSource = new File(transformationSourcePath);
            URI xsltMainFileUri = new URI(xsltMainFileUriString);
            File transformationTarget = new File(transformationTargetPath);

            writer.xsltWrite(transformationSource, xsltMainFileUri, transformationTarget);
        }

    } catch (Exception e) {

        String m = e.getMessage();

        if (m != null) {
            System.err.println(m);
        } else {
            System.err.println("Exception occurred while processing the XSL transformation.");
        }
    }
}

From source file:com.netthreads.mavenize.Pommel.java

/**
 * Arguments: <source dir> <target dir> <project type> [Optional parameter 
 * can be intellij, netbeans]//from  w w  w . ja v a  2s.  c  o m
 * 
 * @param args
 */
public static void main(String[] args) {
    if (args.length > 1) {
        String sourcePath = "";
        String mapFilePath = "";

        boolean isInput = false;
        boolean isMap = false;
        for (String arg : args) {
            try {
                if (arg.startsWith(ARG_INPUT)) {
                    sourcePath = arg.substring(ARG_INPUT.length());
                    isInput = true;
                } else if (arg.startsWith(ARG_MAP)) {
                    mapFilePath = arg.substring(ARG_MAP.length());
                    isMap = true;
                }
            } catch (Exception e) {
                logger.error("Can't process argument, " + arg + ", " + e.getMessage());
            }
        }

        // Execute mapping.
        try {
            if (isInput && isMap) {
                Pommel pommel = new Pommel();

                pommel.process(sourcePath, mapFilePath);
            } else {
                System.out.println(APP_MESSAGE + ARGS_MESSAGE);
            }
        } catch (PommelException e) {
            System.out.println("Application error, " + e.getMessage());
        }
    } else {
        System.out.println(APP_MESSAGE + ARGS_MESSAGE);
    }
}

From source file:com.fluidops.iwb.deepzoom.DZConvert.java

/**
 * @param args the command line arguments
 *///from   w  ww  . j ava  2 s. c  om
public static void main(String[] args) {
    int counter = 0;
    try {
        File inputFiles = new File("webapps/ROOT/wikipedia/source/");
        for (File subDir : inputFiles.listFiles()) {
            for (File imgFile : subDir.listFiles()) {

                outputDir = new File("webapps/ROOT/wikipedia/dzimages/" + subDir.getName());
                System.out.println(counter++ + ": " + imgFile);
                if (!outputDir.exists())
                    GenUtil.mkdir(outputDir);

                try {
                    processImageFile(imgFile, outputDir);
                } catch (Exception e) {
                    logger.error(e.getMessage(), e);
                    logger.error("Could not handle file: " + imgFile);
                }

            }
        }

    } catch (Exception e) {
        logger.error(e.getMessage(), e);
    }
}

From source file:de.dailab.plistacontest.client.ClientAndContestHandler0MQ.java

/**
 * This method starts the server/*from ww  w .jav a2s .c  o m*/
 * 
 * @param args [hostname:port, properties_filename]
 * @throws Exception
 */
public static void main(String[] args) throws Exception {

    // you might want to use a recommender
    Object recommender = null;

    String hostname = "0.0.0.0";
    int port = 8081;
    try {
        hostname = args[0].substring(0, args[0].indexOf(":"));
        port = Integer.parseInt(args[0].substring(args[0].indexOf(":") + 1));
    } catch (Exception e) {
        System.out.println("No hostname and port given. Using default 0.0.0.0:8081");
        logger.info(e.getMessage());
    }

    // initialize zeroMQ
    // initialize the 0MQ
    ZContext context = new ZContext();
    ZMQ.Socket clientSocket = context.createSocket(ZMQ.SUB);
    String serverURL = "tcp://" + hostname + ":" + port;
    if (serverURL == null) {
        serverURL = "tcp://127.0.0.1:8088";
    }
    clientSocket.bind(serverURL);

    // create the handler 
    ClientAndContestHandler0MQ me = new ClientAndContestHandler0MQ();
    for (;;) {
        String message = clientSocket.recvStr();
        // split the message
        String[] token = message.split("\t");

        // call handle and provide the relevant token
        String result = me.handle(token[0], null, token[3], token[4]);

        // send back the result
        clientSocket.send(result);
    }
}

From source file:search.java

public static void main(String argv[]) {
    int optind;//from w ww. ja va  2  s.co  m

    String subject = null;
    String from = null;
    boolean or = false;
    boolean today = false;
    int size = -1;

    for (optind = 0; optind < argv.length; optind++) {
        if (argv[optind].equals("-T")) {
            protocol = argv[++optind];
        } else if (argv[optind].equals("-H")) {
            host = argv[++optind];
        } else if (argv[optind].equals("-U")) {
            user = argv[++optind];
        } else if (argv[optind].equals("-P")) {
            password = argv[++optind];
        } else if (argv[optind].equals("-or")) {
            or = true;
        } else if (argv[optind].equals("-D")) {
            debug = true;
        } else if (argv[optind].equals("-f")) {
            mbox = argv[++optind];
        } else if (argv[optind].equals("-L")) {
            url = argv[++optind];
        } else if (argv[optind].equals("-subject")) {
            subject = argv[++optind];
        } else if (argv[optind].equals("-from")) {
            from = argv[++optind];
        } else if (argv[optind].equals("-today")) {
            today = true;
        } else if (argv[optind].equals("-size")) {
            size = Integer.parseInt(argv[++optind]);
        } else if (argv[optind].equals("--")) {
            optind++;
            break;
        } else if (argv[optind].startsWith("-")) {
            System.out.println("Usage: search [-D] [-L url] [-T protocol] [-H host] "
                    + "[-U user] [-P password] [-f mailbox] "
                    + "[-subject subject] [-from from] [-or] [-today]");
            System.exit(1);
        } else {
            break;
        }
    }

    try {

        if ((subject == null) && (from == null) && !today && size < 0) {
            System.out.println("Specify either -subject, -from, -today, or -size");
            System.exit(1);
        }

        // Get a Properties object
        Properties props = System.getProperties();

        // Get a Session object
        Session session = Session.getInstance(props, null);
        session.setDebug(debug);

        // Get a Store object
        Store store = null;
        if (url != null) {
            URLName urln = new URLName(url);
            store = session.getStore(urln);
            store.connect();
        } else {
            if (protocol != null)
                store = session.getStore(protocol);
            else
                store = session.getStore();

            // Connect
            if (host != null || user != null || password != null)
                store.connect(host, user, password);
            else
                store.connect();
        }

        // Open the Folder

        Folder folder = store.getDefaultFolder();
        if (folder == null) {
            System.out.println("Cant find default namespace");
            System.exit(1);
        }

        folder = folder.getFolder(mbox);
        if (folder == null) {
            System.out.println("Invalid folder");
            System.exit(1);
        }

        folder.open(Folder.READ_ONLY);
        SearchTerm term = null;

        if (subject != null)
            term = new SubjectTerm(subject);
        if (from != null) {
            FromStringTerm fromTerm = new FromStringTerm(from);
            if (term != null) {
                if (or)
                    term = new OrTerm(term, fromTerm);
                else
                    term = new AndTerm(term, fromTerm);
            } else
                term = fromTerm;
        }
        if (today) {
            Calendar c = Calendar.getInstance();
            c.set(Calendar.HOUR, 0);
            c.set(Calendar.MINUTE, 0);
            c.set(Calendar.SECOND, 0);
            c.set(Calendar.MILLISECOND, 0);
            c.set(Calendar.AM_PM, Calendar.AM);
            ReceivedDateTerm startDateTerm = new ReceivedDateTerm(ComparisonTerm.GE, c.getTime());
            c.add(Calendar.DATE, 1); // next day
            ReceivedDateTerm endDateTerm = new ReceivedDateTerm(ComparisonTerm.LT, c.getTime());
            SearchTerm dateTerm = new AndTerm(startDateTerm, endDateTerm);
            if (term != null) {
                if (or)
                    term = new OrTerm(term, dateTerm);
                else
                    term = new AndTerm(term, dateTerm);
            } else
                term = dateTerm;
        }

        if (size >= 0) {
            SizeTerm sizeTerm = new SizeTerm(ComparisonTerm.GT, size);
            if (term != null) {
                if (or)
                    term = new OrTerm(term, sizeTerm);
                else
                    term = new AndTerm(term, sizeTerm);
            } else
                term = sizeTerm;
        }

        Message[] msgs = folder.search(term);
        System.out.println("FOUND " + msgs.length + " MESSAGES");
        if (msgs.length == 0) // no match
            System.exit(1);

        // Use a suitable FetchProfile
        FetchProfile fp = new FetchProfile();
        fp.add(FetchProfile.Item.ENVELOPE);
        folder.fetch(msgs, fp);

        for (int i = 0; i < msgs.length; i++) {
            System.out.println("--------------------------");
            System.out.println("MESSAGE #" + (i + 1) + ":");
            dumpPart(msgs[i]);
        }

        folder.close(false);
        store.close();
    } catch (Exception ex) {
        System.out.println("Oops, got exception! " + ex.getMessage());
        ex.printStackTrace();
    }

    System.exit(1);
}

From source file:com.termmed.statistics.runner.Runner.java

/**
 * The main method.//from   ww w.j a v a 2 s.  c  o m
 *
 * @param args the arguments
 */
public static void main(String[] args) {

    logger = new ProcessLogger();
    if (args.length == 0) {
        logger.logInfo("Error happened getting params. Params file doesn't exist");
        System.exit(0);
        //      }else{
        //         args=new String[]{"config/complete_nl-edition11320160930.xml"};
    }
    File infoFolder = new File(I_Constants.PROCESS_INFO_FOLDER);
    if (!infoFolder.exists()) {
        infoFolder.mkdirs();
    }
    OutputInfoFactory.get().setExecutionId(UUID.randomUUID().toString());
    String msg;
    int posIni;
    long start = logger.startTime();
    File file = new File(args[0]);
    Config configFile = getConfig(file);
    OutputInfoFactory.get().setConfig(configFile);
    System.setProperty("textdb.allow_full_path", "true");
    Connection c;
    try {
        boolean clean = false;
        if (args.length >= 2) {
            for (int i = 1; i < args.length; i++) {
                logger.logInfo("Arg " + i + ": " + args[i]);
                if (args[i].toLowerCase().equals("clean")) {
                    clean = true;
                }
            }
        }
        dataFolder = new File(I_Constants.REPO_FOLDER);
        if (!dataFolder.exists()) {
            dataFolder.mkdirs();
        }

        changedDate = true;
        changedPreviousDate = true;
        getParams(file);
        checkDates();
        /*******************************/
        //         changedDate=false;
        //         changedPreviousDate=false;
        /********************************/
        if (clean || changedDate || changedPreviousDate) {
            logger.logInfo("Removing old data");
            removeDBFolder();
            removeRepoFolder();
            removeReducedFolder();
            changedDate = true;
            changedPreviousDate = true;
        }

        Class.forName("org.hsqldb.jdbcDriver");
        logger.logInfo("Connecting to DB. This task can take several minutes... wait please.");
        c = DriverManager.getConnection("jdbc:hsqldb:file:" + I_Constants.DB_FOLDER, "sa", "sa");

        initFileProviders(file);
        //         OutputInfoFactory.get().getStatisticProcess().setOutputFolder(I_Constants.STATS_OUTPUT_FOLDER);

        /*******************************/
        //         DbSetup dbs=new DbSetup(c);
        //         dbs.recreatePath("org/ihtsdo/statistics/db/setup/storedprocedure");
        //         dbs=null;
        /*******************************/

        ImportManager impor = new ImportManager(c, file, changedDate, changedPreviousDate);
        impor.execute();

        impor = null;

        Processor proc = new Processor(c, file);

        proc.execute();

        proc = null;

        msg = logger.endTime(start);
        posIni = msg.indexOf("ProcessingTime:") + 16;
        OutputInfoFactory.get().getStatisticProcess().setTimeTaken(msg.substring(posIni));
        //         OutputInfoFactory.get().getPatternProcess().setOutputFolder(I_Constants.PATTERN_OUTPUT_FOLDER);
        long startPattern = logger.startTime();
        PatternExecutor pe = new PatternExecutor(file);

        pe.execute();

        pe = null;
        msg = logger.endTime(startPattern);
        posIni = msg.indexOf("ProcessingTime:") + 16;
        OutputInfoFactory.get().getPatternProcess().setTimeTaken(msg.substring(posIni));

        OutputInfoFactory.get().setStatus("Complete");
    } catch (Exception e) {
        OutputInfoFactory.get().setStatus("Error: " + e.getMessage() + " - View log for details.");
        e.printStackTrace();
    }
    msg = logger.endTime(start);
    posIni = msg.indexOf("ProcessingTime:") + 16;
    OutputInfoFactory.get().setTimeTaken(msg.substring(posIni));

    try {
        saveInfo();
    } catch (IOException e) {
        e.printStackTrace();
    }

}

From source file:it.crs4.seal.read_sort.MergeAlignments.java

public static void main(String[] args) {
    int res = 0;//from   w  ww .  j  av a2 s.  co m
    try {
        res = new SealToolRunner().run(new MergeAlignments(), args);
    } catch (Exception e) {
        System.err.println("Error executing MergeAlignments: " + e.getMessage());
        res = 1;
    }
    System.exit(res);
}