org.apache.ws.commons.schema.XmlSchemaType Java Examples

The following examples show how to use org.apache.ws.commons.schema.XmlSchemaType. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SchemaCollection.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void addCrossImportsType(XmlSchema schema, XmlSchemaType schemaType) {
    // the base type might cross schemas.
    if (schemaType instanceof XmlSchemaComplexType) {
        XmlSchemaComplexType complexType = (XmlSchemaComplexType)schemaType;
        XmlSchemaUtils.addImportIfNeeded(schema, complexType.getBaseSchemaTypeName());
        addCrossImports(schema, complexType.getContentModel());
        addCrossImportsAttributeList(schema, complexType.getAttributes());
        // could it be a choice or something else?

        if (complexType.getParticle() instanceof XmlSchemaChoice) {
            XmlSchemaChoice choice = (XmlSchemaChoice)complexType.getParticle();
            addCrossImports(schema, choice);
        } else if (complexType.getParticle() instanceof XmlSchemaAll) {
            XmlSchemaAll all = (XmlSchemaAll)complexType.getParticle();
            addCrossImports(schema, all);
        } else if (complexType.getParticle() instanceof XmlSchemaSequence) {
            XmlSchemaSequence sequence = (XmlSchemaSequence)complexType.getParticle();
            addCrossImports(schema, sequence);
        }
    }
}
 
Example #2
Source File: SequenceVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private CorbaType generateCorbaSequence(CorbaType ctype,
                                            XmlSchemaType schemaType,
                                            Scope scopedName,
                                            long bound,
                                            Scope fullyQualifiedName) {
    //create the corba sequence
    Sequence corbaSeq = new Sequence();
    if (bound == -1) {
        bound = 0;
    }
    corbaSeq.setBound(bound);
    corbaSeq.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
    corbaSeq.setType(schemaType.getQName());
    //REVISIT, if we add qualification then change the below.
    corbaSeq.setElemname(new QName("", ELEMENT_NAME));
    if (ctype != null) {
        corbaSeq.setElemtype(ctype.getQName());
    } else {
        SequenceDeferredAction seqAction =
            new SequenceDeferredAction(corbaSeq);
        wsdlVisitor.getDeferredActions().add(fullyQualifiedName, seqAction);
    }
    corbaSeq.setRepositoryID(scopedName.toIDLRepositoryID());

    return corbaSeq;
}
 
Example #3
Source File: CommonsSchemaInfoBuilder.java    From tomee with Apache License 2.0 6 votes vote down vote up
private void addType(QName typeQName, XmlSchemaType type) {
    // skip built in xml schema types
    if (XML_SCHEMA_NS.equals(typeQName.getNamespaceURI())) {
        return;
    }

    XmlTypeInfo typeInfo = createXmlTypeInfo(typeQName, type);
    xmlTypes.put(typeQName, typeInfo);

    if (type instanceof XmlSchemaComplexType) {
        XmlSchemaComplexType complexType = (XmlSchemaComplexType) type;

        // process elements nested inside of this element
        List<XmlSchemaElement> elements = getNestedElements(complexType);
        for (XmlSchemaElement element : elements) {
            addNestedElement(element, typeInfo);
        }
    }
}
 
Example #4
Source File: OperationVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private XmlSchemaElement addElement(XmlSchemaSequence schemaSequence,
                                    XmlSchemaType schemaType,
                                    Scope fqName,
                                    String name) {
    XmlSchemaElement element = new XmlSchemaElement(schema, false);
    element.setName(name);
    if (schemaType != null) {
        element.setSchemaTypeName(schemaType.getQName());
        if (schemaType.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
            element.setNillable(true);
        }
    } else {
        wsdlVisitor.getDeferredActions().
            add(fqName, new OperationDeferredAction(element));
    }
    schemaSequence.getItems().add(element);

    return element;
}
 
