Example usage for java.net MalformedURLException getMessage

List of usage examples for java.net MalformedURLException getMessage

Introduction

In this page you can find the example usage for java.net MalformedURLException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.cws.esolutions.core.main.NetworkUtility.java

public static final void main(final String[] args) {
    final String methodName = NetworkUtility.CNAME + "#main(final String[] args)";

    if (DEBUG) {/* w  ww  . j  ava  2  s  . com*/
        DEBUGGER.debug(methodName);
        DEBUGGER.debug("Value: {}", (Object) args);
    }

    if (args.length == 0) {
        new HelpFormatter().printHelp(NetworkUtility.CNAME, options, true);

        return;
    }

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

        if (DEBUG) {
            DEBUGGER.debug("CommandLineParser parser: {}", parser);
            DEBUGGER.debug("CommandLine commandLine: {}", commandLine);
        }

        String coreConfiguration = (StringUtils.isBlank(System.getProperty("coreConfigFile")))
                ? NetworkUtility.CORE_SVC_CONFIG
                : System.getProperty("coreConfigFile");
        String securityConfiguration = (StringUtils.isBlank(System.getProperty("secConfigFile")))
                ? NetworkUtility.CORE_LOG_CONFIG
                : System.getProperty("secConfigFile");
        String coreLogging = (StringUtils.isBlank(System.getProperty("coreLogConfig")))
                ? NetworkUtility.SEC_SVC_CONFIG
                : System.getProperty("coreLogConfig");
        String securityLogging = (StringUtils.isBlank(System.getProperty("secLogConfig")))
                ? NetworkUtility.SEC_LOG_CONFIG
                : System.getProperty("secLogConfig");

        if (DEBUG) {
            DEBUGGER.debug("String coreConfiguration: {}", coreConfiguration);
            DEBUGGER.debug("String securityConfiguration: {}", securityConfiguration);
            DEBUGGER.debug("String coreLogging: {}", coreLogging);
            DEBUGGER.debug("String securityLogging: {}", securityLogging);
        }

        SecurityServiceInitializer.initializeService(securityConfiguration, securityLogging, false);
        CoreServiceInitializer.initializeService(coreConfiguration, coreLogging, false, true);

        final CoreConfigurationData coreConfigData = NetworkUtility.appBean.getConfigData();
        final SecurityConfigurationData secConfigData = NetworkUtility.secBean.getConfigData();

        if (DEBUG) {
            DEBUGGER.debug("CoreConfigurationData coreConfigData: {}", coreConfigData);
            DEBUGGER.debug("SecurityConfigurationData secConfig: {}", secConfigData);
        }

        if (commandLine.hasOption("ssh")) {
            if (!(commandLine.hasOption("hostname"))
                    || (!(StringUtils.isBlank(commandLine.getOptionValue("hostname"))))) {
                throw new CoreServiceException("No target host was provided. Unable to process request.");
            } else if (!(commandLine.hasOption("username"))
                    && (StringUtils.isBlank(commandLine.getOptionValue("username")))) {
                throw new CoreServiceException("No username was provided. Using default.");
            }

            // NetworkUtils.executeSshConnection(commandLine.getOptionValue("hostname"), commandList);
        } else if (commandLine.hasOption("http")) {
            if (!(commandLine.hasOption("hostname"))
                    || (!(StringUtils.isBlank(commandLine.getOptionValue("hostname"))))) {
                throw new CoreServiceException("No target host was provided. Unable to process request.");
            } else if (!(commandLine.hasOption("method"))
                    && (StringUtils.isBlank(commandLine.getOptionValue("method")))) {
                throw new CoreServiceException("No HTTP method was provided. Unable to process request.");
            }

            NetworkUtils.executeHttpConnection(new URL(commandLine.getOptionValue("hostname")),
                    commandLine.getOptionValue("method"));
        } else if (commandLine.hasOption("copyFiles")) {
            if (!(commandLine.hasOption("hostname"))
                    || (StringUtils.isBlank(commandLine.getOptionValue("hostname")))) {
                throw new CoreServiceException("No target host was provided. Unable to process request.");
            } else if (!(commandLine.hasOption("sourceFile"))
                    && (StringUtils.isBlank(commandLine.getOptionValue("sourceFile")))) {
                throw new CoreServiceException("No source file(s) were provided. Unable to process request.");
            } else if (!(commandLine.hasOption("targetFile"))
                    && (StringUtils.isBlank(commandLine.getOptionValue("targetFile")))) {
                throw new CoreServiceException("No target file(s) were provided. Unable to process request.");
            }

            List<String> filesToTransfer = new ArrayList<String>(
                    Arrays.asList(commandLine.getOptionValues("sourceFile")));
            List<String> filesToCreate = new ArrayList<String>(
                    Arrays.asList(commandLine.getOptionValues("targetFile")));

            if (DEBUG) {
                DEBUGGER.debug("List<String> filesToTransfer: {}", filesToTransfer);
                DEBUGGER.debug("List<String> filesToCreate: {}", filesToCreate);
            }

            if (commandLine.hasOption("withSSH")) {
                for (String fileName : filesToTransfer) {
                    if (DEBUG) {
                        DEBUGGER.debug("String fileName: {}", fileName);
                    }

                    NetworkUtils.executeSftpTransfer(fileName,
                            filesToCreate.get(filesToTransfer.indexOf(fileName)),
                            commandLine.getOptionValue("hostname"), FileUtils.getFile(fileName).exists());
                }
            }

            else if (commandLine.hasOption("withFTP")) {
                if ((commandLine.hasOption("withSSL"))
                        && (Boolean.valueOf(commandLine.getOptionValue("withSSL")))) {
                    // ftp/s
                }

                // NetworkUtils.executeFtpConnection(sourceFile, targetFile, targetHost, isUpload);
            }
        }
    } catch (ParseException px) {
        ERROR_RECORDER.error(px.getMessage(), px);

        System.err.println("An error occurred during processing: " + px.getMessage());
    } catch (SecurityException sx) {
        ERROR_RECORDER.error(sx.getMessage(), sx);

        System.err.println("An error occurred during processing: " + sx.getMessage());
    } catch (SecurityServiceException ssx) {
        ERROR_RECORDER.error(ssx.getMessage(), ssx);

        System.err.println("An error occurred during processing: " + ssx.getMessage());
    } catch (CoreServiceException csx) {
        ERROR_RECORDER.error(csx.getMessage(), csx);

        System.err.println("An error occurred during processing: " + csx.getMessage());
    } catch (MalformedURLException mux) {
        ERROR_RECORDER.error(mux.getMessage(), mux);

        System.err.println("An error occurred during processing: " + mux.getMessage());
    }
}

