Search in sources :

Example 1 with Anonarray

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

the class WSDLTypes method mapToArray.

public static CorbaType mapToArray(QName name, QName schematypeName, QName arrayType, QName elName, int bound, boolean anonymous) {
    CorbaType corbatype = null;
    if (!anonymous) {
        // Create an Array
        Array corbaArray = new Array();
        corbaArray.setName(name.getLocalPart());
        corbaArray.setType(schematypeName);
        corbaArray.setElemtype(arrayType);
        corbaArray.setElemname(elName);
        corbaArray.setBound(bound);
        corbaArray.setRepositoryID(WSDLToCorbaHelper.REPO_STRING + name.getLocalPart().replace('.', '/') + WSDLToCorbaHelper.IDL_VERSION);
        corbaArray.setQName(name);
        corbatype = corbaArray;
    } else {
        // Create an Anonymous Array
        Anonarray corbaArray = new Anonarray();
        corbaArray.setName(name.getLocalPart());
        corbaArray.setType(schematypeName);
        corbaArray.setElemtype(arrayType);
        corbaArray.setElemname(elName);
        corbaArray.setBound(bound);
        corbaArray.setQName(name);
        corbatype = corbaArray;
    }
    return corbatype;
}
Also used : Array(org.apache.cxf.binding.corba.wsdl.Array) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) Anonarray(org.apache.cxf.binding.corba.wsdl.Anonarray)

Example 2 with Anonarray

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

the class WSDLToCorbaBindingTest method assertMixedArraysMappingDifficultArrays.

/**
 * @param typeMap
 */
private void assertMixedArraysMappingDifficultArrays(CorbaTypeMap typeMap) {
    String corbaTm = "http://schemas.apache.org/idl/anon.idl/corba/typemap/";
    // p11 is unwrapped, so the same case as p9
    Array p11 = (Array) typeMap.getType("MixedArrayType.p11-anonymous-unwrapped-non-primitive-arrayArray");
    assertEquals(new QName("", "p11-anonymous-unwrapped-non-primitive-array"), p11.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p11-anonymous-unwrapped-non-primitive-array"), p11.getElemtype());
    assertFalse(p11.isQualified());
    assertFalse(p11.isWrapped());
    Struct p11item = (Struct) typeMap.getType("MixedArrayType.p11-anonymous-unwrapped-non-primitive-array");
    assertEquals(1, p11item.getMember().size());
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p11item.getMember().get(0).getIdltype());
    assertEquals("item", p11item.getMember().get(0).getName());
    Array p11q = (Array) typeMap.getType("MixedArrayType.p11-anonymous-unwrapped-non-primitive-array-qArray");
    assertEquals(new QName("http://schemas.apache.org/idltypes/anon.idl", "p11-anonymous-unwrapped-non-primitive-array-q"), p11q.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p11-anonymous-unwrapped-non-primitive-array-q"), p11q.getElemtype());
    assertTrue(p11q.isQualified());
    assertFalse(p11q.isWrapped());
    Struct p11qitem = (Struct) typeMap.getType("MixedArrayType.p11-anonymous-unwrapped-non-primitive-array-q");
    assertEquals(1, p11qitem.getMember().size());
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p11qitem.getMember().get(0).getIdltype());
    assertEquals("item", p11qitem.getMember().get(0).getName());
    // p12 us wrapped - see p10
    Anonarray p12 = (Anonarray) typeMap.getType("MixedArrayType.p12-anonymous-wrapped-non-primitive-arrayType");
    assertEquals(new QName("", "item"), p12.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p12-anonymous-wrapped-non-primitive-array.item"), p12.getElemtype());
    assertFalse(p12.isQualified());
    assertTrue(p12.isWrapped());
    Struct p12item = (Struct) typeMap.getType("MixedArrayType.p12-anonymous-wrapped-non-primitive-array.item");
    assertEquals(p12item.getMember().size(), 1);
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p12item.getMember().get(0).getIdltype());
    assertEquals("item", p12item.getMember().get(0).getName());
    assertFalse(p12item.getMember().get(0).isSetQualified());
    Anonarray p12q = (Anonarray) typeMap.getType("MixedArrayType.p12-anonymous-wrapped-non-primitive-array-qType");
    assertEquals(new QName("http://schemas.apache.org/idltypes/anon.idl", "item"), p12q.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p12-anonymous-wrapped-non-primitive-array-q.item"), p12q.getElemtype());
    assertTrue(p12q.isQualified());
    assertTrue(p12q.isWrapped());
    Struct p12qitem = (Struct) typeMap.getType("MixedArrayType.p12-anonymous-wrapped-non-primitive-array-q.item");
    assertEquals(p12qitem.getMember().size(), 1);
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p12qitem.getMember().get(0).getIdltype());
    assertEquals("item", p12qitem.getMember().get(0).getName());
    assertTrue(p12qitem.getMember().get(0).isQualified());
}
Also used : Array(org.apache.cxf.binding.corba.wsdl.Array) QName(javax.xml.namespace.QName) Anonarray(org.apache.cxf.binding.corba.wsdl.Anonarray) Struct(org.apache.cxf.binding.corba.wsdl.Struct)

