Search in sources :

Example 46 with CorbaType

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

the class WSDLToIDLAction method createType.

protected IdlType createType(QName idlType, String[] name, CorbaType corbaType) throws Exception {
    if ("CORBA.Object".equals(idlType.getLocalPart())) {
        return IdlInterface.create(null, "Object");
    }
    CorbaType corbaTypeImpl = corbaType;
    if (corbaTypeImpl == null) {
        corbaTypeImpl = getCorbaType(idlType);
    }
    if (corbaTypeImpl == null) {
        String msgStr = "Type " + idlType.getLocalPart() + " not found.";
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
        throw new Exception(msg.toString());
    }
    IdlScopeBase scope = root;
    StringBuilder dotScopedName = new StringBuilder("");
    for (int i = 0; i < name.length - 1; ++i) {
        dotScopedName.append(name[i]);
        // name array.
        if ("CORBA".equals(dotScopedName.toString()) && name.length == 2 && i == 0 && "Object".equals(name[1])) {
            break;
        }
        IdlDefn idlDef = scope.lookup(name[i]);
        if (idlDef == null) {
            // Before creating module, check to see if a Corba type
            // represent this name aleady exists.
            // For example if type is a.b.c and we are about to create
            // module b, look to see if a.b
            // is an interface that needs to be processed
            QName qname = new QName(corbaTypeImpl.getType().getNamespaceURI(), dotScopedName.toString());
            // Check to see if CORBAType exists. If so, create type for it
            // otherwise
            // create module for this scope
            CorbaType possibleCorbaType = getCorbaType(qname);
            if (possibleCorbaType != null) {
                idlDef = findType(qname);
            }
            if (idlDef == null) {
                idlDef = IdlModule.create(scope, name[i]);
                scope.addToScope(idlDef);
            }
        }
        dotScopedName.append('.');
        scope = (IdlScopeBase) idlDef;
    }
    IdlType result;
    String local = name[name.length - 1];
    if (corbaTypeImpl instanceof Enum) {
        result = createEnum((Enum) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Sequence) {
        result = createSequence((Sequence) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Anonsequence) {
        result = createAnonSequence((Anonsequence) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof org.apache.cxf.binding.corba.wsdl.Exception) {
        result = createIdlException((org.apache.cxf.binding.corba.wsdl.Exception) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Struct) {
        result = createStruct((Struct) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Union) {
        result = createUnion((Union) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Alias) {
        result = createTypedef((Alias) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Array) {
        result = createArray((Array) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Anonarray) {
        result = createAnonArray((Anonarray) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Fixed) {
        result = createFixed((Fixed) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Anonfixed) {
        result = createAnonFixed((Anonfixed) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Const) {
        result = createConst((Const) corbaTypeImpl, scope, local);
    } else {
        result = checkAnon(corbaTypeImpl, scope, local);
    }
    if (result == null && corbaTypeImpl instanceof org.apache.cxf.binding.corba.wsdl.Object) {
        result = createInterface((org.apache.cxf.binding.corba.wsdl.Object) corbaTypeImpl, scope, local);
    }
    return result;
}
Also used : IdlEnum(org.apache.cxf.tools.corba.common.idltypes.IdlEnum) Enum(org.apache.cxf.binding.corba.wsdl.Enum) IdlString(org.apache.cxf.tools.corba.common.idltypes.IdlString) IdlType(org.apache.cxf.tools.corba.common.idltypes.IdlType) Union(org.apache.cxf.binding.corba.wsdl.Union) IdlUnion(org.apache.cxf.tools.corba.common.idltypes.IdlUnion) IdlStruct(org.apache.cxf.tools.corba.common.idltypes.IdlStruct) Struct(org.apache.cxf.binding.corba.wsdl.Struct) Anonarray(org.apache.cxf.binding.corba.wsdl.Anonarray) IdlFixed(org.apache.cxf.tools.corba.common.idltypes.IdlFixed) IdlAnonFixed(org.apache.cxf.tools.corba.common.idltypes.IdlAnonFixed) Fixed(org.apache.cxf.binding.corba.wsdl.Fixed) QName(javax.xml.namespace.QName) IdlDefn(org.apache.cxf.tools.corba.common.idltypes.IdlDefn) Const(org.apache.cxf.binding.corba.wsdl.Const) IdlConst(org.apache.cxf.tools.corba.common.idltypes.IdlConst) IdlScopeBase(org.apache.cxf.tools.corba.common.idltypes.IdlScopeBase) IdlAnonSequence(org.apache.cxf.tools.corba.common.idltypes.IdlAnonSequence) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) IdlSequence(org.apache.cxf.tools.corba.common.idltypes.IdlSequence) ToolException(org.apache.cxf.tools.common.ToolException) IdlException(org.apache.cxf.tools.corba.common.idltypes.IdlException) IdlAnonArray(org.apache.cxf.tools.corba.common.idltypes.IdlAnonArray) Array(org.apache.cxf.binding.corba.wsdl.Array) IdlArray(org.apache.cxf.tools.corba.common.idltypes.IdlArray) Anonfixed(org.apache.cxf.binding.corba.wsdl.Anonfixed) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) Alias(org.apache.cxf.binding.corba.wsdl.Alias) Anonsequence(org.apache.cxf.binding.corba.wsdl.Anonsequence)

Example 47 with CorbaType

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

the class WSDLParameter method getIdlType.

private static QName getIdlType(WSDLToCorbaBinding wsdlToCorbaBinding, XmlSchemaType schemaType, QName typeName, boolean nill) throws Exception {
    final QName idltype;
    if (schemaType == null) {
        CorbaType corbaTypeImpl = (CorbaType) WSDLToCorbaHelper.CORBAPRIMITIVEMAP.get(typeName);
        if (nill) {
            QName qname = corbaTypeImpl.getQName();
            idltype = wsdlToCorbaBinding.getHelper().createQNameCorbaNamespace(qname.getLocalPart() + "_nil");
        } else {
            if (corbaTypeImpl == null) {
                XmlSchemaObject schemaObj = getSchemaObject(wsdlToCorbaBinding, typeName);
                XmlSchemaAnnotation annotation = null;
                if (schemaObj instanceof XmlSchemaElement) {
                    XmlSchemaElement el = (XmlSchemaElement) schemaObj;
                    schemaType = el.getSchemaType();
                    annotation = ((XmlSchemaElement) schemaObj).getAnnotation();
                }
                idltype = getSchemaTypeName(wsdlToCorbaBinding, schemaType, annotation, typeName, nill);
            } else {
                idltype = corbaTypeImpl.getQName();
            }
        }
    } else {
        // We need to get annotation information for the schema type we are
        // about to pass in.
        // This is used to produce the correct object reference type.
        XmlSchemaElement schemaObj = getSchemaObject(wsdlToCorbaBinding, typeName);
        XmlSchemaAnnotation annotation = null;
        if (schemaObj != null) {
            annotation = schemaObj.getAnnotation();
        }
        idltype = getSchemaTypeName(wsdlToCorbaBinding, schemaType, annotation, typeName, nill);
    }
    return idltype;
}
Also used : XmlSchemaAnnotation(org.apache.ws.commons.schema.XmlSchemaAnnotation) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchemaObject(org.apache.ws.commons.schema.XmlSchemaObject) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement)

Example 48 with CorbaType

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

the class WSDLToCorbaHelper method processSequenceType.

protected CorbaType processSequenceType(XmlSchemaSequence seq, QName defaultName, QName schemaTypeName) throws Exception {
    final QName seqName;
    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);
    }
    CorbaType 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.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 49 with CorbaType

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

the class WSDLToCorbaHelper method processAllMember.

private MemberType processAllMember(XmlSchemaAll all, QName defaultName, QName schemaTypeName) throws Exception {
    CorbaType corbatype = processAllType(all, defaultName, schemaTypeName);
    MemberType member = new MemberType();
    member.setName(corbatype.getQName().getLocalPart());
    member.setIdltype(corbatype.getQName());
    if (corbatype.isSetQualified() && corbatype.isQualified()) {
        member.setQualified(true);
    }
    return member;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType)

Example 50 with CorbaType

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

the class WSDLToCorbaHelper method processSimpleContentStruct.

protected Struct processSimpleContentStruct(XmlSchemaSimpleContent simpleContent, QName defaultName, Struct corbaStruct, QName schematypeName) throws Exception {
    List<MemberType> attrMembers = null;
    CorbaType basetype = null;
    String uri;
    if (schematypeName != null) {
        uri = schematypeName.getNamespaceURI();
    } else {
        uri = defaultName.getNamespaceURI();
    }
    if (simpleContent.getContent() instanceof XmlSchemaSimpleContentExtension) {
        XmlSchemaSimpleContentExtension ext = (XmlSchemaSimpleContentExtension) simpleContent.getContent();
        if (ext.getBaseTypeName() != null) {
            basetype = processPrimitiveType(ext.getBaseTypeName());
        }
        if (basetype == null) {
            XmlSchemaType base = getSchemaType(ext.getBaseTypeName());
            basetype = convertSchemaToCorbaType(base, base.getQName(), base, null, false);
        }
        if (basetype == null) {
            return null;
        }
        // process ext types ????
        MemberType basemember = new MemberType();
        basemember.setName("_simpleTypeValue");
        QName baseTypeName = checkPrefix(basetype.getQName());
        basemember.setIdltype(baseTypeName);
        corbaStruct.getMember().add(basemember);
        if (!isDuplicate(basetype)) {
            typeMappingType.getStructOrExceptionOrUnion().add(basetype);
        }
        attrMembers = processAttributesAsMembers(ext.getAttributes(), uri);
    } else if (simpleContent.getContent() instanceof XmlSchemaSimpleContentRestriction) {
        XmlSchemaSimpleContentRestriction restrict = (XmlSchemaSimpleContentRestriction) simpleContent.getContent();
        if (restrict.getBaseTypeName() != null) {
            basetype = processPrimitiveType(restrict.getBaseTypeName());
        }
        if (basetype == null) {
            XmlSchemaType base = getSchemaType(restrict.getBaseTypeName());
            basetype = convertSchemaToCorbaType(base, base.getQName(), base, null, false);
        }
        MemberType basemember = new MemberType();
        basemember.setName("_simpleTypeValue");
        QName baseTypeName = checkPrefix(basetype.getQName());
        basemember.setIdltype(baseTypeName);
        corbaStruct.getMember().add(basemember);
        if (!isDuplicate(basetype)) {
            typeMappingType.getStructOrExceptionOrUnion().add(basetype);
        }
        attrMembers = processAttributesAsMembers(restrict.getAttributes(), uri);
    }
    // Deal with Attributes defined in Extension
    if (attrMembers != null) {
        for (int i = 0; i < attrMembers.size(); i++) {
            MemberType member = attrMembers.get(i);
            corbaStruct.getMember().add(member);
        }
    }
    return corbaStruct;
}
Also used : XmlSchemaSimpleContentExtension(org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) QName(javax.xml.namespace.QName) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) XmlSchemaSimpleContentRestriction(org.apache.ws.commons.schema.XmlSchemaSimpleContentRestriction)

Aggregations

CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)72 QName (javax.xml.namespace.QName)45 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)23 MemberType (org.apache.cxf.binding.corba.wsdl.MemberType)13 AST (antlr.collections.AST)9 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)9 TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)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