Search in sources :

Example 1 with CorbaTypeImpl

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

the class ConstVisitor method visit.

public void visit(AST constNode) {
    // <const_dcl> ::= "const" <const_type> <identifier> "=" <const_exp>
    // <const_type> ::= <integer_type>
    // | <char_type>
    // | <wide_char_type>
    // | <boolean_type>
    // | <floating_pt_type>
    // | <string_type>
    // | <wide_string_type>
    // | <fixed_pt_const_type>
    // | <scoped_name>
    // | <octet_type>
    AST constTypeNode = constNode.getFirstChild();
    AST constNameNode = TypesUtils.getCorbaTypeNameNode(constTypeNode);
    AST constValueNode = constNameNode.getNextSibling();
    // build value string
    StringBuilder constValue = new StringBuilder();
    if (constValueNode.toString() != null) {
        constValue.append(constValueNode.toString());
    }
    constValueNode = constValueNode.getFirstChild();
    if (constValue.length() == 1) {
        // might be a control char
        byte ch = (byte) constValue.charAt(0);
        if (ch >= 0 && ch <= 31) {
            // ascii code between 0 and 31 is invisible control code
            constValue.deleteCharAt(0);
            constValue.append("\\" + Integer.toOctalString(ch));
        }
    }
    while (constValueNode != null) {
        constValue.append(constValueNode.toString());
        constValueNode = constValueNode.getFirstChild();
    }
    QName constQName = new QName(typeMap.getTargetNamespace(), new Scope(getScope(), constNameNode).toString());
    Visitor visitor = null;
    if (PrimitiveTypesVisitor.accept(constTypeNode)) {
        visitor = new PrimitiveTypesVisitor(getScope(), definition, schema, schemas);
    } else if (StringVisitor.accept(constTypeNode)) {
        // string_type_spec
        // wstring_type_spec
        visitor = new StringVisitor(getScope(), definition, schema, wsdlVisitor, constTypeNode);
    } else if (FixedPtConstVisitor.accept(constTypeNode)) {
        visitor = new FixedPtConstVisitor(getScope(), definition, schema, schemas);
    } else if (ScopedNameVisitor.accept(getScope(), definition, schema, constTypeNode, wsdlVisitor)) {
        visitor = new ScopedNameVisitor(getScope(), definition, schema, wsdlVisitor);
    }
    if (visitor == null) {
        throw new RuntimeException("can't resolve type for const " + constNameNode.getText());
    }
    visitor.visit(constTypeNode);
    XmlSchemaType constSchemaType = visitor.getSchemaType();
    CorbaTypeImpl constCorbaType = visitor.getCorbaType();
    // corba:const
    Const corbaConst = new Const();
    corbaConst.setQName(constQName);
    corbaConst.setValue(constValue.toString());
    corbaConst.setType(constSchemaType.getQName());
    corbaConst.setIdltype(constCorbaType.getQName());
    typeMap.getStructOrExceptionOrUnion().add(corbaConst);
}
Also used : AST(antlr.collections.AST) QName(javax.xml.namespace.QName) CorbaTypeImpl(org.apache.cxf.binding.corba.wsdl.CorbaTypeImpl) Const(org.apache.cxf.binding.corba.wsdl.Const) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 2 with CorbaTypeImpl

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

the class PortTypeVisitor method handleDeferredActions.

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);
    }
}
Also used : CorbaTypeImpl(org.apache.cxf.binding.corba.wsdl.CorbaTypeImpl) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Example 3 with CorbaTypeImpl

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

the class AttributeVisitor method generateCorbaParam.

private ParamType generateCorbaParam(AST type) {
    ParamType param = new ParamType();
    param.setName(PARAM_NAME);
    param.setMode(ModeType.IN);
    ParamTypeSpecVisitor visitor = new ParamTypeSpecVisitor(getScope(), definition, schema, wsdlVisitor);
    visitor.visit(type);
    CorbaTypeImpl corbaType = visitor.getCorbaType();
    if (corbaType != null) {
        param.setIdltype(corbaType.getQName());
    } else {
        wsdlVisitor.getDeferredActions().add(visitor.getFullyQualifiedName(), new AttributeDeferredAction(param));
    }
    return param;
}
Also used : CorbaTypeImpl(org.apache.cxf.binding.corba.wsdl.CorbaTypeImpl) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType)

Example 4 with CorbaTypeImpl

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

the class AttributeVisitor method generateCorbaReturnParam.

private ArgType generateCorbaReturnParam(AST type) {
    ArgType param = new ArgType();
    param.setName(RETURN_PARAM_NAME);
    ParamTypeSpecVisitor visitor = new ParamTypeSpecVisitor(getScope(), definition, schema, wsdlVisitor);
    visitor.visit(type);
    CorbaTypeImpl corbaType = visitor.getCorbaType();
    if (corbaType != null) {
        param.setIdltype(corbaType.getQName());
    } else {
        wsdlVisitor.getDeferredActions().add(visitor.getFullyQualifiedName(), new AttributeDeferredAction(param));
    }
    return param;
}
Also used : ArgType(org.apache.cxf.binding.corba.wsdl.ArgType) CorbaTypeImpl(org.apache.cxf.binding.corba.wsdl.CorbaTypeImpl)

