Search in sources :

Example 1 with XmlSchemaAnnotationItem

use of org.apache.ws.commons.schema.XmlSchemaAnnotationItem in project cxf by apache.

the class WSDLToCorbaBinding method addCorbaElements.

private void addCorbaElements(CorbaType corbaTypeImpl, XmlSchema xmlSchemaTypes) throws Exception {
    Map<QName, XmlSchemaElement> elements = xmlSchemaTypes.getElements();
    for (XmlSchemaElement el : elements.values()) {
        QName elName = el.getQName();
        XmlSchemaType schemaType = el.getSchemaType();
        if (elName == null) {
            elName = el.getRef().getTargetQName();
            schemaType = helper.getSchemaType(elName);
        }
        boolean anonymous = false;
        if (schemaType == null) {
            anonymous = true;
        } else {
            anonymous = WSDLTypes.isAnonymous(schemaType.getName());
        }
        if (schemaType != null) {
            XmlSchemaAnnotation annotation = null;
            if (el.getAnnotation() != null) {
                annotation = el.getAnnotation();
            }
            // this situation won't be handled. REVISIT.
            if (annotation != null) {
                XmlSchemaAppInfo appInfo = null;
                for (XmlSchemaAnnotationItem ann : annotation.getItems()) {
                    if (ann instanceof XmlSchemaAppInfo) {
                        appInfo = (XmlSchemaAppInfo) ann;
                        break;
                    }
                }
                if (appInfo != null) {
                    NodeList nlist = appInfo.getMarkup();
                    Node node = nlist.item(0);
                    String info = node.getNodeValue();
                    info = info.trim();
                    String annotationBindingName = "";
                    if ("corba:binding=".equals(info.substring(0, 14))) {
                        annotationBindingName = info.substring(14);
                    }
                    if (bindingName.equals(annotationBindingName)) {
                        annotation = null;
                    }
                }
            }
            corbaTypeImpl = helper.convertSchemaToCorbaType(schemaType, elName, schemaType, annotation, anonymous);
            if (el.isNillable()) {
                QName uname = helper.createQNameCorbaNamespace(corbaTypeImpl.getQName().getLocalPart() + "_nil");
                boolean isQualified = corbaTypeImpl.isSetQualified() && corbaTypeImpl.isQualified();
                corbaTypeImpl = helper.createNillableUnion(uname, helper.checkPrefix(elName), helper.checkPrefix(corbaTypeImpl.getQName()), isQualified);
            }
            if (corbaTypeImpl != null && !helper.isDuplicate(corbaTypeImpl)) {
                typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
            }
        }
    }
}
Also used : XmlSchemaAnnotationItem(org.apache.ws.commons.schema.XmlSchemaAnnotationItem) XmlSchemaAnnotation(org.apache.ws.commons.schema.XmlSchemaAnnotation) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaAppInfo(org.apache.ws.commons.schema.XmlSchemaAppInfo)

Example 2 with XmlSchemaAnnotationItem

use of org.apache.ws.commons.schema.XmlSchemaAnnotationItem in project cxf by apache.

the class WSDLTypes method processObject.

public static CorbaType processObject(Definition definition, XmlSchemaComplexType complex, XmlSchemaAnnotation annotation, QName typeName, QName defaultName, String idlNamespace) throws Exception {
    CorbaType corbaTypeImpl = null;
    if (annotation != null) {
        for (XmlSchemaAnnotationItem item : annotation.getItems()) {
            XmlSchemaAppInfo appInfo = (XmlSchemaAppInfo) item;
            if (appInfo != null) {
                NodeList nlist = appInfo.getMarkup();
                Node node = nlist.item(0);
                String info = node.getNodeValue();
                info = info.trim();
                if ("corba:binding=".equals(info.substring(0, 14))) {
                    String bindingName = info.substring(14);
                    QName bqname = new QName(definition.getTargetNamespace(), bindingName);
                    // Check if the Binding with name already exists
                    Binding binding = null;
                    if (WSDLToCorbaHelper.queryBinding(definition, bqname)) {
                        binding = definition.getBinding(bqname);
                    }
                    if (binding != null) {
                        org.apache.cxf.binding.corba.wsdl.Object obj = new org.apache.cxf.binding.corba.wsdl.Object();
                        PortType portT = binding.getPortType();
                        QName name = new QName(idlNamespace, portT.getQName().getLocalPart(), definition.getPrefix(idlNamespace));
                        obj.setName(name.getLocalPart());
                        obj.setQName(name);
                        QName bName = binding.getQName();
                        obj.setBinding(bName);
                        // get the repository id of the binding.
                        String repId = null;
                        Iterator<?> bindIter = binding.getExtensibilityElements().iterator();
                        while (bindIter.hasNext()) {
                            BindingType type = (BindingType) bindIter.next();
                            repId = type.getRepositoryID();
                        }
                        obj.setRepositoryID(repId);
                        obj.setType(typeName);
                        corbaTypeImpl = obj;
                    } else {
                        // if (isVerboseOn()) {
                        System.out.println("Could not find binding for: " + bqname);
                    // }
                    }
                }
            }
        }
    }
    if (corbaTypeImpl == null) {
        org.apache.cxf.binding.corba.wsdl.Object obj = new org.apache.cxf.binding.corba.wsdl.Object();
        QName name = new QName(idlNamespace, "CORBA.Object", definition.getPrefix(idlNamespace));
        obj.setName(name.getLocalPart());
        obj.setQName(name);
        obj.setRepositoryID("IDL:omg.org/CORBA/Object/1.0");
        obj.setType(typeName);
        corbaTypeImpl = obj;
    }
    return corbaTypeImpl;
}
Also used : Binding(javax.wsdl.Binding) QName(javax.xml.namespace.QName) NodeList(org.w3c.dom.NodeList) Node(org.w3c.dom.Node) XmlSchemaAnnotationItem(org.apache.ws.commons.schema.XmlSchemaAnnotationItem) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) BindingType(org.apache.cxf.binding.corba.wsdl.BindingType) XmlSchemaAppInfo(org.apache.ws.commons.schema.XmlSchemaAppInfo) PortType(javax.wsdl.PortType)

Aggregations

QName (javax.xml.namespace.QName)2 XmlSchemaAnnotationItem (org.apache.ws.commons.schema.XmlSchemaAnnotationItem)2 XmlSchemaAppInfo (org.apache.ws.commons.schema.XmlSchemaAppInfo)2 Node (org.w3c.dom.Node)2 NodeList (org.w3c.dom.NodeList)2 Binding (javax.wsdl.Binding)1 PortType (javax.wsdl.PortType)1 BindingType (org.apache.cxf.binding.corba.wsdl.BindingType)1 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)1 XmlSchemaAnnotation (org.apache.ws.commons.schema.XmlSchemaAnnotation)1 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)1 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)1