Search in sources :

Example 91 with ToolException

use of org.apache.cxf.tools.common.ToolException in project cxf by apache.

the class PluginLoader method loadPlugin.

public void loadPlugin(URL url) throws IOException {
    try {
        LOG.log(Level.FINE, "PLUGIN_LOADING", url);
        loadPlugin(getPlugin(url));
    } catch (JAXBException e) {
        Message msg = new Message("PLUGIN_LOAD_FAIL", LOG, url);
        LOG.log(Level.SEVERE, msg.toString());
        throw new ToolException(msg, e);
    }
}
Also used : Message(org.apache.cxf.common.i18n.Message) JAXBException(javax.xml.bind.JAXBException) ToolException(org.apache.cxf.tools.common.ToolException)

Example 92 with ToolException

use of org.apache.cxf.tools.common.ToolException in project cxf by apache.

the class PluginLoader method getPlugin.

protected Plugin getPlugin(URL url) throws IOException, JAXBException, FileNotFoundException {
    Plugin plugin = plugins.get(url.toString());
    InputStream is = null;
    if (plugin == null) {
        is = url.openStream();
        plugin = getPlugin(is);
        if (plugin == null || StringUtils.isEmpty(plugin.getName())) {
            Message msg = new Message("PLUGIN_LOAD_FAIL", LOG, url);
            LOG.log(Level.SEVERE, msg.toString());
            throw new ToolException(msg);
        }
        plugins.put(url.toString(), plugin);
    }
    if (is == null) {
        return getPlugin(url.toString());
    }
    return plugin;
}
Also used : Message(org.apache.cxf.common.i18n.Message) BufferedInputStream(java.io.BufferedInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) ToolException(org.apache.cxf.tools.common.ToolException) Plugin(org.apache.cxf.tools.plugin.Plugin)

Example 93 with ToolException

use of org.apache.cxf.tools.common.ToolException in project cxf by apache.

the class PluginLoader method getFrontEndGenerators.

private List<FrontEndGenerator> getFrontEndGenerators(FrontEnd frontend) {
    List<FrontEndGenerator> generators = new ArrayList<>();
    String fullClzName = null;
    try {
        for (Generator generator : frontend.getGenerators().getGenerator()) {
            fullClzName = getGeneratorClass(frontend, generator);
            Class<?> clz = ClassLoaderUtils.loadClass(fullClzName, this.getClass());
            generators.add((FrontEndGenerator) clz.newInstance());
        }
    } catch (Exception e) {
        Message msg = new Message("FRONTEND_PROFILE_LOAD_FAIL", LOG, fullClzName);
        LOG.log(Level.SEVERE, msg.toString());
        throw new ToolException(msg, e);
    }
    return generators;
}
Also used : Message(org.apache.cxf.common.i18n.Message) FrontEndGenerator(org.apache.cxf.tools.common.FrontEndGenerator) ArrayList(java.util.ArrayList) ToolException(org.apache.cxf.tools.common.ToolException) XMLStreamException(javax.xml.stream.XMLStreamException) IOException(java.io.IOException) JAXBException(javax.xml.bind.JAXBException) FileNotFoundException(java.io.FileNotFoundException) ToolException(org.apache.cxf.tools.common.ToolException) Generator(org.apache.cxf.tools.plugin.Generator) FrontEndGenerator(org.apache.cxf.tools.common.FrontEndGenerator)

Example 94 with ToolException

use of org.apache.cxf.tools.common.ToolException in project cxf by apache.

the class WSDLToJavaContainerTest method testValidateorSuppressWarningsIsOn.

@Test
public void testValidateorSuppressWarningsIsOn() throws Exception {
    WSDLToJavaContainer container = new WSDLToJavaContainer("dummy", null);
    ToolContext context = new ToolContext();
    context.put(ToolConstants.CFG_WSDLURL, getLocation("hello_world.wsdl"));
    container.setContext(context);
    try {
        container.execute();
    } catch (ToolException te) {
        assertEquals(getLogMessage("FOUND_NO_FRONTEND"), te.getMessage());
    } catch (Exception e) {
        fail("Should not throw any exception but ToolException.");
    }
    assertTrue(context.optionSet(ToolConstants.CFG_SUPPRESS_WARNINGS));
}
Also used : ToolContext(org.apache.cxf.tools.common.ToolContext) ToolException(org.apache.cxf.tools.common.ToolException) ToolException(org.apache.cxf.tools.common.ToolException) URISyntaxException(java.net.URISyntaxException) Test(org.junit.Test)

Example 95 with ToolException

use of org.apache.cxf.tools.common.ToolException in project cxf by apache.

the class WSDLToJavaContainerTest method testNoPlugin.

@Test
public void testNoPlugin() throws Exception {
    WSDLToJavaContainer container = new WSDLToJavaContainer("dummy", null);
    ToolContext context = new ToolContext();
    context.put(ToolConstants.CFG_WSDLURL, getLocation("hello_world.wsdl"));
    container.setContext(context);
    try {
        container.execute();
    } catch (ToolException te) {
        assertEquals(getLogMessage("FOUND_NO_FRONTEND"), te.getMessage());
    } catch (Exception e) {
        fail("Should not throw any exception but ToolException.");
    }
}
Also used : ToolContext(org.apache.cxf.tools.common.ToolContext) ToolException(org.apache.cxf.tools.common.ToolException) ToolException(org.apache.cxf.tools.common.ToolException) URISyntaxException(java.net.URISyntaxException) Test(org.junit.Test)

Aggregations

ToolException (org.apache.cxf.tools.common.ToolException)129 Message (org.apache.cxf.common.i18n.Message)69 IOException (java.io.IOException)38 File (java.io.File)30 QName (javax.xml.namespace.QName)19 WSDLException (javax.wsdl.WSDLException)18 BadUsageException (org.apache.cxf.tools.common.toolspec.parser.BadUsageException)16 ToolContext (org.apache.cxf.tools.common.ToolContext)15 XMLStreamException (javax.xml.stream.XMLStreamException)14 FileNotFoundException (java.io.FileNotFoundException)12 Test (org.junit.Test)12 Element (org.w3c.dom.Element)10 InputStream (java.io.InputStream)9 Writer (java.io.Writer)9 URISyntaxException (java.net.URISyntaxException)9 URL (java.net.URL)9 HashMap (java.util.HashMap)9 ArrayList (java.util.ArrayList)8 SoapBinding (org.apache.cxf.binding.soap.wsdl.extensions.SoapBinding)8 WSDLWriter (javax.wsdl.xml.WSDLWriter)7