Example 5 with CorbaTypeImpl

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

the class OperationVisitor method visit.

public void visit(AST node) {
    // <op_dcl> ::= [<op_attribute>] <op_type_spec>
    // <identifier> <parameter_dcls>
    // [<raises_expr>] [<context_expr>]
    // <op_attribute> ::= "oneway"
    // <op_type_spec> ::= <param_type_spec>
    // | "void"
    // <parameter_dcls> ::= "(" <param_dcl> {"," <param_dcl>}* ")"
    // | "(" ")"
    // <raises_expr> ::= "raises" "(" <scoped_name> {"," <scoped_name>}* ")"
    // <context_expr> ::= "context" "(" <string_literal> {"," <string_literal>}* ")"
    QName operationQName = new QName(schema.getTargetNamespace(), node.toString());
    boolean isDuplicate = false;
    if (schema.getElements().containsKey(operationQName)) {
        isDuplicate = true;
    }
    Operation operation = generateOperation(operationQName.getLocalPart(), isDuplicate);
    BindingOperation bindingOperation = null;
    if (isDuplicate) {
        bindingOperation = generateBindingOperation(binding, operation, operationQName.getLocalPart());
    } else {
        bindingOperation = generateBindingOperation(binding, operation, operation.getName());
    }
    XmlSchemaSequence inputWrappingSequence = new XmlSchemaSequence();
    XmlSchemaElement inputElement = generateWrapper(new QName(schema.getTargetNamespace(), operation.getName()), inputWrappingSequence);
    inputMsg = generateInputMessage(operation, bindingOperation);
    generateInputPart(inputMsg, inputElement);
    // <op_attribute>
    node = node.getFirstChild();
    XmlSchemaSequence outputWrappingSequence = null;
    XmlSchemaElement outputElement = null;
    if (node != null && (node.getType() == IDLTokenTypes.LITERAL_oneway)) {
        // oneway operations map to operations with only input message
        // no outputMsg nor outputPart need be created
        node = node.getNextSibling();
    } else {
        // normal operations map to request-response operations
        // with input and output messages
        outputWrappingSequence = new XmlSchemaSequence();
        outputElement = generateWrapper(new QName(schema.getTargetNamespace(), operation.getName() + RESPONSE_SUFFIX), outputWrappingSequence);
        outputMsg = generateOutputMessage(operation, bindingOperation);
        generateOutputPart(outputMsg, outputElement);
    }
    // <op_type_spec>
    visitOpTypeSpec(node, outputWrappingSequence);
    // <parameter_dcls>
    node = TypesUtils.getCorbaTypeNameNode(node);
    while (ParamDclVisitor.accept(node)) {
        ParamDclVisitor visitor = new ParamDclVisitor(getScope(), definition, schema, wsdlVisitor, inputWrappingSequence, outputWrappingSequence, corbaOperation);
        visitor.visit(node);
        node = node.getNextSibling();
    }
    // <raises_expr>
    if (node != null && node.getType() == IDLTokenTypes.LITERAL_raises) {
        node = node.getFirstChild();
        while (node != null) {
            // 
            ScopedNameVisitor visitor = new ScopedNameVisitor(getScope(), definition, schema, wsdlVisitor);
            visitor.setExceptionMode(true);
            visitor.visit(node);
            CorbaTypeImpl corbaType = visitor.getCorbaType();
            XmlSchemaType schemaType = visitor.getSchemaType();
            // REVISIT, schema type ends with Type for exceptions, so strip it to get the element name.
            int pos = schemaType.getQName().getLocalPart().indexOf("Type");
            QName elementQName = new QName(schemaType.getQName().getNamespaceURI(), schemaType.getQName().getLocalPart().substring(0, pos));
            createFaultMessage(corbaType, operation, bindingOperation, elementQName);
            node = node.getNextSibling();
            visitor.setExceptionMode(false);
        }
    }
}
Also used : XmlSchemaSequence(org.apache.ws.commons.schema.XmlSchemaSequence) BindingOperation(javax.wsdl.BindingOperation) QName(javax.xml.namespace.QName) XmlSchemaElement(org.apache.ws.commons.schema.XmlSchemaElement) CorbaTypeImpl(org.apache.cxf.binding.corba.wsdl.CorbaTypeImpl) Operation(javax.wsdl.Operation) BindingOperation(javax.wsdl.BindingOperation) XmlSchemaType(org.apache.ws.commons.schema.XmlSchemaType)

Aggregations

CorbaTypeImpl (org.apache.cxf.binding.corba.wsdl.CorbaTypeImpl)6 XmlSchemaType (org.apache.ws.commons.schema.XmlSchemaType)4 QName (javax.xml.namespace.QName)2 AST (antlr.collections.AST)1 BindingOperation (javax.wsdl.BindingOperation)1 Operation (javax.wsdl.Operation)1 ArgType (org.apache.cxf.binding.corba.wsdl.ArgType)1 Const (org.apache.cxf.binding.corba.wsdl.Const)1 ParamType (org.apache.cxf.binding.corba.wsdl.ParamType)1 XmlSchemaElement (org.apache.ws.commons.schema.XmlSchemaElement)1 XmlSchemaSequence (org.apache.ws.commons.schema.XmlSchemaSequence)1