Author: jkaputin
Date: Thu Oct 19 07:09:48 2006
New Revision: 465636
URL: http://svn.apache.org/viewvc?view=rev&rev=465636
Log:
Modified OMWSDLReader to inherit refactored
methods from BaseWSDLReader (old methods have been
commented out for now - to be deleted later).
Modified:
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMWSDLReader.java
Modified:
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMWSDLReader.java
URL:
http://svn.apache.org/viewvc/incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMWSDLReader.java?view=diff&rev=465636&r1=465635&r2=465636
==============================================================================
---
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMWSDLReader.java
(original)
+++
incubator/woden/branches/WODEN-44/src/org/apache/woden/internal/OMWSDLReader.java
Thu Oct 19 07:09:48 2006
@@ -18,12 +18,9 @@
import java.io.ByteArrayInputStream;
import java.net.MalformedURLException;
import java.net.URI;
-import java.net.URISyntaxException;
import java.net.URL;
-import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
-import java.util.List;
import java.util.Map;
import javax.xml.namespace.QName;
@@ -31,46 +28,22 @@
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMNamespace;
-import org.apache.woden.XMLElement;
import org.apache.woden.ErrorHandler;
import org.apache.woden.ErrorReporter;
import org.apache.woden.WSDLException;
import org.apache.woden.WSDLSource;
+import org.apache.woden.XMLElement;
import org.apache.woden.internal.schema.ImportedSchemaImpl;
import org.apache.woden.internal.schema.InlinedSchemaImpl;
import org.apache.woden.internal.schema.SchemaConstants;
import org.apache.woden.internal.util.StringUtils;
-import org.apache.woden.internal.util.om.OMUtils;
import org.apache.woden.internal.util.om.OMQNameUtils;
+import org.apache.woden.internal.util.om.OMUtils;
import org.apache.woden.internal.wsdl20.Constants;
import org.apache.woden.schema.Schema;
-import org.apache.woden.types.NCName;
-import org.apache.woden.wsdl20.enumeration.Direction;
-import org.apache.woden.wsdl20.enumeration.MessageLabel;
-import org.apache.woden.wsdl20.extensions.ExtensionDeserializer;
-import org.apache.woden.wsdl20.extensions.ExtensionElement;
-import org.apache.woden.wsdl20.extensions.ExtensionRegistry;
-import org.apache.woden.wsdl20.xml.BindingElement;
-import org.apache.woden.wsdl20.xml.BindingFaultElement;
-import org.apache.woden.wsdl20.xml.BindingFaultReferenceElement;
-import org.apache.woden.wsdl20.xml.BindingMessageReferenceElement;
-import org.apache.woden.wsdl20.xml.BindingOperationElement;
import org.apache.woden.wsdl20.xml.ConfigurableElement;
import org.apache.woden.wsdl20.xml.DescriptionElement;
-import org.apache.woden.wsdl20.xml.DocumentableElement;
-import org.apache.woden.wsdl20.xml.DocumentationElement;
-import org.apache.woden.wsdl20.xml.EndpointElement;
-import org.apache.woden.wsdl20.xml.FeatureElement;
-import org.apache.woden.wsdl20.xml.ImportElement;
-import org.apache.woden.wsdl20.xml.IncludeElement;
-import org.apache.woden.wsdl20.xml.InterfaceElement;
-import org.apache.woden.wsdl20.xml.InterfaceFaultElement;
-import org.apache.woden.wsdl20.xml.InterfaceFaultReferenceElement;
-import org.apache.woden.wsdl20.xml.InterfaceMessageReferenceElement;
-import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
import org.apache.woden.wsdl20.xml.PropertyElement;
-import org.apache.woden.wsdl20.xml.ServiceElement;
-import org.apache.woden.wsdl20.xml.TypesElement;
import org.apache.woden.wsdl20.xml.WSDLElement;
import org.apache.ws.commons.schema.XmlSchema;
import org.apache.ws.commons.schema.XmlSchemaCollection;
@@ -104,9 +77,11 @@
OMElement wsdlDescription = OMUtils.getElement(url.toString());
- return parseDescription(url.toString(), wsdlDescription, null);
+ XMLElement descEl = createXMLElement(wsdlDescription);
+ return parseDescription(url.toString(), descEl, null);
}
+ /*
private DescriptionElement parseDescription(String documentBaseURI,
OMElement omDescription,
Map wsdlModules)
@@ -196,8 +171,9 @@
return desc;
}
+ */
-
+ /*
private DocumentationElement parseDocumentation(OMElement docEl,
DescriptionElement desc,
DocumentableElement parent)
@@ -220,8 +196,9 @@
}
return documentation;
}
+ */
-
+ /*
private TypesElement parseTypes(OMElement typesEl,
DescriptionElement desc)
throws WSDLException {
@@ -256,8 +233,9 @@
}
return types;
}
+ */
-
+ /*
private ServiceElement parseService(OMElement serviceEl,
DescriptionElement desc)
throws WSDLException{
@@ -287,7 +265,7 @@
parseExtensionAttributes(serviceEl, ServiceElement.class, service,
desc);
- /* Parse the child elements of <service>.*/
+ // Parse the child elements of <service>.
Iterator serviceElChildren = serviceEl.getChildElements();
while (serviceElChildren.hasNext()){
OMElement serviceElChild = (OMElement)serviceElChildren.next();
@@ -309,8 +287,9 @@
}
return service;
}
+ */
-
+ /*
private EndpointElement parseEndpoint(OMElement endpointEl,
DescriptionElement desc,
ServiceElement parent)
@@ -348,7 +327,7 @@
parseExtensionAttributes(endpointEl, EndpointElement.class, endpoint,
desc);
- /* Parse the child elements of <endpoint>*/
+ // Parse the child elements of <endpoint>
Iterator endpointElChildren = endpointEl.getChildElements();
while (endpointElChildren.hasNext()){
OMElement endpointElChild = (OMElement)endpointElChildren.next();
@@ -368,8 +347,9 @@
}
return endpoint;
}
+ */
-
+ /*
private BindingElement parseBinding(OMElement bindEl,
DescriptionElement desc)
throws WSDLException{
@@ -404,7 +384,7 @@
parseExtensionAttributes(bindEl, BindingElement.class, binding, desc);
- /* Parse the child elements of <binding>.*/
+ // Parse the child elements of <binding>.
Iterator bindElChildren = bindEl.getChildElements();
while (bindElChildren.hasNext()){
OMElement bindElChild = (OMElement)bindElChildren.next();
@@ -429,8 +409,9 @@
}
return binding;
}
+ */
-
+ /*
private BindingOperationElement parseBindingOperation(OMElement bindOpEl,
DescriptionElement
desc,
BindingElement
parent)
@@ -457,7 +438,7 @@
parseExtensionAttributes(bindOpEl, BindingOperationElement.class,
oper, desc);
- /* Parse the child elements of binding <operation>.*/
+ // Parse the child elements of binding <operation>.
Iterator bindOpElChildren = bindOpEl.getChildElements();
while (bindOpElChildren.hasNext()){
OMElement bindOpElChild = (OMElement)bindOpElChildren.next();
@@ -489,8 +470,9 @@
}
return oper;
}
+ */
-
+ /*
private BindingFaultReferenceElement parseBindingFaultReference(
OMElement faultRefEl,
DescriptionElement desc,
@@ -523,7 +505,7 @@
parseExtensionAttributes(faultRefEl,
BindingFaultReferenceElement.class, faultRef, desc);
- /* Parse the child elements of binding operation <infault> or
<outfault>.*/
+ // Parse the child elements of binding operation <infault> or
<outfault>.
Iterator faultRefElChildren = faultRefEl.getChildElements();
while (faultRefElChildren.hasNext()){
OMElement faultRefChild = (OMElement)faultRefElChildren.next();
@@ -542,8 +524,9 @@
}
return faultRef;
}
+ */
-
+ /*
private BindingMessageReferenceElement parseBindingMessageReference(
OMElement msgRefEl,
DescriptionElement desc,
@@ -576,7 +559,7 @@
parseExtensionAttributes(msgRefEl,
BindingMessageReferenceElement.class, message, desc);
- /* Parse the child elements of binding operation <input> or <output>.*/
+ // Parse the child elements of binding operation <input> or <output>.
Iterator msgRefElChildren = msgRefEl.getChildElements();
while (msgRefElChildren.hasNext()){
OMElement msgRefChild = (OMElement)msgRefElChildren.next();
@@ -595,8 +578,9 @@
}
return message;
}
+ */
-
+ /*
private BindingFaultElement parseBindingFault(OMElement bindFaultEl,
DescriptionElement desc,
BindingElement parent)
@@ -623,7 +607,7 @@
parseExtensionAttributes(bindFaultEl, BindingFaultElement.class,
fault, desc);
- /* Parse the child elements of binding <fault>.*/
+ // Parse the child elements of binding <fault>.
Iterator bindFaultElChildren = bindFaultEl.getChildElements();
while (bindFaultElChildren.hasNext()){
OMElement bindFaultChild = (OMElement)bindFaultElChildren.next();
@@ -642,7 +626,9 @@
}
return fault;
}
+ */
+ /*
private InterfaceElement parseInterface(OMElement interfaceEl,
DescriptionElement desc)
throws WSDLException {
@@ -676,7 +662,7 @@
parseExtensionAttributes(interfaceEl, InterfaceElement.class, intface,
desc);
- /* Parse the child elements of <interface>.*/
+ // Parse the child elements of <interface>.
Iterator interfaceChildren = interfaceEl.getChildElements();
while (interfaceChildren.hasNext()){
OMElement interfaceChild = (OMElement)interfaceChildren.next();
@@ -702,8 +688,9 @@
}
return intface;
}
+ */
-
+ /*
private InterfaceOperationElement parseInterfaceOperation(
OMElement operEl,
DescriptionElement desc,
@@ -736,7 +723,7 @@
parseExtensionAttributes(operEl, InterfaceOperationElement.class,
oper, desc);
- /* Parse the child elements of interface <operation>.*/
+ // Parse the child elements of interface <operation>.
Iterator operElChildren = operEl.getChildElements();
while (operElChildren.hasNext()){
OMElement operElChild = (OMElement)operElChildren.next();
@@ -768,8 +755,9 @@
}
return oper;
}
+ */
-
+ /*
private InterfaceFaultReferenceElement parseInterfaceFaultReference(
OMElement faultRefEl,
DescriptionElement desc,
@@ -828,8 +816,9 @@
}
return faultRef;
}
+ */
-
+ /*
private InterfaceMessageReferenceElement parseInterfaceMessageReference(
OMElement msgRefEl,
DescriptionElement desc,
@@ -902,8 +891,9 @@
}
return message;
}
+ */
-
+ /*
private InterfaceFaultElement parseInterfaceFault(
OMElement faultEl,
DescriptionElement desc,
@@ -956,41 +946,44 @@
}
return fault;
}
+ */
- private PropertyElement parseProperty(OMElement propEl,
+ protected PropertyElement parseProperty(XMLElement propEl,
DescriptionElement desc,
ConfigurableElement parent)
throws WSDLException{
PropertyElement property = parent.addPropertyElement();
property.setParentElement(parent);
-
- String ref = OMUtils.getAttribute(propEl, Constants.ATTR_REF);
+
+ String ref = propEl.getAttributeValue(Constants.ATTR_REF);
if(ref != null){
property.setRef(getURI(ref));
}
parseExtensionAttributes(propEl, PropertyElement.class, property,
desc);
- Iterator propElChildren = propEl.getChildElements();
+ XMLElement tempEl = propEl.getFirstChildElement();
+ QName tempElQN = null;
- while (propElChildren.hasNext()){
- OMElement propElChild = (OMElement)propElChildren.next();
+ while (tempEl != null) {
+ tempElQN = tempEl.getQName();
- if (OMQNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION,
propElChild)){
- parseDocumentation(propElChild, desc, property);
+ if (Constants.Q_ELEM_DOCUMENTATION.equals(tempElQN)){
+ parseDocumentation(tempEl, desc, property);
}
- else if(OMQNameUtils.matches(Constants.Q_ELEM_VALUE, propElChild)){
+ else if(Constants.Q_ELEM_VALUE.equals(tempElQN)){
//the property value consists of the child info items of
<value>
- Iterator propChildValueEls = propElChild.getChildElements();
+ OMElement valueElem = (OMElement)tempEl.getSource();
+ Iterator propChildValueEls = valueElem.getChildElements();
property.setValue(propChildValueEls);
}
- else if(OMQNameUtils.matches(Constants.Q_ELEM_CONSTRAINT,
propElChild)){
+ else if(Constants.Q_ELEM_CONSTRAINT.equals(tempElQN)){
//todo
}
else{
-
property.addExtensionElement(parseExtensionElement(PropertyElement.class,
property, propElChild, desc) );
+
property.addExtensionElement(parseExtensionElement(PropertyElement.class,
property, tempEl, desc) );
}
}
return property;
@@ -1010,19 +1003,19 @@
* - imported schema MUST have a targetNamespace
* - namespace and targetNamespace MUST be the same
*/
- private Schema parseSchemaImport(OMElement importEl,
+ protected Schema parseSchemaImport(XMLElement importEl,
DescriptionElement desc)
throws WSDLException {
ImportedSchemaImpl schema = new ImportedSchemaImpl();
- String ns = OMUtils.getAttribute(importEl, Constants.ATTR_NAMESPACE);
+ String ns = importEl.getAttributeValue(Constants.ATTR_NAMESPACE);
if(ns != null) {
schema.setNamespace(getURI(ns));
}
- String sloc = OMUtils.getAttribute(importEl,
SchemaConstants.ATTR_SCHEMA_LOCATION);
+ String sloc =
importEl.getAttributeValue(SchemaConstants.ATTR_SCHEMA_LOCATION);
if(sloc != null) {
schema.setSchemaLocation(getURI(sloc));
}
@@ -1125,13 +1118,13 @@
}
- private Schema parseSchemaInline(OMElement schemaElement,
+ protected Schema parseSchemaInline(XMLElement schemaElement,
DescriptionElement desc)
throws WSDLException{
InlinedSchemaImpl schema = new InlinedSchemaImpl();
- schema.setId(OMUtils.getAttribute(schemaElement, Constants.ATTR_ID));
- String tns = OMUtils.getAttribute(schemaElement,
Constants.ATTR_TARGET_NAMESPACE);
+ schema.setId(schemaElement.getAttributeValue(Constants.ATTR_ID));
+ String tns =
schemaElement.getAttributeValue(Constants.ATTR_TARGET_NAMESPACE);
if(tns != null) {
schema.setNamespace(getURI(tns));
}
@@ -1142,7 +1135,8 @@
XmlSchema schemaDef = null;
try {
- InputSource schemaSource = OMUtils.getInputSource(schemaElement);
+ OMElement omSchemaElem = (OMElement)schemaElement.getSource();
+ InputSource schemaSource = OMUtils.getInputSource(omSchemaElem);
XmlSchemaCollection xsc = new XmlSchemaCollection();
//Set the baseURI and the namespaces from the DescriptionElement
in the XMLSchemaCollection
@@ -1171,6 +1165,7 @@
}
+ /*
private FeatureElement parseFeature(OMElement featEl,
DescriptionElement desc,
ConfigurableElement parent)
@@ -1191,7 +1186,7 @@
parseExtensionAttributes(featEl, FeatureElement.class, feature, desc);
- /* Parse the child elements of the <feature> element.*/
+ // Parse the child elements of the <feature> element.
Iterator featElChildren = featEl.getChildElements();
while (featElChildren.hasNext()){
OMElement featElChild = (OMElement)featElChildren.next();
@@ -1205,7 +1200,9 @@
}
return feature;
}
+ */
+ /*
private ImportElement parseImport(OMElement importEl,
DescriptionElement desc,
Map wsdlModules)
@@ -1232,7 +1229,9 @@
return imp;
}
+ */
+ /*
private IncludeElement parseInclude(OMElement includeEl,
DescriptionElement desc,
Map wsdlModules)
@@ -1252,8 +1251,10 @@
return include;
}
+ */
+ /*
//TODO
private ExtensionElement parseExtensionElement(Class parentType,
WSDLElement parent,
@@ -1295,10 +1296,11 @@
throw e;
}
}
+ */
//TODO
- private void parseExtensionAttributes(OMElement domEl,
+ protected void parseExtensionAttributes(XMLElement domEl,
Class wsdlClass,
WSDLElement wsdlObj,
DescriptionElement desc)
@@ -1342,7 +1344,7 @@
* Convert a string of type xs:anyURI to a java.net.URI.
* An empty string argument will return an empty string URI.
* A null argument will return a null.
- */
+ *
private URI getURI(String anyURI) throws WSDLException{
URI uri = null;
if(anyURI != null){
@@ -1360,6 +1362,7 @@
}
return uri;
}
+ */
/*
* Check the actual OM element encountered against the expected qname
@@ -1367,7 +1370,7 @@
* @param el actual element encountered
* @param qname expected element's qname
* @throws WSDLException
- */
+ *
private void checkElementName(OMElement el,
QName qname)
throws WSDLException {
@@ -1382,6 +1385,7 @@
//TODO wsdlExc.setLocation(XPathUtils.getXPathExprFromNode(el));
}
}
+ */
/*
* Retrieve a WSDL document by resolving the location URI specified
@@ -1389,7 +1393,7 @@
*
* TODO add support for a URL Catalog Resolver
*/
- private DescriptionElement getWSDLFromLocation(String locationURI,
+ protected DescriptionElement getWSDLFromLocation(String locationURI,
DescriptionElement desc,
Map wsdlModules)
throws WSDLException{
@@ -1438,8 +1442,10 @@
return null;
}
+ XMLElement descEl = createXMLElement(docEl);
+
referencedDesc = parseDescription(locationStr,
- docEl,
+ descEl,
wsdlModules);
if(!wsdlModules.containsKey(locationStr)){
@@ -1462,5 +1468,28 @@
}
+ protected void parseNamespaceDeclarations(
+ XMLElement xmlElem,
+ WSDLElement wsdlElem)
+ throws WSDLException {
+ OMElement omDescription = (OMElement)xmlElem.getSource();
+
+ //TODO remove this cast when support for NS decls is expanded from
DescriptionElement to all WSDLElements
+ DescriptionElement desc = (DescriptionElement)wsdlElem;
+
+ Iterator namespaces = omDescription.getAllDeclaredNamespaces();
+ while(namespaces.hasNext()){
+ OMNamespace namespace = (OMNamespace)namespaces.next();
+ String localPart = namespace.getPrefix();
+ String value = namespace.getNamespaceURI();
+
+ if (!(Constants.ATTR_XMLNS).equals(localPart)){
+ desc.addNamespace(localPart, getURI(value)); //a prefixed
namespace
+ }
+ else{
+ desc.addNamespace(null, getURI(value)); //the default
namespace
+ }
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]