Search in sources :

Example 16 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class WSDLToCorbaHelper method processSimpleType.

private CorbaType processSimpleType(XmlSchemaSimpleType stype, QName defaultName, boolean anonymous) throws Exception {
    CorbaType corbaTypeImpl = null;
    QName name;
    QName schematypeName = null;
    if (stype.getQName() == null) {
        schematypeName = defaultName;
        name = createQNameTargetNamespace(defaultName.getLocalPart() + "Type");
    } else {
        schematypeName = checkPrefix(stype.getQName());
        if (schematypeName == null) {
            schematypeName = stype.getQName();
        }
        name = createQNameCorbaNamespace(schematypeName.getLocalPart());
    }
    if (stype.getParent().getTargetNamespace().equals(W3CConstants.NU_SCHEMA_XSD)) {
        // built in types
        QName stypeName = createQNameXmlSchemaNamespace(stype.getName());
        corbaTypeImpl = getLocalType(stypeName);
    } else if (stype.getContent() instanceof XmlSchemaSimpleTypeRestriction) {
        corbaTypeImpl = processSimpleRestrictionType(stype, name, schematypeName, anonymous);
    } else if (stype.getContent() instanceof XmlSchemaSimpleTypeList) {
        XmlSchemaSimpleTypeList ltype = (XmlSchemaSimpleTypeList) stype.getContent();
        CorbaType itemType = null;
        if (ltype.getItemType() != null) {
            itemType = convertSchemaToCorbaType(ltype.getItemType(), name, stype, null, false);
            if (itemType != null) {
                return WSDLTypes.mapToSequence(name, checkPrefix(schematypeName), itemType.getQName(), null, 0, false);
            }
            return itemType;
        }
        QName ltypeName = createQNameXmlSchemaNamespace(ltype.getItemTypeName().getLocalPart());
        itemType = processPrimitiveType(ltypeName);
        if (itemType != null) {
            return WSDLTypes.mapToSequence(name, checkPrefix(schematypeName), itemType.getQName(), null, 0, false);
        }
        // if the type of the simpleContent is a list with another simple type.
        XmlSchemaType base = getSchemaType(ltype.getItemTypeName());
        itemType = convertSchemaToCorbaType(base, base.getQName(), base, null, false);
        if (itemType != null) {
            return WSDLTypes.mapToSequence(name, checkPrefix(schematypeName), itemType.getQName(), null, 0, false);
        }
    } else if (stype.getContent() == null) {
        // elements primitive type
        QName stypeName = createQNameXmlSchemaNamespace(stype.getName());
        corbaTypeImpl = getLocalType(stypeName);
    } else {
        System.out.println("SimpleType Union Not Supported in CORBA Binding");
    }
    return corbaTypeImpl;
}
Also used : XmlSchemaSimpleTypeList(org.apache.ws.commons.schema.XmlSchemaSimpleTypeList) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) XmlSchemaSimpleTypeRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 17 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class WSDLToCorbaHelper method isDuplicate.

protected boolean isDuplicate(CorbaType corbaTypeImpl) {
    String corbaName = corbaTypeImpl.getName();
    QName corbaType = corbaTypeImpl.getType();
    QName primName = createQNameXmlSchemaNamespace(corbaName);
    if ((CorbaType) CORBAPRIMITIVEMAP.get(primName) != null) {
        return true;
    }
    if (!typeMappingType.getStructOrExceptionOrUnion().isEmpty()) {
        Iterator<CorbaType> i = typeMappingType.getStructOrExceptionOrUnion().iterator();
        while (i.hasNext()) {
            CorbaType type = i.next();
            if ((corbaName != null) && type.getType() != null && corbaType != null && (corbaName.equals(type.getName())) && (corbaType.getLocalPart().equals(type.getType().getLocalPart())) && (corbaTypeImpl.getClass().getName().equals(type.getClass().getName()))) {
                return true;
            }
        }
    }
    return false;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName)

Example 18 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class WSDLToCorbaHelper method processAttributesAsMembers.

