Search in sources :

Example 36 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class JavaScriptContainer method setNamespaceJavascriptPrefixes.

public void setNamespaceJavascriptPrefixes(ToolContext env) {
    Map<String, String> nsPrefixMap = new HashMap<>();
    if (env.get(ToolConstants.CFG_JSPACKAGEPREFIX) != null) {
        final String[] pns;
        try {
            pns = (String[]) env.get(ToolConstants.CFG_JSPACKAGEPREFIX);
        } catch (ClassCastException e) {
            Message msg = new Message("INVALID_PREFIX_MAPPING", LOG, env.get(ToolConstants.CFG_JSPACKAGEPREFIX));
            throw new ToolException(msg);
        }
        for (String jsprefix : pns) {
            int pos = jsprefix.indexOf('=');
            if (pos != -1) {
                String ns = jsprefix.substring(0, pos);
                jsprefix = jsprefix.substring(pos + 1);
                nsPrefixMap.put(ns, jsprefix);
            }
        }
        env.put(ToolConstants.CFG_JSPREFIXMAP, nsPrefixMap);
    }
}
Also used : Message(org.apache.cxf.common.i18n.Message) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ToolException(org.apache.cxf.tools.common.ToolException)

Example 37 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class JavaScriptContainer method validate.

public void validate(ToolContext env) throws ToolException {
    String outdir = (String) env.get(ToolConstants.CFG_OUTPUTDIR);
    if (outdir != null) {
        File dir = new File(outdir);
        if (!dir.exists() && !dir.mkdirs()) {
            Message msg = new Message("DIRECTORY_COULD_NOT_BE_CREATED", LOG, outdir);
            throw new ToolException(msg);
        }
        if (!dir.isDirectory()) {
            Message msg = new Message("NOT_A_DIRECTORY", LOG, outdir);
            throw new ToolException(msg);
        }
    }
    if (env.optionSet(ToolConstants.CFG_COMPILE)) {
        String clsdir = (String) env.get(ToolConstants.CFG_CLASSDIR);
        if (clsdir != null) {
            File dir = new File(clsdir);
            if (!dir.exists() && !dir.mkdirs()) {
                Message msg = new Message("DIRECTORY_COULD_NOT_BE_CREATED", LOG, clsdir);
                throw new ToolException(msg);
            }
        }
    }
    String wsdl = (String) env.get(ToolConstants.CFG_WSDLURL);
    if (StringUtils.isEmpty(wsdl)) {
        Message msg = new Message("NO_WSDL_URL", LOG);
        throw new ToolException(msg);
    }
    env.put(ToolConstants.CFG_WSDLURL, URIParserUtil.normalize(wsdl));
    String[] bindingFiles;
    try {
        bindingFiles = (String[]) env.get(ToolConstants.CFG_BINDING);
        if (bindingFiles == null) {
            return;
        }
    } catch (ClassCastException e) {
        bindingFiles = new String[1];
        bindingFiles[0] = (String) env.get(ToolConstants.CFG_BINDING);
    }
    for (int i = 0; i < bindingFiles.length; i++) {
        bindingFiles[i] = URIParserUtil.getAbsoluteURI(bindingFiles[i]);
    }
    env.put(ToolConstants.CFG_BINDING, bindingFiles);
}
Also used : Message(org.apache.cxf.common.i18n.Message) ToolException(org.apache.cxf.tools.common.ToolException) File(java.io.File)

Example 38 with Message

use of org.apache.cxf.common.i18n.Message 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));
    try (JarOutputStream jarout = new JarOutputStream(Files.newOutputStream(clientJarFile.toPath()), new Manifest())) {
        createClientJar(tmpDir, jarout);
    } 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 39 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class WSDLToJavaContainer method generateTypes.

public void generateTypes() throws ToolException {
    DataBindingProfile dataBindingProfile = context.get(DataBindingProfile.class);
    if (dataBindingProfile == null) {
        Message msg = new Message("FOUND_NO_DATABINDING", LOG);
        throw new ToolException(msg);
    }
    dataBindingProfile.initialize(context);
    if (passthrough()) {
        return;
    }
    dataBindingProfile.generate(context);
}
Also used : Message(org.apache.cxf.common.i18n.Message) DataBindingProfile(org.apache.cxf.tools.wsdlto.core.DataBindingProfile) ToolException(org.apache.cxf.tools.common.ToolException)

Example 40 with Message

use of org.apache.cxf.common.i18n.Message in project cxf by apache.

the class ParameterProcessor method processInput.

private void processInput(JavaMethod method, MessageInfo inputMessage) throws ToolException {
    if (requireOutOfBandHeader()) {
        try {
            Class.forName("org.apache.cxf.binding.soap.SoapBindingFactory");
        } catch (Exception e) {
            LOG.log(Level.WARNING, new Message("SOAP_MISSING", LOG).toString());
        }
    }
    JAXWSBinding mBinding = inputMessage.getOperation().getExtensor(JAXWSBinding.class);
    for (MessagePartInfo part : inputMessage.getMessageParts()) {
        if (isOutOfBandHeader(part) && !requireOutOfBandHeader()) {
            continue;
        }
        JavaParameter param = getParameterFromPart(method, part, JavaType.Style.IN);
        if (mBinding != null && mBinding.getJaxwsParas() != null) {
            for (JAXWSParameter jwp : mBinding.getJaxwsParas()) {
                if (part.getName().getLocalPart().equals(jwp.getPart())) {
                    param.setName(jwp.getName());
                }
            }
        }
        addParameter(part, method, param);
    }
}
Also used : Message(org.apache.cxf.common.i18n.Message) JAXWSParameter(org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSParameter) JavaParameter(org.apache.cxf.tools.common.model.JavaParameter) JAXWSBinding(org.apache.cxf.tools.wsdlto.frontend.jaxws.customization.JAXWSBinding) MessagePartInfo(org.apache.cxf.service.model.MessagePartInfo) ToolException(org.apache.cxf.tools.common.ToolException)

Aggregations

Message (org.apache.cxf.common.i18n.Message)201 ToolException (org.apache.cxf.tools.common.ToolException)69 IOException (java.io.IOException)45 QName (javax.xml.namespace.QName)42 Fault (org.apache.cxf.interceptor.Fault)34 XMLStreamException (javax.xml.stream.XMLStreamException)27 JAXBException (javax.xml.bind.JAXBException)23 ArrayList (java.util.ArrayList)19 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)17 Element (org.w3c.dom.Element)17 File (java.io.File)16 WSDLException (javax.wsdl.WSDLException)15 Method (java.lang.reflect.Method)14 SoapMessage (org.apache.cxf.binding.soap.SoapMessage)13 ServiceInfo (org.apache.cxf.service.model.ServiceInfo)12 InputStream (java.io.InputStream)11 HashMap (java.util.HashMap)11 List (java.util.List)11 Map (java.util.Map)11 ServiceConstructionException (org.apache.cxf.service.factory.ServiceConstructionException)11