axis-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1377526 [3/3] - in /axis/axis2/java/core/branches/1_6: ./ modules/jaxws/src/org/apache/axis2/jaxws/message/util/impl/ modules/saaj/ modules/saaj/src/org/apache/axis2/saaj/ modules/saaj/src/org/apache/axis2/saaj/util/ modules/saaj/test/org/...
Date Sun, 26 Aug 2012 21:42:36 GMT
Modified: axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPHeaderImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPHeaderImpl.java?rev=1377526&r1=1377525&r2=1377526&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPHeaderImpl.java
(original)
+++ axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPHeaderImpl.java
Sun Aug 26 21:42:35 2012
@@ -19,17 +19,13 @@
 
 package org.apache.axis2.saaj;
 
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
-import org.apache.axiom.om.impl.dom.ElementImpl;
-import org.apache.axiom.om.impl.dom.NamespaceImpl;
-import org.apache.axiom.om.impl.dom.NodeImpl;
+import org.apache.axiom.soap.SOAP11Version;
+import org.apache.axiom.soap.SOAP12Version;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.SOAPHeaderBlock;
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11HeaderBlockImpl;
-import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
-import org.apache.axiom.soap.impl.dom.soap12.SOAP12HeaderBlockImpl;
 import org.apache.axis2.namespace.Constants;
 import org.w3c.dom.Element;
 
@@ -44,9 +40,7 @@ import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
 
-public class SOAPHeaderImpl extends SOAPElementImpl implements SOAPHeader {
-
-    private org.apache.axiom.soap.SOAPHeader omSOAPHeader;
+public class SOAPHeaderImpl extends SOAPElementImpl<org.apache.axiom.soap.SOAPHeader>
implements SOAPHeader {
 
     /**
      * Constructor
@@ -54,8 +48,7 @@ public class SOAPHeaderImpl extends SOAP
      * @param header
      */
     public SOAPHeaderImpl(org.apache.axiom.soap.SOAPHeader header) {
-        super((ElementImpl)header);
-        omSOAPHeader = header;
+        super(header);
     }
 
     /* (non-Javadoc)
@@ -82,18 +75,11 @@ public class SOAPHeaderImpl extends SOAP
     */
     public SOAPElement addChildElement(String localName, String prefix, String uri)
             throws SOAPException {
-        OMNamespace ns = new NamespaceImpl(uri, prefix);
-        SOAPHeaderBlock headerBlock = null;
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
-            headerBlock = new SOAP11HeaderBlockImpl(localName, ns, omSOAPHeader,
-                                                    (SOAPFactory)this.element.getOMFactory());
-        } else {
-            headerBlock = new SOAP12HeaderBlockImpl(localName, ns, omSOAPHeader,
-                                                    (SOAPFactory)this.element.getOMFactory());
-        }
+        OMNamespace ns = omTarget.getOMFactory().createOMNamespace(uri, prefix);
+        SOAPHeaderBlock headerBlock = ((SOAPFactory)this.omTarget.getOMFactory()).createSOAPHeaderBlock(localName,
ns, omTarget);
         SOAPHeaderElementImpl soapHeaderElement = new SOAPHeaderElementImpl(headerBlock);
-        element.setUserData(SAAJ_NODE, this, null);
-        soapHeaderElement.element.setUserData(SAAJ_NODE, soapHeaderElement, null);
+        target.setUserData(SAAJ_NODE, this, null);
+        soapHeaderElement.target.setUserData(SAAJ_NODE, soapHeaderElement, null);
         soapHeaderElement.setParentElement(this);
         return soapHeaderElement;
     }
@@ -109,47 +95,29 @@ public class SOAPHeaderImpl extends SOAP
     * @see javax.xml.soap.SOAPElement#addChildElement(javax.xml.soap.SOAPElement)
     */
     public SOAPElement addChildElement(SOAPElement soapElement) throws SOAPException {
-        OMNamespace ns = new NamespaceImpl(soapElement.getNamespaceURI(),
+        OMNamespace ns = omTarget.getOMFactory().createOMNamespace(soapElement.getNamespaceURI(),
                                            soapElement.getPrefix());
-        SOAPHeaderBlock headerBlock = null;
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
-            headerBlock = new SOAP11HeaderBlockImpl(soapElement.getLocalName(), ns,
-                                                    omSOAPHeader,
-                                                    (SOAPFactory)this.element.getOMFactory());
-        } else {
-            headerBlock = new SOAP12HeaderBlockImpl(soapElement.getLocalName(), ns,
-                                                    omSOAPHeader,
-                                                    (SOAPFactory)this.element.getOMFactory());
-
-        }
+        SOAPHeaderBlock headerBlock = ((SOAPFactory)this.omTarget.getOMFactory()).createSOAPHeaderBlock(
+                soapElement.getLocalName(), ns, omTarget);
         SOAPHeaderElementImpl soapHeaderElement = new SOAPHeaderElementImpl(headerBlock);
-        element.setUserData(SAAJ_NODE, this, null);
-        soapHeaderElement.element.setUserData(SAAJ_NODE, soapHeaderElement, null);
+        target.setUserData(SAAJ_NODE, this, null);
+        soapHeaderElement.target.setUserData(SAAJ_NODE, soapHeaderElement, null);
         soapHeaderElement.setParentElement(this);
         return soapHeaderElement;
     }
 
     @Override
-    protected Element appendElement(ElementImpl child) throws SOAPException {     
-        OMNamespace ns = new NamespaceImpl(child.getNamespaceURI(),
+    protected Element appendElement(Element child) throws SOAPException {     
+        OMNamespace ns = omTarget.getOMFactory().createOMNamespace(child.getNamespaceURI(),
                                            child.getPrefix());
-        SOAPHeaderBlock headerBlock = null;
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
-            headerBlock = new SOAP11HeaderBlockImpl(child.getLocalName(), ns,
-                                                    omSOAPHeader,
-                                                    (SOAPFactory)this.element.getOMFactory());
-        } else {
-            headerBlock = new SOAP12HeaderBlockImpl(child.getLocalName(), ns,
-                                                    omSOAPHeader,
-                                                    (SOAPFactory)this.element.getOMFactory());
-
-        }
+        SOAPHeaderBlock headerBlock = ((SOAPFactory)this.omTarget.getOMFactory()).createSOAPHeaderBlock(
+                child.getLocalName(), ns, omTarget);
      
-        element.setUserData(SAAJ_NODE, this, null);
+        target.setUserData(SAAJ_NODE, this, null);
         
         SOAPHeaderElementImpl soapHeaderElement = new SOAPHeaderElementImpl(headerBlock);
         copyContents(soapHeaderElement, child);
-        soapHeaderElement.element.setUserData(SAAJ_NODE, soapHeaderElement, null);
+        soapHeaderElement.target.setUserData(SAAJ_NODE, soapHeaderElement, null);
         soapHeaderElement.setParentElement(this);
         return soapHeaderElement;
     }
@@ -172,20 +140,14 @@ public class SOAPHeaderImpl extends SOAP
                     "a namespace.");
         }
         String prefix = name.getPrefix() == null ? "" : name.getPrefix();
