Search in sources :

Example 16 with MemberType

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

the class StructVisitor method visitStructMembers.

private void visitStructMembers(AST identifierNode, Struct struct, XmlSchemaSequence sequence, Scope structScope) {
    AST memberTypeNode = identifierNode.getNextSibling();
    while (memberTypeNode != null) {
        AST memberNode = TypesUtils.getCorbaTypeNameNode(memberTypeNode);
        XmlSchemaType schemaType = null;
        CorbaType corbaType = null;
        Scope fqName = null;
        try {
            TypesVisitor visitor = new TypesVisitor(structScope, definition, schema, wsdlVisitor, null);
            visitor.visit(memberTypeNode);
            schemaType = visitor.getSchemaType();
            corbaType = visitor.getCorbaType();
            fqName = visitor.getFullyQualifiedName();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
        // (hence the ScopedNameVisitor.accept() call).
        while (memberNode != null && memberNode.getType() == IDLTokenTypes.IDENT && !ScopedNameVisitor.accept(structScope, definition, schema, memberNode, wsdlVisitor, true)) {
            XmlSchemaType memberSchemaType = schemaType;
            CorbaType memberCorbaType = corbaType;
            // needed for anonymous arrays in structs
            if (ArrayVisitor.accept(memberNode)) {
                Scope anonScope = new Scope(structScope, TypesUtils.getCorbaTypeNameNode(memberTypeNode));
                ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope, definition, schema, wsdlVisitor, null, fqName);
                arrayVisitor.setSchemaType(schemaType);
                arrayVisitor.setCorbaType(corbaType);
                arrayVisitor.visit(memberNode);
                memberSchemaType = arrayVisitor.getSchemaType();
                memberCorbaType = arrayVisitor.getCorbaType();
                fqName = arrayVisitor.getFullyQualifiedName();
            }
            XmlSchemaElement member = createXmlSchemaElement(memberNode, memberSchemaType, fqName);
            sequence.getItems().add(member);
            MemberType memberType = createMemberType(memberNode, memberCorbaType, fqName);
            struct.getMember().add(memberType);
            memberNode = memberNode.getNextSibling();
        }
        memberTypeNode = memberNode;
    }
}
Also used : AST(antlr.collections.AST) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 17 with MemberType

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

the class WSDLToCorbaBinding method convertFaultToCorbaType.

private CorbaType convertFaultToCorbaType(XmlSchema xmlSchema, Fault fault) throws Exception {
    org.apache.cxf.binding.corba.wsdl.Exception corbaex = null;
    XmlSchemaType schemaType = null;
    Iterator<Part> parts = CastUtils.cast(fault.getMessage().getParts().values().iterator());
    if (!parts.hasNext()) {
        String msgStr = "Fault " + fault.getMessage().getQName().getLocalPart() + " UNSUPPORTED_FAULT.";
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
        throw new Exception(msg.toString());
    }
    Part part = parts.next();
    schemaType = helper.lookUpType(part);
    if (schemaType != null) {
        QName name = schemaType.getQName();
        if (name == null) {
            name = part.getElementName();
        }
        if (!helper.isSchemaTypeException(schemaType)) {
            corbaex = new org.apache.cxf.binding.corba.wsdl.Exception();
            String faultName = fault.getMessage().getQName().getLocalPart();
            int pos = faultName.indexOf("_exception.");
            if (pos != -1) {
                faultName = faultName.substring(pos + 11);
                faultName = faultName + "Exception";
            }
            QName faultMsgName = helper.createQNameCorbaNamespace(faultName);
            corbaex.setName(faultName);
            corbaex.setQName(faultMsgName);
            CorbaType corbaTypeImpl = helper.convertSchemaToCorbaType(schemaType, name, null, null, false);
            if (corbaTypeImpl != null) {
                MemberType member = new MemberType();
                member.setName(corbaTypeImpl.getQName().getLocalPart());
                member.setIdltype(corbaTypeImpl.getQName());
                if (corbaTypeImpl.isSetQualified() && corbaTypeImpl.isQualified()) {
                    member.setQualified(true);
                }
                corbaex.getMember().add(member);
            }
        } else {
            corbaex = createCorbaException(name, schemaType);
        }
    }
    if (schemaType == null) {
        String msgStr = "Fault " + fault.getMessage().getQName().getLocalPart() + " INCORRECT_FAULT_MSG.";
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
        throw new Exception(msg.toString());
    }
    if (corbaex == null) {
        String msgStr = "Fault " + fault.getMessage().getQName().getLocalPart() + " UNSUPPORTED_FAULT.";
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
        throw new Exception(msg.toString());
    }
    // Set the repository ID for Exception
    // add to CorbaTypeMapping
    String repoId = WSDLToCorbaHelper.REPO_STRING + corbaex.getName().replace('.', '/') + WSDLToCorbaHelper.IDL_VERSION;
    corbaex.setRepositoryID(repoId);
    CorbaType corbaTypeImpl = corbaex;
    if (!helper.isDuplicate(corbaTypeImpl)) {
        CorbaType dup = helper.isDuplicateException(corbaTypeImpl);
        if (dup != null) {
            typeMappingType.getStructOrExceptionOrUnion().remove(dup);
            typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
        } else {
            typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
        }
    }
    return corbaex;
}
Also used : QName(javax.xml.namespace.QName) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) WSDLException(javax.wsdl.WSDLException) ToolException(org.apache.cxf.tools.common.ToolException) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) Part(javax.wsdl.Part)

Example 18 with MemberType

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