From source file:OrientedTest.java

public static void main(String[] args) {
    java.net.URL earthURL = null;
    java.net.URL stoneURL = null;
    try {/*from w  ww.j  a v  a 2s  . c  o  m*/
        // the paths to the image files for an application
        earthURL = new java.net.URL("file:earth.jpg");
        stoneURL = new java.net.URL("file:stone.jpg");
    } catch (java.net.MalformedURLException ex) {
        System.out.println(ex.getMessage());
        System.exit(1);
    }

    new MainFrame(new OrientedTest(earthURL, stoneURL), 400, 400);
}

From source file:InterleavedTest.java

public static void main(String[] args) {
    java.net.URL texURL1 = null;//from w w w .  j  a va2s  .  c  om
    java.net.URL texURL2 = null;
    // the path to the image for an application
    try {
        texURL1 = new java.net.URL("file:bg.jpg");
        texURL2 = new java.net.URL("file:one.jpg");
    } catch (java.net.MalformedURLException ex) {
        System.out.println(ex.getMessage());
        System.exit(1);
    }

    Frame frame = new MainFrame(new InterleavedTest(texURL1, texURL2), 800, 800);
}

From source file:InterleavedNIOBuffer.java

public static void main(String[] args) {
    java.net.URL texURL1 = null;/*from  ww w. jav a 2 s  .c  o  m*/
    java.net.URL texURL2 = null;
    // the path to the image for an application
    try {
        texURL1 = new java.net.URL("file:bg.jpg");
        texURL2 = new java.net.URL("file:one.jpg");
    } catch (java.net.MalformedURLException ex) {
        System.out.println(ex.getMessage());
        System.exit(1);
    }

    Frame frame = new MainFrame(new InterleavedNIOBuffer(texURL1, texURL2), 800, 800);
}

From source file:de.dfki.dmas.owls2wsdl.core.OWLS2WSDL.java