-        OMNamespace ns = new NamespaceImpl(name.getURI(), prefix);
+        OMNamespace ns = omTarget.getOMFactory().createOMNamespace(name.getURI(), prefix);
 
-        SOAPHeaderBlock headerBlock = null;
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
-            headerBlock = new SOAP11HeaderBlockImpl(name.getLocalName(), ns, omSOAPHeader,
-                                                    (SOAPFactory)this.element.getOMFactory());
-        } else {
-            headerBlock = new SOAP12HeaderBlockImpl(name.getLocalName(), ns, omSOAPHeader,
-                                                    (SOAPFactory)this.element.getOMFactory());
-        }
+        SOAPHeaderBlock headerBlock = ((SOAPFactory)this.omTarget.getOMFactory()).createSOAPHeaderBlock(
+                name.getLocalName(), ns, omTarget);
 
         SOAPHeaderElementImpl soapHeaderElement = new SOAPHeaderElementImpl(headerBlock);
-        element.setUserData(SAAJ_NODE, this, null);
-        soapHeaderElement.element.setUserData(SAAJ_NODE, soapHeaderElement, null);
+        target.setUserData(SAAJ_NODE, this, null);
+        soapHeaderElement.target.setUserData(SAAJ_NODE, soapHeaderElement, null);
         soapHeaderElement.setParentElement(this);
         return soapHeaderElement;
     }
