Author: jkaputin
Date: Thu Nov 16 07:51:58 2006
New Revision: 475781

URL: http://svn.apache.org/viewvc?view=rev&rev=475781
Log:
WODEN-91 Fixed by correctly implementing the 
getElementDeclaration method.

Modified:
    
incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/extensions/soap/SOAPHeaderBlockImpl.java

Modified: 
incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/extensions/soap/SOAPHeaderBlockImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/extensions/soap/SOAPHeaderBlockImpl.java?view=diff&rev=475781&r1=475780&r2=475781
==============================================================================
--- 
incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/extensions/soap/SOAPHeaderBlockImpl.java
 (original)
+++ 
incubator/woden/trunk/java/src/org/apache/woden/internal/wsdl20/extensions/soap/SOAPHeaderBlockImpl.java
 Thu Nov 16 07:51:58 2006
@@ -21,15 +21,21 @@
 
 import javax.xml.namespace.QName;
 
+import org.apache.woden.internal.wsdl20.BindingImpl;
 import org.apache.woden.internal.wsdl20.TypesImpl;
 import org.apache.woden.internal.wsdl20.extensions.AttributeExtensibleImpl;
 import org.apache.woden.internal.wsdl20.extensions.ElementExtensibleImpl;
+import org.apache.woden.wsdl20.Description;
 import org.apache.woden.wsdl20.ElementDeclaration;
+import org.apache.woden.wsdl20.NestedComponent;
+import org.apache.woden.wsdl20.TypeDefinition;
 import org.apache.woden.wsdl20.WSDLComponent;
 import org.apache.woden.wsdl20.extensions.ExtensionElement;
 import org.apache.woden.wsdl20.extensions.soap.SOAPHeaderBlock;
 import org.apache.woden.wsdl20.extensions.soap.SOAPHeaderBlockElement;
+import org.apache.woden.wsdl20.xml.DescriptionElement;
 import org.apache.woden.wsdl20.xml.DocumentationElement;
+import org.apache.woden.wsdl20.xml.NestedElement;
 import org.apache.woden.wsdl20.xml.TypesElement;
 import org.apache.woden.wsdl20.xml.WSDLElement;
 import org.apache.woden.xml.XMLAttr;
@@ -52,7 +58,6 @@
     private AttributeExtensibleImpl fAttrExt = new AttributeExtensibleImpl();
     private ElementExtensibleImpl fElemExt = new ElementExtensibleImpl();
     private QName fElementDeclQN = null;
-    private ElementDeclaration fElementDecl = null;
     private Boolean fMustUnderstand = null;
     
     private TypesImpl fTypes = null;
@@ -67,7 +72,10 @@
      */
     public ElementDeclaration getElementDeclaration() 
     {
-        return fElementDecl;
+        ElementDeclaration elemDecl = null;
+        Description desc = getDescriptionComponent(getParent());
+        elemDecl = desc.getElementDeclaration(fElementDeclQN);
+        return elemDecl;
     }
 
     /* (non-Javadoc)
@@ -282,13 +290,42 @@
      *  Non-API implementation methods
      * ************************************************************/
     
-    public void setElementDeclaration(ElementDeclaration elementDecl)
-    {
-        fElementDecl = elementDecl;
-    }
-
     public void setTypes(TypesElement types) {
         fTypes = (TypesImpl)types;
     }
 
+    /*
+     * This method traverses up the element graph to get the root 
<description>.
+     * TODO consider its usefulness to user-defined extensions and whether to 
refactor it.
+     * e.g. declared in ExtensionElement and implemented in 
ExtensionElementImpl
+     */
+    private DescriptionElement getDescriptionElement(WSDLElement wsdlElem)
+    {
+        if(wsdlElem instanceof BindingImpl) 
+        {
+            return (DescriptionElement) 
((NestedElement)wsdlElem).getParentElement();
+        }
+        else
+        {
+            WSDLElement parentElem = 
((NestedElement)wsdlElem).getParentElement();
+            return getDescriptionElement(parentElem);
+        }
+    }
+    
+    /* 
+     * TODO ditto previous comment about possibly refactoring this for 
user-defined extensions to reuse. 
+     */
+    private Description getDescriptionComponent(WSDLComponent wsdlComp)
+    {
+        if(wsdlComp instanceof BindingImpl) 
+        {
+            return ((BindingImpl)wsdlComp).getDescriptionComponent();
+        }
+        else 
+        {
+            WSDLComponent parentComp = ((NestedComponent)wsdlComp).getParent();
+            return getDescriptionComponent(parentComp);
+        } 
+    }
+    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to