use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class WSDLParameter method processOutputParams.
private void processOutputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation, SchemaCollection xmlSchemaList, List<ParamType> inputs, List<ParamType> outputs) throws Exception {
Output output = operation.getOutput();
if (output != null) {
Message msg = output.getMessage();
List<Part> parts = CastUtils.cast(msg.getOrderedParts(null));
for (Part part : parts) {
XmlSchemaType schemaType = null;
// check if in input list
String mode = "out";
ParamType paramtype = null;
boolean isObjectRef = isObjectReference(xmlSchemaList, part.getElementName());
for (int x = 0; x < inputs.size(); x++) {
paramtype = null;
ParamType d2 = inputs.get(x);
if (part.getElementName() != null && !isObjectRef) {
XmlSchemaElement el = getElement(part, xmlSchemaList);
if (el != null) {
if (el.getSchemaType() != null) {
schemaType = el.getSchemaType();
}
QName typeName = el.getSchemaTypeName();
if (typeName == null) {
typeName = el.getQName();
}
QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, el.isNillable());
if ((d2.getName().equals(part.getName())) && (d2.getIdltype().equals(idltype))) {
inputs.remove(x);
paramtype = createParam(wsdlToCorbaBinding, "inout", part.getName(), idltype);
inputs.add(paramtype);
}
}
} else {
schemaType = getType(part, xmlSchemaList);
QName typeName = part.getTypeName();
if (isObjectRef) {
typeName = part.getElementName();
}
QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, false);
if ((d2.getName().equals(part.getName())) && (d2.getIdltype().equals(idltype))) {
inputs.remove(x);
paramtype = createParam(wsdlToCorbaBinding, "inout", part.getName(), idltype);
inputs.add(paramtype);
}
}
}
if (paramtype == null) {
if (part.getElementName() != null && !isObjectRef) {
XmlSchemaElement el = getElement(part, xmlSchemaList);
QName typeName = el.getSchemaTypeName();
if (typeName == null) {
typeName = el.getQName();
}
QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, el.isNillable());
paramtype = createParam(wsdlToCorbaBinding, mode, part.getName(), idltype);
} else {
QName typeName = part.getTypeName();
if (isObjectRef) {
typeName = part.getElementName();
}
QName idltype = getIdlType(wsdlToCorbaBinding, schemaType, typeName, false);
paramtype = createParam(wsdlToCorbaBinding, mode, part.getName(), idltype);
}
if (paramtype != null) {
outputs.add(paramtype);
}
}
}
}
}
use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class WSDLToCorbaHelper method processSimpleRestrictionType.
private CorbaType processSimpleRestrictionType(XmlSchemaSimpleType stype, QName name, QName schematypeName, boolean anonymous) throws Exception {
CorbaType corbaTypeImpl;
// checks if enumeration
XmlSchemaSimpleTypeRestriction restrictionType = (XmlSchemaSimpleTypeRestriction) stype.getContent();
QName baseName = checkPrefix(restrictionType.getBaseTypeName());
String maxLength = null;
String length = null;
for (XmlSchemaFacet val : restrictionType.getFacets()) {
if (val instanceof XmlSchemaMaxLengthFacet) {
maxLength = val.getValue().toString();
}
if (val instanceof XmlSchemaLengthFacet) {
length = val.getValue().toString();
}
}
if (isEnumeration(restrictionType)) {
corbaTypeImpl = createCorbaEnum(restrictionType, name, schematypeName);
} else {
if (restrictionType.getBaseType() != null) {
corbaTypeImpl = convertSchemaToCorbaType(restrictionType.getBaseType(), schematypeName, stype, null, false);
} else {
corbaTypeImpl = processPrimitiveType(baseName);
if (corbaTypeImpl == null) {
XmlSchemaType schematype = findSchemaType(baseName);
corbaTypeImpl = convertSchemaToCorbaType(schematype, schematypeName, schematype, null, false);
}
}
if (corbaTypeImpl != null) {
if (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_STRING) || (baseName.equals(W3CConstants.NT_SCHEMA_STRING))) {
corbaTypeImpl = WSDLTypes.processStringType(corbaTypeImpl, name, maxLength, length);
} else if (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_DECIMAL) || (baseName.equals(W3CConstants.NT_SCHEMA_DECIMAL))) {
corbaTypeImpl = WSDLTypes.processDecimalType(restrictionType, name, corbaTypeImpl, anonymous);
} else if ((corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_BASE64)) || (baseName.equals(W3CConstants.NT_SCHEMA_BASE64)) || (corbaTypeImpl.getType().equals(W3CConstants.NT_SCHEMA_HBIN))) {
corbaTypeImpl = WSDLTypes.processBase64Type(corbaTypeImpl, name, maxLength, length);
}
}
}
return corbaTypeImpl;
}
use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class WSDLToCorbaHelper method getSchemaType.
public XmlSchemaType getSchemaType(QName name) throws Exception {
XmlSchemaType type = null;
for (XmlSchema xmlSchema : xmlSchemaList.getXmlSchemas()) {
String nspace = name.getNamespaceURI();
if (nspace == null) {
nspace = xmlSchema.getTargetNamespace();
}
// QName tname = createQName(nspace, name.getLocalPart(), "xsd");
QName tname = createQName(nspace, name.getLocalPart(), "");
type = findSchemaType(tname);
if (type != null) {
break;
}
}
return type;
}
use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class WSDLToCorbaHelper method processLiteralArray.
private CorbaType processLiteralArray(XmlSchemaComplexType complex, QName defaultName, boolean anonymous) throws Exception {
// NEED TO DO
QName name;
QName typeName = null;
QName schematypeName = checkPrefix(complex.getQName());
if (schematypeName == null) {
schematypeName = defaultName;
name = createQNameCorbaNamespace(defaultName.getLocalPart() + "Type");
schematypeName = checkPrefix(schematypeName);
name = checkPrefix(name);
} else {
name = createQNameCorbaNamespace(schematypeName.getLocalPart());
name = checkPrefix(name);
}
CorbaType arrayType = null;
XmlSchemaElement arrayEl = null;
QName elName = null;
if (complex.getParticle() instanceof XmlSchemaSequence) {
XmlSchemaSequence seq = (XmlSchemaSequence) complex.getParticle();
Iterator<XmlSchemaSequenceMember> iterator = seq.getItems().iterator();
Iterator<XmlSchemaSequenceMember> iter = seq.getItems().iterator();
while (iterator.hasNext()) {
if (iter.next() instanceof XmlSchemaElement) {
arrayEl = (XmlSchemaElement) iterator.next();
elName = arrayEl.getQName();
XmlSchemaType atype = arrayEl.getSchemaType();
if (elName == null) {
elName = arrayEl.getRef().getTargetQName();
/*
* TODO: why are we looking up an element name with findSchemaType?
*/
atype = findSchemaType(elName);
}
String uri = defaultName.getNamespaceURI();
if (complex.getQName() != null) {
uri = complex.getQName().getNamespaceURI();
}
if (elName.getNamespaceURI().isEmpty()) {
elName = new QName(uri, elName.getLocalPart());
}
QName arrayTypeName = elName;
if (anonymous) {
arrayTypeName = new QName(elName.getNamespaceURI(), defaultName.getLocalPart() + "." + elName.getLocalPart());
}
arrayType = convertSchemaToCorbaType(atype, arrayTypeName, atype, null, true);
boolean isQualified = getElementQualification(arrayEl, uri);
if (isQualified) {
arrayType.setQualified(isQualified);
} else {
elName = new QName("", elName.getLocalPart());
}
typeName = arrayType.getQName();
}
}
}
Long maxOccurs = null;
Long minOccurs = null;
if (arrayEl != null) {
if (arrayEl.isNillable()) {
QName nilunionname = createQNameTargetNamespace(arrayType.getQName().getLocalPart() + "_nil");
boolean isQualified = arrayType.isSetQualified() && arrayType.isQualified();
arrayType = createNillableUnion(nilunionname, elName, arrayType.getQName(), isQualified);
typeName = createQNameCorbaNamespace(arrayType.getQName().getLocalPart());
if (arrayType != null && !isDuplicate(arrayType)) {
typeMappingType.getStructOrExceptionOrUnion().add(arrayType);
}
}
maxOccurs = arrayEl.getMaxOccurs();
minOccurs = arrayEl.getMinOccurs();
}
return createArray(name, schematypeName, checkPrefix(typeName), elName, maxOccurs, minOccurs, anonymous);
}
use of org.apache.ws.commons.schema.XmlSchemaType in project cxf by apache.
the class WSDLToCorbaHelper method processLocalElement.
private CorbaType processLocalElement(QName containingTypeName, XmlSchemaElement element, String uri) throws Exception {
CorbaType membertype = new CorbaType();
XmlSchemaType schemaType = element.getSchemaType();
QName schemaName = element.getQName();
if (schemaType == null) {
if (element.getRef().getTarget() != null) {
schemaType = findSchemaType(element.getRef().getTarget().getSchemaTypeName());
schemaName = element.getRef().getTargetQName();
} else {
schemaType = findSchemaType(element.getSchemaTypeName());
}
}
if (schemaName.getNamespaceURI().isEmpty()) {
schemaName = new QName(uri, schemaName.getLocalPart());
}
QName elemName = schemaName;
boolean elementQualified = getElementQualification(element, uri);
if (!elementQualified) {
elemName = new QName("", elemName.getLocalPart());
}
QName memName = null;
if (element.isNillable()) {
CorbaType elemtype = convertSchemaToCorbaType(schemaType, elemName, schemaType, null, true);
QName name = createQNameTargetNamespace(elemtype.getQName().getLocalPart() + "_nil");
QName elName = checkPrefix(elemName);
if (elName == null) {
elName = createQNameTargetNamespace(elemName.getLocalPart());
}
CorbaType memtype = createNillableUnion(elName, name, elemtype.getQName(), elementQualified);
memName = createQNameCorbaNamespace(memtype.getQName().getLocalPart());
if (!isDuplicate(memtype)) {
typeMappingType.getStructOrExceptionOrUnion().add(memtype);
}
membertype.setQName(memName);
membertype.setName(memtype.getName());
membertype.setType(memtype.getType());
} else if (schemaType != null) {
XmlSchemaType st = schemaType;
boolean anonymous = WSDLTypes.isAnonymous(st.getName());
final QName typeName;
if (anonymous) {
typeName = new QName(elemName.getNamespaceURI(), containingTypeName.getLocalPart() + "." + elemName.getLocalPart());
} else {
typeName = st.getQName();
}
membertype = convertSchemaToCorbaType(st, typeName, st, null, anonymous);
} else if (element.getSchemaTypeName() != null) {
QName name = checkPrefix(element.getSchemaTypeName());
membertype = getLocalType(name);
}
if (membertype == null) {
return null;
}
if (element.getMaxOccurs() != 1 || element.getMinOccurs() != 1) {
QName name = createQNameCorbaNamespace(getModulePrefix(membertype) + elemName.getLocalPart() + "Array");
final CorbaType arraytype;
if (memName != null) {
arraytype = createArray(name, /*schemaName*/
name, memName, elemName, element.getMaxOccurs(), element.getMinOccurs(), false);
} else {
arraytype = createArray(name, /*schemaName*/
name, membertype.getQName(), elemName, element.getMaxOccurs(), element.getMinOccurs(), false);
}
if (arraytype != null) {
if (arraytype instanceof Abstractsequence) {
((Abstractsequence) arraytype).setWrapped(false);
}
if (arraytype instanceof Abstractanonsequence) {
((Abstractanonsequence) arraytype).setWrapped(false);
}
if (!isDuplicate(arraytype)) {
typeMappingType.getStructOrExceptionOrUnion().add(arraytype);
}
// the local element with maxOccurs != 1 or minOccurs != 1 becomes the just created array
membertype = arraytype;
}
}
membertype.setQualified(elementQualified);
return membertype;
}
Aggregations