Example #5
Source File: OperationVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void visitOpTypeSpec(AST node, XmlSchemaSequence outputWrappingSequence) {
    if (node.getType() == IDLTokenTypes.LITERAL_void) {
        // nothing to do here, move along
        return;
    }
    ParamTypeSpecVisitor visitor = new ParamTypeSpecVisitor(getScope(),
                                                            definition,
                                                            schema,
                                                            wsdlVisitor);

    visitor.visit(node);

    XmlSchemaType schemaType = visitor.getSchemaType();
    CorbaTypeImpl corbaType = visitor.getCorbaType();
    Scope fqName = visitor.getFullyQualifiedName();

    addElement(outputWrappingSequence, schemaType, fqName, RETURN_PARAMETER);
    addCorbaReturn(corbaType, fqName, RETURN_PARAMETER);
}
 
Example #6
Source File: FixedPtConstVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
public void visit(AST fixedNode) {
    //      <fixed_pt_const_type> ::= "fixed"

    XmlSchemaType stype = null;
    CorbaType ctype = null;

    QName corbaTypeQName = CorbaConstants.NE_CORBA_FIXED;

    if (corbaTypeQName != null) {
        QName schemaTypeQName = Constants.XSD_DECIMAL;
        if (schemaTypeQName != null) {
            stype = schemas.getTypeByQName(schemaTypeQName);
            if (stype != null) {
                ctype = new CorbaType();
                ctype.setQName(corbaTypeQName);
                ctype.setType(stype.getQName());
                ctype.setName(stype.getQName().getLocalPart());
            }
        }
    }

    schemaType = stype;
    corbaType = ctype;
}
 
Example #7
Source File: XsdToNeutralSchemaRepo.java    From secure-data-service with Apache License 2.0 6 votes vote down vote up
private NeutralSchema parse(XmlSchemaType type, String name, XmlSchema schema) {
    NeutralSchema prior = partialSchemas.get(type);
    if (prior != null) {
        // we already have a schema of this type
        NeutralSchema nSchema = getSchemaFactory().copySchema(prior);
        return nSchema;
    }
    if (type instanceof XmlSchemaComplexType) {
        NeutralSchema complexSchema = getSchemaFactory().createSchema(name);
        partialSchemas.put(type, complexSchema); // avoid infinite recursion in self-referential
                                                 // schemas
        return parseComplexType((XmlSchemaComplexType) type, complexSchema, schema);

    } else if (type instanceof XmlSchemaSimpleType) {
        return parseSimpleType((XmlSchemaSimpleType) type, schema, name);

    } else {
        throw new RuntimeException("Unsupported schema type: " + type.getClass().getCanonicalName());
    }
}
 
Example #8
Source File: ArrayVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example #9
Source File: SchemaCollection.java    From cxf with Apache License 2.0 6 votes vote down vote up
/**
 * Determines whether the schema has already received (cross) imports for the schemaType
 *
 * @param schema
 * @param schemaType
 * @return false if cross imports for schemaType must still be added to schema
 */
private boolean crossImportsAdded(XmlSchema schema, XmlSchemaType schemaType) {
    boolean result = true;
    if (schemaType != null) {
        Set<XmlSchemaType> xmlTypesCheckedForCrossImports;
        if (!xmlTypesCheckedForCrossImportsPerSchema.containsKey(schema)) {
            xmlTypesCheckedForCrossImports = new HashSet<>();
            xmlTypesCheckedForCrossImportsPerSchema.put(schema, xmlTypesCheckedForCrossImports);
        } else {
            xmlTypesCheckedForCrossImports = xmlTypesCheckedForCrossImportsPerSchema.get(schema);
        }
        if (!xmlTypesCheckedForCrossImports.contains(schemaType)) {
            // cross imports for this schemaType have not yet been added
            xmlTypesCheckedForCrossImports.add(schemaType);
            result = false;
        }
    }
    return result;
}
 
