Search in sources :

Example 1 with Anonsequence

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

the class ScopedNameVisitor method findNonSchemaType.

protected static boolean findNonSchemaType(String name, WSDLASTVisitor wsdlVisitor, VisitorTypeHolder holder) {
    boolean result = false;
    TypeMappingType typeMap = wsdlVisitor.getTypeMap();
    XmlSchemaCollection schemas = wsdlVisitor.getSchemas();
    QName qname = new QName(typeMap.getTargetNamespace(), name);
    CorbaType corbaType = findCorbaType(typeMap, qname);
    if (corbaType != null) {
        if (corbaType instanceof Alias) {
            result = true;
            if (holder != null) {
                populateAliasSchemaType(corbaType, wsdlVisitor, holder);
            }
        } else if (((corbaType instanceof Sequence) || (corbaType instanceof Anonsequence)) && ((corbaType.getType().equals(Constants.XSD_BASE64)))) {
            // special case of sequence of octets
            result = true;
            if (holder != null) {
                holder.setCorbaType(corbaType);
                holder.setSchemaType(schemas.getTypeByQName(corbaType.getType()));
            }
        }
    }
    return result;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) Alias(org.apache.cxf.binding.corba.wsdl.Alias) TypeMappingType(org.apache.cxf.binding.corba.wsdl.TypeMappingType) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) XmlSchemaCollection(org.apache.ws.commons.schema.XmlSchemaCollection) Anonsequence(org.apache.cxf.binding.corba.wsdl.Anonsequence)

Example 2 with Anonsequence

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

the class WSDLTypes method mapToSequence.

public static CorbaType mapToSequence(QName name, QName schematypeName, QName arrayType, QName elName, int bound, boolean anonymous) {
    final CorbaType corbaTypeImpl;
    // schematypeName = checkPrefix(schematypeName);
    if (!anonymous) {
        // Create a Sequence
        Sequence corbaSeq = new Sequence();
        corbaSeq.setName(name.getLocalPart());
        corbaSeq.setQName(name);
        corbaSeq.setType(schematypeName);
        corbaSeq.setElemtype(arrayType);
        corbaSeq.setElemname(elName);
        corbaSeq.setBound(bound);
        corbaSeq.setRepositoryID(WSDLToCorbaHelper.REPO_STRING + name.getLocalPart().replace('.', '/') + WSDLToCorbaHelper.IDL_VERSION);
        corbaTypeImpl = corbaSeq;
    } else {
        // Create a Anonymous Sequence
        Anonsequence corbaSeq = new Anonsequence();
        corbaSeq.setName(name.getLocalPart());
        corbaSeq.setQName(name);
        corbaSeq.setType(schematypeName);
        corbaSeq.setElemtype(arrayType);
        corbaSeq.setElemname(elName);
        corbaSeq.setBound(bound);
        corbaTypeImpl = corbaSeq;
    }
    return corbaTypeImpl;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) Anonsequence(org.apache.cxf.binding.corba.wsdl.Anonsequence)

Example 3 with Anonsequence

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

the class WSDLToCorbaBindingTest method assertMixedArraysMappingDifficultSequences.

/**
 * @param typeMap
 */
