You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by jk...@apache.org on 2005/10/03 07:19:49 UTC

svn commit: r293251 - in /incubator/woden/java/src/org/apache/woden: internal/DOMWSDLReader.java internal/wsdl20/InterfaceFaultImpl.java internal/wsdl20/InterfaceImpl.java internal/wsdl20/InterfaceOperationImpl.java wsdl20/xml/InterfaceFaultElement.java

Author: jkaputin
Date: Sun Oct  2 22:19:38 2005
New Revision: 293251

URL: http://svn.apache.org/viewcvs?rev=293251&view=rev
Log:
More interface parsing - faults, features, property.

Modified:
    incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
    incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceFaultImpl.java
    incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceImpl.java
    incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceOperationImpl.java
    incubator/woden/java/src/org/apache/woden/wsdl20/xml/InterfaceFaultElement.java

Modified: incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java?rev=293251&r1=293250&r2=293251&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/DOMWSDLReader.java Sun Oct  2 22:19:38 2005
@@ -18,8 +18,8 @@
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.Map;
 import java.util.Hashtable;
+import java.util.Map;
 
 import javax.xml.namespace.QName;
 import javax.xml.parsers.DocumentBuilder;
@@ -39,15 +39,17 @@
 import org.apache.woden.schema.SchemaImport;
 import org.apache.woden.wsdl20.xml.DescriptionElement;
 import org.apache.woden.wsdl20.xml.DocumentationElement;
+import org.apache.woden.wsdl20.xml.FeatureElement;
 import org.apache.woden.wsdl20.xml.ImportElement;
 import org.apache.woden.wsdl20.xml.InterfaceElement;
+import org.apache.woden.wsdl20.xml.InterfaceFaultElement;
+import org.apache.woden.wsdl20.xml.InterfaceOperationElement;
+import org.apache.woden.wsdl20.xml.PropertyElement;
 import org.apache.woden.wsdl20.xml.TypesElement;
-
 import org.apache.xerces.xs.XSException;
 import org.apache.xerces.xs.XSImplementation;
 import org.apache.xerces.xs.XSLoader;
 import org.apache.xerces.xs.XSModel;
