use of org.apache.ws.commons.schema.XmlSchemaComplexType in project cxf by apache.
the class ProcessorUtil method getWrappedElement.
public static List<WrapperElement> getWrappedElement(ToolContext context, QName partElement) {
ServiceInfo serviceInfo = context.get(ServiceInfo.class);
SchemaCollection schema = serviceInfo.getXmlSchemaCollection();
XmlSchemaElement elementByName = schema.getElementByQName(partElement);
XmlSchemaComplexType type = (XmlSchemaComplexType) elementByName.getSchemaType();
XmlSchemaSequence seq = (XmlSchemaSequence) type.getParticle();
List<WrapperElement> qnames = createWrappedElements(seq);
// If it's extension
if (seq == null && type.getContentModel() != null) {
Object configuredMaxStackDepth = context.get(ToolConstants.CFG_MAX_EXTENSION_STACK_DEPTH);
Integer maxStackDepth = Integer.valueOf(5);
if (configuredMaxStackDepth instanceof Integer) {
maxStackDepth = (Integer) configuredMaxStackDepth;
} else if (configuredMaxStackDepth instanceof String) {
maxStackDepth = Integer.valueOf((String) configuredMaxStackDepth);
}
qnames.addAll(createWrappedElementsFromExtension(schema, type, maxStackDepth));
}
return qnames;
}
use of org.apache.ws.commons.schema.XmlSchemaComplexType in project cxf by apache.
the class ProcessorUtil method createWrappedElementsFromExtension.
private static List<WrapperElement> createWrappedElementsFromExtension(SchemaCollection schema, XmlSchemaComplexType type, int maxStackDepth) {
List<WrapperElement> qnames = new ArrayList<>();
XmlSchemaContent schemaContent = type.getContentModel().getContent();
if (!(schemaContent instanceof XmlSchemaComplexContentExtension) || maxStackDepth == 0) {
return qnames;
}
XmlSchemaComplexContentExtension extension = (XmlSchemaComplexContentExtension) schemaContent;
QName baseTypeName = extension.getBaseTypeName();
XmlSchemaType baseType = schema.getTypeByQName(baseTypeName);
if (baseType instanceof XmlSchemaComplexType) {
XmlSchemaComplexType complexBaseType = (XmlSchemaComplexType) baseType;
if (complexBaseType.getParticle() == null && complexBaseType.getContentModel() != null) {
// continue up the extension ladder
qnames.addAll(createWrappedElementsFromExtension(schema, complexBaseType, maxStackDepth - 1));
} else if (complexBaseType.getParticle() instanceof XmlSchemaSequence) {
XmlSchemaSequence seq = (XmlSchemaSequence) complexBaseType.getParticle();
qnames.addAll(createWrappedElements(seq));
}
}
if (extension.getParticle() instanceof XmlSchemaSequence) {
XmlSchemaSequence xmlSchemaSeq = (XmlSchemaSequence) extension.getParticle();
qnames.addAll(createWrappedElements(xmlSchemaSeq));
}
return qnames;
}
use of org.apache.ws.commons.schema.XmlSchemaComplexType in project cxf by apache.
the class WSDLToCorbaBinding method createCorbaException.
private org.apache.cxf.binding.corba.wsdl.Exception createCorbaException(QName schemaTypeName, XmlSchemaType stype) throws Exception {
org.apache.cxf.binding.corba.wsdl.Exception corbaex = null;
if (stype instanceof XmlSchemaComplexType) {
QName defaultName = schemaTypeName;
XmlSchemaComplexType complex = (XmlSchemaComplexType) stype;
corbaex = new org.apache.cxf.binding.corba.wsdl.Exception();
corbaex.setQName(schemaTypeName);
corbaex.setType(helper.checkPrefix(schemaTypeName));
corbaex.setName(schemaTypeName.getLocalPart());
corbaex.setRepositoryID(WSDLToCorbaHelper.REPO_STRING + "/" + defaultName.getLocalPart() + WSDLToCorbaHelper.IDL_VERSION);
String uri = defaultName.getNamespaceURI();
List<MemberType> attributeMembers = helper.processAttributesAsMembers(complex.getAttributes(), uri);
for (MemberType memberType : attributeMembers) {
corbaex.getMember().add(memberType);
}
List<MemberType> members = helper.processContainerAsMembers(complex.getParticle(), stype.getQName(), defaultName);
for (MemberType memberType : members) {
corbaex.getMember().add(memberType);
}
}
return corbaex;
}
use of org.apache.ws.commons.schema.XmlSchemaComplexType in project cxf by apache.
the class WSDLParameter method processWrappedInputParams.
private void processWrappedInputParams(WSDLToCorbaBinding wsdlToCorbaBinding, Operation operation, SchemaCollection xmlSchemaList, List<ParamType> inputs) throws Exception {
Input input = operation.getInput();
if (input != null) {
Message msg = input.getMessage();
Part part = (Part) msg.getOrderedParts(null).iterator().next();
XmlSchemaElement el = getElement(part, xmlSchemaList);
if (el == null) {
return;
}
XmlSchemaComplexType schemaType = null;
if (el.getSchemaType() != null) {
schemaType = (XmlSchemaComplexType) el.getSchemaType();
}
XmlSchemaSequence seq = (XmlSchemaSequence) schemaType.getParticle();
if (seq != null) {
for (XmlSchemaSequenceMember seqItem : seq.getItems()) {
if (seqItem instanceof XmlSchemaElement) {
el = (XmlSchemaElement) seqItem;
// REVISIT, handle element ref's?
QName typeName = el.getSchemaTypeName();
if (typeName == null) {
typeName = el.getQName();
}
QName idltype = getIdlType(wsdlToCorbaBinding, el.getSchemaType(), typeName, el.isNillable());
ParamType paramtype = createParam(wsdlToCorbaBinding, "in", el.getQName().getLocalPart(), idltype);
if (paramtype != null) {
inputs.add(paramtype);
}
}
}
}
}
}
use of org.apache.ws.commons.schema.XmlSchemaComplexType in project cxf by apache.
the class WSDLParameter method isWrappedOperation.
private boolean isWrappedOperation(Operation op, SchemaCollection xmlSchemaList) throws Exception {
Message inputMessage = op.getInput().getMessage();
Message outputMessage = null;
if (op.getOutput() != null) {
outputMessage = op.getOutput().getMessage();
}
boolean passedRule = true;
// input message must exist
if (inputMessage == null || inputMessage.getParts().size() != 1 || (outputMessage != null && outputMessage.getParts().size() > 1)) {
passedRule = false;
}
if (!passedRule) {
return false;
}
XmlSchemaElement inputEl = null;
XmlSchemaElement outputEl = null;
// RULE No.2:
// The input message part refers to a global element decalration whose
// localname
// is equal to the operation name
Part inputPart = (Part) inputMessage.getParts().values().iterator().next();
if (inputPart.getElementName() == null) {
passedRule = false;
} else {
QName inputElementName = inputPart.getElementName();
inputEl = getElement(inputPart, xmlSchemaList);
if (inputEl == null || !op.getName().equals(inputElementName.getLocalPart())) {
passedRule = false;
}
}
if (!passedRule) {
return false;
}
// The output message part refers to a global element declaration
if (outputMessage != null && outputMessage.getParts().size() == 1) {
Part outputPart = (Part) outputMessage.getParts().values().iterator().next();
if (outputPart != null) {
if ((outputPart.getElementName() == null) || getElement(outputPart, xmlSchemaList) == null) {
passedRule = false;
} else {
outputEl = getElement(outputPart, xmlSchemaList);
}
}
}
if (!passedRule) {
return false;
}
if (inputEl.getSchemaType() instanceof XmlSchemaComplexType) {
XmlSchemaComplexType xsct = (XmlSchemaComplexType) inputEl.getSchemaType();
if (hasAttributes(xsct) || !isWrappableSequence(xsct)) {
passedRule = false;
}
} else {
passedRule = false;
}
if (!passedRule) {
return false;
}
if (outputMessage != null) {
if (outputEl != null && outputEl.getSchemaType() instanceof XmlSchemaComplexType) {
XmlSchemaComplexType xsct = (XmlSchemaComplexType) outputEl.getSchemaType();
if (hasAttributes(xsct) || !isWrappableSequence(xsct)) {
passedRule = false;
}
} else {
passedRule = false;
}
}
return passedRule;
}
Aggregations