Search in sources :

Example 56 with CorbaType

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

the class UnionVisitor method processCaseNodes.

private void processCaseNodes(AST caseNode, Scope scope, XmlSchemaChoice choice, Union corbaUnion) {
    while (caseNode != null) {
        final AST typeNode;
        final AST nameNode;
        // xmlschema:element
        XmlSchemaElement element = new XmlSchemaElement(schema, false);
        // corba:unionbranch
        Unionbranch unionBranch = new Unionbranch();
        if (caseNode.getType() == IDLTokenTypes.LITERAL_default) {
            // default:
            unionBranch.setDefault(true);
            typeNode = caseNode.getFirstChild();
            nameNode = typeNode.getNextSibling();
        } else {
            // case:
            createCase(caseNode, unionBranch);
            AST labelNode = caseNode.getFirstChild();
            if (labelNode.getType() == IDLTokenTypes.LITERAL_case) {
                labelNode = labelNode.getNextSibling();
            }
            typeNode = labelNode.getNextSibling();
            nameNode = typeNode.getNextSibling();
        }
        TypesVisitor visitor = new TypesVisitor(scope, definition, schema, wsdlVisitor, null);
        visitor.visit(typeNode);
        XmlSchemaType stype = visitor.getSchemaType();
        CorbaType ctype = visitor.getCorbaType();
        Scope fullyQualifiedName = visitor.getFullyQualifiedName();
        // needed for anonymous arrays in unions
        if (ArrayVisitor.accept(nameNode)) {
            Scope anonScope = new Scope(scope, TypesUtils.getCorbaTypeNameNode(nameNode));
            ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope, definition, schema, wsdlVisitor, null, fullyQualifiedName);
            arrayVisitor.setSchemaType(stype);
            arrayVisitor.setCorbaType(ctype);
            arrayVisitor.visit(nameNode);
            stype = arrayVisitor.getSchemaType();
            ctype = arrayVisitor.getCorbaType();
            fullyQualifiedName = visitor.getFullyQualifiedName();
        }
        // xmlschema:element
        element.setName(nameNode.toString());
        if (stype != null) {
            element.setSchemaTypeName(stype.getQName());
            if (stype.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
                element.setNillable(true);
            }
        } else {
            UnionDeferredAction elementAction = new UnionDeferredAction(element);
            wsdlVisitor.getDeferredActions().add(fullyQualifiedName, elementAction);
        }
        choice.getItems().add(element);
        // corba:unionbranch
        unionBranch.setName(nameNode.toString());
        if (ctype != null) {
            unionBranch.setIdltype(ctype.getQName());
        } else {
            // its type is forward declared.
            UnionDeferredAction unionBranchAction = new UnionDeferredAction(unionBranch);
            wsdlVisitor.getDeferredActions().add(fullyQualifiedName, unionBranchAction);
        }
        corbaUnion.getUnionbranch().add(unionBranch);
        caseNode = caseNode.getNextSibling();
    }
}
Also used : AST(antlr.collections.AST) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) Unionbranch(org.apache.cxf.binding.corba.wsdl.Unionbranch)

Example 57 with CorbaType

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

the class WSDLParameter method getSchemaTypeName.

private static QName getSchemaTypeName(WSDLToCorbaBinding wsdlToCorbaBinding, XmlSchemaType schemaType, XmlSchemaAnnotation annotation, QName typeName, boolean nill) throws Exception {
    final QName idltype;
    CorbaType 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;
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName)

Example 58 with CorbaType

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

the class WSDLToCorbaBinding method addCorbaOperationExtElement.

private void addCorbaOperationExtElement(BindingOperation bo, Operation op) throws Exception {
    final OperationType operationType;
    try {
        operationType = (OperationType) extReg.createExtension(BindingOperation.class, CorbaConstants.NE_CORBA_OPERATION);
    } catch (WSDLException wse) {
        LOG.log(Level.SEVERE, "Failed to create a Binding Operation extension", wse);
        throw new Exception(LOG.toString(), wse);
    }
    operationType.setName(op.getName());
    List<ParamType> params = new ArrayList<>();
    List<ArgType> returns = new ArrayList<>();
    wsdlParameter.processParameters(this, op, def, xmlSchemaList, params, returns, true);
    for (ParamType paramtype : params) {
        operationType.getParam().add(paramtype);
    }
    for (ArgType retType : returns) {
        operationType.setReturn(retType);
    }
    Collection<Fault> faults = CastUtils.cast(op.getFaults().values());
    for (Fault fault : faults) {
        RaisesType raisestype = new RaisesType();
        CorbaType extype = convertFaultToCorbaType(xmlSchemaType, fault);
        if (extype != null) {
            raisestype.setException(helper.createQNameCorbaNamespace(extype.getName()));
            operationType.getRaises().add(raisestype);
        }
    }
    bo.addExtensibilityElement((ExtensibilityElement) operationType);
}
Also used : ArgType(org.apache.cxf.binding.corba.wsdl.ArgType) RaisesType(org.apache.cxf.binding.corba.wsdl.RaisesType) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) WSDLException(javax.wsdl.WSDLException) ArrayList(java.util.ArrayList) Fault(javax.wsdl.Fault) BindingFault(javax.wsdl.BindingFault) OperationType(org.apache.cxf.binding.corba.wsdl.OperationType) WSDLException(javax.wsdl.WSDLException) ToolException(org.apache.cxf.tools.common.ToolException) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType)

