Search in sources :

Example 96 with XmlSchemaComplexType

use of org.apache.ws.commons.schema.XmlSchemaComplexType in project cxf by apache.

the class ProcessorUtil method getWrappedElement.

public static List<WrapperElement> getWrappedElement(ToolContext context, QName partElement) {
    ServiceInfo serviceInfo = context.get(ServiceInfo.class);
    SchemaCollection schema = serviceInfo.getXmlSchemaCollection();
    XmlSchemaElement elementByName = schema.getElementByQName(partElement);
    XmlSchemaComplexType type = (XmlSchemaComplexType) elementByName.getSchemaType();
    XmlSchemaSequence seq = (XmlSchemaSequence) type.getParticle();
    List<WrapperElement> qnames = createWrappedElements(seq);
    // If it's extension
    if (seq == null && type.getContentModel() != null) {
        Object configuredMaxStackDepth = context.get(ToolConstants.CFG_MAX_EXTENSION_STACK_DEPTH);
        Integer maxStackDepth = Integer.valueOf(5);
        if (configuredMaxStackDepth instanceof Integer) {
            maxStackDepth = (Integer) configuredMaxStackDepth;
        } else if (configuredMaxStackDepth instanceof String) {
            maxStackDepth = Integer.valueOf((String) configuredMaxStackDepth);
        }
        qnames.addAll(createWrappedElementsFromExtension(schema, type, maxStackDepth));
    }
    return qnames;
}
Also used : ServiceInfo(org.apache.cxf.service.model.ServiceInfo) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) SchemaCollection(org.apache.cxf.common.xmlschema.SchemaCollection)

Example 97 with XmlSchemaComplexType

use of org.apache.ws.commons.schema.XmlSchemaComplexType in project cxf by apache.

the class ProcessorUtil method createWrappedElementsFromExtension.

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;
}
Also used : XmlSchemaComplexContentExtension(org.apache.ws.commons.schema.XmlSchemaComplexContentExtension) XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) QName(javax.xml.namespace.QName) XmlSchemaContent(org.apache.ws.commons.schema.XmlSchemaContent) ArrayList(java.util.ArrayList) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 98 with XmlSchemaComplexType

use of org.apache.ws.commons.schema.XmlSchemaComplexType 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;
    if (stype instanceof XmlSchemaComplexType) {
        QName defaultName = schemaTypeName;
        XmlSchemaComplexType 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 99 with XmlSchemaComplexType

use of org.apache.ws.commons.schema.XmlSchemaComplexType in project cxf by apache.

the class WSDLParameter method processWrappedInputParams.

private void processWrappedInputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation, SchemaCollection xmlSchemaList, List<ParamType> inputs) throws Exception {
    Input input = operation.getInput();
    if (input != null) {
        Message msg = input.getMessage();
        Part part = (Part) msg.getOrderedParts(null).iterator().next();
        XmlSchemaElement el = getElement(part, xmlSchemaList);
        if (el == null) {
            return;
        }
        XmlSchemaComplexType schemaType = null;
        if (el.getSchemaType() != null) {
            schemaType = (XmlSchemaComplexType) el.getSchemaType();
        }
        XmlSchemaSequence seq = (XmlSchemaSequence) schemaType.getParticle();
        if (seq != null) {
            for (XmlSchemaSequenceMember seqItem : seq.getItems()) {
                if (seqItem instanceof XmlSchemaElement) {
                    el = (XmlSchemaElement) seqItem;
                    // REVISIT, handle element ref's?
                    QName typeName = el.getSchemaTypeName();
                    if (typeName == null) {
                        typeName = el.getQName();
                    }
                    QName idltype = getIdlType(wsdlToCorbaBinding, el.getSchemaType(), typeName, el.isNillable());
                    ParamType paramtype = createParam(wsdlToCorbaBinding, "in", el.getQName().getLocalPart(), idltype);
                    if (paramtype != null) {
                        inputs.add(paramtype);
                    }
                }
            }
        }
    }
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) Input(javax.wsdl.Input) Message(javax.wsdl.Message) Part(javax.wsdl.Part) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) QName(javax.xml.namespace.QName) XmlSchemaSequenceMember(org.apache.ws.commons.schema.XmlSchemaSequenceMember) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType)

Example 100 with XmlSchemaComplexType

use of org.apache.ws.commons.schema.XmlSchemaComplexType in project cxf by apache.

the class WSDLParameter method isWrappedOperation.