Example #10
Source File: TypedefVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void generateAlias(AST identifierNode,
                           XmlSchemaType schemaType,
                           CorbaType corbaType,
                           Scope fqName) {

    Scope scopedName = new Scope(getScope(), identifierNode);
    // corba:alias
    Alias alias = new Alias();
    alias.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
    if (corbaType != null) {
        alias.setBasetype(corbaType.getQName());
    // if (schemaType == null) might not be correct here
    } else if (schemaType == null) {
        wsdlVisitor.getDeferredActions().
            add(fqName, new TypedefDeferredAction(alias));
        scopedNames.add(scopedName);
    }
    alias.setRepositoryID(scopedName.toIDLRepositoryID());

    // add corba:alias
    setCorbaType(alias);
}
 
Example #11
Source File: TypedefVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void generateStringAlias(AST typeDeclaratorNode,
                                 AST identifierNode,
                                 XmlSchemaType schemaType,
                                 CorbaType corbaType,
                                 Scope fqName) {

    Scope typedefScope = new Scope(getScope(), identifierNode);

    Alias corbaString = new Alias();
    if (typeDeclaratorNode.getType() == IDLTokenTypes.LITERAL_string) {
        corbaString.setBasetype(CorbaConstants.NT_CORBA_STRING);
    } else if (typeDeclaratorNode.getType() == IDLTokenTypes.LITERAL_wstring) {
        corbaString.setBasetype(CorbaConstants.NT_CORBA_WSTRING);
    } else {
        // should never get here
        throw new RuntimeException("[TypedefVisitor] Attempted to visit an invalid node: "
                                   + typeDeclaratorNode.toString());
    }
    Scope newScope = new Scope(typedefScope.getParent(), identifierNode);
    corbaString.setQName(new QName(typeMap.getTargetNamespace(), newScope.toString()));
    corbaString.setType(Constants.XSD_STRING);
    corbaString.setRepositoryID(newScope.toIDLRepositoryID());

    typeMap.getStructOrExceptionOrUnion().add(corbaString);

}
 
Example #12
Source File: UnionVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void processForwardUnionActions(Scope unionScope) {
    if (wsdlVisitor.getDeferredActions() != null) {
        DeferredActionCollection deferredActions = wsdlVisitor.getDeferredActions();
        List<DeferredAction> list = deferredActions.getActions(unionScope);
        if ((list != null) && !list.isEmpty()) {
            XmlSchemaType stype = getSchemaType();
            CorbaType ctype = getCorbaType();
            Iterator<DeferredAction> iterator = list.iterator();
            while (iterator.hasNext()) {
                SchemaDeferredAction action = (SchemaDeferredAction)iterator.next();
                action.execute(stype, ctype);
            }
            iterator = list.iterator();
            while (iterator.hasNext()) {
                iterator.next();
                iterator.remove();
            }
        }
    }
}
 
Example #13
Source File: ReflectionServiceFactoryBean.java    From cxf with Apache License 2.0 6 votes vote down vote up
protected void checkForElement(ServiceInfo serviceInfo, MessagePartInfo mpi) {
    SchemaInfo si = getOrCreateSchema(serviceInfo, mpi.getElementQName().getNamespaceURI(),
                                      getQualifyWrapperSchema());
    XmlSchemaElement e = si.getSchema().getElementByName(mpi.getElementQName().getLocalPart());
    if (e != null) {
        mpi.setXmlSchema(e);
        return;
    }
    XmlSchema schema = si.getSchema();
    si.setElement(null); //cached element is now invalid

    XmlSchemaElement el = new XmlSchemaElement(schema, true);
    el.setName(mpi.getElementQName().getLocalPart());
    el.setNillable(true);

    XmlSchemaType tp = (XmlSchemaType)mpi.getXmlSchema();
    if (tp == null) {
        throw new ServiceConstructionException(new Message("INTRACTABLE_PART", LOG,
                                                           mpi.getName(),
                                                           mpi.getMessageInfo().getName()));
    }
    el.setSchemaTypeName(tp.getQName());
    mpi.setXmlSchema(el);
}
 