public static void main(String[] args) {
    // http://jakarta.apache.org/commons/cli/usage.html
    System.out.println("ARG COUNT: " + args.length);

    OWLS2WSDLSettings.getInstance();/*from   w  w w.ja v a 2s  .c  o m*/

    Options options = new Options();
    Option help = new Option("help", "print help message");
    options.addOption(help);

    // create the parser
    CommandLineParser parser = new GnuParser();
    CommandLine cmdLine = null;

    for (int i = 0; i < args.length; i++) {
        System.out.println("ARG: " + args[i].toString());
    }

    if (args.length > 0) {
        if (args[args.length - 1].toString().endsWith(".owl")) {
            // -kbdir d:\tmp\KB http://127.0.0.1/ontology/ActorDefault.owl
            Option test = new Option("test", "parse only, don't save");
            @SuppressWarnings("static-access")
            Option kbdir = OptionBuilder.withArgName("dir").hasArg()
                    .withDescription("knowledgebase directory; necessary").create("kbdir");
            options.addOption(test);
            options.addOption(kbdir);

            try {
                cmdLine = parser.parse(options, args);
                if (cmdLine.hasOption("help")) {
                    HelpFormatter formatter = new HelpFormatter();
                    formatter.printHelp("owls2wsdl [options] FILE.owl", options);
                    System.exit(0);
                }
            } catch (ParseException exp) {
                // oops, something went wrong
                System.out.println("Error: Parsing failed, reason: " + exp.getMessage());
                HelpFormatter formatter = new HelpFormatter();
                formatter.printHelp("owls2wsdl", options, true);
            }

            if (args.length == 1) {
                HelpFormatter formatter = new HelpFormatter();
                formatter.printHelp("owls2wsdl [options] FILE.owl", options);
                System.out.println("Error: Option -kbdir is missing.");
                System.exit(0);
            } else {
                String ontURI = args[args.length - 1].toString();
                String persistentName = "KB_"
                        + ontURI.substring(ontURI.lastIndexOf("/") + 1, ontURI.lastIndexOf(".")) + "-MAP.xml";

                try {
                    if (cmdLine.hasOption("kbdir")) {
                        String kbdirValue = cmdLine.getOptionValue("kbdir");
                        if (new File(kbdirValue).isDirectory()) {
                            DatatypeParser p = new DatatypeParser();
                            p.parse(args[args.length - 1].toString());
                            p.getAbstractDatatypeKBData();
                            if (!cmdLine.hasOption("test")) {
                                System.out.println("AUSGABE: " + kbdirValue + File.separator + persistentName);
                                FileOutputStream ausgabeStream = new FileOutputStream(
                                        kbdirValue + File.separator + persistentName);
                                AbstractDatatypeKB.getInstance().marshallAsXML(ausgabeStream, true); // System.out);
                            }
                        }
                    }
                } catch (java.net.MalformedURLException murle) {
                    System.err.println("MalformedURLException: " + murle.getMessage());
                    System.err.println("Try something like: http://127.0.0.1/ontology/my_ontology.owl");
                } catch (Exception e) {
                    System.err.println("Exception: " + e.toString());
                }
            }
        } else if (args[args.length - 1].toString().endsWith(".xml")) {
            // -owlclass http://127.0.0.1/ontology/Student.owl#HTWStudent
            // -xsd -d 1 -h D:\tmp\KB\KB_Student-MAP.xml
            Option xsd = new Option("xsd", "generate XML Schema");
            Option info = new Option("info", "print datatype information");
            @SuppressWarnings("static-access")
            Option owlclass = OptionBuilder.withArgName("class").hasArg()
                    .withDescription("owl class to translate; necessary").create("owlclass");
            Option keys = new Option("keys", "list all owlclass keys");
            options.addOption(keys);
            options.addOption(owlclass);
            options.addOption(info);
            options.addOption(xsd);
            options.addOption("h", "hierarchy", false, "use hierarchy pattern");
            options.addOption("d", "depth", true, "set recursion depth");
            options.addOption("b", "behavior", true, "set inheritance bevavior");
            options.addOption("p", "primitive", true, "set default primitive type");

            try {
                cmdLine = parser.parse(options, args);
                if (cmdLine.hasOption("help")) {
                    HelpFormatter formatter = new HelpFormatter();
                    formatter.printHelp("owls2wsdl [options] FILE.xml", options);
                    System.exit(0);
                }
            } catch (ParseException exp) {
                // oops, something went wrong
                System.out.println("Error: Parsing failed, reason: " + exp.getMessage());
                HelpFormatter formatter = new HelpFormatter();
                formatter.printHelp("owls2wsdl", options, true);
            }

            if (args.length == 1) {
                HelpFormatter formatter = new HelpFormatter();
                formatter.printHelp("owls2wsdl [options] FILE.xml", options);
                System.exit(0);
            } else if (cmdLine.hasOption("keys")) {
                File f = new File(args[args.length - 1].toString());
                try {
                    AbstractDatatypeMapper.getInstance().loadAbstractDatatypeKB(f);
                } catch (Exception e) {
                    System.err.println("Error: " + e.getMessage());
                    System.exit(1);
                }
                AbstractDatatypeKB.getInstance().getAbstractDatatypeKBData().printRegisteredDatatypes();
                System.exit(0);
            } else if (!cmdLine.hasOption("owlclass")) {
                HelpFormatter formatter = new HelpFormatter();
                formatter.printHelp("owls2wsdl [options] FILE.xml", "", options,
                        "Info: owl class not set.\n e.g. -owlclass http://127.0.0.1/ontology/Student.owl#Student");
                System.exit(0);
            } else {
                File f = new File(args[args.length - 1].toString());
                try {
                    AbstractDatatypeMapper.getInstance().loadAbstractDatatypeKB(f);
                } catch (Exception e) {
                    System.err.println("Error: " + e.getMessage());
                    System.exit(1);
                }

                String owlclassString = cmdLine.getOptionValue("owlclass");
                if (!AbstractDatatypeKB.getInstance().getAbstractDatatypeKBData().containsKey(owlclassString)) {
                    System.err.println("Error: Key " + owlclassString + " not in knowledgebase.");
                    System.exit(1);
                }

                if (cmdLine.hasOption("info")) {
                    AbstractDatatypeKB.getInstance().getAbstractDatatypeKBData().get(owlclassString)
                            .printDatatype();
                }
                if (cmdLine.hasOption("xsd")) {
                    boolean hierachy = false;
                    int depth = 0;
                    String inheritanceBehavior = AbstractDatatype.InheritanceByNone;
                    String defaultPrimitiveType = "http://www.w3.org/2001/XMLSchema#string";

                    if (cmdLine.hasOption("h")) {
                        hierachy = true;
                    }
                    if (cmdLine.hasOption("d")) {
                        depth = Integer.parseInt(cmdLine.getOptionValue("d"));
                    }
                    if (cmdLine.hasOption("b")) {
                        System.out.print("Set inheritance behaviour to: ");
                        if (cmdLine.getOptionValue("b")
                                .equals(AbstractDatatype.InheritanceByParentsFirstRDFTypeSecond)) {
                            System.out.println(AbstractDatatype.InheritanceByParentsFirstRDFTypeSecond);
                            inheritanceBehavior = AbstractDatatype.InheritanceByNone;
                        } else if (cmdLine.getOptionValue("b")
                                .equals(AbstractDatatype.InheritanceByRDFTypeFirstParentsSecond)) {
                            System.out.println(AbstractDatatype.InheritanceByRDFTypeFirstParentsSecond);
                            inheritanceBehavior = AbstractDatatype.InheritanceByRDFTypeFirstParentsSecond;
                        } else if (cmdLine.getOptionValue("b")
                                .equals(AbstractDatatype.InheritanceByRDFTypeOnly)) {
                            System.out.println(AbstractDatatype.InheritanceByRDFTypeOnly);
                            inheritanceBehavior = AbstractDatatype.InheritanceByRDFTypeOnly;
                        } else if (cmdLine.getOptionValue("b")
                                .equals(AbstractDatatype.InheritanceBySuperClassOnly)) {
                            System.out.println(AbstractDatatype.InheritanceBySuperClassOnly);
                            inheritanceBehavior = AbstractDatatype.InheritanceBySuperClassOnly;
                        } else {
                            System.out.println(AbstractDatatype.InheritanceByNone);
                            inheritanceBehavior = AbstractDatatype.InheritanceByNone;
                        }
                    }
                    if (cmdLine.hasOption("p")) {
                        defaultPrimitiveType = cmdLine.getOptionValue("p");
                        if (defaultPrimitiveType.split("#")[0].equals("http://www.w3.org/2001/XMLSchema")) {
                            System.err.println("Error: Primitive Type not valid: " + defaultPrimitiveType);
                            System.exit(1);
                        }
                    }
                    XsdSchemaGenerator xsdgen = new XsdSchemaGenerator("SCHEMATYPE", hierachy, depth,
                            inheritanceBehavior, defaultPrimitiveType);

                    try {
                        AbstractDatatypeKB.getInstance().toXSD(owlclassString, xsdgen, System.out);
                    } catch (Exception e) {
                        System.err.println("Error: " + e.getMessage());
                    }
                }

            }
        } else {
            try {
                cmdLine = parser.parse(options, args);
                if (cmdLine.hasOption("help")) {
                    printDefaultHelpMessage();
                }
            } catch (ParseException exp) {
                // oops, something went wrong
                System.out.println("Error: Parsing failed, reason: " + exp.getMessage());
                printDefaultHelpMessage();
            }
        }
    } else {
        OWLS2WSDLGui.createAndShowGUI();
    }

    // for(Iterator it=options.getOptions().iterator(); it.hasNext(); ) {
    // String optString = ((Option)it.next()).getOpt();
    // if(cmdLine.hasOption(optString)) {
    // System.out.println("Option set: "+optString);
    // }
    // }

}