private void assertMixedArraysMappingDifficultSequences(CorbaTypeMap typeMap) {
    String corbaTm = "http://schemas.apache.org/idl/anon.idl/corba/typemap/";
    // p9 is unwrapped, so there's "MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequenceArray" type
    // registered and "MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequence" as type of the element
    // which is Struct
    Sequence p9 = (Sequence) typeMap.getType("MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequenceArray");
    assertEquals(new QName("", "p9-anonymous-unwrapped-non-primitive-sequence"), p9.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequence"), p9.getElemtype());
    assertFalse(p9.isQualified());
    assertFalse(p9.isWrapped());
    Struct p9item = (Struct) typeMap.getType("MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequence");
    assertEquals(1, p9item.getMember().size());
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p9item.getMember().get(0).getIdltype());
    assertEquals("item", p9item.getMember().get(0).getName());
    Sequence p9q = (Sequence) typeMap.getType("MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequence-qArray");
    assertEquals(new QName("http://schemas.apache.org/idltypes/anon.idl", "p9-anonymous-unwrapped-non-primitive-sequence-q"), p9q.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequence-q"), p9q.getElemtype());
    assertTrue(p9q.isQualified());
    assertFalse(p9q.isWrapped());
    Struct p9qitem = (Struct) typeMap.getType("MixedArrayType.p9-anonymous-unwrapped-non-primitive-sequence-q");
    assertEquals(1, p9qitem.getMember().size());
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p9qitem.getMember().get(0).getIdltype());
    assertEquals("item", p9qitem.getMember().get(0).getName());
    // p10 is wrapped, so there's no "MixedArrayType.p10-anonymous-wrapped-non-primitive-sequenceArray"
    Anonsequence p10 = (Anonsequence) typeMap.getType("MixedArrayType.p10-anonymous-wrapped-non-primitive-sequenceType");
    assertEquals(new QName("", "item"), p10.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p10-anonymous-wrapped-non-primitive-sequence.item"), p10.getElemtype());
    assertFalse(p10.isQualified());
    assertTrue(p10.isWrapped());
    Struct p10item = (Struct) typeMap.getType("MixedArrayType.p10-anonymous-wrapped-non-primitive-sequence.item");
    assertEquals(p10item.getMember().size(), 1);
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p10item.getMember().get(0).getIdltype());
    assertEquals("item", p10item.getMember().get(0).getName());
    assertFalse(p10item.getMember().get(0).isSetQualified());
    Anonsequence p10q = (Anonsequence) typeMap.getType("MixedArrayType.p10-anonymous-wrapped-non-primitive-sequence-qType");
    assertEquals(new QName("http://schemas.apache.org/idltypes/anon.idl", "item"), p10q.getElemname());
    assertEquals(new QName(corbaTm, "MixedArrayType.p10-anonymous-wrapped-non-primitive-sequence-q.item"), p10q.getElemtype());
    assertTrue(p10q.isQualified());
    assertTrue(p10q.isWrapped());
    Struct p10qitem = (Struct) typeMap.getType("MixedArrayType.p10-anonymous-wrapped-non-primitive-sequence-q.item");
    assertEquals(p10qitem.getMember().size(), 1);
    assertEquals(new QName(CorbaConstants.NU_WSDL_CORBA, "string"), p10qitem.getMember().get(0).getIdltype());
    assertEquals("item", p10qitem.getMember().get(0).getName());
    assertTrue(p10qitem.getMember().get(0).isQualified());
}
Also used : QName(javax.xml.namespace.QName) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) Anonsequence(org.apache.cxf.binding.corba.wsdl.Anonsequence) Struct(org.apache.cxf.binding.corba.wsdl.Struct)

Example 4 with Anonsequence

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

the class CorbaUtils method getAnonTypeCode.

private static TypeCode getAnonTypeCode(ORB orb, QName type, Object obj, CorbaTypeMap typeMap, Stack<QName> seenTypes) {
    TypeCode tc = null;
    if (obj instanceof Anonarray) {
        Anonarray anonArrayType = (Anonarray) obj;
        tc = orb.create_array_tc((int) anonArrayType.getBound(), getTypeCode(orb, anonArrayType.getElemtype(), typeMap, seenTypes));
    } else if (obj instanceof Anonfixed) {
        Anonfixed anonFixedType = (Anonfixed) obj;
        tc = orb.create_fixed_tc((short) anonFixedType.getDigits(), (short) anonFixedType.getScale());
    } else if (obj instanceof Anonsequence) {
        Anonsequence anonSeqType = (Anonsequence) obj;
        tc = orb.create_sequence_tc((int) anonSeqType.getBound(), getTypeCode(orb, anonSeqType.getElemtype(), typeMap, seenTypes));
    } else if (obj instanceof Anonstring) {
        Anonstring anonStringType = (Anonstring) obj;
        tc = orb.create_string_tc((int) anonStringType.getBound());
    } else if (obj instanceof Anonwstring) {
        Anonwstring anonWStringType = (Anonwstring) obj;
        tc = orb.create_wstring_tc((int) anonWStringType.getBound());
    }
    return tc;
}
Also used : Anonfixed(org.apache.cxf.binding.corba.wsdl.Anonfixed) Anonwstring(org.apache.cxf.binding.corba.wsdl.Anonwstring) TypeCode(org.omg.CORBA.TypeCode) Anonarray(org.apache.cxf.binding.corba.wsdl.Anonarray) Anonsequence(org.apache.cxf.binding.corba.wsdl.Anonsequence) Anonstring(org.apache.cxf.binding.corba.wsdl.Anonstring)