Example #14
Source File: WSDLToCorbaHelper.java    From cxf with Apache License 2.0 6 votes vote down vote up
public XmlSchemaType getSchemaType(QName name) throws Exception {
    XmlSchemaType type = null;
    for (XmlSchema xmlSchema : xmlSchemaList.getXmlSchemas()) {
        String nspace = name.getNamespaceURI();
        if (nspace == null) {
            nspace = xmlSchema.getTargetNamespace();
        }
        //QName tname = createQName(nspace, name.getLocalPart(), "xsd");
        QName tname = createQName(nspace, name.getLocalPart(), "");
        type = findSchemaType(tname);
        if (type != null) {
            break;
        }
    }
    return type;
}
 
Example #15
Source File: WSDLToCorbaHelper.java    From cxf with Apache License 2.0 6 votes vote down vote up
private CorbaType processElementType(XmlSchemaElement stype, QName defaultName, String uri)
    throws Exception {

    String name = null;
    QName schemaTypeName = null;
    XmlSchemaType schemaType = stype.getSchemaType();

    if (stype.getQName() == null) {
        if (stype.getRef().getTargetQName() == null) {
            schemaTypeName = defaultName;
        } else {
            name = stype.getRef().getTargetQName().getLocalPart();
            schemaType = findSchemaType(stype.getRef().getTargetQName());
        }
    } else {
        name = stype.getQName().getLocalPart();
    }
    if (schemaTypeName == null) {
        schemaTypeName = createQNameTargetNamespace(name);
    }
    CorbaType result = convertSchemaToCorbaType(schemaType, schemaTypeName,
                                                    schemaType, null, false);

    result.setQualified(getElementQualification(stype, uri));
    return result;
}
 
Example #16
Source File: WSDLToCorbaHelper.java    From cxf with Apache License 2.0 6 votes vote down vote up
private XmlSchemaType findTypeInSchema(XmlSchema xmlSchema, QName typeName) {
    XmlSchemaType schemaType = null;

    if (xmlSchema.getElementByName(typeName) != null) {
        XmlSchemaElement schemaElement = xmlSchema.getElementByName(typeName);
        schemaType = schemaElement.getSchemaType();
    } else if (xmlSchema.getTypeByName(typeName) != null) {
        schemaType = xmlSchema.getTypeByName(typeName);
    }
    if (schemaType != null) {
        return schemaType;
    }
    for (XmlSchemaExternal extSchema : xmlSchema.getExternals()) {
        if (!(extSchema instanceof XmlSchemaImport)) {
            schemaType = findTypeInSchema(extSchema.getSchema(), typeName);
            if (schemaType != null) {
                return schemaType;
            }
        }
    }

    return null;
}
 
Example #17
Source File: WSDLParameter.java    From cxf with Apache License 2.0 6 votes vote down vote up
private static QName getSchemaTypeName(WSDLToCorbaBinding wsdlToCorbaBinding, XmlSchemaType schemaType,
                                       XmlSchemaAnnotation annotation, QName typeName, boolean nill)
    throws Exception {
    QName idltype = null;
    CorbaType corbaTypeImpl = null;

    corbaTypeImpl = wsdlToCorbaBinding.getHelper().convertSchemaToCorbaType(schemaType, typeName, null,
                                                                            annotation, false);
    if (corbaTypeImpl == null) {
        throw new Exception("Couldn't convert schema type to corba type : " + typeName);
    }
    if (nill) {
        QName qname = corbaTypeImpl.getQName();
        idltype = wsdlToCorbaBinding.getHelper().createQNameCorbaNamespace(qname.getLocalPart()
                                                                               + "_nil");
    } else {
        idltype = corbaTypeImpl.getQName();
    }
    return idltype;
}
 
Example #18
Source File: ScopedNameVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private static CorbaType getCorbaSchemaType(XmlSchema xmlSchema,
                                                TypeMappingType typeMap,
                                                XmlSchemaType stype,
                                                Scope scopedName) {
    CorbaType ctype = null;
    if (stype.getQName().equals(Constants.XSD_STRING)) {
        ctype = new CorbaType();
        ctype.setName(CorbaConstants.NT_CORBA_STRING.getLocalPart());
        ctype.setQName(CorbaConstants.NT_CORBA_STRING);
        ctype.setType(Constants.XSD_STRING);
    } else {
        QName qname = stype.getQName();
        ctype = findCorbaTypeForSchemaType(typeMap, qname, scopedName);
    }
    return ctype;
}
 
