You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by ve...@apache.org on 2016/02/29 23:31:55 UTC

svn commit: r1732962 - in /webservices/axiom/trunk: aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/mixin/ implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/ implementations/axiom-impl/src/main/java/org/apache/axiom/soa...

Author: veithen
Date: Mon Feb 29 22:31:55 2016
New Revision: 1732962

URL: http://svn.apache.org/viewvc?rev=1732962&view=rev
Log:
Unify the SOAPEnvelope#getBody() method.

Modified:
    webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/mixin/AxiomSOAPEnvelopeSupport.aj
    webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java
    webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java

Modified: webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/mixin/AxiomSOAPEnvelopeSupport.aj
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/mixin/AxiomSOAPEnvelopeSupport.aj?rev=1732962&r1=1732961&r2=1732962&view=diff
==============================================================================
--- webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/mixin/AxiomSOAPEnvelopeSupport.aj (original)
+++ webservices/axiom/trunk/aspects/om-aspects/src/main/java/org/apache/axiom/soap/impl/mixin/AxiomSOAPEnvelopeSupport.aj Mon Feb 29 22:31:55 2016
@@ -20,6 +20,7 @@ package org.apache.axiom.soap.impl.mixin
 
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMNode;
 import org.apache.axiom.soap.SOAPBody;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.SOAPHeader;
@@ -42,6 +43,22 @@ public aspect AxiomSOAPEnvelopeSupport {
         return header != null ? header : ((SOAPFactory)getOMFactory()).createSOAPHeader(this);
     }
 
+    public final SOAPBody AxiomSOAPEnvelope.getBody() {
+        OMElement element = getFirstElement();
+        if (element instanceof SOAPBody) {
+            return (SOAPBody)element;
+        } else if (element instanceof SOAPHeader) {
+            OMNode node = element.getNextOMSibling();
+            while (node != null && !(node instanceof OMElement)) {
+                node = node.getNextOMSibling();
+            }
+            if (node instanceof SOAPBody) {
+                return (SOAPBody)node;
+            }
+        }
+        return null;
+    }
+
     public final boolean AxiomSOAPEnvelope.hasFault() {
         SOAPBody body = getBody();
         return (body == null) ? false : body.hasFault();

Modified: webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java?rev=1732962&r1=1732961&r2=1732962&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java (original)
+++ webservices/axiom/trunk/implementations/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java Mon Feb 29 22:31:55 2016
@@ -20,14 +20,10 @@
 package org.apache.axiom.soap.impl.dom;
 
 import org.apache.axiom.om.OMConstants;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.soap.SOAP11Version;
 import org.apache.axiom.soap.SOAPBody;
-import org.apache.axiom.soap.SOAPConstants;
 import org.apache.axiom.soap.SOAPHeader;
-import org.apache.axiom.soap.SOAPProcessingException;
 import org.apache.axiom.soap.impl.intf.AxiomSOAPEnvelope;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Node;
@@ -80,42 +76,4 @@ public abstract class SOAPEnvelopeImpl e
         }
         return super.insertBefore(newChild, refChild);
     }
-
-    /**
-     * Returns the <CODE>SOAPBody</CODE> object associated with this <CODE>SOAPEnvelope</CODE>
-     * object.
-     * <p/>
-     * This SOAPBody will just be a container for all the BodyElements in the <CODE>OMMessage</CODE>
-     * </P>
-     *
-     * @return the <CODE>SOAPBody</CODE> object for this <CODE> SOAPEnvelope</CODE> object or
-     *         <CODE>null</CODE> if there is none
-     * @throws org.apache.axiom.om.OMException
-     *                     if there is a problem obtaining the <CODE>SOAPBody</CODE> object
-     * @throws OMException
-     */
-    public SOAPBody getBody() throws OMException {
-        // check for the first element
-        OMElement element = getFirstElement();
-        if (element != null) {
-            if (SOAPConstants.BODY_LOCAL_NAME.equals(element.getLocalName())) {
-                return (SOAPBody) element;
-            } else { // if not second element SHOULD be the body
-                OMNode node = element.getNextOMSibling();
-                while (node != null && node.getType() != OMNode.ELEMENT_NODE) {
-                    node = node.getNextOMSibling();
-                }
-                if (node == null) {
-                    // The envelope only contains a header
-                    return null;
-                } else if (SOAPConstants.BODY_LOCAL_NAME.equals(((OMElement)node).getLocalName())) {
-                    return (SOAPBody)node;
-                } else {
-                    throw new OMException("SOAPEnvelope must contain a body element " +
-                            "which is either first or second child element of the SOAPEnvelope.");
-                }
-            }
-        }
-        return null;
-    }
 }

Modified: webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java?rev=1732962&r1=1732961&r2=1732962&view=diff
==============================================================================
--- webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java (original)
+++ webservices/axiom/trunk/implementations/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java Mon Feb 29 22:31:55 2016
@@ -20,11 +20,8 @@
 package org.apache.axiom.soap.impl.llom;
 
 import org.apache.axiom.om.OMConstants;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.soap.SOAPBody;
-import org.apache.axiom.soap.SOAPConstants;
 import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axiom.soap.impl.intf.AxiomSOAPEnvelope;
 
@@ -68,38 +65,4 @@ public abstract class SOAPEnvelopeImpl e
         }
         super.addChild(child);
     }
-    
-    /**
-     * Returns the <CODE>SOAPBody</CODE> object associated with this <CODE>SOAPEnvelope</CODE>
-     * object. <P> This SOAPBody will just be a container for all the BodyElements in the
-     * <CODE>OMMessage</CODE> </P>
-     *
-     * @return the <CODE>SOAPBody</CODE> object for this <CODE> SOAPEnvelope</CODE> object or
-     *         <CODE>null</CODE> if there is none
-     * @throws OMException if there is a problem obtaining the <CODE>SOAPBody</CODE> object
-     */
-    public SOAPBody getBody() throws OMException {
-        //check for the first element
-        OMElement element = getFirstElement();
-        if (element != null) {
-            if (SOAPConstants.BODY_LOCAL_NAME.equals(element.getLocalName())) {
-                return (SOAPBody) element;
-            } else {      // if not second element SHOULD be the body
-                OMNode node = element.getNextOMSibling();
-                while (node != null && node.getType() != OMNode.ELEMENT_NODE) {
-                    node = node.getNextOMSibling();
-                }
-                if (node == null) {
-                    // The envelope only contains a header
-                    return null;
-                } else if (SOAPConstants.BODY_LOCAL_NAME.equals(((OMElement)node).getLocalName())) {
-                    return (SOAPBody)node;
-                } else {
-                    throw new OMException("SOAPEnvelope must contain a body element " +
-                            "which is either first or second child element of the SOAPEnvelope.");
-                }
-            }
-        }
-        return null;
-    }
 }