Example 5 with Anonsequence

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

the class CorbaHandlerUtils method initializeSequenceHandler.

public static void initializeSequenceHandler(ORB orb, CorbaObjectHandler obj, CorbaTypeMap typeMap, ServiceInfo serviceInfo, Map<QName, CorbaObjectHandler> seenTypes) {
    final QName seqElementType;
    final long seqBound;
    CorbaType baseType = obj.getType();
    QName elementName;
    if (baseType instanceof Sequence) {
        Sequence seqType = (Sequence) baseType;
        seqElementType = seqType.getElemtype();
        seqBound = seqType.getBound();
        elementName = seqType.getElemname();
    } else {
        Anonsequence seqType = (Anonsequence) baseType;
        seqElementType = seqType.getElemtype();
        seqBound = seqType.getBound();
        elementName = seqType.getElemname();
    }
    if (seqBound == 0) {
        // This is an unbounded sequence.  Store a 'template' object that we can use to create
        // new objects as needed
        final CorbaObjectHandler elementObj;
        // Check for a recursive type
        if (seenTypes.get(seqElementType) != null) {
            elementObj = seenTypes.get(seqElementType);
            elementObj.setRecursive(true);
            ((CorbaSequenceHandler) obj).hasRecursiveTypeElement(true);
        } else {
            elementObj = initializeObjectHandler(orb, elementName, seqElementType, typeMap, serviceInfo, seenTypes);
        }
        ((CorbaSequenceHandler) obj).setTemplateElement(elementObj);
    }
    for (long i = 0; i < seqBound; ++i) {
        final CorbaObjectHandler elementObj;
        // Check for a recursive type
        if (seenTypes.get(seqElementType) != null) {
            // Even though this is bounded, if we have a recursive type, we'll still use the
            // template object so that we don't overwrite the value of the element.
            elementObj = seenTypes.get(seqElementType);
            elementObj.setRecursive(true);
            ((CorbaSequenceHandler) obj).hasRecursiveTypeElement(true);
            ((CorbaSequenceHandler) obj).setTemplateElement(elementObj);
        } else {
            elementObj = initializeObjectHandler(orb, elementName, seqElementType, typeMap, serviceInfo, seenTypes);
            ((CorbaSequenceHandler) obj).addElement(elementObj);
        }
    }
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) Anonsequence(org.apache.cxf.binding.corba.wsdl.Anonsequence)

Aggregations

Anonsequence (org.apache.cxf.binding.corba.wsdl.Anonsequence)10 QName (javax.xml.namespace.QName)7 Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)7 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)6 Anonarray (org.apache.cxf.binding.corba.wsdl.Anonarray)4 Array (org.apache.cxf.binding.corba.wsdl.Array)3 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)3 Alias (org.apache.cxf.binding.corba.wsdl.Alias)2 Anonfixed (org.apache.cxf.binding.corba.wsdl.Anonfixed)2 Struct (org.apache.cxf.binding.corba.wsdl.Struct)2 TypeMappingType (org.apache.cxf.binding.corba.wsdl.TypeMappingType)2 File (java.io.File)1 HashMap (java.util.HashMap)1 Definition (javax.wsdl.Definition)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 Union (org.apache.cxf.binding.corba.wsdl.Union)1