Example #19
Source File: StructVisitor.java    From cxf with Apache License 2.0 6 votes vote down vote up
private XmlSchemaElement createXmlSchemaElement(AST memberNode,
                                                XmlSchemaType schemaType,
                                                Scope fqName) {
    // xmlschema:member
    XmlSchemaElement member = new XmlSchemaElement(schema, false);
    String memberName = memberNode.toString();
    member.setName(memberName);
    member.setSchemaType(schemaType);
    if (schemaType != null) {
        member.setSchemaTypeName(schemaType.getQName());
        if (schemaType.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
            member.setNillable(true);
        }
    } else {
        wsdlVisitor.getDeferredActions().
            add(fqName, new StructDeferredAction(member));
    }
    return member;
}
 
Example #20
Source File: SchemaCollection.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void addElementCrossImportsElement(XmlSchema schema, XmlSchemaElement item) {
    XmlSchemaElement element = item;
    XmlSchemaUtils.addImportIfNeeded(schema, element.getRef().getTargetQName());
    XmlSchemaUtils.addImportIfNeeded(schema, element.getSchemaTypeName());
    // if there's an anonymous type, it might have element refs in it.
    XmlSchemaType schemaType = element.getSchemaType();
    if (!crossImportsAdded(schema, schemaType)) {
        addCrossImportsType(schema, schemaType);
    }
}
 
Example #21
Source File: WSDLParameter.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static XmlSchemaType getType(Part part, SchemaCollection xmlSchemaList) throws Exception {
    XmlSchemaType schemaType = null;

    for (XmlSchema xmlSchema : xmlSchemaList.getXmlSchemas()) {
        if (part.getTypeName() != null) {
            schemaType = findSchemaType(xmlSchema, part.getTypeName());
            if (schemaType != null) {
                return schemaType;
            }
        }
    }

    return schemaType;
}
 
Example #22
Source File: WSDLToCorbaBinding.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void addCorbaTypes(XmlSchema xmlSchemaTypes) throws Exception {
    Map<QName, XmlSchemaType> objs = xmlSchemaTypes.getSchemaTypes();
    CorbaType corbaTypeImpl = null;
    for (XmlSchemaType type : objs.values()) {
        boolean anonymous = WSDLTypes.isAnonymous(type.getName());
        corbaTypeImpl = helper.convertSchemaToCorbaType(type, type.getQName(), null,
                                                        null, anonymous);
        if (corbaTypeImpl != null
            && !helper.isDuplicate(corbaTypeImpl)) {
            typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
        }
    }
    addCorbaElements(corbaTypeImpl, xmlSchemaTypes);
}
 
Example #23
Source File: ProcessorUtil.java    From cxf with Apache License 2.0 5 votes vote down vote up
private static List<WrapperElement> createWrappedElementsFromExtension(SchemaCollection schema,
                                                                       XmlSchemaComplexType type,
                                                                       int maxStackDepth) {
    List<WrapperElement> qnames = new ArrayList<>();

    XmlSchemaContent schemaContent = type.getContentModel().getContent();
    if (!(schemaContent instanceof XmlSchemaComplexContentExtension) || maxStackDepth == 0) {
        return qnames;
    }

    XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension)schemaContent;
    QName baseTypeName = extension.getBaseTypeName();
    XmlSchemaType baseType = schema.getTypeByQName(baseTypeName);

    if (baseType instanceof XmlSchemaComplexType) {
        XmlSchemaComplexType complexBaseType = (XmlSchemaComplexType)baseType;

        if (complexBaseType.getParticle() == null && complexBaseType.getContentModel() != null) {
            // continue up the extension ladder
            qnames.addAll(createWrappedElementsFromExtension(schema, complexBaseType, maxStackDepth - 1));
        } else if (complexBaseType.getParticle() instanceof XmlSchemaSequence) {
            XmlSchemaSequence seq = (XmlSchemaSequence)complexBaseType.getParticle();
            qnames.addAll(createWrappedElements(seq));
        }
    }

    if (extension.getParticle() instanceof XmlSchemaSequence) {
        XmlSchemaSequence xmlSchemaSeq = (XmlSchemaSequence)extension.getParticle();
        qnames.addAll(createWrappedElements(xmlSchemaSeq));
    }

    return qnames;
}
 