-
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -185,21 +187,20 @@
         
         /* Parse the child elements. As per the WSDL 2.0 spec, 
          * they must be in the following order if present:
-         * <document>
+         * <documentation>
          * <import> <include> or WSDL extension elements in any order
          * <types>
          * <interface> <binding> <service> or WSDL extension elements in any order.
+         * TODO validate that the elements are in correct order
          */ 
 
         Element tempEl = DOMUtils.getFirstChildElement(descEl);
 
         while (tempEl != null)
         {
-            //TODO validate that the elements are in correct order
-
             if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
             {
-                desc.setDocumentationElement(parseDocumentation(tempEl, desc));
+                desc.addDocumentationElement(parseDocumentation(tempEl, desc));
             }
             else if (QNameUtils.matches(Constants.Q_ELEM_TYPES, tempEl))
             {
@@ -207,7 +208,7 @@
             }
             else if (QNameUtils.matches(Constants.Q_ELEM_INTERFACE, tempEl))
             {
-                //desc.addInterfaceElement(parseInterface(tempEl, desc));
+                desc.addInterfaceElement(parseInterface(tempEl, desc));
             }
             else
             {
@@ -228,6 +229,52 @@
         return documentation;
     }
 
+    private FeatureElement parseFeature(Element featEl, 
+                                        DescriptionElement desc) 
+    {
+        FeatureElement feature = desc.createFeatureElement();
+
+        String ref = 
+            DOMUtils.getAttribute(featEl, Constants.ATTR_REF);
+        
+        feature.setRef(ref);
+        
+        String req = 
+            DOMUtils.getAttribute(featEl, Constants.ATTR_REQUIRED);
+        
+        feature.setRequired("true".equals(req) ? true : false);
+        
+        //TODO t.b.c. what if attr value is not true or false?
+        
+        //TODO extension attributes
+        
+        /* Parse the child elements of the <feature> element. 
+         * As per WSDL 2.0 spec, they must be in the following order if present:
+         * <documentation>
+         * extension elements.
+         * 
+         * TODO validate that the elements are in correct order
+         */ 
+
+        Element tempEl = DOMUtils.getFirstChildElement(featEl);
+
+        while (tempEl != null)
+        {
+            if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+            {
+                feature.addDocumentationElement(parseDocumentation(tempEl, desc));
+            }
+            else
+            {
+                //TODO extensions
+            }
+            
+            tempEl = DOMUtils.getNextSiblingElement(tempEl);
+        }
+           
+        return feature;
+    }
+    
     private ImportElement parseImport(Element importEl,
                                       DescriptionElement desc,
                                       Map importedDescs) 
@@ -241,7 +288,7 @@
                                             DescriptionElement desc) 
                                             throws WSDLException
     {
-        InterfaceElement interfaceElement = desc.createInterfaceElement();
+        InterfaceElement intface = desc.createInterfaceElement();
 
         String localName = 
             DOMUtils.getAttribute(interfaceEl, Constants.ATTR_NAME);
@@ -249,15 +296,126 @@
         if(localName != null)
         {
             QName qname = new QName(desc.getTargetNamespace(), localName);
-            interfaceElement.setName(qname);
+            intface.setName(qname);
+        }
+        //TODO what if name null? Handle here or leave to validator?
+        
+        //TODO extends attribute
+        //TODO styleDefault attribute
+        
+        /* Parse the child elements of <interface>. 
+         * As per WSDL 2.0 spec, they must be in the following order if present:
+         * <documentation>
+         * <fault> <operation> <feature> <property> or extension elements in any order
+         * TODO validate that the elements are in correct order
+         */ 
+
+        Element tempEl = DOMUtils.getFirstChildElement(interfaceEl);
+
+        while (tempEl != null)
+        {
+            if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+            {
+                intface.addDocumentationElement(parseDocumentation(tempEl, desc));
+            }
+            else if (QNameUtils.matches(Constants.Q_ELEM_FAULT, tempEl))
+            {
+                intface.addInterfaceFaultElement(parseInterfaceFault(tempEl, desc));
+            }
+            else if (QNameUtils.matches(Constants.Q_ELEM_OPERATION, tempEl))
+            {
+                intface.addInterfaceOperationElement(parseInterfaceOperation(tempEl, desc));
+            }
+            else
+            {
+                //TODO feature, property, extensions
+            }
+            
+            tempEl = DOMUtils.getNextSiblingElement(tempEl);
+        }
+        
+        return intface;
+    }
+
+    private InterfaceFaultElement parseInterfaceFault(
+                                             Element faultEl,
+                                             DescriptionElement desc) 
+                                             throws WSDLException
+    {
+        InterfaceFaultElement fault = desc.createInterfaceFaultElement();
+        
+        String localName = 
+            DOMUtils.getAttribute(faultEl, Constants.ATTR_NAME);
+        
+        if(localName != null)
+        {
+            QName qname = new QName(desc.getTargetNamespace(), localName);
+            fault.setName(qname);
         }
         //TODO what if name null? Handle here or leave to validator?
         
+        String element = 
+            DOMUtils.getAttribute(faultEl, Constants.ATTR_ELEMENT);
         
+        // TODO report bad qname here or leave it for the validator?
+        QName qname = DOMUtils.getQName(element, faultEl, desc);
+        fault.setElement(qname);
+        
+        //TODO extension attributes
+        
+        /* Parse the child elements of interface <fault>. 
+         * As per WSDL 2.0 spec, they must be in the following order if present:
+         * <documentation>
+         * <fault> <operation> <feature> <property> or extension elements in any order
+         * 
+         * TODO validate that the elements are in correct order
+         */ 
+
+        Element tempEl = DOMUtils.getFirstChildElement(faultEl);
+
+        while (tempEl != null)
+        {
+            if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
+            {
+                fault.addDocumentationElement(parseDocumentation(tempEl, desc));
+            }
+            else if (QNameUtils.matches(Constants.Q_ELEM_FEATURE, tempEl))
+            {
+                fault.addFeatureElement(parseFeature(tempEl, desc));
+            }
+            else if (QNameUtils.matches(Constants.Q_ELEM_PROPERTY, tempEl))
+            {
+                fault.addPropertyElement(parseProperty(tempEl, desc));
+            }
+            else
+            {
+                //TODO extensions
+            }
+            
+            tempEl = DOMUtils.getNextSiblingElement(tempEl);
+        }
         
-        return null;
+        return fault;
     }
     