From source file:AppearanceMixed.java

public static void main(String[] args) {
    // the path to the image file for an application
    java.net.URL bgurl = null;/* w w  w  .  j a  v a2s  . com*/
    java.net.URL texurl = null;
    try {
        bgurl = new java.net.URL("file:bg.jpg");
        texurl = new java.net.URL("file:apimage.jpg");
    } catch (java.net.MalformedURLException ex) {
        System.out.println(ex.getMessage());
        System.exit(1);
    }
    new MainFrame(new AppearanceMixed(bgurl, texurl), 700, 700);
}

From source file:TickTockPicking.java

public static void main(String[] args) {
    // the path the the texture map for an application
    java.net.URL url = null;/* w  w w  . j  a v  a  2s .c  o m*/
    try {
        url = new java.net.URL("file:apimage.jpg");
    } catch (java.net.MalformedURLException ex) {
        System.out.println(ex.getMessage());
        System.exit(1);
    }
    new MainFrame(new TickTockPicking(url), 700, 700);
}

From source file:ImageComponentByReferenceTest.java

public static void main(String[] args) {
    java.net.URL url = null;//from  ww w  .jav  a2 s . co m
    // the path to the image file for an application
    try {
        url = new java.net.URL("file:one.jpg");
    } catch (java.net.MalformedURLException ex) {
        System.out.println(ex.getMessage());
        System.exit(1);
    }

    new MainFrame(new ImageComponentByReferenceTest(url), 800, 700);
}