Example #24
Source File: CorbaUtils.java    From cxf with Apache License 2.0 5 votes vote down vote up
public static XmlSchemaType getXmlSchemaType(ServiceInfo serviceInfo, QName name) {
    XmlSchemaType result = null;
    if ((name != null) && (serviceInfo != null)) {
        SchemaCollection col = serviceInfo.getXmlSchemaCollection();
        result = col.getTypeByQName(name);
        if (result == null) {
            //check the name, if it is an element
            XmlSchemaElement el = col.getElementByQName(name);
            if (el != null) {
                result = el.getSchemaType();
            }
        }
    }
    return result;
}
 
Example #25
Source File: ReflectionServiceFactoryBean.java    From cxf with Apache License 2.0 5 votes vote down vote up
/**
 * Code elsewhere in this function will fill in the name of the type of an
 * element but not the reference to the type. This function fills in the
 * type references. This does not set the type reference for elements that
 * are declared as refs to other elements. It is a giant pain to find them,
 * since they are not (generally) root elements and the code would have to
 * traverse all the types to find all of them. Users should look them up
 * through the collection, that's what it is for.
 */
private void fillInSchemaCrossreferences() {
    Service service = getService();
    for (ServiceInfo serviceInfo : service.getServiceInfos()) {
        SchemaCollection schemaCollection = serviceInfo.getXmlSchemaCollection();

        // First pass, fill in any types for which we have a name but no
        // type.
        for (SchemaInfo schemaInfo : serviceInfo.getSchemas()) {
            Map<QName, XmlSchemaElement> elementsTable = schemaInfo.getSchema().getElements();
            for (XmlSchemaElement element : elementsTable.values()) {
                if (element.getSchemaType() == null) {
                    QName typeName = element.getSchemaTypeName();
                    if (typeName != null) {
                        XmlSchemaType type = schemaCollection.getTypeByQName(typeName);
                        if (type == null) {
                            Message message = new Message("REFERENCE_TO_UNDEFINED_TYPE", LOG, element
                                .getQName(), typeName, service.getName());
                            LOG.severe(message.toString());
                        } else {
                            element.setSchemaType(type);
                        }
                    }
                }
            }

        }
    }
}
 
Example #26
Source File: WSDLToCorbaHelper.java    From cxf with Apache License 2.0 5 votes vote down vote up
private XmlSchemaType findSchemaType(QName typeName) {
    for (XmlSchema xmlSchema : xmlSchemaList.getXmlSchemas()) {
        // if the schema includes other schemas need to search there.
        XmlSchemaType schemaType = findTypeInSchema(xmlSchema, typeName);
        if (schemaType != null) {
            return schemaType;
        }
    }
    return null;
}
 
Example #27
Source File: UnionDeferredAction.java    From cxf with Apache License 2.0 5 votes vote down vote up
public void execute(XmlSchemaType stype, CorbaTypeImpl ctype) {
    if (unionBranch != null) {
        unionBranch.setIdltype(ctype.getQName());
    }
    if (element != null) {
        element.setSchemaTypeName(stype.getQName());
        if (stype.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
            element.setNillable(true);
        }
    }
}
 