+    private InterfaceOperationElement parseInterfaceOperation(
+                                                 Element operEl, 
+                                                 DescriptionElement desc) 
+                                                 throws WSDLException
+    {
+        InterfaceOperationElement oper = desc.createInterfaceOperationElement();
+        
+        return oper;
+    }
+
+    private PropertyElement parseProperty(Element propEl, 
+                                          DescriptionElement desc) 
+    {
+        PropertyElement property = desc.createPropertyElement();
+        
+        return property;
+    }
+
     /*
      * TODO use ws-commons XmlSchema, instead of Xerces XML Schema API
      */
@@ -522,7 +680,7 @@
             
             if (QNameUtils.matches(Constants.Q_ELEM_DOCUMENTATION, tempEl))
             {
-                types.setDocumentationElement(parseDocumentation(tempEl, desc));
+                types.addDocumentationElement(parseDocumentation(tempEl, desc));
             }
             else if (SchemaConstants.XSD_IMPORT_QNAME_LIST.contains(tempElType))
             {

Modified: incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceFaultImpl.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceFaultImpl.java?rev=293251&r1=293250&r2=293251&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceFaultImpl.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceFaultImpl.java Sun Oct  2 22:19:38 2005
@@ -15,6 +15,9 @@
  */
 package org.apache.woden.internal.wsdl20;
 
+import java.util.List;
+import java.util.Vector;
+
 import javax.xml.namespace.QName;
 
 import org.apache.woden.wsdl20.Component;
@@ -34,33 +37,87 @@
  * @author jkaputin@apache.org
  */
 public class InterfaceFaultImpl implements InterfaceFault,
-        InterfaceFaultElement {
-
-    /* (non-Javadoc)
+                                           InterfaceFaultElement 
+{
+    private QName fName = null;
+    private QName fElement = null;
+    private List fDocumentationElements = new Vector();
+    private List fFeatureElements = new Vector();
+    private List fPropertyElements = new Vector();
+
+    /*
+     * InterfaceFault Component data.
+     * 
+     * These lists represent the properties of the InterfaceFault Component, 
+     * cached here to make the 'InterfaceFault' methods efficient. 
+     * These properties are exposed on the API as typed arrays, 
+     * but are implemented as Lists for convenience.
+     * 
+     * TODO clear cached component data if xml model is modified
+     */
+    private Component fParent = null;
+    private ElementDeclaration fElementDeclaration = null;
+    private List fFeatures = new Vector();
+    private List fProperties = new Vector();
+    
+    /* 
+     * @see org.apache.woden.wsdl20.xml.InterfaceFaultElement#setName(QName)
+     */
+    public void setName(QName qname)
+    {
+        fName = qname;
+    }
+    
+    /*
      * @see org.apache.woden.wsdl20.InterfaceFault#getName()
+     * @see org.apache.woden.wsdl20.xml.InterfaceFaultElement#getName()
      */
-    public QName getName() {
-        // TODO Auto-generated method stub
-        return null;
+    public QName getName() 
+    {
+        return fName;
     }
 
-    /* (non-Javadoc)
+    /* 
+     * @see org.apache.woden.wsdl20.xml.InterfaceFaultElement#setElement(QName)
+     */
+    public void setElement(QName qname)
+    {
+        fElement = qname;
+    }
+    
+    /*
+     * @see org.apache.woden.wsdl20.xml.InterfaceFaultElement#getElement()
+     */
+    public QName getElement() 
+    {
+        return fElement;
+    }
+
+    /*
      * @see org.apache.woden.wsdl20.InterfaceFault#getElementDeclaration()
      */
-    public ElementDeclaration getElementDeclaration() {
-        // TODO Auto-generated method stub
-        return null;
+    public ElementDeclaration getElementDeclaration() 
+    {
+        return fElementDeclaration;
+    }
+
+    /*
+     * Public implementation method (not on API)
+     */
+    public void setParent(Component parent) 
+    {
+        fParent = parent;
     }
 
-    /* (non-Javadoc)
+    /*
      * @see org.apache.woden.wsdl20.NestedComponent#getParent()
      */
-    public Component getParent() {
-        // TODO Auto-generated method stub
-        return null;
+    public Component getParent() 
+    {
+        return fParent;
     }
 
-    /* (non-Javadoc)
+    /*
      * @see org.apache.woden.wsdl20.ConfigurableComponent#getFeatures()
      */
     public Feature[] getFeatures() {
@@ -68,7 +125,7 @@
         return null;
     }
 
-    /* (non-Javadoc)
+    /*
      * @see org.apache.woden.wsdl20.ConfigurableComponent#getProperties()
      */
     public Property[] getProperties() {
@@ -76,52 +133,52 @@
         return null;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.woden.wsdl20.xml.DocumentableElement#setDocumentationElement(org.apache.woden.wsdl20.xml.DocumentationElement)
+    /*
+     * @see org.apache.woden.wsdl20.xml.DocumentableElement#addDocumentationElement(DocumentationElement)
      */
-    public void setDocumentationElement(DocumentationElement docEl) {
-        // TODO Auto-generated method stub
-
+    public void addDocumentationElement(DocumentationElement docEl) 
+    {
+        fDocumentationElements.add(docEl);
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.woden.wsdl20.xml.DocumentableElement#getDocumentationElement()
+    /*
+     * @see org.apache.woden.wsdl20.xml.DocumentableElement#getDocumentationElements()
      */
-    public DocumentationElement getDocumentationElement() {
-        // TODO Auto-generated method stub
-        return null;
+    public DocumentationElement[] getDocumentationElements() 
+    {
+        return (DocumentationElement[])fDocumentationElements.toArray();
     }
-
-    /* (non-Javadoc)
+    
+    /*
      * @see org.apache.woden.wsdl20.xml.ConfigurableElement#addFeatureElement(org.apache.woden.wsdl20.xml.FeatureElement)
      */
-    public void addFeatureElement(FeatureElement feature) {
-        // TODO Auto-generated method stub
-
+    public void addFeatureElement(FeatureElement feature) 
+    {
+        fFeatureElements.add(feature);
     }
 
-    /* (non-Javadoc)
+    /*
      * @see org.apache.woden.wsdl20.xml.ConfigurableElement#getFeatureElements()
      */
-    public FeatureElement[] getFeatureElements() {
-        // TODO Auto-generated method stub
-        return null;
+    public FeatureElement[] getFeatureElements() 
+    {
+        return (FeatureElement[])fFeatureElements.toArray();
     }
 
-    /* (non-Javadoc)
+    /*
      * @see org.apache.woden.wsdl20.xml.ConfigurableElement#addPropertyElement(org.apache.woden.wsdl20.xml.PropertyElement)
      */
-    public void addPropertyElement(PropertyElement property) {
-        // TODO Auto-generated method stub
-
+    public void addPropertyElement(PropertyElement property) 
+    {
+        fPropertyElements.add(property);
     }
 
-    /* (non-Javadoc)
+    /*
      * @see org.apache.woden.wsdl20.xml.ConfigurableElement#getPropertyElements()
      */
-    public PropertyElement[] getPropertyElements() {
-        // TODO Auto-generated method stub
-        return null;
+    public PropertyElement[] getPropertyElements() 
+    {
+        return (PropertyElement[])fPropertyElements.toArray();
     }
 
 }

Modified: incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceImpl.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceImpl.java?rev=293251&r1=293250&r2=293251&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceImpl.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceImpl.java Sun Oct  2 22:19:38 2005
@@ -47,7 +47,7 @@
     private List fExtendsQNames = new Vector();
     private List fStyleDefaults = new Vector();
     
-    private DocumentationElement fDocumentationElement = null;
+    private List fDocumentationElements = new Vector();
     private List fInterfaceFaultElements = new Vector();
     private List fInterfaceOperationElements = new Vector();
     private List fFeatureElements = new Vector();
@@ -69,23 +69,6 @@
     private List fFeatures = new Vector();
     private List fProperties = new Vector();
     
-
-    /* 
-     * @see org.apache.woden.wsdl20.xml.DocumentableElement#setDocumentationElement(DocumentationElement)
-     */
-    public void setDocumentationElement(DocumentationElement documentation)
-    {
-        fDocumentationElement = documentation;
-    }
-    
-    /* 
-     * @see org.apache.woden.wsdl20.xml.DocumentableElement#getDocumentationElement()
-     */
-    public DocumentationElement getDocumentationElement() 
-    {
-        return fDocumentationElement;
-    }
-    
     /* 
      * @see org.apache.woden.wsdl20.xml.InterfaceElement#setName(QName)
      */
@@ -191,6 +174,22 @@
         return (InterfaceOperation[])fInterfaceOperations.toArray();
     }
 
+    /*
+     * @see org.apache.woden.wsdl20.xml.DocumentableElement#addDocumentationElement(DocumentationElement)
+     */
+    public void addDocumentationElement(DocumentationElement docEl) 
+    {
+        fDocumentationElements.add(docEl);
+    }
+
+    /*
+     * @see org.apache.woden.wsdl20.xml.DocumentableElement#getDocumentationElements()
+     */
+    public DocumentationElement[] getDocumentationElements() 
+    {
+        return (DocumentationElement[])fDocumentationElements.toArray();
+    }
+    
     /*
      * @see org.apache.woden.wsdl20.xml.ConfigurableElement#addFeatureElement(FeatureElement)
      */

Modified: incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceOperationImpl.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceOperationImpl.java?rev=293251&r1=293250&r2=293251&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceOperationImpl.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/wsdl20/InterfaceOperationImpl.java Sun Oct  2 22:19:38 2005
@@ -16,6 +16,8 @@
 package org.apache.woden.internal.wsdl20;
 
 import java.net.URI;
+import java.util.List;
+import java.util.Vector;
 
 import javax.xml.namespace.QName;
 
@@ -23,6 +25,7 @@
 import org.apache.woden.wsdl20.Feature;
 import org.apache.woden.wsdl20.InterfaceFaultReference;
 import org.apache.woden.wsdl20.InterfaceMessageReference;
+import org.apache.woden.wsdl20.InterfaceOperation;
 import org.apache.woden.wsdl20.Property;
 import org.apache.woden.wsdl20.xml.DocumentationElement;
 import org.apache.woden.wsdl20.xml.FeatureElement;
@@ -35,8 +38,10 @@
  * 
  * @author jkaputin@apache.org
  */
-public class InterfaceOperationImpl implements
-        org.apache.woden.wsdl20.InterfaceOperation, InterfaceOperationElement {
+public class InterfaceOperationImpl implements InterfaceOperation, 
+                                               InterfaceOperationElement 
+{
+    private List fDocumentationElements = new Vector();
 
     /* (non-Javadoc)
      * @see org.apache.woden.wsdl20.InterfaceOperation#getName()
@@ -102,20 +107,20 @@
         return null;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.woden.wsdl20.xml.DocumentableElement#setDocumentationElement(org.apache.woden.wsdl20.xml.DocumentationElement)
+    /*
+     * @see org.apache.woden.wsdl20.xml.DocumentableElement#addDocumentationElement(DocumentationElement)
      */
-    public void setDocumentationElement(DocumentationElement docEl) {
-        // TODO Auto-generated method stub
-
+    public void addDocumentationElement(DocumentationElement docEl) 
+    {
+        fDocumentationElements.add(docEl);
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.woden.wsdl20.xml.DocumentableElement#getDocumentationElement()
+    /*
+     * @see org.apache.woden.wsdl20.xml.DocumentableElement#getDocumentationElements()
      */
-    public DocumentationElement getDocumentationElement() {
-        // TODO Auto-generated method stub
-        return null;
+    public DocumentationElement[] getDocumentationElements() 
+    {
+        return (DocumentationElement[])fDocumentationElements.toArray();
     }
 
     /* (non-Javadoc)

Modified: incubator/woden/java/src/org/apache/woden/wsdl20/xml/InterfaceFaultElement.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/wsdl20/xml/InterfaceFaultElement.java?rev=293251&r1=293250&r2=293251&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/wsdl20/xml/InterfaceFaultElement.java (original)
+++ incubator/woden/java/src/org/apache/woden/wsdl20/xml/InterfaceFaultElement.java Sun Oct  2 22:19:38 2005
@@ -15,6 +15,8 @@
  */
 package org.apache.woden.wsdl20.xml;
 
+import javax.xml.namespace.QName;
+
 /**
  * This interface represents a &lt;fault&gt; child element of the
  * WSDL &lt.interface&gt. element. 
@@ -26,5 +28,14 @@
 public interface InterfaceFaultElement extends DocumentableElement, 
                                                ConfigurableElement 
 {
-    //TODO
+    /*
+     * Attributes
+     */
+
+    public void setName(QName qname);
+    public QName getName();
+    
+    public void setElement(QName qname);
+    public QName getElement();
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org