use of org.apache.cxf.tools.corba.common.idltypes.IdlType 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;
}
use of org.apache.cxf.tools.corba.common.idltypes.IdlType in project cxf by apache.
the class WSDLToIDLAction method createIdlException.
private IdlType createIdlException(org.apache.cxf.binding.corba.wsdl.Exception e, IdlScopeBase scope, String local) throws Exception {
IdlType result = null;
Object obj = scope.lookup(local);
if (obj != null && (obj instanceof IdlException)) {
result = (IdlType) obj;
} else {
IdlException exc = IdlException.create(scope, local);
scope.holdForScope(exc);
for (MemberType m : e.getMember()) {
QName qname = m.getIdltype();
IdlType type = findType(qname);
exc.addToScope(IdlField.create(exc, m.getName(), type));
}
result = exc;
scope.promoteHeldToScope();
}
return result;
}
use of org.apache.cxf.tools.corba.common.idltypes.IdlType in project cxf by apache.
the class WSDLToIDLAction method createAnonSequence.
private IdlType createAnonSequence(Anonsequence s, IdlScopeBase scope, String local) throws Exception {
IdlType idlType = null;
IdlType base = findType(s.getElemtype());
int bound = (int) s.getBound();
idlType = IdlAnonSequence.create(scope, base, bound);
scope.addToScope(idlType);
return idlType;
}
use of org.apache.cxf.tools.corba.common.idltypes.IdlType in project cxf by apache.
the class WSDLToIDLAction method createIdlOperation.
public void createIdlOperation(org.apache.cxf.binding.corba.wsdl.OperationType opType, String name, boolean isOneway) throws Exception {
IdlOperation idlOp = IdlOperation.create(intf, opType.getName(), isOneway);
intf.holdForScope(idlOp);
ArgType crt = opType.getReturn();
if (crt != null) {
IdlType rt = findType(crt.getIdltype());
idlOp.addReturnType(rt);
}
for (ParamType arg : opType.getParam()) {
IdlType type = findType(arg.getIdltype());
String mode = arg.getMode().value();
IdlParam param = IdlParam.create(idlOp, arg.getName(), type, mode);
idlOp.addParameter(param);
}
for (RaisesType rs : opType.getRaises()) {
IdlType type = findType(rs.getException());
if (type instanceof IdlException) {
idlOp.addException((IdlException) type);
} else {
String msgStr = type.fullName() + " is not a type.";
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
throw new Exception(msg.toString());
}
}
root.flush();
intf.promoteHeldToScope();
}
use of org.apache.cxf.tools.corba.common.idltypes.IdlType 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;
}
Aggregations