use of org.apache.ws.commons.schema.XmlSchemaElement in project cxf by apache.
the class JavascriptUtils method getObjectParticle.
/**
* If the object is an element or an any, return the particle. If it's not a particle, or it's a group,
* throw. We're not ready for groups yet.
* @param object
*/
public static XmlSchemaParticle getObjectParticle(XmlSchemaObject object, QName contextName, XmlSchema currentSchema) {
if (!(object instanceof XmlSchemaParticle)) {
throw unsupportedConstruct("NON_PARTICLE_CHILD", object.getClass().getSimpleName(), contextName, object);
}
if (object instanceof XmlSchemaGroupRef) {
QName groupName = ((XmlSchemaGroupRef) object).getRefName();
XmlSchemaGroup group = currentSchema.getGroupByName(groupName);
if (group == null) {
throw unsupportedConstruct("MISSING_GROUP", groupName.toString(), contextName, null);
}
XmlSchemaParticle groupParticle = group.getParticle();
if (!(groupParticle instanceof XmlSchemaSequence)) {
throw unsupportedConstruct("GROUP_REF_UNSUPPORTED_TYPE", groupParticle.getClass().getSimpleName(), contextName, groupParticle);
}
return groupParticle;
}
if (!(object instanceof XmlSchemaElement) && !(object instanceof XmlSchemaAny) && !(object instanceof XmlSchemaChoice) && !(object instanceof XmlSchemaSequence)) {
throw unsupportedConstruct("GROUP_CHILD", object.getClass().getSimpleName(), contextName, object);
}
return (XmlSchemaParticle) object;
}
use of org.apache.ws.commons.schema.XmlSchemaElement in project cxf by apache.
the class WSDLServiceBuilder method buildMessage.
private void buildMessage(AbstractMessageContainer minfo, Message msg) {
SchemaCollection schemas = minfo.getOperation().getInterface().getService().getXmlSchemaCollection();
List<?> orderedParam = msg.getOrderedParts(null);
for (Part part : cast(orderedParam, Part.class)) {
MessagePartInfo pi = minfo.addMessagePart(new QName(minfo.getName().getNamespaceURI(), part.getName()));
if (part.getTypeName() != null) {
pi.setTypeQName(part.getTypeName());
pi.setElement(false);
pi.setXmlSchema(schemas.getTypeByQName(part.getTypeName()));
} else if (part.getElementName() != null) {
pi.setElementQName(part.getElementName());
XmlSchemaElement schemaElement = schemas.getElementByQName(part.getElementName());
if (null == schemaElement) {
org.apache.cxf.common.i18n.Message errorMessage = new org.apache.cxf.common.i18n.Message("WSDL4J_BAD_ELEMENT_PART", LOG, part.getName(), part.getElementName());
throw new WSDLRuntimeException(errorMessage);
}
pi.setElement(true);
pi.setXmlSchema(schemaElement);
} else {
org.apache.cxf.common.i18n.Message errorMessage = new org.apache.cxf.common.i18n.Message("PART_NO_NAME_NO_TYPE", LOG, part.getName());
throw new WSDLRuntimeException(errorMessage);
}
}
}
use of org.apache.ws.commons.schema.XmlSchemaElement in project cxf by apache.
the class WSDLServiceBuilder method buildMessageParts.
private static boolean buildMessageParts(XmlSchemaSequence seq, String namespaceURI, MessageInfo wrapper, boolean allowRefs) {
List<XmlSchemaSequenceMember> items = seq.getItems();
boolean ret = true;
for (XmlSchemaSequenceMember seqItem : items) {
if (!(seqItem instanceof XmlSchemaElement)) {
return false;
}
XmlSchemaElement el = (XmlSchemaElement) seqItem;
if (el.getSchemaTypeName() != null) {
MessagePartInfo mpi = wrapper.addMessagePart(new QName(namespaceURI, el.getName()));
mpi.setTypeQName(el.getSchemaTypeName());
mpi.setElement(true);
mpi.setElementQName(el.getWireName());
mpi.setConcreteName(el.getWireName());
mpi.setXmlSchema(el);
} else if (el.getRef().getTargetQName() != null) {
MessagePartInfo mpi = wrapper.addMessagePart(el.getRef().getTargetQName());
mpi.setTypeQName(el.getRef().getTargetQName());
mpi.setElementQName(el.getRef().getTargetQName());
mpi.setElement(true);
mpi.setXmlSchema(el);
mpi.setProperty("isRefElement", true);
// element reference is not permitted for wrapper element
if (!allowRefs) {
ret = false;
}
} else {
// anonymous type
MessagePartInfo mpi = wrapper.addMessagePart(new QName(namespaceURI, el.getName()));
mpi.setElementQName(mpi.getName());
mpi.setConcreteName(el.getWireName());
mpi.setElement(true);
mpi.setXmlSchema(el);
}
}
return ret;
}
use of org.apache.ws.commons.schema.XmlSchemaElement in project cxf by apache.
the class ParameterProcessor method processReturn.
private void processReturn(JavaMethod method, MessagePartInfo part) {
String name = part == null ? "return" : part.getName().getLocalPart();
String type = part == null ? "void" : ProcessorUtil.resolvePartType(part, context);
String namespace = part == null ? null : ProcessorUtil.resolvePartNamespace(part);
JavaReturn returnType = new JavaReturn(name, type, namespace);
if (part != null) {
returnType.setDefaultValueWriter(ProcessorUtil.getDefaultValueWriter(part, context));
}
returnType.setQName(ProcessorUtil.getElementName(part));
returnType.setStyle(JavaType.Style.OUT);
if (namespace != null && type != null && !"void".equals(type)) {
returnType.setClassName(ProcessorUtil.getFullClzName(part, context, false));
}
if (part != null && part.getXmlSchema() instanceof XmlSchemaSimpleType) {
processXmlSchemaSimpleType((XmlSchemaSimpleType) part.getXmlSchema(), method, part);
} else if (part != null && part.getXmlSchema() instanceof XmlSchemaElement) {
XmlSchemaElement element = (XmlSchemaElement) part.getXmlSchema();
if (element.getSchemaType() instanceof XmlSchemaSimpleType) {
processXmlSchemaSimpleType((XmlSchemaSimpleType) element.getSchemaType(), method, part);
}
}
method.setReturn(returnType);
}
use of org.apache.ws.commons.schema.XmlSchemaElement in project cxf by apache.
the class OperationVisitor method addElement.
private XmlSchemaElement addElement(XmlSchemaSequence schemaSequence, XmlSchemaType schemaType, Scope fqName, String name) {
XmlSchemaElement element = new XmlSchemaElement(schema, false);
element.setName(name);
if (schemaType != null) {
element.setSchemaTypeName(schemaType.getQName());
if (schemaType.getQName().equals(ReferenceConstants.WSADDRESSING_TYPE)) {
element.setNillable(true);
}
} else {
wsdlVisitor.getDeferredActions().add(fqName, new OperationDeferredAction(element));
}
schemaSequence.getItems().add(element);
return element;
}
Aggregations