use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.
the class IDLToWSDLProcessor method cleanUpTypeMap.
public void cleanUpTypeMap(TypeMappingType typeMap) {
List<CorbaType> types = typeMap.getStructOrExceptionOrUnion();
if (types != null) {
for (int i = 0; i < types.size(); i++) {
CorbaType type = types.get(i);
if (type.getQName() != null) {
type.setName(type.getQName().getLocalPart());
type.setQName(null);
}
}
}
}
use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.
the class IDLToWSDLProcessor method addTypeMapSchemaImports.
public void addTypeMapSchemaImports(Definition def, WSDLASTVisitor visitor) {
List<CorbaType> types = visitor.getTypeMap().getStructOrExceptionOrUnion();
ModuleToNSMapper mapper = visitor.getModuleToNSMapper();
WSDLSchemaManager manager = visitor.getManager();
Collection<String> namespaces = CastUtils.cast(def.getNamespaces().values());
Set<Map.Entry<String, String>> userModuleMappings = mapper.getUserMapping().entrySet();
if (types != null) {
for (int i = 0; i < types.size(); i++) {
CorbaType type = types.get(i);
QName schemaType = type.getType();
if (schemaType != null) {
String typeNamespace = schemaType.getNamespaceURI();
try {
// a remote location.
if (!namespaces.contains(typeNamespace) && typeNamespace.equals(ReferenceConstants.WSADDRESSING_NAMESPACE)) {
// build up the ws-addressing schema import
Schema wsdlSchema = (Schema) def.getExtensionRegistry().createExtension(Types.class, new QName(Constants.URI_2001_SCHEMA_XSD, "schema"));
SchemaImport schemaimport = wsdlSchema.createImport();
schemaimport.setNamespaceURI(ReferenceConstants.WSADDRESSING_NAMESPACE);
schemaimport.setSchemaLocationURI(ReferenceConstants.WSADDRESSING_LOCATION);
wsdlSchema.addImport(schemaimport);
// add the import and the prefix to the definition
def.getTypes().addExtensibilityElement(wsdlSchema);
CastUtils.cast(def.getNamespaces(), String.class, String.class).put(ReferenceConstants.WSADDRESSING_PREFIX, typeNamespace);
} else if (!namespaces.contains(typeNamespace)) {
String prefix = getModulePrefixForNamespace(userModuleMappings, mapper, typeNamespace);
// prefix = mapper.mapNSToPrefix(typeNamespace);
XmlSchema schema = manager.getXmlSchema(typeNamespace);
// TODO: REVISIT - Is this the only way we can create the file name for the
// imported schema?
String importFile = visitor.getOutputDir() + System.getProperty("file.separator") + prefix + ".xsd";
manager.addWSDLSchemaImport(def, typeNamespace, importFile);
manager.getImportedXmlSchemas().put(new File(importFile), schema);
CastUtils.cast(def.getNamespaces(), String.class, String.class).put(prefix, typeNamespace);
}
} catch (Exception ex) {
throw new ToolException("Unable to add schema import for namespace" + typeNamespace);
}
}
}
}
}
use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.
the class ExceptionVisitor method visit.
public void visit(AST node) {
// <exception_dcl> ::= "exception" <identifier> "{" <member>* "}"
// <member> ::= <type_spec> <declarators> ";"
// <type_spec> visited by TypesVisitor
// Following should be visited by a separate visitor
// <declarators> ::= <declarator> { "," <declarator> }*
// <declarator> ::= <simple_declarator>
// | <complex_declarator>
// <simple_declarator> ::= <identifier>
// <complex_declarator> ::= <array_declarator>
// <array_declarator> ::= <identifier> <fixed_array_size>+
// <fixed_array_size> ::= "[" <positive_int_const> "]"
AST identifierNode = node.getFirstChild();
Scope exceptionScope = new Scope(getScope(), identifierNode);
// xmlschema:exception
Scope scopedName = new Scope(getScope(), identifierNode);
String exceptionName = mapper.mapToQName(scopedName);
XmlSchemaElement element = new XmlSchemaElement(schema, true);
element.setName(mapper.mapToQName(scopedName));
String exceptionTypeName = exceptionName + TYPE_SUFFIX;
XmlSchemaComplexType complexType = new XmlSchemaComplexType(schema, true);
complexType.setName(exceptionTypeName);
// complexType.setQName(new QName(schema.getTargetNamespace(), exceptionTypeName));
XmlSchemaSequence sequence = new XmlSchemaSequence();
complexType.setParticle(sequence);
element.setSchemaTypeName(complexType.getQName());
// corba:exception
org.apache.cxf.binding.corba.wsdl.Exception exception = new org.apache.cxf.binding.corba.wsdl.Exception();
exception.setQName(new QName(typeMap.getTargetNamespace(), exceptionName));
exception.setType(complexType.getQName());
exception.setRepositoryID(scopedName.toIDLRepositoryID());
// exception members
AST memberTypeNode = identifierNode.getNextSibling();
while (memberTypeNode != null) {
AST memberNode = TypesUtils.getCorbaTypeNameNode(memberTypeNode);
TypesVisitor visitor = new TypesVisitor(exceptionScope, definition, schema, wsdlVisitor, null);
visitor.visit(memberTypeNode);
XmlSchemaType stype = visitor.getSchemaType();
CorbaType ctype = visitor.getCorbaType();
Scope fullyQualifiedName = visitor.getFullyQualifiedName();
// needed for anonymous arrays in exceptions
if (ArrayVisitor.accept(memberNode)) {
Scope anonScope = new Scope(exceptionScope, TypesUtils.getCorbaTypeNameNode(memberTypeNode));
ArrayVisitor arrayVisitor = new ArrayVisitor(anonScope, definition, schema, wsdlVisitor, null, fullyQualifiedName);
arrayVisitor.setSchemaType(stype);
arrayVisitor.setCorbaType(ctype);
arrayVisitor.visit(memberNode);
stype = arrayVisitor.getSchemaType();
ctype = arrayVisitor.getCorbaType();
}
XmlSchemaElement member = createElementType(memberNode, stype, fullyQualifiedName);
sequence.getItems().add(member);
MemberType memberType = createMemberType(memberNode, ctype, fullyQualifiedName);
exception.getMember().add(memberType);
memberTypeNode = memberNode.getNextSibling();
}
// add exception to corba typemap
typeMap.getStructOrExceptionOrUnion().add(exception);
setSchemaType(complexType);
setCorbaType(exception);
createFaultMessage(element.getQName());
}
use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.
the class FixedVisitor method visit.
public void visit(AST fixedNode) {
// "typedef" <type_declarator>
// <type_declarator> ::= <type_spec> <declarators>
// <type_spec> ::= <simple_type_spec>
// | <constr_type_spec>
// <simple_type_spec> ::= <base_type_spec>
// | <template_type_spec>
// | <scoped_name>
// <base_type_spec> ::= ... omitted (integer, char, octect, etc)
// <template_type_spec> ::= <sequence_type>
// | <string_type>
// | <wstring_type>
// | <fixed_pt_type>
// <constr_type_spec> ::= <struct_type>
// | <union_type>
// | <enum_type>
// <declarators> ::= <declarator> {"," <declarator>}*
// <declarator> ::= <simple_declarator>
// | <complex_declarator>
// <simple_declarator> ::= <identifier>
// <complex_declarator> ::= <array_declarator>
// <array_declarator> ::= <identifier> <fixed_array_size>+
// <fixed_array_size> ::= "[" <positive_int_const> "]"
AST digitsNode = fixedNode.getFirstChild();
AST scaleNode = digitsNode.getNextSibling();
final Scope scopedName;
if (identifierNode == null) {
scopedName = TypesUtils.generateAnonymousScopedName(getScope(), schema);
} else {
scopedName = new Scope(getScope(), identifierNode);
}
// validate digits and scale
Long digits = Long.valueOf(digitsNode.toString());
Long scale = Long.valueOf(scaleNode.toString());
if (digits < 1 || digits > 31) {
// throw IllegalIDLException();
System.out.println("Digits cannot be greater than 31");
return;
}
if (scale.compareTo(digits) > 0) {
// throw IllegalIDLException();
System.out.println("Scale cannot be greater than digits");
return;
}
// xmlschema:fixed
XmlSchemaSimpleType fixedSimpleType = new XmlSchemaSimpleType(schema, true);
XmlSchemaSimpleTypeRestriction fixedRestriction = new XmlSchemaSimpleTypeRestriction();
fixedRestriction.setBaseTypeName(Constants.XSD_DECIMAL);
XmlSchemaTotalDigitsFacet fixedTotalDigits = new XmlSchemaTotalDigitsFacet();
fixedTotalDigits.setValue(digitsNode.toString());
XmlSchemaFractionDigitsFacet fixedFractionDigits = new XmlSchemaFractionDigitsFacet();
fixedFractionDigits.setValue(scaleNode.toString());
fixedFractionDigits.setFixed(true);
fixedRestriction.getFacets().add(fixedTotalDigits);
fixedRestriction.getFacets().add(fixedFractionDigits);
fixedSimpleType.setName(mapper.mapToQName(scopedName));
fixedSimpleType.setContent(fixedRestriction);
// add xmlschema:fixed
setSchemaType(fixedSimpleType);
final CorbaType type;
if (identifierNode != null) {
// corba:fixed
Fixed corbaFixed = new Fixed();
corbaFixed.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
corbaFixed.setDigits(digits);
corbaFixed.setScale(scale);
corbaFixed.setRepositoryID(scopedName.toIDLRepositoryID());
// corbaFixed.setType(Constants.XSD_DECIMAL);
corbaFixed.setType(fixedSimpleType.getQName());
type = corbaFixed;
} else {
// corba:anonfixed
Anonfixed corbaFixed = new Anonfixed();
corbaFixed.setQName(new QName(typeMap.getTargetNamespace(), scopedName.toString()));
corbaFixed.setDigits(digits);
corbaFixed.setScale(scale);
// corbaFixed.setType(Constants.XSD_DECIMAL);
corbaFixed.setType(fixedSimpleType.getQName());
typeMap.getStructOrExceptionOrUnion().add(corbaFixed);
type = corbaFixed;
}
// add corba:fixed
setCorbaType(type);
}
use of org.apache.cxf.binding.corba.wsdl.CorbaType in project cxf by apache.
the class ArrayVisitor method visit.
public void visit(AST node) {
// <array_declarator> ::= <identifier> <fixed_array_size>+
// <fixed_array_size> ::= "[" <positive_int_const> "]"
AST firstSizeNode = node.getFirstChild();
AST nextSizeNode = firstSizeNode.getNextSibling();
final Types result;
// process all anonarrays, skip first array as it might not be anonymous
if (nextSizeNode != null) {
result = doAnonarray(nextSizeNode, getSchemaType(), getCorbaType());
} else {
result = new Types();
result.setSchemaType(getSchemaType());
result.setCorbaType(getCorbaType());
result.setFullyQualifiedName(getFullyQualifiedName());
}
// process first array
Long size = Long.valueOf(firstSizeNode.toString());
final XmlSchemaType stype;
final CorbaType ctype;
if (identifierNode != null) {
Scope scopedName = getScope();
if (result.getSchemaType() != null) {
stype = generateSchemaArray(scopedName, size, result.getSchemaType(), result.getFullyQualifiedName());
} else {
stype = generateSchemaArray(scopedName, size, null, result.getFullyQualifiedName());
}
if (result.getCorbaType() != null) {
ctype = generateCorbaArray(scopedName, size, result.getCorbaType(), stype, getFullyQualifiedName());
} else {
ctype = generateCorbaArray(scopedName, size, null, stype, getFullyQualifiedName());
}
} else {
// anonymous array
Scope scopedName = TypesUtils.generateAnonymousScopedName(getScope(), schema);
if (result.getSchemaType() != null) {
stype = generateSchemaArray(scopedName, size, result.getSchemaType(), getFullyQualifiedName());
} else {
stype = generateSchemaArray(scopedName, size, null, getFullyQualifiedName());
}
if (result.getCorbaType() != null) {
ctype = generateCorbaAnonarray(scopedName.toString(), size, result.getCorbaType(), stype, getFullyQualifiedName());
} else {
ctype = generateCorbaAnonarray(scopedName.toString(), size, null, stype, getFullyQualifiedName());
}
}
// add corbaType
typeMap.getStructOrExceptionOrUnion().add(ctype);
setSchemaType(stype);
setCorbaType(ctype);
}
Aggregations