Example #28
Source File: ParamDclVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private XmlSchemaElement addElement(XmlSchemaSequence schemaSequence,
                                    XmlSchemaType schemaType,
                                    String name,
                                    Scope fullyQualifiedName) {
    XmlSchemaElement element = new XmlSchemaElement(schema, false);
    element.setName(name);
    if (schemaType == null) {
        ParamDeferredAction elementAction;
        if (mapper.isDefaultMapping()) {
            elementAction = new ParamDeferredAction(element);
        } else {
            elementAction = new ParamDeferredAction(element,
                                                    fullyQualifiedName.getParent(),
                                                    schema,
                                                    schemas,
                                                    manager,
                                                    mapper);
        }
        wsdlVisitor.getDeferredActions().add(fullyQualifiedName, elementAction);

        //ParamDeferredAction elementAction =
        //    new ParamDeferredAction(element);
        //wsdlVisitor.getDeferredActions().add(fullyQualifiedName, elementAction);
    } else {
        element.setSchemaTypeName(schemaType.getQName());
        if (schemaType.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
            element.setNillable(true);
        }
    }
    schemaSequence.getItems().add(element);
    return element;
}
 
Example #29
Source File: PortTypeVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
private void handleDeferredActions(DeferredActionCollection deferredActions,
                                   Scope scopedName,
                                   AST identifierNode) {
    List<DeferredAction> list = deferredActions.getActions(scopedName);
    if ((list != null) && !list.isEmpty()) {
        XmlSchemaType stype = null;
        CorbaTypeImpl ctype = null;
        if (ObjectReferenceVisitor.accept(getScope(), schema,
                                          definition, identifierNode, wsdlVisitor)) {
            ObjectReferenceVisitor visitor = new ObjectReferenceVisitor(getScope(),
                                                                        definition,
                                                                        schema,
                                                                        wsdlVisitor);
            visitor.visit(identifierNode);
            stype = visitor.getSchemaType();
            ctype = visitor.getCorbaType();
        }
        for (DeferredAction action : list) {
            if (action instanceof SchemaDeferredAction
                && (stype != null) && (ctype != null)) {
                SchemaDeferredAction schemaAction = (SchemaDeferredAction) action;
                schemaAction.execute(stype, ctype);
            }
        }
        deferredActions.removeScope(scopedName);
    }
}
 
Example #30
Source File: ParamDclVisitor.java    From cxf with Apache License 2.0 5 votes vote down vote up
public void visit(AST node) {
    // <param_dcl> ::= <param_attribute> <param_type_spec> <simple_declarator>
    // <param_attribute> ::= "in"
    //                     | "out"
    //                     | "inout"

    AST typeNode = node.getFirstChild();
    AST nameNode = TypesUtils.getCorbaTypeNameNode(typeNode);
    ParamTypeSpecVisitor visitor = new ParamTypeSpecVisitor(getScope(),
                                                            definition,
                                                            schema,
                                                            wsdlVisitor);
    visitor.visit(typeNode);
    XmlSchemaType schemaType = visitor.getSchemaType();
    CorbaType corbaType = visitor.getCorbaType();
    Scope fullyQualifiedName = visitor.getFullyQualifiedName();

    switch (node.getType()) {
    case IDLTokenTypes.LITERAL_in:
        addElement(inWrappingSequence, schemaType, nameNode.toString(), fullyQualifiedName);
        addCorbaParam(corbaType, ModeType.IN, nameNode.toString(), fullyQualifiedName);
        break;
    case IDLTokenTypes.LITERAL_out:
        addElement(outWrappingSequence, schemaType, nameNode.toString(), fullyQualifiedName);
        addCorbaParam(corbaType, ModeType.OUT, nameNode.toString(), fullyQualifiedName);
        break;
    case IDLTokenTypes.LITERAL_inout:
        addElement(inWrappingSequence, schemaType, nameNode.toString(), fullyQualifiedName);
        addElement(outWrappingSequence, schemaType, nameNode.toString(), fullyQualifiedName);
        addCorbaParam(corbaType, ModeType.INOUT, nameNode.toString(), fullyQualifiedName);
        break;
    default:
        throw new RuntimeException("[ParamDclVisitor: illegal IDL!]");
    }

    setSchemaType(schemaType);
    setCorbaType(corbaType);
}