protected List<MemberType> processAttributesAsMembers(List<XmlSchemaAttributeOrGroupRef> list, String uri) throws Exception {
    QName memName = null;
    List<MemberType> members = new ArrayList<>();
    for (XmlSchemaAttributeOrGroupRef aog : list) {
        if (!(aog instanceof XmlSchemaAttribute)) {
            LOG.warning(aog.getClass() + " not supported in CORBA binding.  Skipping.");
            continue;
        }
        XmlSchemaAttribute attribute = (XmlSchemaAttribute) aog;
        QName attrName = attribute.getQName();
        if (attrName.getNamespaceURI().equals("")) {
            attrName = new QName(uri, attrName.getLocalPart());
        }
        CorbaType membertype = null;
        boolean attrQualified = getAttributeQualification(attribute, uri);
        if (attribute.getUse() == XmlSchemaUse.NONE || attribute.getUse() == XmlSchemaUse.OPTIONAL) {
            CorbaType attType = null;
            if (attribute.getSchemaType() != null) {
                // REVISIT, edell bug in XmlSchema 1.2.
                // https://issues.apache.org/jira/browse/WSCOMMONS-208
                attType = convertSchemaToCorbaType(attribute.getSchemaType(), checkPrefix(attrName), attribute.getSchemaType(), null, true);
                if (attType != null) {
                    QName typeName = attType.getQName();
                    if (!isDuplicate(attType)) {
                        typeMappingType.getStructOrExceptionOrUnion().add(attType);
                    }
                    QName name = createQNameTargetNamespace(typeName.getLocalPart() + "_nil");
                    membertype = createNillableUnion(name, checkPrefix(attrName), createQNameCorbaNamespace(typeName.getLocalPart()), attrQualified);
                }
            } else {
                attType = processPrimitiveType(attribute.getSchemaTypeName());
                // {http://www.w3.org/2005/08/addressing}RelationshipTypeOpenEnum
                if (attType != null) {
                    QName name = createQNameTargetNamespace(attType.getQName().getLocalPart() + "_nil");
                    // REVISIT, Edell - bug in Xmlschema 1.2
                    // https://issues.apache.org/jira/browse/WSCOMMONS-208
                    membertype = createNillableUnion(name, checkPrefix(attrName), attType.getQName(), attrQualified);
                }
            }
            if (membertype != null) {
                memName = createQNameCorbaNamespace(membertype.getQName().getLocalPart());
                if (!isDuplicate(membertype)) {
                    typeMappingType.getStructOrExceptionOrUnion().add(membertype);
                }
            }
        } else {
            if (attribute.getSchemaType() != null) {
                membertype = convertSchemaToCorbaType(attribute.getSchemaType(), attrName, attribute.getSchemaType(), null, false);
            } else {
                membertype = processPrimitiveType(attribute.getSchemaTypeName());
            }
        }
        if (membertype != null) {
            MemberType member;
            String memberName = attrName.getLocalPart();
            member = new MemberType();
            member.setName(memberName);
            if (memName != null) {
                member.setIdltype(memName);
            } else {
                member.setIdltype(membertype.getQName());
            }
            if (attrQualified) {
                member.setQualified(true);
            }
            members.add(member);
        } else {
            String msg = "Unsupported Attribute Found in CORBA Binding Generation:" + attrName;
            LOG.log(Level.WARNING, msg);
        }
    }
    return members;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) XmlSchemaAttribute(org.apache.ws.commons.schema.XmlSchemaAttribute) XmlSchemaAttributeOrGroupRef(org.apache.ws.commons.schema.XmlSchemaAttributeOrGroupRef)

Example 19 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.

the class WSDLToCorbaHelper method processContainerAsMembers.