Example 3 with Anonarray

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

the class WSDLToIDLAction method createType.

protected IdlType createType(QName idlType, String[] name, CorbaType corbaType) throws Exception {
    if (idlType.getLocalPart().equals("CORBA.Object")) {
        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 && name[1].equals("Object")) {
            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 = null;
    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) 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 4 with Anonarray

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

the class ArrayVisitor method generateCorbaAnonarray.

private Anonarray generateCorbaAnonarray(String name, Long size, CorbaType type, XmlSchemaType stype, Scope fQName) {
    Anonarray anonarray = new Anonarray();
    anonarray.setQName(new QName(typeMap.getTargetNamespace(), name));
    anonarray.setBound(size);
    anonarray.setType(stype.getQName());
    // REVISIT, if we add qualification option, then change below.
    anonarray.setElemname(new QName("", ELEMENT_NAME));
    if (type != null) {
        anonarray.setElemtype(type.getQName());
    } else {
        ArrayDeferredAction anonarrayAction = new ArrayDeferredAction(anonarray);
        wsdlVisitor.getDeferredActions().add(fQName, anonarrayAction);
    }
    return anonarray;
}
Also used : QName(javax.xml.namespace.QName) Anonarray(org.apache.cxf.binding.corba.wsdl.Anonarray)

Example 5 with Anonarray

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

the class CorbaHandlerUtils method initializeArrayHandler.

public static void initializeArrayHandler(ORB orb, CorbaObjectHandler obj, CorbaTypeMap typeMap, ServiceInfo serviceInfo, Map<QName, CorbaObjectHandler> seenTypes) {
    QName arrayElementType = null;
    long arrayBound = 0;
    CorbaType baseType = obj.getType();
    QName elementName;
    if (baseType instanceof Array) {
        Array arrayType = (Array) baseType;
        arrayElementType = arrayType.getElemtype();
        arrayBound = arrayType.getBound();
        elementName = arrayType.getElemname();
    } else {
        Anonarray anonArrayType = (Anonarray) baseType;
        arrayElementType = anonArrayType.getElemtype();
        arrayBound = anonArrayType.getBound();
        elementName = anonArrayType.getElemname();
    }
    for (int i = 0; i < arrayBound; ++i) {
        CorbaObjectHandler elementObj = initializeObjectHandler(orb, elementName, arrayElementType, typeMap, serviceInfo, seenTypes);
        ((CorbaArrayHandler) obj).addElement(elementObj);
    }
}
Also used : Array(org.apache.cxf.binding.corba.wsdl.Array) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) Anonarray(org.apache.cxf.binding.corba.wsdl.Anonarray)

Aggregations

Anonarray (org.apache.cxf.binding.corba.wsdl.Anonarray)8 Array (org.apache.cxf.binding.corba.wsdl.Array)6 QName (javax.xml.namespace.QName)5 Anonsequence (org.apache.cxf.binding.corba.wsdl.Anonsequence)4 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)4 Anonfixed (org.apache.cxf.binding.corba.wsdl.Anonfixed)2 Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)2 Struct (org.apache.cxf.binding.corba.wsdl.Struct)2 File (java.io.File)1 HashMap (java.util.HashMap)1 Definition (javax.wsdl.Definition)1 Alias (org.apache.cxf.binding.corba.wsdl.Alias)1 Anonstring (org.apache.cxf.binding.corba.wsdl.Anonstring)1 Anonwstring (org.apache.cxf.binding.corba.wsdl.Anonwstring)1 Const (org.apache.cxf.binding.corba.wsdl.Const)1 Enum (org.apache.cxf.binding.corba.wsdl.Enum)1 Fixed (org.apache.cxf.binding.corba.wsdl.Fixed)1 TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)1 Union (org.apache.cxf.binding.corba.wsdl.Union)1 IdlAnonArray (org.apache.cxf.tools.corba.common.idltypes.IdlAnonArray)1