Example 59 with CorbaType

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

the class WSDLToCorbaBinding method addCorbaTypes.

private void addCorbaTypes(XmlSchema xmlSchemaTypes) throws Exception {
    Map<QName, XmlSchemaType> objs = xmlSchemaTypes.getSchemaTypes();
    for (XmlSchemaType type : objs.values()) {
        boolean anonymous = WSDLTypes.isAnonymous(type.getName());
        CorbaType corbaTypeImpl = helper.convertSchemaToCorbaType(type, type.getQName(), null, null, anonymous);
        if (corbaTypeImpl != null && !helper.isDuplicate(corbaTypeImpl)) {
            typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
        }
    }
    addCorbaElements(xmlSchemaTypes);
}
Also used : CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) QName(javax.xml.namespace.QName) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 60 with CorbaType

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

the class WSDLToCorbaBinding method convertFaultToCorbaType.

private CorbaType convertFaultToCorbaType(XmlSchema xmlSchema, Fault fault) throws Exception {
    org.apache.cxf.binding.corba.wsdl.Exception corbaex = null;
    Iterator<Part> parts = CastUtils.cast(fault.getMessage().getParts().values().iterator());
    if (!parts.hasNext()) {
        String msgStr = "Fault " + fault.getMessage().getQName().getLocalPart() + " UNSUPPORTED_FAULT.";
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
        throw new Exception(msg.toString());
    }
    Part part = parts.next();
    XmlSchemaType schemaType = helper.lookUpType(part);
    if (schemaType != null) {
        QName name = schemaType.getQName();
        if (name == null) {
            name = part.getElementName();
        }
        if (!helper.isSchemaTypeException(schemaType)) {
            corbaex = new org.apache.cxf.binding.corba.wsdl.Exception();
            String faultName = fault.getMessage().getQName().getLocalPart();
            int pos = faultName.indexOf("_exception.");
            if (pos != -1) {
                faultName = faultName.substring(pos + 11);
                faultName = faultName + "Exception";
            }
            QName faultMsgName = helper.createQNameCorbaNamespace(faultName);
            corbaex.setName(faultName);
            corbaex.setQName(faultMsgName);
            CorbaType corbaTypeImpl = helper.convertSchemaToCorbaType(schemaType, name, null, null, false);
            if (corbaTypeImpl != null) {
                MemberType member = new MemberType();
                member.setName(corbaTypeImpl.getQName().getLocalPart());
                member.setIdltype(corbaTypeImpl.getQName());
                if (corbaTypeImpl.isSetQualified() && corbaTypeImpl.isQualified()) {
                    member.setQualified(true);
                }
                corbaex.getMember().add(member);
            }
        } else {
            corbaex = createCorbaException(name, schemaType);
        }
    }
    if (schemaType == null) {
        String msgStr = "Fault " + fault.getMessage().getQName().getLocalPart() + " INCORRECT_FAULT_MSG.";
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
        throw new Exception(msg.toString());
    }
    if (corbaex == null) {
        String msgStr = "Fault " + fault.getMessage().getQName().getLocalPart() + " UNSUPPORTED_FAULT.";
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
        throw new Exception(msg.toString());
    }
    // Set the repository ID for Exception
    // add to CorbaTypeMapping
    String repoId = WSDLToCorbaHelper.REPO_STRING + corbaex.getName().replace('.', '/') + WSDLToCorbaHelper.IDL_VERSION;
    corbaex.setRepositoryID(repoId);
    CorbaType corbaTypeImpl = corbaex;
    if (!helper.isDuplicate(corbaTypeImpl)) {
        CorbaType dup = helper.isDuplicateException(corbaTypeImpl);
        if (dup != null) {
            typeMappingType.getStructOrExceptionOrUnion().remove(dup);
            typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
        } else {
            typeMappingType.getStructOrExceptionOrUnion().add(corbaTypeImpl);
        }
    }
    return corbaex;
}
Also used : QName(javax.xml.namespace.QName) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType) WSDLException(javax.wsdl.WSDLException) ToolException(org.apache.cxf.tools.common.ToolException) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) MemberType(org.apache.cxf.binding.corba.wsdl.MemberType) Part(javax.wsdl.Part)

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