@@ -205,8 +167,8 @@ public class SOAPHeaderImpl extends SOAP
      */
     public Iterator examineHeaderElements(String actor) {
         Collection elements = new ArrayList();
-        for (Iterator iterator = omSOAPHeader.examineHeaderBlocks(actor); iterator.hasNext();)
{
-            elements.add(toSAAJNode((NodeImpl)iterator.next()));
+        for (Iterator iterator = omTarget.examineHeaderBlocks(actor); iterator.hasNext();)
{
+            elements.add(toSAAJNode((org.w3c.dom.Node)iterator.next()));
         }
         return elements.iterator();
     }
@@ -226,8 +188,8 @@ public class SOAPHeaderImpl extends SOAP
      */
     public Iterator extractHeaderElements(String actor) {
         Collection elements = new ArrayList();
-        for (Iterator iterator = omSOAPHeader.extractHeaderBlocks(actor); iterator.hasNext();)
{
-            elements.add(toSAAJNode((NodeImpl)iterator.next()));
+        for (Iterator iterator = omTarget.extractHeaderBlocks(actor); iterator.hasNext();)
{
+            elements.add(toSAAJNode((org.w3c.dom.Node)iterator.next()));
         }
         return elements.iterator();
     }
@@ -243,9 +205,9 @@ public class SOAPHeaderImpl extends SOAP
      */
     public Iterator examineMustUnderstandHeaderElements(String actor) {
         Collection elements = new ArrayList();
-        for (Iterator iterator = omSOAPHeader.examineMustUnderstandHeaderBlocks(actor);
+        for (Iterator iterator = omTarget.examineMustUnderstandHeaderBlocks(actor);
              iterator.hasNext();) {
-            elements.add(toSAAJNode((NodeImpl)iterator.next()));
+            elements.add(toSAAJNode((org.w3c.dom.Node)iterator.next()));
         }
         return elements.iterator();
     }
@@ -259,8 +221,8 @@ public class SOAPHeaderImpl extends SOAP
      */
     public Iterator examineAllHeaderElements() {
         Collection elements = new ArrayList();
-        for (Iterator iterator = omSOAPHeader.examineAllHeaderBlocks(); iterator.hasNext();)
{
-            elements.add(toSAAJNode((NodeImpl)iterator.next()));
+        for (Iterator iterator = omTarget.examineAllHeaderBlocks(); iterator.hasNext();)
{
+            elements.add(toSAAJNode((org.w3c.dom.Node)iterator.next()));
         }
         return elements.iterator();
     }
@@ -274,8 +236,8 @@ public class SOAPHeaderImpl extends SOAP
      */
     public Iterator extractAllHeaderElements() {
         Collection elements = new ArrayList();
-        for (Iterator iterator = omSOAPHeader.extractAllHeaderBlocks(); iterator.hasNext();)
{
-            elements.add(toSAAJNode((NodeImpl)iterator.next()));
+        for (Iterator iterator = omTarget.extractAllHeaderBlocks(); iterator.hasNext();)
{
+            elements.add(toSAAJNode((org.w3c.dom.Node)iterator.next()));
         }
         return elements.iterator();
     }
@@ -299,12 +261,12 @@ public class SOAPHeaderImpl extends SOAP
 
     public SOAPHeaderElement addNotUnderstoodHeaderElement(QName qname) throws SOAPException
{
         SOAPHeaderBlock soapHeaderBlock = null;
-        OMNamespace ns = new NamespaceImpl(qname.getNamespaceURI(), qname.getPrefix());
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        OMNamespace ns = omTarget.getOMFactory().createOMNamespace(qname.getNamespaceURI(),
qname.getPrefix());
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton())
{
             throw new UnsupportedOperationException();
         } else {
-            soapHeaderBlock = this.omSOAPHeader.addHeaderBlock(
-                    Constants.ELEM_NOTUNDERSTOOD, this.element.getNamespace());
+            soapHeaderBlock = this.omTarget.addHeaderBlock(
+                    Constants.ELEM_NOTUNDERSTOOD, this.omTarget.getNamespace());
             soapHeaderBlock.addAttribute(qname.getLocalPart(), qname.getPrefix(), ns);
         }
         SOAPHeaderElementImpl soapHeaderElementImpl = new SOAPHeaderElementImpl(soapHeaderBlock);
@@ -321,8 +283,8 @@ public class SOAPHeaderImpl extends SOAP
      * @throws SOAPException - if a SOAP error occurs.
      */
     public SOAPHeaderElement addUpgradeHeaderElement(Iterator iterator) throws SOAPException
{
-        SOAPHeaderBlock upgrade = this.omSOAPHeader.addHeaderBlock(
-                Constants.ELEM_UPGRADE, this.element.getNamespace());
+        SOAPHeaderBlock upgrade = this.omTarget.addHeaderBlock(
+                Constants.ELEM_UPGRADE, this.omTarget.getNamespace());
 
         int index = 0;
         String prefix = "ns";
@@ -330,25 +292,14 @@ public class SOAPHeaderImpl extends SOAP
             index++;
             String supported = (String)iterator.next();
 
-            OMNamespace namespace = new NamespaceImpl(supported, prefix + index);
+            OMNamespace namespace = omTarget.getOMFactory().createOMNamespace(supported,
prefix + index);
 
-            if (this.element.getOMFactory() instanceof SOAP11Factory) {
-                SOAP11HeaderBlockImpl supportedEnvelop =
-                        new SOAP11HeaderBlockImpl(Constants.ELEM_SUPPORTEDENVELOPE,
-                                                  namespace,
-                                                  (SOAPFactory)this.element.getOMFactory());
-                supportedEnvelop.addAttribute(Constants.ATTR_QNAME, prefix + index + ":"
-                        + Constants.ELEM_ENVELOPE, null);
-                upgrade.addChild(supportedEnvelop);
-            } else {
-                SOAP12HeaderBlockImpl supportedEnvelop =
-                        new SOAP12HeaderBlockImpl(Constants.ELEM_SUPPORTEDENVELOPE,
-                                                  namespace,
-                                                  (SOAPFactory)this.element.getOMFactory());
-                supportedEnvelop.addAttribute(Constants.ATTR_QNAME, prefix + index + ":"
-                        + Constants.ELEM_ENVELOPE, null);
-                upgrade.addChild(supportedEnvelop);
-            }
+            OMElement supportedEnvelop =
+                    omTarget.getOMFactory().createOMElement(Constants.ELEM_SUPPORTEDENVELOPE,
+                            namespace);
+            supportedEnvelop.addAttribute(Constants.ATTR_QNAME, prefix + index + ":"
+                    + Constants.ELEM_ENVELOPE, null);
+            upgrade.addChild(supportedEnvelop);
         }
         SOAPHeaderElementImpl soapHeaderElementImpl = new SOAPHeaderElementImpl(upgrade);
         return soapHeaderElementImpl;
@@ -376,9 +327,9 @@ public class SOAPHeaderImpl extends SOAP
     }
 
     public SOAPElement addTextNode(String text) throws SOAPException {
-        if (this.element.getOMFactory() instanceof SOAP11Factory) {
+        if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton())
{
             return super.addTextNode(text);
-        } else if (this.element.getOMFactory() instanceof SOAP12Factory) {
+        } else if (((SOAPFactory)this.omTarget.getOMFactory()).getSOAPVersion() == SOAP12Version.getSingleton())
{
             throw new SOAPException("Cannot add text node to SOAPHeader");
         } else {
             return null;
@@ -387,11 +338,11 @@ public class SOAPHeaderImpl extends SOAP
 
     public Iterator getChildElements(Name name) {
         QName qName = new QName(name.getURI(), name.getLocalName());
-        return getChildren(element.getChildrenWithName(qName));
+        return getChildren(omTarget.getChildrenWithName(qName));
     }
 
     public Iterator getChildElements() {
-        return getChildren(element.getChildren());
+        return getChildren(omTarget.getChildren());
     }
 
     private Iterator getChildren(Iterator childIter) {
@@ -404,7 +355,7 @@ public class SOAPHeaderImpl extends SOAP
             } else if (!(saajNode instanceof SOAPHeaderElement)) {
                 // silently replace node, as per saaj 1.2 spec
                 SOAPHeaderElement headerEle = new SOAPHeaderElementImpl((SOAPHeaderBlock)domNode);
-                ((NodeImpl)domNode).setUserData(SAAJ_NODE, headerEle, null);
+                domNode.setUserData(SAAJ_NODE, headerEle, null);
                 childElements.add(headerEle);
             } else {
                 childElements.add(saajNode);
@@ -418,7 +369,7 @@ public class SOAPHeaderImpl extends SOAP
     }
 
     public OMNode detach() {
-        OMNode omNode = omSOAPHeader.detach();
+        OMNode omNode = omTarget.detach();
         parentElement = null;
         return omNode;
     }

Modified: axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java?rev=1377526&r1=1377525&r2=1377526&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java
(original)
+++ axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPMessageImpl.java
Sun Aug 26 21:42:35 2012
@@ -23,9 +23,10 @@ import org.apache.axiom.attachments.Atta
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMOutputFormat;
 import org.apache.axiom.om.impl.OMMultipartWriter;
+import org.apache.axiom.soap.SOAP11Version;
+import org.apache.axiom.soap.SOAP12Version;
 import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
-import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
+import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.util.UIDGenerator;
 import org.apache.axis2.saaj.util.SAAJUtil;
 import org.apache.axis2.transport.http.HTTPConstants;
@@ -62,9 +63,9 @@ public class SOAPMessageImpl extends SOA
 
     public SOAPMessageImpl(SOAPEnvelopeImpl soapEnvelope) {
         this.mimeHeaders = new MimeHeaders();
-        if (soapEnvelope.getOMFactory() instanceof SOAP11Factory) {
+        if (((SOAPFactory)soapEnvelope.omTarget.getOMFactory()).getSOAPVersion() == SOAP11Version.getSingleton())
{
             this.mimeHeaders.addHeader("content-type", HTTPConstants.MEDIA_TYPE_TEXT_XML);
-        } else if (soapEnvelope.getOMFactory() instanceof SOAP12Factory) {
+        } else if (((SOAPFactory)soapEnvelope.omTarget.getOMFactory()).getSOAPVersion() ==
SOAP12Version.getSingleton()) {
             this.mimeHeaders.addHeader("content-type",
                     HTTPConstants.MEDIA_TYPE_APPLICATION_SOAP_XML);
         }
@@ -92,11 +93,11 @@ public class SOAPMessageImpl extends SOA
                 // the available information.
                 MimeHeaders soapPartHeaders = new MimeHeaders();
                 soapPartHeaders.addHeader(HTTPConstants.HEADER_CONTENT_TYPE,
-                        attachments.getSOAPPartContentType());
-                String soapPartContentId = attachments.getSOAPPartContentID();
+                        attachments.getRootPartContentType());
+                String soapPartContentId = attachments.getRootPartContentID();
                 soapPartHeaders.addHeader("Content-ID", "<" + soapPartContentId + ">");
                 
-                soapPart = new SOAPPartImpl(this, attachments.getSOAPPartInputStream(),
+                soapPart = new SOAPPartImpl(this, attachments.getRootPartInputStream(),
                         soapPartHeaders, processMTOM ? attachments : null);
                 
                 for (String contentId : attachments.getAllContentIDs()) {
@@ -377,7 +378,7 @@ public class SOAPMessageImpl extends SOA
                 format.setIgnoreXMLDeclaration(true);
             }
             
-            SOAPEnvelope envelope = ((SOAPEnvelopeImpl) soapPart.getEnvelope()).getOMEnvelope();
+            SOAPEnvelope envelope = ((SOAPEnvelopeImpl) soapPart.getEnvelope()).getOMTarget();
             if (attachmentParts.isEmpty()) {
                 envelope.serialize(out, format);
             } else {
@@ -400,7 +401,7 @@ public class SOAPMessageImpl extends SOA
                 }
                 format.setRootContentId(rootContentId);
 
-                format.setSOAP11(((SOAPEnvelopeImpl) soapPart.getEnvelope()).getOMFactory()
instanceof SOAP11Factory);
+                format.setSOAP11(((SOAPFactory)((SOAPEnvelopeImpl) soapPart.getEnvelope()).omTarget.getOMFactory()).getSOAPVersion()
== SOAP11Version.getSingleton());
                 
                 //Double save the content-type in case anything is updated
                 mimeHeaders.setHeader(HTTPConstants.HEADER_CONTENT_TYPE, contentType.toString());
@@ -612,7 +613,7 @@ public class SOAPMessageImpl extends SOA
     }
     
     private String getBaseType() throws SOAPException {
-        boolean isSOAP12 = ((SOAPEnvelopeImpl) soapPart.getEnvelope()).getOMFactory() instanceof
SOAP12Factory;
+        boolean isSOAP12 = ((SOAPFactory)((SOAPEnvelopeImpl) soapPart.getEnvelope()).omTarget.getOMFactory()).getSOAPVersion()
== SOAP12Version.getSingleton();
         return isSOAP12 ? HTTPConstants.MEDIA_TYPE_APPLICATION_SOAP_XML : HTTPConstants.MEDIA_TYPE_TEXT_XML;
     }
     

Modified: axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java?rev=1377526&r1=1377525&r2=1377526&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java
(original)
+++ axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/SOAPPartImpl.java
Sun Aug 26 21:42:35 2012
@@ -20,6 +20,8 @@
 package org.apache.axis2.saaj;
 
 import org.apache.axiom.attachments.Attachments;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.om.impl.MTOMConstants;
 import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axiom.soap.SOAP11Constants;
@@ -27,8 +29,6 @@ import org.apache.axiom.soap.SOAP12Const
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.impl.builder.MTOMStAXSOAPModelBuilder;
 import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
-import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
 import org.apache.axis2.saaj.util.IDGenerator;
 import org.apache.axis2.saaj.util.SAAJUtil;
 import org.apache.axis2.transport.http.HTTPConstants;
@@ -138,11 +138,12 @@ public class SOAPPartImpl extends SOAPPa
         String charset;
         boolean isMTOM;
         String soapEnvelopeNamespaceURI;
+        OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
         SOAPFactory soapFactory;
         if (contentType == null) {
             charset = null;
             isMTOM = false;
-            soapFactory = new SOAP11Factory();
+            soapFactory = metaFactory.getSOAP11Factory();
             soapEnvelopeNamespaceURI = null;
         } else {
             String baseType = contentType.getBaseType().toLowerCase();
@@ -162,10 +163,10 @@ public class SOAPPartImpl extends SOAPPa
             
             if (soapContentType.equals(HTTPConstants.MEDIA_TYPE_TEXT_XML)) {
                 soapEnvelopeNamespaceURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
-                soapFactory = new SOAP11Factory();
+                soapFactory = metaFactory.getSOAP11Factory();
             } else if (soapContentType.equals(HTTPConstants.MEDIA_TYPE_APPLICATION_SOAP_XML))
{
                 soapEnvelopeNamespaceURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
-                soapFactory = new SOAP12Factory();
+                soapFactory = metaFactory.getSOAP12Factory();
             } else {
                 throw new SOAPException("Unrecognized content type '" + soapContentType +
"'");
             }
@@ -198,9 +199,8 @@ public class SOAPPartImpl extends SOAPPa
         
         try {
             org.apache.axiom.soap.SOAPEnvelope soapEnvelope = builder.getSOAPEnvelope();
-            envelope = new SOAPEnvelopeImpl(
-                    (org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl)soapEnvelope);
-            envelope.element.build();
+            envelope = new SOAPEnvelopeImpl(soapEnvelope);
+            envelope.omTarget.build();
             this.document = envelope.getOwnerDocument();
             envelope.setSOAPPartParent(this);
         } catch (Exception e) {
@@ -348,21 +348,12 @@ public class SOAPPartImpl extends SOAPPa
                 reader = inputFactory.createXMLStreamReader(is);
             }
 
-            StAXSOAPModelBuilder builder1 = null;
-            if (this.envelope.element.getOMFactory() instanceof SOAP11Factory) {
-                builder1 = new StAXSOAPModelBuilder(reader,
-                                                    (SOAP11Factory)this.envelope.element
-                                                            .getOMFactory(), null);
-            } else if (this.envelope.element.getOMFactory() instanceof SOAP12Factory) {
-                builder1 = new StAXSOAPModelBuilder(reader,
-                                                    (SOAP12Factory)this.envelope.element
-                                                            .getOMFactory(), null);
-            }
+            StAXSOAPModelBuilder builder1 = new StAXSOAPModelBuilder(reader,
+                                                (SOAPFactory)this.envelope.omTarget
+                                                        .getOMFactory(), null);
 
-            org.apache.axiom.soap.SOAPEnvelope soapEnvelope = builder1.getSOAPEnvelope();
-            envelope = new SOAPEnvelopeImpl(
-                    (org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl)soapEnvelope);
-            envelope.element.build();
+            envelope = new SOAPEnvelopeImpl(builder1.getSOAPEnvelope());
+            envelope.omTarget.build();
             this.document = envelope.getOwnerDocument();
             envelope.setSOAPPartParent(this);
         } catch (TransformerFactoryConfigurationError e) {
@@ -922,7 +913,7 @@ public class SOAPPartImpl extends SOAPPa
      */
     public Node removeChild(Node oldChild) throws DOMException {
         if (oldChild instanceof SOAPElementImpl) {
-            oldChild = ((SOAPElementImpl)oldChild).getElement();
+            oldChild = ((SOAPElementImpl)oldChild).getTarget();
         } else if (oldChild instanceof TextImplEx) {
             // TODO: handle text nodes somehow
         }
@@ -1196,6 +1187,6 @@ public class SOAPPartImpl extends SOAPPa
     }
     
     javax.xml.soap.Node toSAAJNode(org.w3c.dom.Node domNode) {
-        return NodeImplEx.toSAAJNode(domNode, this);
+        return SAAJNode.toSAAJNode(domNode, this);
     }
 }

Modified: axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/TextImplEx.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/TextImplEx.java?rev=1377526&r1=1377525&r2=1377526&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/TextImplEx.java
(original)
+++ axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/TextImplEx.java
Sun Aug 26 21:42:35 2012
@@ -19,51 +19,33 @@
 
 package org.apache.axis2.saaj;
 
-import org.apache.axiom.om.OMContainer;
-import org.apache.axiom.om.OMException;
-import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
-import org.apache.axiom.om.impl.dom.TextImpl;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMText;
 import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
 
 import javax.xml.soap.SOAPElement;
 import javax.xml.soap.Text;
-import javax.xml.stream.XMLStreamException;
-
-public class TextImplEx extends NodeImplEx implements Text {
-
-    //TODO: assign textNode
-
-    private TextImpl textNode;
 
+public class TextImplEx extends SAAJNode<org.w3c.dom.Text,OMText> implements Text {
     private org.w3c.dom.Node previousSibling;
     private org.w3c.dom.Node nextSibling;
 
     public TextImplEx(String data, SOAPElement parent) {
-        super(((SOAPElementImpl)parent).getOMFactory());
-        textNode = (TextImpl)DOOMAbstractFactory.getOMFactory().createOMText(data);
-        this.parentElement = parent;
+        this(OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM).getOMFactory().createOMText(data),
parent);
     }
 
-    public TextImplEx(TextImpl textNode, SOAPElement parent) {
-        super(((SOAPElementImpl)parent).getOMFactory());
-        this.textNode = textNode;
+    public TextImplEx(OMText textNode, SOAPElement parent) {
+        super((org.w3c.dom.Text)textNode, textNode);
         this.parentElement = parent;
     }
 
     public TextImplEx(String data, SOAPElement parent,
                       org.w3c.dom.Node prevSibling, org.w3c.dom.Node nextSibling) {
-        super(((SOAPElementImpl)parent).getOMFactory());
-        textNode = (TextImpl)DOOMAbstractFactory.getOMFactory().createOMText(data);
-        this.parentElement = parent;
+        this(data, parent);
         this.previousSibling = prevSibling;
         this.nextSibling = nextSibling;
     }
 
-    TextImpl getTextNode() {
-        return textNode;
-    }
-    
     public void setNextSibling(org.w3c.dom.Node nextSibling) {
         this.nextSibling = nextSibling;
     }
@@ -79,20 +61,10 @@ public class TextImplEx extends NodeImpl
      *         otherwise
      */
     public boolean isComment() {
-        String value = textNode.getText();
+        String value = omTarget.getText();
         return value.startsWith("<!--") && value.endsWith("-->");
     }
 
-    /** The name of this node, depending on its type; see the table above. */
-    public String getNodeName() {
-        return textNode.getNodeName();
-    }
-
-    /** A code representing the type of the underlying object, as defined above. */
-    public short getNodeType() {
-        return textNode.getNodeType();
-    }
-
     /**
      * Breaks this node into two nodes at the specified <code>offset</code>,
keeping both in the
      * tree as siblings. After being split, this node will contain all the content up to
the
@@ -108,7 +80,7 @@ public class TextImplEx extends NodeImpl
      *                      <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is
readonly.
      */
     public org.w3c.dom.Text splitText(int offset) throws DOMException {
-        return textNode.splitText(offset);
+        return target.splitText(offset);
     }
 
     public boolean isElementContentWhitespace() {
@@ -138,7 +110,7 @@ public class TextImplEx extends NodeImpl
      *                      in a <code>DOMString</code> variable on the implementation
platform.
      */
     public String getData() throws DOMException {
-        return textNode.getData();
+        return target.getData();
     }
 
     /**
@@ -153,7 +125,7 @@ public class TextImplEx extends NodeImpl
      *                      in a <code>DOMString</code> variable on the implementation
platform.
      */
     public void setData(String data) throws DOMException {
-        textNode.setData(data);
+        target.setData(data);
     }
 
     /**
@@ -171,7 +143,7 @@ public class TextImplEx extends NodeImpl
      *                      <code>DOMString</code>.
      */
     public String substringData(int offset, int count) throws DOMException {
-        return textNode.substringData(offset, count);
+        return target.substringData(offset, count);
     }
 
     /**
@@ -183,7 +155,7 @@ public class TextImplEx extends NodeImpl
      * @throws DOMException NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
      */
     public void appendData(String value) throws DOMException {
-        textNode.appendData(value);
+        target.appendData(value);
     }
 
     /**
@@ -196,7 +168,7 @@ public class TextImplEx extends NodeImpl
      *                      <br>NO_MODIFICATION_ALLOWED_ERR: Raised if this node is
readonly.
      */
     public void insertData(int offset, String data) throws DOMException {
-        textNode.insertData(offset, data);
+        target.insertData(offset, data);
     }
 
     /**
@@ -213,7 +185,7 @@ public class TextImplEx extends NodeImpl
      *                      Raised if this node is readonly.
      */
     public void deleteData(int offset, int count) throws DOMException {
-        textNode.deleteData(offset, count);
+        target.deleteData(offset, count);
     }
 
     /**
@@ -233,37 +205,7 @@ public class TextImplEx extends NodeImpl
      *                      Raised if this node is readonly.
      */
     public void replaceData(int offset, int count, String data) throws DOMException {
-        textNode.replaceData(offset, count, data);
-    }
-
-    /* (non-Javadoc)
-      * @see org.apache.axiom.om.impl.OMNodeEx#setParent(org.apache.axiom.om.OMContainer)
-      */
-    public void setParent(OMContainer element) {
-        textNode.setParent(element);
-    }
-
-    public Document getOwnerDocument() {
-        return textNode.getOwnerDocument();
-    }
-
-    /* (non-Javadoc)
-      * @see org.apache.axiom.om.OMNode#getParent()
-      */
-    public OMContainer getParent() {
-        return textNode.getParent();
-    }
-
-    /* (non-Javadoc)
-      * @see org.apache.axiom.om.OMNode#discard()
-      */
-    public void discard() throws OMException {
-        textNode.discard();
-    }
-
-    public void internalSerialize(javax.xml.stream.XMLStreamWriter writer, boolean cache)
-            throws XMLStreamException {
-        textNode.internalSerialize(writer, cache);
+        target.replaceData(offset, count, data);
     }
 
     /**
@@ -272,11 +214,7 @@ public class TextImplEx extends NodeImpl
      * @return The text value (data) of this
      */
     public String getValue() {
-        return textNode.getData();
-    }
-
-    public String getNodeValue() {
-        return textNode.getData();
+        return target.getData();
     }
 
     /**
@@ -290,11 +228,7 @@ public class TextImplEx extends NodeImpl
      *                               child node or has a child node that is not a Text node
      */
     public void setValue(String value) {
-        textNode.setData(value);
-    }
-
-    public void setNodeValue(String value) {
-        textNode.setData(value);
+        target.setData(value);
     }
 
     public String toString() {
@@ -310,4 +244,8 @@ public class TextImplEx extends NodeImpl
     public org.w3c.dom.Node getPreviousSibling() {
         return toSAAJNode(previousSibling);
     }
+
+    public int getLength() {
+        return target.getLength();
+    }
 }

Modified: axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/util/SAAJUtil.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/util/SAAJUtil.java?rev=1377526&r1=1377525&r2=1377526&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/util/SAAJUtil.java
(original)
+++ axis/axis2/java/core/branches/1_6/modules/saaj/src/org/apache/axis2/saaj/util/SAAJUtil.java
Sun Aug 26 21:42:35 2012
@@ -20,8 +20,9 @@
 package org.apache.axis2.saaj.util;
 
 import org.apache.axiom.attachments.Attachments;
+import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
+import org.apache.axiom.om.OMMetaFactory;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPEnvelope;
@@ -56,14 +57,15 @@ public class SAAJUtil {
 
         //Check the namespace and find SOAP version and factory
         String nsURI;
+        OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
         SOAPFactory factory;
         if (env.getNamespace().getNamespaceURI()
                 .equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
             nsURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
-            factory = DOOMAbstractFactory.getSOAP11Factory();
+            factory = metaFactory.getSOAP11Factory();
         } else {
             nsURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
-            factory = DOOMAbstractFactory.getSOAP12Factory();
+            factory = metaFactory.getSOAP12Factory();
         }
 
         StAXSOAPModelBuilder stAXSOAPModelBuilder =
@@ -81,20 +83,20 @@ public class SAAJUtil {
      * @param env An org.apache.axiom.soap.SOAPEnvelope instance
      * @return the org.apache.axis2.soap.impl.dom.SOAPEnvelopeImpl of the given SOAP Envelope
      */
-    public static org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl
-            toDOOMSOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope env) {
+    public static Element toDOOMSOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope env) {
         env.build();
 
         //Check the namespace and find SOAP version and factory
         String nsURI;
+        OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
         SOAPFactory factory;
         if (env.getNamespace().getNamespaceURI()
                 .equals(SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI)) {
             nsURI = SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
-            factory = DOOMAbstractFactory.getSOAP11Factory();
+            factory = metaFactory.getSOAP11Factory();
         } else {
             nsURI = SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
-            factory = DOOMAbstractFactory.getSOAP11Factory();
+            factory = metaFactory.getSOAP11Factory();
         }
 
         StAXSOAPModelBuilder stAXSOAPModelBuilder =
@@ -102,7 +104,7 @@ public class SAAJUtil {
         SOAPEnvelope envelope = (stAXSOAPModelBuilder).getSOAPEnvelope();
         envelope.build();
 
-        return (org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl)envelope;
+        return (Element)envelope;
     }
 
     public static org.apache.axiom.soap.SOAPEnvelope

Modified: axis/axis2/java/core/branches/1_6/modules/saaj/test/org/apache/axis2/saaj/SOAPPartTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/saaj/test/org/apache/axis2/saaj/SOAPPartTest.java?rev=1377526&r1=1377525&r2=1377526&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_6/modules/saaj/test/org/apache/axis2/saaj/SOAPPartTest.java
(original)
+++ axis/axis2/java/core/branches/1_6/modules/saaj/test/org/apache/axis2/saaj/SOAPPartTest.java
Sun Aug 26 21:42:35 2012
@@ -224,10 +224,10 @@ public class SOAPPartTest extends Assert
 
         SOAP11Factory axiomSF = new SOAP11Factory();
         org.apache.axiom.soap.SOAPEnvelope axiomSE = axiomSF.createSOAPEnvelope();
-        org.apache.axiom.soap.SOAPMessage axiomSM = axiomSF.createSOAPMessage(axiomSE, null);
+        org.apache.axiom.soap.SOAPMessage axiomSM = axiomSF.createSOAPMessage();
+        axiomSM.setSOAPEnvelope(axiomSE);
         
-        SOAPEnvelopeImpl se = 
-            new SOAPEnvelopeImpl((org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl)axiomSE);
+        SOAPEnvelopeImpl se = new SOAPEnvelopeImpl(axiomSE);
         SOAPMessageImpl sm = new SOAPMessageImpl(se);
         SOAPPartImpl sp = new SOAPPartImpl(sm, se);
         

Modified: axis/axis2/java/core/branches/1_6/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/branches/1_6/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java?rev=1377526&r1=1377525&r2=1377526&view=diff
==============================================================================
--- axis/axis2/java/core/branches/1_6/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java
(original)
+++ axis/axis2/java/core/branches/1_6/modules/saaj/test/org/apache/axis2/saaj/integration/IntegrationTest.java
Sun Aug 26 21:42:35 2012
@@ -116,7 +116,7 @@ public class IntegrationTest extends Ass
                     Attachments inAttachments = inMessage.getAttachmentMap();
                     Attachments outAttachments = outMessage.getAttachmentMap();
                     for (String contentId : inAttachments.getAllContentIDs()) {
-                        if (!contentId.equals(inAttachments.getSOAPPartContentID())) {
+                        if (!contentId.equals(inAttachments.getRootPartContentID())) {
                             outAttachments.addDataHandler(contentId,
                                     inAttachments.getDataHandler(contentId));
                         }



Mime
View raw message