protected List<MemberType> processContainerAsMembers(XmlSchemaParticle particle, QName defaultName, QName schemaTypeName) throws Exception {
    List<MemberType> members = new ArrayList<>();
    Iterator<? extends XmlSchemaObjectBase> iterL = null;
    if (particle instanceof XmlSchemaSequence) {
        XmlSchemaSequence scontainer = (XmlSchemaSequence) particle;
        iterL = scontainer.getItems().iterator();
    } else if (particle instanceof XmlSchemaChoice) {
        XmlSchemaChoice scontainer = (XmlSchemaChoice) particle;
        iterL = scontainer.getItems().iterator();
    } else if (particle instanceof XmlSchemaAll) {
        XmlSchemaAll acontainer = (XmlSchemaAll) particle;
        iterL = acontainer.getItems().iterator();
    } else {
        LOG.warning("Unknown particle type " + particle.getClass().getName());
        iterL = new ArrayList<XmlSchemaObjectBase>().iterator();
    }
    while (iterL.hasNext()) {
        XmlSchemaParticle container = (XmlSchemaParticle) iterL.next();
        if (container instanceof XmlSchemaSequence) {
            XmlSchemaSequence sequence = (XmlSchemaSequence) container;
            CorbaType memberType = processSequenceType(sequence, defaultName, schemaTypeName);
            QName typeName = memberType.getQName();
            if (memberType instanceof Struct && !isDuplicate(memberType)) {
                typeMappingType.getStructOrExceptionOrUnion().add(memberType);
            }
            MemberType member = new MemberType();
            member.setName(memberType.getName() + "_f");
            member.setIdltype(typeName);
            member.setAnonschematype(true);
            if (memberType.isSetQualified() && memberType.isQualified()) {
                member.setQualified(true);
            }
            members.add(member);
        } else if (container instanceof XmlSchemaChoice) {
            XmlSchemaChoice choice = (XmlSchemaChoice) container;
            MemberType member = processChoiceMember(choice, defaultName, schemaTypeName);
            member.setAnonschematype(true);
            members.add(member);
        } else if (container instanceof XmlSchemaAll) {
            XmlSchemaAll all = (XmlSchemaAll) container;
            MemberType member = processAllMember(all, defaultName, schemaTypeName);
            member.setAnonschematype(true);
            members.add(member);
        } else if (container instanceof XmlSchemaElement) {
            XmlSchemaElement element = (XmlSchemaElement) container;
            CorbaType corbatype = processLocalElement(defaultName, element, schemaTypeName.getNamespaceURI());
            QName elName = element.getQName();
            if (elName == null) {
                elName = element.getRef().getTargetQName();
            }
            if (corbatype != null) {
                MemberType member;
                String memberName = elName.getLocalPart();
                member = new MemberType();
                member.setName(memberName);
                member.setIdltype(corbatype.getQName());
                if (corbatype.isSetQualified() && corbatype.isQualified()) {
                    member.setQualified(true);
                }
                members.add(member);
            } else {
                LOG.log(Level.WARNING, "Unsupported Element Found in CORBA Binding Generation:" + elName);
            }
        }
    }
    return members;
}
Also used : QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) ArrayList(java.util.ArrayList) XmlSchemaParticle(org.apache.ws.commons.schema.XmlSchemaParticle) Struct(org.apache.cxf.binding.corba.wsdl.Struct) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) XmlSchemaAll(org.apache.ws.commons.schema.XmlSchemaAll) XmlSchemaChoice(org.apache.ws.commons.schema.XmlSchemaChoice)

Example 20 with CorbaType

use of org.apache.cxf.binding.corba.wsdl.CorbaType 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

CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)71 QName (javax.xml.namespace.QName)44 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)22 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)13 AST (antlr.collections.AST)9 TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)8 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)8 Test (org.junit.Test)8 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)7 Alias (org.apache.cxf.binding.corba.wsdl.Alias)6 Anonsequence (org.apache.cxf.binding.corba.wsdl.Anonsequence)6 Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)6 Struct (org.apache.cxf.binding.corba.wsdl.Struct)6 Union (org.apache.cxf.binding.corba.wsdl.Union)6 File (java.io.File)5 Definition (javax.wsdl.Definition)5 ArrayList (java.util.ArrayList)4 Anonarray (org.apache.cxf.binding.corba.wsdl.Anonarray)4 Anonstring (org.apache.cxf.binding.corba.wsdl.Anonstring)4 Array (org.apache.cxf.binding.corba.wsdl.Array)4