Search in sources :

Example 1 with IdlDefn

use of org.apache.cxf.tools.corba.common.idltypes.IdlDefn in project cxf by apache.

the class WSDLToIDLAction method createType.

protected IdlType createType(QName idlType, String[] name, CorbaType corbaType) throws Exception {
    if (idlType.getLocalPart().equals("CORBA.Object")) {
        return IdlInterface.create(null, "Object");
    }
    CorbaType corbaTypeImpl = corbaType;
    if (corbaTypeImpl == null) {
        corbaTypeImpl = getCorbaType(idlType);
    }
    if (corbaTypeImpl == null) {
        String msgStr = "Type " + idlType.getLocalPart() + " not found.";
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
        throw new Exception(msg.toString());
    }
    IdlScopeBase scope = root;
    StringBuilder dotScopedName = new StringBuilder("");
    for (int i = 0; i < name.length - 1; ++i) {
        dotScopedName.append(name[i]);
        // name array.
        if ("CORBA".equals(dotScopedName.toString()) && name.length == 2 && i == 0 && name[1].equals("Object")) {
            break;
        }
        IdlDefn idlDef = scope.lookup(name[i]);
        if (idlDef == null) {
            // Before creating module, check to see if a Corba type
            // represent this name aleady exists.
            // For example if type is a.b.c and we are about to create
            // module b, look to see if a.b
            // is an interface that needs to be processed
            QName qname = new QName(corbaTypeImpl.getType().getNamespaceURI(), dotScopedName.toString());
            // Check to see if CORBAType exists. If so, create type for it
            // otherwise
            // create module for this scope
            CorbaType possibleCorbaType = getCorbaType(qname);
            if (possibleCorbaType != null) {
                idlDef = findType(qname);
            }
            if (idlDef == null) {
                idlDef = IdlModule.create(scope, name[i]);
                scope.addToScope(idlDef);
            }
        }
        dotScopedName.append(".");
        scope = (IdlScopeBase) idlDef;
    }
    IdlType result = null;
    String local = name[name.length - 1];
    if (corbaTypeImpl instanceof Enum) {
        result = createEnum((Enum) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Sequence) {
        result = createSequence((Sequence) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Anonsequence) {
        result = createAnonSequence((Anonsequence) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof org.apache.cxf.binding.corba.wsdl.Exception) {
        result = createIdlException((org.apache.cxf.binding.corba.wsdl.Exception) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Struct) {
        result = createStruct((Struct) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Union) {
        result = createUnion((Union) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Alias) {
        result = createTypedef((Alias) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Array) {
        result = createArray((Array) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Anonarray) {
        result = createAnonArray((Anonarray) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Fixed) {
        result = createFixed((Fixed) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Anonfixed) {
        result = createAnonFixed((Anonfixed) corbaTypeImpl, scope, local);
    } else if (corbaTypeImpl instanceof Const) {
        result = createConst((Const) corbaTypeImpl, scope, local);
    } else {
        result = checkAnon(corbaTypeImpl, scope, local);
    }
    if (result == null && corbaTypeImpl instanceof org.apache.cxf.binding.corba.wsdl.Object) {
        result = createInterface((org.apache.cxf.binding.corba.wsdl.Object) corbaTypeImpl, scope, local);
    }
    return result;
}
Also used : IdlEnum(org.apache.cxf.tools.corba.common.idltypes.IdlEnum) Enum(org.apache.cxf.binding.corba.wsdl.Enum) IdlString(org.apache.cxf.tools.corba.common.idltypes.IdlString) IdlType(org.apache.cxf.tools.corba.common.idltypes.IdlType) Union(org.apache.cxf.binding.corba.wsdl.Union) IdlUnion(org.apache.cxf.tools.corba.common.idltypes.IdlUnion) IdlStruct(org.apache.cxf.tools.corba.common.idltypes.IdlStruct) Struct(org.apache.cxf.binding.corba.wsdl.Struct) Anonarray(org.apache.cxf.binding.corba.wsdl.Anonarray) IdlFixed(org.apache.cxf.tools.corba.common.idltypes.IdlFixed) IdlAnonFixed(org.apache.cxf.tools.corba.common.idltypes.IdlAnonFixed) Fixed(org.apache.cxf.binding.corba.wsdl.Fixed) QName(javax.xml.namespace.QName) IdlDefn(org.apache.cxf.tools.corba.common.idltypes.IdlDefn) Const(org.apache.cxf.binding.corba.wsdl.Const) IdlConst(org.apache.cxf.tools.corba.common.idltypes.IdlConst) IdlScopeBase(org.apache.cxf.tools.corba.common.idltypes.IdlScopeBase) IdlAnonSequence(org.apache.cxf.tools.corba.common.idltypes.IdlAnonSequence) Sequence(org.apache.cxf.binding.corba.wsdl.Sequence) IdlSequence(org.apache.cxf.tools.corba.common.idltypes.IdlSequence) IdlException(org.apache.cxf.tools.corba.common.idltypes.IdlException) IdlAnonArray(org.apache.cxf.tools.corba.common.idltypes.IdlAnonArray) Array(org.apache.cxf.binding.corba.wsdl.Array) IdlArray(org.apache.cxf.tools.corba.common.idltypes.IdlArray) Anonfixed(org.apache.cxf.binding.corba.wsdl.Anonfixed) CorbaType(org.apache.cxf.binding.corba.wsdl.CorbaType) Alias(org.apache.cxf.binding.corba.wsdl.Alias) Anonsequence(org.apache.cxf.binding.corba.wsdl.Anonsequence)

Example 2 with IdlDefn

use of org.apache.cxf.tools.corba.common.idltypes.IdlDefn in project cxf by apache.

the class WSDLToIDLAction method createIdlAttribute.

public void createIdlAttribute(org.apache.cxf.binding.corba.wsdl.OperationType opType, String name) throws Exception {
    String attrNm = name.substring(5, name.length());
    IdlAttribute attr;
    IdlDefn idlDef = intf.lookup(attrNm);
    if (idlDef == null) {
        if (name.startsWith("_get_")) {
            ArgType t = opType.getReturn();
            attr = IdlAttribute.create(intf, attrNm, findType(t.getIdltype()), true);
        } else {
            ParamType arg = opType.getParam().iterator().next();
            attr = IdlAttribute.create(intf, attrNm, findType(arg.getIdltype()), false);
        }
        intf.addAttribute(attr);
    } else {
        attr = (IdlAttribute) idlDef;
        if (attr.readonly() && name.startsWith("_set_")) {
            attr.setReadonly(false);
        }
    }
}
Also used : ArgType(org.apache.cxf.binding.corba.wsdl.ArgType) IdlDefn(org.apache.cxf.tools.corba.common.idltypes.IdlDefn) IdlAttribute(org.apache.cxf.tools.corba.common.idltypes.IdlAttribute) IdlString(org.apache.cxf.tools.corba.common.idltypes.IdlString) ParamType(org.apache.cxf.binding.corba.wsdl.ParamType)

Example 3 with IdlDefn

use of org.apache.cxf.tools.corba.common.idltypes.IdlDefn in project cxf by apache.

the class WSDLToIDLAction method createPrimitiveType.

protected IdlType createPrimitiveType(QName idlType, String name) throws Exception {
    IdlDefn result = root.lookup(name);
    if (result != null && (!(result instanceof IdlType))) {
        String msgStr = idlType.getLocalPart() + " is an incorrect idltype.";
        org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
        throw new Exception(msg.toString());
    }
    /**
     * If we find a corba:dateTime then add the TimeBase.idl to the include
     * list for the root.
     */
    if (idlType.equals(CorbaConstants.NT_CORBA_DATETIME)) {
        root.addInclude("<omg/TimeBase.idl>");
    }
    return (IdlType) result;
}
Also used : IdlDefn(org.apache.cxf.tools.corba.common.idltypes.IdlDefn) IdlString(org.apache.cxf.tools.corba.common.idltypes.IdlString) IdlType(org.apache.cxf.tools.corba.common.idltypes.IdlType) IdlException(org.apache.cxf.tools.corba.common.idltypes.IdlException)

Example 4 with IdlDefn

use of org.apache.cxf.tools.corba.common.idltypes.IdlDefn in project cxf by apache.

the class WSDLToIDLAction method findIdlType.

private IdlType findIdlType(String local, QName ntype, CorbaType corbatypeImpl) throws Exception {
    IdlType idlType = null;
    if (ntype.getNamespaceURI().equals(CorbaConstants.NU_WSDL_CORBA)) {
        try {
            idlType = createPrimitiveType(ntype, local);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    } else {
        if (CorbaUtils.isTimeBaseDef(local)) {
            root.addInclude("<omg/TimeBase.idl>");
        }
        String[] name = unscopeName(local);
        IdlDefn defn = root.lookup(name);
        if (defn != null) {
            if (defn instanceof IdlType) {
                return (IdlType) defn;
            }
            String msgStr = local + " is an incorrect idltype.";
            org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
            throw new Exception(msg.toString());
        }
        try {
            idlType = createType(ntype, name, corbatypeImpl);
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
    return idlType;
}
Also used : IdlDefn(org.apache.cxf.tools.corba.common.idltypes.IdlDefn) IdlString(org.apache.cxf.tools.corba.common.idltypes.IdlString) IdlType(org.apache.cxf.tools.corba.common.idltypes.IdlType) IdlException(org.apache.cxf.tools.corba.common.idltypes.IdlException)

Example 5 with IdlDefn

use of org.apache.cxf.tools.corba.common.idltypes.IdlDefn in project cxf by apache.

the class WSDLToIDLAction method createInterface.

private IdlType createInterface(org.apache.cxf.binding.corba.wsdl.Object obj, IdlScopeBase scope, String local) throws Exception {
    IdlType result = null;
    QName bqname = obj.getBinding();
    Binding binding = def.getBinding(bqname);
    if (binding != null) {
        IdlDefn defn = scope.lookup(local);
        if (defn instanceof IdlInterface) {
            return (IdlInterface) defn;
        } else if (defn == null) {
            try {
                IdlInterface storedIntf = intf;
                intf = IdlInterface.create(scope, local);
                scope.holdForScope(intf);
                collectIdlDefns(binding);
                scope.promoteHeldToScope();
                result = intf;
                intf = storedIntf;
            } catch (Exception ex) {
                String msgStr = "Interface type " + intf.fullName() + " not found.";
                org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
                throw new Exception(msg.toString());
            }
        }
    }
    return result;
}
Also used : Binding(javax.wsdl.Binding) QName(javax.xml.namespace.QName) IdlDefn(org.apache.cxf.tools.corba.common.idltypes.IdlDefn) IdlInterface(org.apache.cxf.tools.corba.common.idltypes.IdlInterface) IdlString(org.apache.cxf.tools.corba.common.idltypes.IdlString) IdlType(org.apache.cxf.tools.corba.common.idltypes.IdlType) IdlException(org.apache.cxf.tools.corba.common.idltypes.IdlException)

Aggregations

IdlDefn (org.apache.cxf.tools.corba.common.idltypes.IdlDefn)5 IdlString (org.apache.cxf.tools.corba.common.idltypes.IdlString)5 IdlException (org.apache.cxf.tools.corba.common.idltypes.IdlException)4 IdlType (org.apache.cxf.tools.corba.common.idltypes.IdlType)4 QName (javax.xml.namespace.QName)2 Binding (javax.wsdl.Binding)1 Alias (org.apache.cxf.binding.corba.wsdl.Alias)1 Anonarray (org.apache.cxf.binding.corba.wsdl.Anonarray)1 Anonfixed (org.apache.cxf.binding.corba.wsdl.Anonfixed)1 Anonsequence (org.apache.cxf.binding.corba.wsdl.Anonsequence)1 ArgType (org.apache.cxf.binding.corba.wsdl.ArgType)1 Array (org.apache.cxf.binding.corba.wsdl.Array)1 Const (org.apache.cxf.binding.corba.wsdl.Const)1 CorbaType (org.apache.cxf.binding.corba.wsdl.CorbaType)1 Enum (org.apache.cxf.binding.corba.wsdl.Enum)1 Fixed (org.apache.cxf.binding.corba.wsdl.Fixed)1 ParamType (org.apache.cxf.binding.corba.wsdl.ParamType)1 Sequence (org.apache.cxf.binding.corba.wsdl.Sequence)1 Struct (org.apache.cxf.binding.corba.wsdl.Struct)1 Union (org.apache.cxf.binding.corba.wsdl.Union)1