From source file:TextureByReference.java

public static void main(String[] args) {
    java.net.URL fnames[] = null;
    if (args.length > 1) {
        fnames = new java.net.URL[args.length];
        for (int i = 0; i < args.length; i++) {
            try {
                fnames[i] = new java.net.URL("file:" + args[i]);
            } catch (java.net.MalformedURLException ex) {
                System.out.println(ex.getMessage());
            }/*from  w  w  w.  j a v  a  2 s.c o m*/
        }
    } else {
        fnames = new java.net.URL[TextureByReference.defaultFiles.length];
        for (int i = 0; i < TextureByReference.defaultFiles.length; i++) {
            try {
                fnames[i] = new java.net.URL("file:" + TextureByReference.defaultFiles[i]);
            } catch (java.net.MalformedURLException ex) {
                System.out.println(ex.getMessage());
                System.exit(1);
            }
        }
    }
    new MainFrame((new TextureByReference(fnames)), 650, 750);
}

From source file:Morphing.java

public static void main(String[] args) {
    java.net.URL[] urls = new java.net.URL[3];
    // the path to the image file for an application
    try {/* ww w .  j  a va  2s.  c o m*/
        urls[0] = new java.net.URL("file:./hand1.obj");
        urls[1] = new java.net.URL("file:./hand2.obj");
        urls[2] = new java.net.URL("file:./hand3.obj");
    } catch (java.net.MalformedURLException ex) {
        System.out.println(ex.getMessage());
        System.exit(1);
    }
    new MainFrame(new Morphing(urls), 700, 700);
}