private boolean isWrappedOperation(Operation op, SchemaCollection xmlSchemaList) throws Exception {
    Message inputMessage = op.getInput().getMessage();
    Message outputMessage = null;
    if (op.getOutput() != null) {
        outputMessage = op.getOutput().getMessage();
    }
    boolean passedRule = true;
    // input message must exist
    if (inputMessage == null || inputMessage.getParts().size() != 1 || (outputMessage != null && outputMessage.getParts().size() > 1)) {
        passedRule = false;
    }
    if (!passedRule) {
        return false;
    }
    XmlSchemaElement inputEl = null;
    XmlSchemaElement outputEl = null;
    // RULE No.2:
    // The input message part refers to a global element decalration whose
    // localname
    // is equal to the operation name
    Part inputPart = (Part) inputMessage.getParts().values().iterator().next();
    if (inputPart.getElementName() == null) {
        passedRule = false;
    } else {
        QName inputElementName = inputPart.getElementName();
        inputEl = getElement(inputPart, xmlSchemaList);
        if (inputEl == null || !op.getName().equals(inputElementName.getLocalPart())) {
            passedRule = false;
        }
    }
    if (!passedRule) {
        return false;
    }
    // The output message part refers to a global element declaration
    if (outputMessage != null && outputMessage.getParts().size() == 1) {
        Part outputPart = (Part) outputMessage.getParts().values().iterator().next();
        if (outputPart != null) {
            if ((outputPart.getElementName() == null) || getElement(outputPart, xmlSchemaList) == null) {
                passedRule = false;
            } else {
                outputEl = getElement(outputPart, xmlSchemaList);
            }
        }
    }
    if (!passedRule) {
        return false;
    }
    if (inputEl.getSchemaType() instanceof XmlSchemaComplexType) {
        XmlSchemaComplexType xsct = (XmlSchemaComplexType) inputEl.getSchemaType();
        if (hasAttributes(xsct) || !isWrappableSequence(xsct)) {
            passedRule = false;
        }
    } else {
        passedRule = false;
    }
    if (!passedRule) {
        return false;
    }
    if (outputMessage != null) {
        if (outputEl != null && outputEl.getSchemaType() instanceof XmlSchemaComplexType) {
            XmlSchemaComplexType xsct = (XmlSchemaComplexType) outputEl.getSchemaType();
            if (hasAttributes(xsct) || !isWrappableSequence(xsct)) {
                passedRule = false;
            }
        } else {
            passedRule = false;
        }
    }
    return passedRule;
}
Also used : Message(javax.wsdl.Message) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) Part(javax.wsdl.Part) QName(javax.xml.namespace.QName) XmlSchemaComplexType(org.apache.ws.commons.schema.XmlSchemaComplexType)

Aggregations

XmlSchemaComplexType (org.apache.ws.commons.schema.XmlSchemaComplexType)136 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)101 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)71 QName (javax.xml.namespace.QName)59 XmlSchemaSimpleType (org.apache.ws.commons.schema.XmlSchemaSimpleType)33 XmlSchema (org.apache.ws.commons.schema.XmlSchema)32 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)31 XmlSchemaAttribute (org.apache.ws.commons.schema.XmlSchemaAttribute)23 XmlSchemaObject (org.apache.ws.commons.schema.XmlSchemaObject)20 XmlSchemaObjectCollection (org.apache.ws.commons.schema.XmlSchemaObjectCollection)18 Test (org.junit.Test)18 XmlSchemaParticle (org.apache.ws.commons.schema.XmlSchemaParticle)16 XmlSchemaComplexContentExtension (org.apache.ws.commons.schema.XmlSchemaComplexContentExtension)15 ArrayList (java.util.ArrayList)13 XmlSchemaGroupBase (org.apache.ws.commons.schema.XmlSchemaGroupBase)12 XmlSchemaSequenceMember (org.apache.ws.commons.schema.XmlSchemaSequenceMember)12 XmlSchemaSimpleContentExtension (org.apache.ws.commons.schema.XmlSchemaSimpleContentExtension)12 XmlSchemaComplexContentRestriction (org.apache.ws.commons.schema.XmlSchemaComplexContentRestriction)8 FeatureMetacardType (org.codice.ddf.spatial.ogc.wfs.catalog.common.FeatureMetacardType)8 ParameterInfo (org.talend.designer.webservice.ws.wsdlinfo.ParameterInfo)8