Search in sources :

Example 46 with ToolException

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

the class Wrapper method isWrapperBeanClassNotExist.

public boolean isWrapperBeanClassNotExist() {
    try {
        Message msg = new Message("LOADING_WRAPPER_CLASS", LOG, getJavaClass().getFullClassName());
        LOG.log(Level.FINE, msg.toString());
        getWrapperClass();
        return false;
    } catch (ToolException e) {
        return true;
    }
}
Also used : Message(org.apache.cxf.common.i18n.Message) ToolException(org.apache.cxf.tools.common.ToolException)

Example 47 with ToolException

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

the class WSDLToJava method main.

public static void main(String[] pargs) {
    System.setProperty("org.apache.cxf.JDKBugHacks.defaultUsesCaches", "true");
    CommandInterfaceUtils.commandCommonMain();
    WSDLToJava w2j = new WSDLToJava(pargs);
    try {
        w2j.run(new ToolContext());
    } catch (ToolException ex) {
        System.err.println();
        System.err.println("WSDLToJava Error: " + ex.getMessage());
        System.err.println();
        if (w2j.isVerbose()) {
            ex.printStackTrace();
        }
        if (w2j.isExitOnFinish()) {
            System.exit(1);
        }
    } catch (Exception ex) {
        System.err.println("WSDLToJava Error: " + ex.getMessage());
        System.err.println();
        if (w2j.isVerbose()) {
            ex.printStackTrace();
        }
        if (w2j.isExitOnFinish()) {
            System.exit(1);
        }
    }
    if (w2j.isExitOnFinish()) {
        System.exit(0);
    }
}
Also used : ToolContext(org.apache.cxf.tools.common.ToolContext) ToolException(org.apache.cxf.tools.common.ToolException) ToolException(org.apache.cxf.tools.common.ToolException)

Example 48 with ToolException

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

the class WSDLToJavaContainer method processClientJar.

private void processClientJar(ToolContext context) {
    ClassCollector oldCollector = context.get(ClassCollector.class);
    ClassCollector newCollector = new ClassCollector();
    String oldClassDir = (String) context.get(ToolConstants.CFG_CLASSDIR);
    File tmpDir = FileUtils.createTmpDir();
    context.put(ToolConstants.CFG_CLASSDIR, tmpDir.getAbsolutePath());
    newCollector.setTypesClassNames(oldCollector.getTypesClassNames());
    newCollector.setSeiClassNames(oldCollector.getSeiClassNames());
    newCollector.setExceptionClassNames(oldCollector.getExceptionClassNames());
    newCollector.setServiceClassNames(oldCollector.getServiceClassNames());
    context.put(ClassCollector.class, newCollector);
    new ClassUtils().compile(context);
    generateLocalWSDL(context);
    File clientJarFile = new File((String) context.get(ToolConstants.CFG_OUTPUTDIR), (String) context.get(ToolConstants.CFG_CLIENT_JAR));
    JarOutputStream jarout = null;
    try {
        jarout = new JarOutputStream(Files.newOutputStream(clientJarFile.toPath()), new Manifest());
        createClientJar(tmpDir, jarout);
        jarout.close();
    } catch (Exception e) {
        LOG.log(Level.SEVERE, "FAILED_TO_CREAT_CLIENTJAR", e);
        Message msg = new Message("FAILED_TO_CREAT_CLIENTJAR", LOG);
        throw new ToolException(msg, e);
    }
    context.put(ToolConstants.CFG_CLASSDIR, oldClassDir);
    context.put(ClassCollector.class, oldCollector);
}
Also used : Message(org.apache.cxf.common.i18n.Message) ClassCollector(org.apache.cxf.tools.util.ClassCollector) JarOutputStream(java.util.jar.JarOutputStream) ToolException(org.apache.cxf.tools.common.ToolException) Manifest(java.util.jar.Manifest) File(java.io.File) ClassUtils(org.apache.cxf.tools.common.ClassUtils) BadUsageException(org.apache.cxf.tools.common.toolspec.parser.BadUsageException) IOException(java.io.IOException) ToolException(org.apache.cxf.tools.common.ToolException)

Example 49 with ToolException

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

the class WSDLToJavaContainer method validate.

public void validate(final ServiceInfo service) throws ToolException {
    for (ServiceValidator validator : getServiceValidators()) {
        service.setProperty(ToolContext.class.getName(), context);
        validator.setService(service);
        if (!validator.isValid()) {
            throw new ToolException(validator.getErrorMessage());
        }
    }
}
Also used : ServiceValidator(org.apache.cxf.tools.validator.ServiceValidator) ToolContext(org.apache.cxf.tools.common.ToolContext) ToolException(org.apache.cxf.tools.common.ToolException)

Example 50 with ToolException

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

the class WSDLToJavaContainer method execute.

public void execute() throws ToolException {
    if (hasInfoOption()) {
        return;
    }
    buildToolContext();
    boolean isWsdlList = context.optionSet(ToolConstants.CFG_WSDLLIST);
    if (isWsdlList) {
        BufferedReader reader = null;
        try {
            ToolContext initialContextState = context.makeCopy();
            String wsdlURL = (String) context.get(ToolConstants.CFG_WSDLURL);
            wsdlURL = URIParserUtil.getAbsoluteURI(wsdlURL);
            URL url = new URL(wsdlURL);
            InputStream is = (InputStream) url.getContent();
            reader = new BufferedReader(new InputStreamReader(is));
            String tempLine = null;
            while ((tempLine = reader.readLine()) != null) {
                ToolContext freshContext = initialContextState.makeCopy();
                freshContext.put(ToolConstants.CFG_WSDLURL, tempLine);
                setContext(freshContext);
                buildToolContext();
                processWsdl();
            }
            if (context.getErrorListener().getErrorCount() > 0) {
                context.getErrorListener().throwToolException();
            }
        } catch (IOException e) {
            throw new ToolException(e);
        } finally {
            try {
                if (reader != null) {
                    reader.close();
                }
            } catch (IOException e) {
                throw new ToolException(e);
            }
        }
    } else {
        processWsdl();
        if (context.getErrorListener().getErrorCount() > 0) {
            context.getErrorListener().throwToolException();
        }
    }
}
Also used : InputStreamReader(java.io.InputStreamReader) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) BufferedReader(java.io.BufferedReader) ToolContext(org.apache.cxf.tools.common.ToolContext) IOException(java.io.IOException) ToolException(org.apache.cxf.tools.common.ToolException) URL(java.net.URL)

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