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();
}
}
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;
}
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);
}
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);
}
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;
}
Aggregations