the class WSDLToCorbaBinding method createCorbaException.

private org.apache.cxf.binding.corba.wsdl.Exception createCorbaException(QName schemaTypeName, XmlSchemaType stype) throws Exception {
    org.apache.cxf.binding.corba.wsdl.Exception corbaex = null;
    XmlSchemaComplexType complex = null;
    if (stype instanceof XmlSchemaComplexType) {
        QName defaultName = schemaTypeName;
        complex = (XmlSchemaComplexType) stype;
        corbaex = new org.apache.cxf.binding.corba.wsdl.Exception();
        corbaex.setQName(schemaTypeName);
        corbaex.setType(helper.checkPrefix(schemaTypeName));
        corbaex.setName(schemaTypeName.getLocalPart());
        corbaex.setRepositoryID(WSDLToCorbaHelper.REPO_STRING + "/" + defaultName.getLocalPart() + WSDLToCorbaHelper.IDL_VERSION);
        String uri = defaultName.getNamespaceURI();
        List<MemberType> attributeMembers = helper.processAttributesAsMembers(complex.getAttributes(), uri);
        for (MemberType memberType : attributeMembers) {
            corbaex.getMember().add(memberType);
        }
        List<MemberType> members = helper.processContainerAsMembers(complex.getParticle(), stype.getQName(), defaultName);
        for (MemberType memberType : members) {
            corbaex.getMember().add(memberType);
        }
    }
    return corbaex;
}
Also used : MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) QName(javax.xml.namespace.QName) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType)

Example 19 with MemberType

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

the class WSDLToCorbaHelper method processSequenceType.

protected CorbaType processSequenceType(XmlSchemaSequence seq, QName defaultName, QName schemaTypeName) throws Exception {
    CorbaType type = null;
    QName seqName = null;
    if (schemaTypeName == null) {
        seqName = createQNameCorbaNamespace(defaultName.getLocalPart() + "SequenceStruct");
    } else {
        seqName = createQNameCorbaNamespace(schemaTypeName.getLocalPart() + "SequenceStruct");
    }
    schemaTypeName = checkPrefix(schemaTypeName);
    Struct struct = new Struct();
    struct.setName(seqName.getLocalPart());
    struct.setQName(seqName);
    struct.setRepositoryID(REPO_STRING + seqName.getLocalPart().replace('.', '/') + IDL_VERSION);
    struct.setType(schemaTypeName);
    List<MemberType> members = processContainerAsMembers(seq, defaultName, schemaTypeName);
    for (MemberType memberType : members) {
        struct.getMember().add(memberType);
    }
    type = struct;
    if (seq.getMaxOccurs() != 1 || seq.getMinOccurs() != 1) {
        QName name = createQNameTargetNamespace(type.getQName().getLocalPart() + "Array");
        CorbaType atype = createArray(name, type.getQName(), type.getQName(), seq.getMaxOccurs(), seq.getMinOccurs(), false);
        if (atype != null && !isDuplicate(atype)) {
            typeMappingType.getStructOrExceptionOrUnion().add(atype);
        }
    }
    if ((struct != null) && (struct.getMember().isEmpty())) {
        String msgStr = "Cannot create CORBA Struct" + struct.getName() + "from container with no members";
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
        throw new Exception(msg.toString());
    }
    return type;
}
Also used : QName(javax.xml.namespace.QName) Struct(org.apache.cxf.binding.corba.wsdl.Struct) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType)

Example 20 with MemberType

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

the class WSDLToCorbaHelper method processComplexContentStructChoice.

protected MemberType processComplexContentStructChoice(XmlSchemaChoice choice, QName schematypeName, QName defaultName) throws Exception {
    QName choicename = createQNameTargetNamespace(schematypeName.getLocalPart() + "ChoiceType");
    Union choiceunion = createUnion(choicename, choice, defaultName, schematypeName);
    MemberType choicemem = new MemberType();
    if (choiceunion != null) {
        String repoId = REPO_STRING + choiceunion.getQName().getLocalPart().replace('.', '/') + IDL_VERSION;
        choiceunion.setRepositoryID(repoId);
        choicemem.setName(choiceunion.getQName().getLocalPart() + "_f");
        choicemem.setIdltype(createQNameCorbaNamespace(choiceunion.getQName().getLocalPart()));
        if (!isDuplicate(choiceunion)) {
            typeMappingType.getStructOrExceptionOrUnion().add(choiceunion);
        }
    }
    return choicemem;
}
Also used : MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) QName(javax.xml.namespace.QName) Union(org.apache.cxf.binding.corba.wsdl.Union)

Aggregations

MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)32 QName (javax.xml.namespace.QName)23 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)13 Struct (org.apache.cxf.binding.corba.wsdl.Struct)9 StructMember (org.omg.CORBA.StructMember)6 TypeCode (org.omg.CORBA.TypeCode)6 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)4 CorbaPrimitiveHandler (org.apache.cxf.binding.corba.types.CorbaPrimitiveHandler)4 Exception (org.apache.cxf.binding.corba.wsdl.Exception)4 Union (org.apache.cxf.binding.corba.wsdl.Union)4 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)4 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)4 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)4 InputStream (org.omg.CORBA.portable.InputStream)4 OutputStream (org.omg.CORBA.portable.OutputStream)4 XmlSchemaChoice (org.apache.ws.commons.schema.XmlSchemaChoice)3 AST (antlr.collections.AST)2 IOException (java.io.IOException)2 CorbaBindingException (org.apache.cxf.binding.corba.CorbaBindingException)2