use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.
the class WSDLToIDLAction method createType.
protected IdlType createType(QName idlType, String[] name, CorbaType corbaType) throws Exception {
if ("CORBA.Object".equals(idlType.getLocalPart())) {
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 && "Object".equals(name[1])) {
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;
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.binding.corba.wsdl.CorbaType in project cxf by apache.
the class WSDLParameter method getIdlType.
private static QName getIdlType(WSDLToCorbaBinding wsdlToCorbaBinding, XmlSchemaType schemaType, QName typeName, boolean nill) throws Exception {
final QName idltype;
if (schemaType == null) {
CorbaType corbaTypeImpl = (CorbaType) WSDLToCorbaHelper.CORBAPRIMITIVEMAP.get(typeName);
if (nill) {
QName qname = corbaTypeImpl.getQName();
idltype = wsdlToCorbaBinding.getHelper().createQNameCorbaNamespace(qname.getLocalPart() + "_nil");
} else {
if (corbaTypeImpl == null) {
XmlSchemaObject schemaObj = getSchemaObject(wsdlToCorbaBinding, typeName);
XmlSchemaAnnotation annotation = null;
if (schemaObj instanceof XmlSchemaElement) {
XmlSchemaElement el = (XmlSchemaElement) schemaObj;
schemaType = el.getSchemaType();
annotation = ((XmlSchemaElement) schemaObj).getAnnotation();
}
idltype = getSchemaTypeName(wsdlToCorbaBinding, schemaType, annotation, typeName, nill);
} else {
idltype = corbaTypeImpl.getQName();
}
}
} else {
// We need to get annotation information for the schema type we are
// about to pass in.
// This is used to produce the correct object reference type.
XmlSchemaElement schemaObj = getSchemaObject(wsdlToCorbaBinding, typeName);
XmlSchemaAnnotation annotation = null;
if (schemaObj != null) {
annotation = schemaObj.getAnnotation();
}
idltype = getSchemaTypeName(wsdlToCorbaBinding, schemaType, annotation, typeName, nill);
}
return idltype;
}
use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.
the class WSDLToCorbaHelper method processSequenceType.
protected CorbaType processSequenceType(XmlSchemaSequence seq, QName defaultName, QName schemaTypeName) throws Exception {
final QName seqName;
if (schemaTypeName == null) {
seqName = createQNameCorbaNamespace(defaultName.getLocalPart() + "SequenceStruct");
} else {
seqName = createQNameCorbaNamespace(schemaTypeName.getLocalPart() + "SequenceStruct");
}
schemaTypeName = checkPrefix(schemaTypeName);
Struct struct = new Struct();
struct.setName(seqName.getLocalPart());
struct.setQName(seqName);
struct.setRepositoryID(REPO_STRING + seqName.getLocalPart().replace('.', '/') + IDL_VERSION);
struct.setType(schemaTypeName);
List<MemberType> members = processContainerAsMembers(seq, defaultName, schemaTypeName);
for (MemberType memberType : members) {
struct.getMember().add(memberType);
}
CorbaType type = struct;
if (seq.getMaxOccurs() != 1 || seq.getMinOccurs() != 1) {
QName name = createQNameTargetNamespace(type.getQName().getLocalPart() + "Array");
CorbaType atype = createArray(name, type.getQName(), type.getQName(), seq.getMaxOccurs(), seq.getMinOccurs(), false);
if (atype != null && !isDuplicate(atype)) {
typeMappingType.getStructOrExceptionOrUnion().add(atype);
}
}
if (struct.getMember().isEmpty()) {
String msgStr = "Cannot create CORBA Struct" + struct.getName() + "from container with no members";
org.apache.cxf.common.i18n.Message msg = new org.apache.cxf.common.i18n.Message(msgStr, LOG);
throw new Exception(msg.toString());
}
return type;
}
use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.
the class WSDLToCorbaHelper method processAllMember.
private MemberType processAllMember(XmlSchemaAll all, QName defaultName, QName schemaTypeName) throws Exception {
CorbaType corbatype = processAllType(all, defaultName, schemaTypeName);
MemberType member = new MemberType();
member.setName(corbatype.getQName().getLocalPart());
member.setIdltype(corbatype.getQName());
if (corbatype.isSetQualified() && corbatype.isQualified()) {
member.setQualified(true);
}
return member;
}
use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.
the class WSDLToCorbaHelper method processSimpleContentStruct.
protected Struct processSimpleContentStruct(XmlSchemaSimpleContent simpleContent, QName defaultName, Struct corbaStruct, QName schematypeName) throws Exception {
List<MemberType> attrMembers = null;
CorbaType basetype = null;
String uri;
if (schematypeName != null) {
uri = schematypeName.getNamespaceURI();
} else {
uri = defaultName.getNamespaceURI();
}
if (simpleContent.getContent() instanceof XmlSchemaSimpleContentExtension) {
XmlSchemaSimpleContentExtension ext = (XmlSchemaSimpleContentExtension) simpleContent.getContent();
if (ext.getBaseTypeName() != null) {
basetype = processPrimitiveType(ext.getBaseTypeName());
}
if (basetype == null) {
XmlSchemaType base = getSchemaType(ext.getBaseTypeName());
basetype = convertSchemaToCorbaType(base, base.getQName(), base, null, false);
}
if (basetype == null) {
return null;
}
// process ext types ????
MemberType basemember = new MemberType();
basemember.setName("_simpleTypeValue");
QName baseTypeName = checkPrefix(basetype.getQName());
basemember.setIdltype(baseTypeName);
corbaStruct.getMember().add(basemember);
if (!isDuplicate(basetype)) {
typeMappingType.getStructOrExceptionOrUnion().add(basetype);
}
attrMembers = processAttributesAsMembers(ext.getAttributes(), uri);
} else if (simpleContent.getContent() instanceof XmlSchemaSimpleContentRestriction) {
XmlSchemaSimpleContentRestriction restrict = (XmlSchemaSimpleContentRestriction) simpleContent.getContent();
if (restrict.getBaseTypeName() != null) {
basetype = processPrimitiveType(restrict.getBaseTypeName());
}
if (basetype == null) {
XmlSchemaType base = getSchemaType(restrict.getBaseTypeName());
basetype = convertSchemaToCorbaType(base, base.getQName(), base, null, false);
}
MemberType basemember = new MemberType();
basemember.setName("_simpleTypeValue");
QName baseTypeName = checkPrefix(basetype.getQName());
basemember.setIdltype(baseTypeName);
corbaStruct.getMember().add(basemember);
if (!isDuplicate(basetype)) {
typeMappingType.getStructOrExceptionOrUnion().add(basetype);
}
attrMembers = processAttributesAsMembers(restrict.getAttributes(), uri);
}
// Deal with Attributes defined in Extension
if (attrMembers != null) {
for (int i = 0; i < attrMembers.size(); i++) {
MemberType member = attrMembers.get(i);
corbaStruct.getMember().add(member);
}
}
return corbaStruct;
}
Aggregations