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 2012/04/23 12:27:05 UTC

svn commit: r1329164 [8/12] - in /webservices/axiom/branches/AXIOM-201: ./ etc/ legal/ modules/axiom-all/ modules/axiom-api/ modules/axiom-api/src/main/java/org/apache/axiom/attachments/ modules/axiom-api/src/main/java/org/apache/axiom/attachments/impl...

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMMetaFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMMetaFactory.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMMetaFactory.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMMetaFactory.java Mon Apr 23 10:26:45 2012
@@ -19,29 +19,48 @@
 
 package org.apache.axiom.om.impl.dom.factory;
 
+import javax.xml.parsers.DocumentBuilderFactory;
+
 import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.dom.DOMMetaFactory;
 import org.apache.axiom.om.impl.common.factory.AbstractOMMetaFactory;
+import org.apache.axiom.om.impl.dom.DOMImplementationImpl;
+import org.apache.axiom.om.impl.dom.jaxp.DOOMDocumentBuilderFactory;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.impl.dom.soap11.SOAP11Factory;
 import org.apache.axiom.soap.impl.dom.soap12.SOAP12Factory;
+import org.w3c.dom.DOMImplementation;
 
 /**
  * Meta factory for the DOOM implementation.
- * <p>
- * As explained in {@link OMDOMFactory}, OM factories for DOOM are not stateless.
- * Therefore {@link #getOMFactory()}, {@link #getSOAP11Factory()} and
- * {@link #getSOAP12Factory()} will return a new instance on every invocation.
  */
-public class OMDOMMetaFactory extends AbstractOMMetaFactory {
+public class OMDOMMetaFactory extends AbstractOMMetaFactory implements DOMMetaFactory {
+    // This singleton is necessary to support the no-arg constructor in DOOMDocumentBuilderFactory.
+    // Since that method is deprecated, this singleton should disappear in Axiom 1.3.
+    public static final OMDOMMetaFactory INSTANCE = new OMDOMMetaFactory();
+    
+    private final OMFactory omFactory = new OMDOMFactory(this);
+    private final SOAPFactory soap11Factory = new SOAP11Factory(this);
+    private final SOAPFactory soap12Factory = new SOAP12Factory(this);
+    private final DOMImplementation domImplementation = new DOMImplementationImpl(omFactory);
+    
     public OMFactory getOMFactory() {
-        return new OMDOMFactory(this);
+        return omFactory;
     }
 
     public SOAPFactory getSOAP11Factory() {
-        return new SOAP11Factory(this);
+        return soap11Factory;
     }
 
     public SOAPFactory getSOAP12Factory() {
-        return new SOAP12Factory(this);
+        return soap12Factory;
+    }
+
+    public DocumentBuilderFactory newDocumentBuilderFactory() {
+        return new DOOMDocumentBuilderFactory(omFactory);
+    }
+
+    public DOMImplementation getDOMImplementation() {
+        return domImplementation;
     }
 }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMMetaFactoryLoader.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMMetaFactoryLoader.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMMetaFactoryLoader.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/factory/OMDOMMetaFactoryLoader.java Mon Apr 23 10:26:45 2012
@@ -25,6 +25,6 @@ import org.apache.axiom.om.OMMetaFactory
 
 public class OMDOMMetaFactoryLoader implements OMMetaFactoryLoader {
     public OMMetaFactory load(Map properties) {
-        return new OMDOMMetaFactory();
+        return OMDOMMetaFactory.INSTANCE;
     }
 }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DOOMDocumentBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DOOMDocumentBuilder.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DOOMDocumentBuilder.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DOOMDocumentBuilder.java Mon Apr 23 10:26:45 2012
@@ -19,10 +19,10 @@
 
 package org.apache.axiom.om.impl.dom.jaxp;
 
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.dom.DOMMetaFactory;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.impl.dom.DOMImplementationImpl;
 import org.apache.axiom.om.impl.dom.DocumentImpl;
-import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
 import org.apache.axiom.om.util.StAXUtils;
 import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Document;
@@ -34,13 +34,20 @@ import org.xml.sax.SAXException;
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
+import javax.xml.validation.Schema;
+
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
 public class DOOMDocumentBuilder extends DocumentBuilder {
-    protected DOOMDocumentBuilder() {
+    private final OMFactory factory;
+    private final Schema schema;
+    
+    DOOMDocumentBuilder(OMFactory factory, Schema schema) {
+        this.factory = factory;
+        this.schema = schema;
     }
 
     /**
@@ -63,8 +70,12 @@ public class DOOMDocumentBuilder extends
         return true;
     }
 
+    public Schema getSchema() {
+        return schema;
+    }
+
     public DOMImplementation getDOMImplementation() {
-        return new DOMImplementationImpl();
+        return ((DOMMetaFactory)factory.getMetaFactory()).getDOMImplementation();
     }
 
     /**
@@ -73,24 +84,22 @@ public class DOOMDocumentBuilder extends
      * @see javax.xml.parsers.DocumentBuilder#newDocument()
      */
     public Document newDocument() {
-        OMDOMFactory factory = new OMDOMFactory();
         DocumentImpl documentImpl = new DocumentImpl(factory);
         documentImpl.setComplete(true);
         return documentImpl;
     }
 
-    public void setEntityResolver(EntityResolver arg0) {
+    public void setEntityResolver(EntityResolver er) {
         // TODO
     }
 
-    public void setErrorHandler(ErrorHandler arg0) {
+    public void setErrorHandler(ErrorHandler eh) {
         // TODO 
     }
 
     public Document parse(InputSource inputSource) throws SAXException,
             IOException {
         try {
-            OMDOMFactory factory = new OMDOMFactory();
             // Not really sure whether this will work :-?
             XMLStreamReader reader = StAXUtils
                     .createXMLStreamReader(inputSource.getCharacterStream());
@@ -106,7 +115,6 @@ public class DOOMDocumentBuilder extends
     /** @see javax.xml.parsers.DocumentBuilder#parse(java.io.InputStream) */
     public Document parse(InputStream is) throws SAXException, IOException {
         try {
-            OMDOMFactory factory = new OMDOMFactory();
             XMLStreamReader reader = StAXUtils
                     .createXMLStreamReader(is);
             StAXOMBuilder builder = new StAXOMBuilder(factory, reader);

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DOOMDocumentBuilderFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DOOMDocumentBuilderFactory.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DOOMDocumentBuilderFactory.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DOOMDocumentBuilderFactory.java Mon Apr 23 10:26:45 2012
@@ -22,22 +22,43 @@ package org.apache.axiom.om.impl.dom.jax
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
 import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.validation.Schema;
+
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.dom.DOMMetaFactory;
+import org.apache.axiom.om.impl.dom.factory.OMDOMMetaFactory;
 
 /**
  * Document builder factory that conforms to JAXP.
  */
 public class DOOMDocumentBuilderFactory extends DocumentBuilderFactory {
+    private final OMFactory factory;
+    private Schema schema;
+    
+    /**
+     * @deprecated Application code should not instantiate this class directly, but use
+     *             {@link DOMMetaFactory#newDocumentBuilderFactory()} to get an Axiom compatible
+     *             {@link DocumentBuilderFactory}.
+     */
+    public DOOMDocumentBuilderFactory() {
+        this(OMDOMMetaFactory.INSTANCE.getOMFactory());
+    }
+    
+    public DOOMDocumentBuilderFactory(OMFactory factory) {
+        this.factory = factory;
+    }
+    
     public DocumentBuilder newDocumentBuilder()
             throws ParserConfigurationException {
-        return new DOOMDocumentBuilder();
+        return new DOOMDocumentBuilder(factory, schema);
     }
 
-    public Object getAttribute(String arg0) throws IllegalArgumentException {
+    public Object getAttribute(String name) throws IllegalArgumentException {
         // TODO
         throw new UnsupportedOperationException("TODO");
     }
 
-    public void setAttribute(String arg0, Object arg1)
+    public void setAttribute(String name, Object value)
             throws IllegalArgumentException {
         // // TODO
         // throw new UnsupportedOperationException("TODO");
@@ -48,8 +69,16 @@ public class DOOMDocumentBuilderFactory 
         // TODO TODO OS
     }
 
-    public boolean getFeature(String arg0) throws ParserConfigurationException {
+    public boolean getFeature(String name) throws ParserConfigurationException {
         // TODO TODO
         throw new UnsupportedOperationException("TODO");
     }
+
+    public Schema getSchema() {
+        return schema;
+    }
+
+    public void setSchema(Schema schema) {
+        this.schema = schema;
+    }
 }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderFactoryImpl.java Mon Apr 23 10:26:45 2012
@@ -30,7 +30,7 @@ import javax.xml.validation.Schema;
  *    DOM implementation as returned by JAXP. This was a hack introduced for Rampart.
  *    Recent versions of Rampart no longer rely on this hack. On the other hand
  *    usage of {@link #setDOOMRequired(boolean)} in a concurrent environment can
- *    lead to unexpected behavior and severe bugs, as shown in WSCOMMONS-210 and AXIS2-1570.
+ *    lead to unexpected behavior and severe bugs, as shown in AXIOM-3 and AXIS2-1570.
  *    Due to the way {@link #newDocumentBuilder()} is implemented, it is not possible
  *    to get rid of the setDOOMRequired hack without the risk of breaking existing code.
  *    Therefore this class has been deprecated in favor of {@link DOOMDocumentBuilderFactory}. 
@@ -95,12 +95,12 @@ public class DocumentBuilderFactoryImpl 
                 : originalDocumentBuilderFactory.newDocumentBuilder();
     }
 
-    public Object getAttribute(String arg0) throws IllegalArgumentException {
+    public Object getAttribute(String name) throws IllegalArgumentException {
         // TODO
         throw new UnsupportedOperationException("TODO");
     }
 
-    public void setAttribute(String arg0, Object arg1)
+    public void setAttribute(String name, Object value)
             throws IllegalArgumentException {
         // // TODO
         // throw new UnsupportedOperationException("TODO");
@@ -115,7 +115,7 @@ public class DocumentBuilderFactoryImpl 
         // TODO TODO OS
     }
 
-    public boolean getFeature(String arg0) throws ParserConfigurationException {
+    public boolean getFeature(String name) throws ParserConfigurationException {
         // TODO TODO
         throw new UnsupportedOperationException("TODO");
     }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderImpl.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderImpl.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/om/impl/dom/jaxp/DocumentBuilderImpl.java Mon Apr 23 10:26:45 2012
@@ -20,10 +20,10 @@
 package org.apache.axiom.om.impl.dom.jaxp;
 
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.impl.dom.DOMImplementationImpl;
 import org.apache.axiom.om.impl.dom.DocumentImpl;
 import org.apache.axiom.om.impl.dom.ElementImpl;
 import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
+import org.apache.axiom.om.impl.dom.factory.OMDOMMetaFactory;
 import org.apache.axiom.om.util.StAXUtils;
 import org.w3c.dom.DOMImplementation;
 import org.w3c.dom.Document;
@@ -75,7 +75,7 @@ public class DocumentBuilderImpl extends
     }
 
     public DOMImplementation getDOMImplementation() {
-        return new DOMImplementationImpl();
+        return OMDOMMetaFactory.INSTANCE.getDOMImplementation();
     }
 
     /**
@@ -90,11 +90,11 @@ public class DocumentBuilderImpl extends
         return documentImpl;
     }
 
-    public void setEntityResolver(EntityResolver arg0) {
+    public void setEntityResolver(EntityResolver er) {
         // TODO
     }
 
-    public void setErrorHandler(ErrorHandler arg0) {
+    public void setErrorHandler(ErrorHandler eh) {
         // TODO 
     }
 

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPEnvelopeImpl.java Mon Apr 23 10:26:45 2012
@@ -26,8 +26,8 @@ import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
+import org.apache.axiom.om.impl.dom.ChildNode;
 import org.apache.axiom.om.impl.dom.DocumentImpl;
-import org.apache.axiom.om.impl.dom.NodeImpl;
 import org.apache.axiom.om.impl.util.OMSerializerUtil;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP11Version;
@@ -41,7 +41,6 @@ import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axiom.soap.SOAPProcessingException;
 import org.apache.axiom.soap.SOAPVersion;
 import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
-import org.apache.axiom.soap.impl.dom.factory.DOMSOAPFactory;
 import org.w3c.dom.DOMException;
 import org.w3c.dom.Node;
 
@@ -69,9 +68,7 @@ public class SOAPEnvelopeImpl extends SO
 
     /** @param ns  */
     public SOAPEnvelopeImpl(OMNamespace ns, SOAPFactory factory) {
-        super(((DOMSOAPFactory) factory).getDocument(),
-              SOAPConstants.SOAPENVELOPE_LOCAL_NAME, ns, factory);
-        this.getOwnerDocument().appendChild(this);
+        super(null, SOAPConstants.SOAPENVELOPE_LOCAL_NAME, ns, factory);
     }
 
     public SOAPVersion getVersion() {
@@ -140,7 +137,7 @@ public class SOAPEnvelopeImpl extends SO
                 // body and insert the header.  If the body is not found,
                 // this indicates that it has not been parsed yet...and
                 // the code will fall through to the super.addChild.
-                OMNode node = this.lastChild;
+                OMNode node = (OMNode)this.lastChild;
                 while (node != null) {
                     if (node instanceof SOAPBody) {
                         node.insertSiblingBefore(child);
@@ -204,15 +201,6 @@ public class SOAPEnvelopeImpl extends SO
         return null;
     }
 
-    /**
-     * Method detach
-     *
-     * @throws OMException
-     */
-    public OMNode detach() throws OMException {
-        throw new OMException("Root Element can not be detached");
-    }
-
     protected void checkParent(OMElement parent) throws SOAPProcessingException {
         // here do nothing as SOAPEnvelope doesn't have a parent !!!
     }
@@ -253,11 +241,11 @@ public class SOAPEnvelopeImpl extends SO
                 OMSerializerUtil.serializeStartpart(this, writer);
                 OMElement header = getHeader();
                 if ((header != null) && (header.getFirstOMChild() != null)) {
-                    serializeInternally((NodeImpl) header, writer);
+                    serializeInternally((ChildNode) header, writer);
                 }
                 SOAPBody body = getBody();
                 if (body != null) {
-                    serializeInternally((NodeImpl) body, writer);
+                    serializeInternally((ChildNode) body, writer);
                 }
                 OMSerializerUtil.serializeEndpart(writer);
             } else {
@@ -266,7 +254,7 @@ public class SOAPEnvelopeImpl extends SO
         }
     }
 
-    private void serializeInternally(NodeImpl child, MTOMXMLStreamWriter writer)
+    private void serializeInternally(ChildNode child, MTOMXMLStreamWriter writer)
             throws XMLStreamException {
         if ((!(child instanceof OMElement)) || child.isComplete() || child.builder == null) {
             child.internalSerialize(writer, false);
@@ -279,8 +267,9 @@ public class SOAPEnvelopeImpl extends SO
     }
 
     public OMNode getNextOMSibling() throws OMException {
-        if (this.ownerNode != null && !this.ownerNode.isComplete()) {
-            this.ownerNode.setComplete(true);
+        DocumentImpl ownerDocument = (DocumentImpl)getOwnerDocument();
+        if (ownerDocument != null && !ownerDocument.isComplete()) {
+            ownerDocument.setComplete(true);
         }
         return null;
     }
@@ -290,9 +279,8 @@ public class SOAPEnvelopeImpl extends SO
         if (payloadQName != null) {
             if (SOAPConstants.SOAPFAULT_LOCAL_NAME.equals(payloadQName.getLocalPart())) {
                 String ns = payloadQName.getNamespaceURI();
-                return (ns != null &&
-                    (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(ns) ||
-                     SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(ns)));                                                         
+                return SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(ns) ||
+                       SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(ns);                                                         
             } 
         }
         

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPFaultTextImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPFaultTextImpl.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPFaultTextImpl.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPFaultTextImpl.java Mon Apr 23 10:26:45 2012
@@ -23,6 +23,7 @@ import org.apache.axiom.om.OMAttribute;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.dom.AttrImpl;
+import org.apache.axiom.om.impl.dom.DocumentImpl;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.SOAPFaultReason;
@@ -57,7 +58,7 @@ public abstract class SOAPFaultTextImpl 
 
     public void setLang(String lang) {
         langAttr =
-                new AttrImpl(this.ownerNode,
+                new AttrImpl((DocumentImpl)getOwnerDocument(),
                              SOAP12Constants.SOAP_FAULT_TEXT_LANG_ATTR_LOCAL_NAME,
                              langNamespace,
                              lang, this.factory);

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderBlockImpl.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderBlockImpl.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderBlockImpl.java Mon Apr 23 10:26:45 2012
@@ -26,9 +26,9 @@ import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.common.OMNamespaceImpl;
 import org.apache.axiom.om.impl.dom.AttrImpl;
+import org.apache.axiom.om.impl.dom.DocumentImpl;
 import org.apache.axiom.om.impl.dom.ElementImpl;
 import org.apache.axiom.om.impl.dom.ParentNode;
-import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
 import org.apache.axiom.soap.SOAPConstants;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.SOAPHeader;
@@ -55,7 +55,7 @@ public abstract class SOAPHeaderBlockImp
 
     public SOAPHeaderBlockImpl(String localName, OMNamespace ns,
                                SOAPFactory factory) throws SOAPProcessingException {
-        super(((OMDOMFactory) factory).getDocument(), localName, (OMNamespaceImpl) ns, factory);
+        super(null, localName, (OMNamespaceImpl) ns, factory);
         this.setNamespace(ns);
     }
 
@@ -86,7 +86,7 @@ public abstract class SOAPHeaderBlockImp
         if (omAttribute != null) {
             omAttribute.setAttributeValue(attrValue);
         } else {
-            OMAttribute attribute = new AttrImpl(this.ownerNode, attributeName,
+            OMAttribute attribute = new AttrImpl((DocumentImpl)getOwnerDocument(), attributeName,
                                                  new OMNamespaceImpl(soapEnvelopeNamespaceURI,
                                                                    SOAPConstants.SOAP_DEFAULT_NAMESPACE_PREFIX),
                                                  attrValue, this.factory);

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderImpl.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderImpl.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPHeaderImpl.java Mon Apr 23 10:26:45 2012
@@ -26,206 +26,22 @@ import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.OMNodeEx;
 import org.apache.axiom.soap.RolePlayer;
-import org.apache.axiom.soap.SOAP12Constants;
-import org.apache.axiom.soap.SOAP12Version;
 import org.apache.axiom.soap.SOAPConstants;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axiom.soap.SOAPHeaderBlock;
 import org.apache.axiom.soap.SOAPProcessingException;
-import org.apache.axiom.soap.SOAPVersion;
+import org.apache.axiom.soap.impl.common.HeaderIterator;
+import org.apache.axiom.soap.impl.common.MURoleChecker;
+import org.apache.axiom.soap.impl.common.RoleChecker;
+import org.apache.axiom.soap.impl.common.RolePlayerChecker;
 
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 
-/**
- * A local interface we can use to make "header checker" objects which can be used by
- * HeaderIterators to filter results.  This really SHOULD be done with anonymous classes:
- * <p/>
- * public void getHeadersByRole(final String role) {
- *     return new HeaderIterator() {
- *         public boolean checkHeader(SOAPHeaderBlock header) {
- *             ...
- *             if (role.equals(headerRole)) return true;
- *             return false;
- *         }
- *     }
- * }
- * <p/>
- * ...but there appears to be some kind of weird problem with the JVM not correctly scoping the
- * passed "role" value in a situation like the above.  As such, we have to make Checker objects
- * instead (sigh).
- */
-interface Checker {
-    boolean checkHeader(SOAPHeaderBlock header);
-}
-
-/**
- * A Checker to make sure headers match a given role.  If the role we're looking for is null, then
- * everything matches.
- */
-class RoleChecker implements Checker {
-    String role;
-
-    public RoleChecker(String role) {
-        this.role = role;
-    }
-
-    public boolean checkHeader(SOAPHeaderBlock header) {
-        if (role == null) {
-            return true;
-        }
-        String thisRole = header.getRole();
-        return (role.equals(thisRole));
-    }
-}
-
-/**
- * This Checker uses a RolePlayer to return the appropriate headers for that RolePlayer to process.
- * Ignore "none", always "next", etc.
- */
-class RolePlayerChecker implements Checker {
-    RolePlayer rolePlayer;
-
-    /** Optional namespace - if non-null we'll only return headers that match */
-    String namespace;
-
-    /**
-     * Constructor.
-     *
-     * @param rolePlayer the RolePlayer to check against.  This can be null, in which
-     *                   case we assume we're the ultimate destination.
-     */
-    public RolePlayerChecker(RolePlayer rolePlayer) {
-        this.rolePlayer = rolePlayer;
-    }
-
-    public RolePlayerChecker(RolePlayer rolePlayer, String namespace) {
-        this.rolePlayer = rolePlayer;
-        this.namespace = namespace;
-    }
-
-    public boolean checkHeader(SOAPHeaderBlock header) {
-        // If we're filtering on namespace, check that first since the compare is simpler.
-        if (namespace != null) {
-            OMNamespace headerNamespace = header.getNamespace();
-            if (headerNamespace == null || !namespace.equals(headerNamespace.getNamespaceURI())) {
-                return false;
-            }
-        }
-
-        String role = header.getRole();
-        SOAPVersion version = header.getVersion();
-
-        // 1. If role is ultimatedest, go by what the rolePlayer says
-        if (role == null || role.equals("") ||
-                (version instanceof SOAP12Version &&
-                        role.equals(SOAP12Constants.SOAP_ROLE_ULTIMATE_RECEIVER))) {
-            return (rolePlayer == null || rolePlayer.isUltimateDestination());
-        }
-
-        // 2. If role is next, always return true
-        if (role.equals(version.getNextRoleURI())) return true;
-
-        // 3. If role is none, always return false
-        if (version instanceof SOAP12Version &&
-                role.equals(SOAP12Constants.SOAP_ROLE_NONE)) {
-            return false;
-        }
-
-        // 4. Return t/f depending on match
-        List roles = (rolePlayer == null) ? null : rolePlayer.getRoles();
-        if (roles != null) {
-            for (Iterator i = roles.iterator(); i.hasNext();) {
-                String thisRole = (String) i.next();
-                if (thisRole.equals(role)) return true;
-            }
-        }
-
-        return false;
-    }
-}
-
-/** A Checker to see that we both match a given role AND are mustUnderstand=true */
-class MURoleChecker extends RoleChecker {
-    public MURoleChecker(String role) {
-        super(role);
-    }
-
-    public boolean checkHeader(SOAPHeaderBlock header) {
-        if (header.getMustUnderstand())
-            return super.checkHeader(header);
-        return false;
-    }
-}
-
 public abstract class SOAPHeaderImpl extends SOAPElement implements SOAPHeader {
-    
-    /** An Iterator which walks the header list as needed, potentially filtering as we traverse. */
-    class HeaderIterator implements Iterator {
-        SOAPHeaderBlock current;
-        boolean advance = false;
-        Checker checker;
-
-        public HeaderIterator() {
-            this(null);
-        }
-
-        public HeaderIterator(Checker checker) {
-            this.checker = checker;
-            current = (SOAPHeaderBlock) getFirstElement();
-            if (current != null) {
-                if (!checkHeader(current)) {
-                    advance = true;
-                    hasNext();
-                }
-            }
-        }
-
-        public void remove() {
-        }
-
-        public boolean checkHeader(SOAPHeaderBlock header) {
-            if (checker == null) return true;
-            return checker.checkHeader(header);
-        }
-
-        public boolean hasNext() {
-            if (!advance) {
-                return current != null;
-            }
-
-            advance = false;
-            OMNode sibling = current.getNextOMSibling();
-
-            while (sibling != null) {
-                if (sibling instanceof SOAPHeaderBlock) {
-                    SOAPHeaderBlock possible = (SOAPHeaderBlock) sibling;
-                    if (checkHeader(possible)) {
-                        current = (SOAPHeaderBlock) sibling;
-                        return true;
-                    }
-                }
-                sibling = sibling.getNextOMSibling();
-            }
-
-            current = null;
-            return false;
-        }
-
-        public Object next() {
-            SOAPHeaderBlock ret = current;
-            if (ret != null) {
-                advance = true;
-                hasNext();
-            }
-            return ret;
-        }
-    }
-
-
     /** @param envelope  */
     public SOAPHeaderImpl(SOAPEnvelope envelope, SOAPFactory factory)
             throws SOAPProcessingException {
@@ -270,21 +86,21 @@ public abstract class SOAPHeaderImpl ext
     protected abstract SOAPHeaderBlock createHeaderBlock(String localname, OMNamespace ns);
     
     public Iterator getHeadersToProcess(RolePlayer rolePlayer) {
-        return new HeaderIterator(new RolePlayerChecker(rolePlayer));
+        return new HeaderIterator(this, new RolePlayerChecker(rolePlayer));
     }
 
     public Iterator getHeadersToProcess(RolePlayer rolePlayer, String namespace) {
-        return new HeaderIterator(new RolePlayerChecker(rolePlayer, namespace));
+        return new HeaderIterator(this, new RolePlayerChecker(rolePlayer, namespace));
     }
 
     public Iterator examineHeaderBlocks(String role) {
-        return new HeaderIterator(new RoleChecker(role));
+        return new HeaderIterator(this, new RoleChecker(role));
     }
 
     public abstract Iterator extractHeaderBlocks(String role);
 
     public Iterator examineMustUnderstandHeaderBlocks(String actor) {
-        return new HeaderIterator(new MURoleChecker(actor));
+        return new HeaderIterator(this, new MURoleChecker(actor));
     }
 
     public Iterator examineAllHeaderBlocks() {

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPMessageImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPMessageImpl.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPMessageImpl.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/SOAPMessageImpl.java Mon Apr 23 10:26:45 2012
@@ -59,6 +59,6 @@ public class SOAPMessageImpl extends Doc
 
     protected void internalSerialize(XMLStreamWriter writer, boolean cache,
                                      boolean includeXMLDeclaration) throws XMLStreamException {
-        ((OMNodeEx) this.ownerNode.getDocumentElement()).internalSerialize(writer, cache);
+        ((OMNodeEx)getOwnerDocument().getDocumentElement()).internalSerialize(writer, cache);
     }
 }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/factory/DOMSOAPFactory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/factory/DOMSOAPFactory.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/factory/DOMSOAPFactory.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/factory/DOMSOAPFactory.java Mon Apr 23 10:26:45 2012
@@ -30,7 +30,6 @@ import org.apache.axiom.soap.SOAPEnvelop
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.SOAPFault;
 import org.apache.axiom.soap.SOAPFaultCode;
-import org.apache.axiom.soap.SOAPFaultDetail;
 import org.apache.axiom.soap.SOAPFaultNode;
 import org.apache.axiom.soap.SOAPFaultReason;
 import org.apache.axiom.soap.SOAPFaultRole;
@@ -41,13 +40,11 @@ import org.apache.axiom.soap.SOAPHeader;
 import org.apache.axiom.soap.SOAPHeaderBlock;
 import org.apache.axiom.soap.SOAPMessage;
 import org.apache.axiom.soap.SOAPProcessingException;
-import org.apache.axiom.soap.SOAPVersion;
 import org.apache.axiom.soap.impl.dom.SOAPEnvelopeImpl;
 import org.apache.axiom.soap.impl.dom.SOAPMessageImpl;
-import org.apache.axiom.soap.impl.dom.soap11.SOAP11FaultDetailImpl;
 import org.apache.axiom.soap.impl.dom.soap12.SOAP12FaultImpl;
 
-public class DOMSOAPFactory extends OMDOMFactory implements SOAPFactory {
+public abstract class DOMSOAPFactory extends OMDOMFactory implements SOAPFactory {
     public DOMSOAPFactory(OMDOMMetaFactory metaFactory) {
         super(metaFactory);
     }
@@ -55,171 +52,27 @@ public class DOMSOAPFactory extends OMDO
     public DOMSOAPFactory() {
     }
 
-    public DOMSOAPFactory(DocumentImpl doc) {
-        super(doc);
-    }
-
-    public String getSoapVersionURI() {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPVersion getSOAPVersion() {
-        throw new UnsupportedOperationException();
-    }
-
     public SOAPMessage createSOAPMessage(OMXMLParserWrapper builder) {
-        SOAPMessageImpl messageImpl = new SOAPMessageImpl(builder, this);
-        this.document = messageImpl;
-        return messageImpl;
+        return new SOAPMessageImpl(builder, this);
     }
 
     public SOAPMessage createSOAPMessage(SOAPEnvelope envelope, OMXMLParserWrapper parserWrapper) {
-        SOAPMessageImpl messageImpl = new SOAPMessageImpl(envelope, parserWrapper, this);
-        this.document = messageImpl;
-        return messageImpl;
+        return new SOAPMessageImpl(envelope, parserWrapper, this);
     }
 
     public SOAPEnvelope createSOAPEnvelope(OMXMLParserWrapper builder) {
         return new SOAPEnvelopeImpl((DocumentImpl) this.createOMDocument(), builder, this);
     }
 
-    public SOAPEnvelope createSOAPEnvelope() throws SOAPProcessingException {
-        throw new UnsupportedOperationException();
-    }
-    
-    public SOAPEnvelope createSOAPEnvelope(OMNamespace ns) {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPHeader createSOAPHeader(SOAPEnvelope envelope) throws SOAPProcessingException {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPHeader createSOAPHeader(SOAPEnvelope envelope, OMXMLParserWrapper builder) {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPHeaderBlock createSOAPHeaderBlock(String localName, OMNamespace ns,
-                                                 SOAPHeader parent) throws SOAPProcessingException {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPHeaderBlock createSOAPHeaderBlock(String localName, OMNamespace ns,
-                                                 SOAPHeader parent, OMXMLParserWrapper builder)
-            throws SOAPProcessingException {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFault createSOAPFault(SOAPBody parent, Exception e) throws SOAPProcessingException {
-        throw new UnsupportedOperationException();
-    }
-
     public SOAPFault createSOAPFault(SOAPBody parent) throws SOAPProcessingException {
         return new SOAP12FaultImpl(parent, this);
     }
 
-    public SOAPFault createSOAPFault(SOAPBody parent, OMXMLParserWrapper builder) {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPBody createSOAPBody(SOAPEnvelope envelope) throws SOAPProcessingException {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPBody createSOAPBody(SOAPEnvelope envelope, OMXMLParserWrapper builder) {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultCode createSOAPFaultCode(SOAPFault parent) throws SOAPProcessingException {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultCode createSOAPFaultCode(SOAPFault parent, OMXMLParserWrapper builder) {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultValue createSOAPFaultValue(SOAPFaultCode parent)
-            throws SOAPProcessingException {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultValue createSOAPFaultValue(SOAPFaultCode parent, OMXMLParserWrapper builder) {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultValue createSOAPFaultValue(SOAPFaultSubCode parent)
-            throws SOAPProcessingException {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultValue createSOAPFaultValue(SOAPFaultSubCode parent,
-                                               OMXMLParserWrapper builder) {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultSubCode createSOAPFaultSubCode(SOAPFaultCode parent)
-            throws SOAPProcessingException {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultSubCode createSOAPFaultSubCode(SOAPFaultCode parent,
-                                                   OMXMLParserWrapper builder) {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultSubCode createSOAPFaultSubCode(SOAPFaultSubCode parent)
-            throws SOAPProcessingException {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultSubCode createSOAPFaultSubCode(SOAPFaultSubCode parent,
-                                                   OMXMLParserWrapper builder) {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultReason createSOAPFaultReason(SOAPFault parent) throws SOAPProcessingException {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultReason createSOAPFaultReason(SOAPFault parent, OMXMLParserWrapper builder) {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultText createSOAPFaultText(SOAPFaultReason parent)
-            throws SOAPProcessingException {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultText createSOAPFaultText(SOAPFaultReason parent, OMXMLParserWrapper builder) {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultNode createSOAPFaultNode(SOAPFault parent) throws SOAPProcessingException {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultNode createSOAPFaultNode(SOAPFault parent, OMXMLParserWrapper builder) {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultRole createSOAPFaultRole(SOAPFault parent) throws SOAPProcessingException {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultRole createSOAPFaultRole(SOAPFault parent, OMXMLParserWrapper builder) {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultDetail createSOAPFaultDetail(SOAPFault parent) throws SOAPProcessingException {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPFaultDetail createSOAPFaultDetail(SOAPFault parent, OMXMLParserWrapper builder) {
-        throw new UnsupportedOperationException();
-    }
-
-    public SOAPEnvelope getDefaultEnvelope() throws SOAPProcessingException {
-        throw new UnsupportedOperationException();
+    public final SOAPEnvelope getDefaultEnvelope() throws SOAPProcessingException {
+        SOAPEnvelopeImpl env = new SOAPEnvelopeImpl(getNamespace(), this);
+        createSOAPHeader(env);
+        createSOAPBody(env);
+        return env;
     }
 
     public SOAPEnvelope getDefaultFaultEnvelope() throws SOAPProcessingException {
@@ -247,15 +100,6 @@ public class DOMSOAPFactory extends OMDO
         throw new UnsupportedOperationException("TODO");
     }
 
-    public SOAPHeaderBlock createSOAPHeaderBlock(String localName, OMNamespace ns)
-            throws SOAPProcessingException {
-        throw new UnsupportedOperationException("TODO");
-    }
-
-    public SOAPFault createSOAPFault() throws SOAPProcessingException {
-        return null;
-    }
-
     public SOAPBody createSOAPBody() throws SOAPProcessingException {
         throw new UnsupportedOperationException("TODO");
     }
@@ -288,14 +132,6 @@ public class DOMSOAPFactory extends OMDO
         throw new UnsupportedOperationException("TODO");
     }
 
-    public SOAPFaultDetail createSOAPFaultDetail() throws SOAPProcessingException {
-        return new SOAP11FaultDetailImpl(this);
-    }
-
-    public OMNamespace getNamespace() {
-        throw new UnsupportedOperationException();
-    }
-
     public SOAPHeaderBlock createSOAPHeaderBlock(String localName, OMNamespace ns, OMDataSource ds) throws SOAPProcessingException {
         throw new UnsupportedOperationException("TODO");
     }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11Factory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11Factory.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11Factory.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11Factory.java Mon Apr 23 10:26:45 2012
@@ -22,7 +22,6 @@ package org.apache.axiom.soap.impl.dom.s
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.common.OMNamespaceImpl;
-import org.apache.axiom.om.impl.dom.DocumentImpl;
 import org.apache.axiom.om.impl.dom.factory.OMDOMMetaFactory;
 import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAPBody;
@@ -55,10 +54,6 @@ public class SOAP11Factory extends DOMSO
     public SOAP11Factory() {
     }
 
-    public SOAP11Factory(DocumentImpl doc) {
-        super(doc);
-    }
-
     public String getSoapVersionURI() {
         return SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI;
     }
@@ -240,15 +235,8 @@ public class SOAP11Factory extends DOMSO
         return new SOAP11FaultDetailImpl(parent, builder, this);
     }
 
-    public SOAPEnvelope getDefaultEnvelope() throws SOAPProcessingException {
-        OMNamespace ns =
-                new OMNamespaceImpl(
-                        SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI,
-                        SOAP11Constants.SOAP_DEFAULT_NAMESPACE_PREFIX);
-        SOAPEnvelopeImpl env = new SOAPEnvelopeImpl(ns, this);
-        createSOAPHeader(env);
-        createSOAPBody(env);
-        return env;
+    public SOAPFaultDetail createSOAPFaultDetail() throws SOAPProcessingException {
+        return new SOAP11FaultDetailImpl(this);
     }
 
     public OMNamespace getNamespace() {

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11FaultCodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11FaultCodeImpl.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11FaultCodeImpl.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11FaultCodeImpl.java Mon Apr 23 10:26:45 2012
@@ -31,6 +31,7 @@ import org.apache.axiom.soap.SOAPFaultVa
 import org.apache.axiom.soap.SOAPProcessingException;
 import org.apache.axiom.soap.impl.dom.SOAPFaultCodeImpl;
 
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
@@ -105,4 +106,8 @@ public class SOAP11FaultCodeImpl extends
     public String getLocalName() {
         return SOAP11Constants.SOAP_FAULT_CODE_LOCAL_NAME;
     }
+
+    public void setValue(QName value) {
+        setText(value);
+    }
 }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11FaultSubCodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11FaultSubCodeImpl.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11FaultSubCodeImpl.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap11/SOAP11FaultSubCodeImpl.java Mon Apr 23 10:26:45 2012
@@ -19,6 +19,9 @@
 
 package org.apache.axiom.soap.impl.dom.soap11;
 
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.soap.SOAP12Constants;
@@ -68,6 +71,7 @@ public class SOAP11FaultSubCodeImpl exte
 
     public void setSubCode(SOAPFaultSubCode subCode)
             throws SOAPProcessingException {
+        OMContainer parentNode = getParent();
         if (!((parentNode instanceof SOAP11FaultSubCodeImpl) ||
                 (parentNode instanceof SOAP11FaultCodeImpl))) {
             throw new SOAPProcessingException(
@@ -87,5 +91,8 @@ public class SOAP11FaultSubCodeImpl exte
         super.setValue(soapFaultSubCodeValue);
     }
 
-
+    public void setValue(QName value) {
+        // TODO: AXIOM-394: SOAPFaultSubCode should not exist for SOAP 1.1
+        throw new UnsupportedOperationException();
+    }
 }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12Factory.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12Factory.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12Factory.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12Factory.java Mon Apr 23 10:26:45 2012
@@ -22,7 +22,6 @@ package org.apache.axiom.soap.impl.dom.s
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.common.OMNamespaceImpl;
-import org.apache.axiom.om.impl.dom.DocumentImpl;
 import org.apache.axiom.om.impl.dom.factory.OMDOMMetaFactory;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPBody;
@@ -54,10 +53,6 @@ public class SOAP12Factory extends DOMSO
     public SOAP12Factory() {
     }
 
-    public SOAP12Factory(DocumentImpl doc) {
-        super(doc);
-    }
-
     public String getSoapVersionURI() {
         return SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI;
     }
@@ -228,16 +223,13 @@ public class SOAP12Factory extends DOMSO
         return new SOAP12FaultDetailImpl(parent, builder, this);
     }
 
-    public SOAPEnvelope getDefaultEnvelope() throws SOAPProcessingException {
-        OMNamespace ns =
-                new OMNamespaceImpl(
-                        SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI,
-                        SOAP12Constants.SOAP_DEFAULT_NAMESPACE_PREFIX);
-        SOAPEnvelopeImpl env = new SOAPEnvelopeImpl(ns, this);
-        createSOAPHeader(env);
-        createSOAPBody(env);
+    public SOAPFaultDetail createSOAPFaultDetail() throws SOAPProcessingException {
+        return new SOAP12FaultDetailImpl(this);
+    }
 
-        return env;
+    public OMNamespace getNamespace() {
+        return new OMNamespaceImpl(SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI,
+                                 SOAP12Constants.SOAP_DEFAULT_NAMESPACE_PREFIX);
     }
 
     public SOAPFault createSOAPFault() throws SOAPProcessingException {

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12FaultCodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12FaultCodeImpl.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12FaultCodeImpl.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12FaultCodeImpl.java Mon Apr 23 10:26:45 2012
@@ -81,4 +81,12 @@ public class SOAP12FaultCodeImpl extends
                             "the parent. But received some other implementation");
         }
     }
+
+    public void setValue(QName value) {
+        SOAPFaultValue valueElement = getValue();
+        if (valueElement == null) {
+            valueElement = ((SOAPFactory)getOMFactory()).createSOAPFaultValue(this);
+        }
+        valueElement.setText(value);
+    }
 }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12FaultDetailImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12FaultDetailImpl.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12FaultDetailImpl.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12FaultDetailImpl.java Mon Apr 23 10:26:45 2012
@@ -38,6 +38,10 @@ public class SOAP12FaultDetailImpl exten
         super(parent, builder, factory);
     }
 
+    public SOAP12FaultDetailImpl(SOAPFactory factory) {
+        super(factory);
+    }
+
     protected void checkParent(OMElement parent) throws SOAPProcessingException {
         if (!(parent instanceof SOAP12FaultImpl)) {
             throw new SOAPProcessingException(

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12FaultSubCodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12FaultSubCodeImpl.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12FaultSubCodeImpl.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/main/java/org/apache/axiom/soap/impl/dom/soap12/SOAP12FaultSubCodeImpl.java Mon Apr 23 10:26:45 2012
@@ -19,6 +19,8 @@
 
 package org.apache.axiom.soap.impl.dom.soap12;
 
+import javax.xml.namespace.QName;
+
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.soap.SOAP12Constants;
@@ -84,4 +86,12 @@ public class SOAP12FaultSubCodeImpl exte
         }
         super.setValue(soapFaultSubCodeValue);
     }
+
+    public void setValue(QName value) {
+        SOAPFaultValue valueElement = getValue();
+        if (valueElement == null) {
+            valueElement = ((SOAPFactory)getOMFactory()).createSOAPFaultValue(this);
+        }
+        valueElement.setText(value);
+    }
 }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/DOMImplementationTest.java Mon Apr 23 10:26:45 2012
@@ -21,12 +21,12 @@ package org.apache.axiom.om.impl.dom;
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
-import org.apache.axiom.om.impl.dom.jaxp.DOOMDocumentBuilderFactory;
+import org.apache.axiom.om.impl.dom.factory.OMDOMMetaFactory;
 import org.apache.axiom.ts.dom.DOMTestSuiteBuilder;
 
 public class DOMImplementationTest extends TestCase {
     public static TestSuite suite() {
-        DOMTestSuiteBuilder builder = new DOMTestSuiteBuilder(new DOOMDocumentBuilderFactory());
+        DOMTestSuiteBuilder builder = new DOMTestSuiteBuilder(new OMDOMMetaFactory().newDocumentBuilderFactory());
         return builder.build();
     }
 }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-dom/src/test/java/org/apache/axiom/om/impl/dom/OMImplementationTest.java Mon Apr 23 10:26:45 2012
@@ -22,37 +22,19 @@ import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
 import org.apache.axiom.om.impl.dom.factory.OMDOMMetaFactory;
-import org.apache.axiom.ts.OMTestSuiteBuilder;
+import org.apache.axiom.ts.om.OMTestSuiteBuilder;
 import org.apache.axiom.ts.om.builder.TestCreateOMBuilderFromDOMSource;
 import org.apache.axiom.ts.om.container.TestSerialize;
 import org.apache.axiom.ts.om.document.TestDigest;
 import org.apache.axiom.ts.om.element.TestGetChildrenWithName4;
-import org.apache.axiom.ts.om.element.TestGetXMLStreamReaderCDATAEventFromElement;
-import org.apache.axiom.ts.om.element.TestGetXMLStreamReaderWithOMSourcedElementDescendant;
-import org.apache.axiom.ts.om.element.TestSetTextQName;
-import org.apache.axiom.ts.om.element.TestSetTextQNameWithEmptyPrefix;
-import org.apache.axiom.ts.om.element.TestSetTextQNameWithoutNamespace;
 import org.apache.axiom.ts.om.factory.TestCreateOMElementWithGeneratedPrefix;
 import org.apache.axiom.ts.om.factory.TestCreateOMElementWithNamespaceInScope;
 import org.apache.axiom.ts.om.node.TestInsertSiblingAfterOnChild;
 import org.apache.axiom.ts.om.node.TestInsertSiblingBeforeOnChild;
-import org.apache.axiom.ts.xpath.TestAXIOMXPath;
 
 public class OMImplementationTest extends TestCase {
     public static TestSuite suite() {
-        OMTestSuiteBuilder builder = new OMTestSuiteBuilder(new OMDOMMetaFactory());
-        // OMElement#setText(QName) is unsupported
-        builder.exclude(TestSetTextQName.class);
-        builder.exclude(TestSetTextQNameWithEmptyPrefix.class);
-        builder.exclude(TestSetTextQNameWithoutNamespace.class);
-        
-        // TODO: AXIOM-315
-        builder.exclude(org.apache.axiom.ts.om.document.TestIsCompleteAfterAddingIncompleteChild.class);
-        builder.exclude(org.apache.axiom.ts.om.element.TestIsCompleteAfterAddingIncompleteChild.class);
-        
-        // TODO: these need to be investigated; may be related to AXIOM-315
-        builder.exclude(org.apache.axiom.ts.om.document.TestSerializeAndConsumeWithIncompleteDescendant.class);
-        builder.exclude(org.apache.axiom.ts.om.element.TestSerializeAndConsumeWithIncompleteDescendant.class);
+        OMTestSuiteBuilder builder = new OMTestSuiteBuilder(new OMDOMMetaFactory(), false);
         
         // TODO: Axiom should throw an exception if an attempt is made to create a cyclic parent-child relationship
         builder.exclude(TestInsertSiblingAfterOnChild.class);
@@ -63,12 +45,6 @@ public class OMImplementationTest extend
         builder.exclude(TestCreateOMElementWithNamespaceInScope.class, "(variant=QName,OMContainer)");
         builder.exclude(TestCreateOMElementWithNamespaceInScope.class, "(variant=String,OMNamespace,OMContainer)");
         
-        // DOOM doesn't support CDATA sections
-        builder.exclude(TestGetXMLStreamReaderCDATAEventFromElement.class);
-        
-        // WSCOMMONS-453
-        builder.exclude(TestGetXMLStreamReaderWithOMSourcedElementDescendant.class);
-        
         // TODO: this case is not working because Axiom generates an XML declaration
         //       but uses another charset encoding to serialize the document
         builder.exclude(TestSerialize.class, "(&(file=iso-8859-1.xml)(container=document))");
@@ -88,9 +64,6 @@ public class OMImplementationTest extend
         // TODO: if there is a comment node surrounded by text, then these text nodes need to be merged
         builder.exclude(TestDigest.class, "(|(file=digest3.xml)(file=digest4.xml))");
         
-        // TODO: investigate this failure
-        builder.exclude(TestAXIOMXPath.class, "(test=id54298)");
-        
         return builder.build();
     }
 }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-impl/pom.xml
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-impl/pom.xml?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-impl/pom.xml (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-impl/pom.xml Mon Apr 23 10:26:45 2012
@@ -22,7 +22,7 @@
     <parent>
         <groupId>org.apache.ws.commons.axiom</groupId>
         <artifactId>axiom-parent</artifactId>
-        <version>1.2.13-SNAPSHOT</version>
+        <version>1.2.14-SNAPSHOT</version>
         <relativePath>../axiom-parent/pom.xml</relativePath>
     </parent>
     <artifactId>axiom-impl</artifactId>
@@ -100,7 +100,6 @@
         <dependency>
             <groupId>xalan</groupId>
             <artifactId>xalan</artifactId>
-            <version>2.7.1</version>
             <scope>test</scope>
         </dependency>
         <dependency>
@@ -131,9 +130,7 @@
                 </configuration>
             </plugin>
             <plugin>
-                <groupId>${project.groupId}</groupId>
-                <artifactId>shade-plugin-patched</artifactId>
-                <version>${project.version}</version>
+                <artifactId>maven-shade-plugin</artifactId>
                 <executions>
                     <execution>
                         <phase>package</phase>
@@ -151,6 +148,10 @@
                                     <pattern>org.apache.axiom.om.impl.common</pattern>
                                     <shadedPattern>org.apache.axiom.om.impl.llom</shadedPattern>
                                 </relocation>
+                                <relocation>
+                                    <pattern>org.apache.axiom.soap.impl.common</pattern>
+                                    <shadedPattern>org.apache.axiom.soap.impl.llom</shadedPattern>
+                                </relocation>
                             </relocations>
                             <transformers>
                                 <transformer implementation="org.apache.axiom.buildutils.OSGiManifestResourceTransformer" />

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMAttributeImpl.java Mon Apr 23 10:26:45 2012
@@ -38,7 +38,18 @@ public class OMAttributeImpl implements 
     /** Field type */
     private String type;
 
-    /** Field namespace */
+    /**
+     * The namespace of this attribute. Possible values:
+     * <ul>
+     * <li><code>null</code> (if the attribute has no namespace)
+     * <li>any {@link OMNamespace} instance, with the following exceptions:
+     * <ul>
+     * <li>an {@link OMNamespace} instance with a <code>null</code> prefix
+     * <li>an {@link OMNamespace} instance with an empty prefix (because an unprefixed attribute
+     * never has a namespace)
+     * </ul>
+     * </ul>
+     */
     private OMNamespace namespace;
     
     private QName qName;
@@ -61,8 +72,12 @@ public class OMAttributeImpl implements 
         if (localName == null || localName.trim().length() == 0)
             throw new IllegalArgumentException("Local name may not be null or empty");
         
-        if (ns != null && ns.getNamespaceURI().length() == 0 && ns.getPrefix().length() > 0) {
-            throw new IllegalArgumentException("Cannot create a prefixed attribute with an empty namespace name");
+        if (ns != null && ns.getNamespaceURI().length() == 0) {
+            if (ns.getPrefix().length() > 0) {
+                throw new IllegalArgumentException("Cannot create a prefixed attribute with an empty namespace name");
+            } else {
+                ns = null;
+            }
         }
 
         this.localName = localName;
@@ -79,12 +94,7 @@ public class OMAttributeImpl implements 
         }
 
         if (namespace != null) {
-            // Guard against QName implementation sillyness.
-            if (namespace.getPrefix() == null) {
-                this.qName = new QName(namespace.getNamespaceURI(), localName);
-            } else {
-                this.qName =  new QName(namespace.getNamespaceURI(), localName, namespace.getPrefix());
-            }
+            this.qName =  new QName(namespace.getNamespaceURI(), localName, namespace.getPrefix());
         } else {
             this.qName =  new QName(localName);
         }
@@ -169,6 +179,16 @@ public class OMAttributeImpl implements 
         return namespace;
     }
 
+    public String getPrefix() {
+        OMNamespace ns = getNamespace();
+        if (ns == null) {
+            return null;
+        } else {
+            String prefix = ns.getPrefix();
+            return prefix.length() == 0 ? null : prefix;
+        }
+    }
+
     public String getNamespaceURI() {
         OMNamespace ns = getNamespace();
         if (ns == null) {

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocumentImpl.java Mon Apr 23 10:26:45 2012
@@ -24,13 +24,16 @@ import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.OMXMLStreamReaderConfiguration;
 import org.apache.axiom.om.impl.MTOMXMLStreamWriter;
 import org.apache.axiom.om.impl.OMContainerEx;
 import org.apache.axiom.om.impl.OMNodeEx;
 import org.apache.axiom.om.impl.common.OMChildrenLocalNameIterator;
 import org.apache.axiom.om.impl.common.OMChildrenNamespaceIterator;
 import org.apache.axiom.om.impl.common.OMChildrenQNameIterator;
+import org.apache.axiom.om.impl.common.OMContainerHelper;
 import org.apache.axiom.om.impl.common.OMDescendantsIterator;
 import org.apache.axiom.om.impl.common.OMDocumentImplUtil;
 import org.apache.axiom.om.impl.jaxp.OMSource;
@@ -186,6 +189,10 @@ public class OMDocumentImpl extends OMSe
         child.setParent(this);
         lastChild = child;
 
+        if (!child.isComplete() && 
+            !(child instanceof OMSourcedElement)) {
+            this.setComplete(false);
+        }
     }
 
     /**
@@ -344,6 +351,23 @@ public class OMDocumentImpl extends OMSe
         return OMContainerHelper.getXMLStreamReader(this, cache);
     }
 
+    public XMLStreamReader getXMLStreamReader(boolean cache, OMXMLStreamReaderConfiguration configuration) {
+        return OMContainerHelper.getXMLStreamReader(this, cache, configuration);
+    }
+
+    void notifyChildComplete() {
+        if (!this.done && builder == null) {
+            Iterator iterator = getChildren();
+            while (iterator.hasNext()) {
+                OMNode node = (OMNode) iterator.next();
+                if (!node.isComplete()) {
+                    return;
+                }
+            }
+            this.setComplete(true);
+        }
+    }
+    
     public SAXSource getSAXSource(boolean cache) {
         return new OMSource(this);
     }

Modified: webservices/axiom/branches/AXIOM-201/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/AXIOM-201/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=1329164&r1=1329163&r2=1329164&view=diff
==============================================================================
--- webservices/axiom/branches/AXIOM-201/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java (original)
+++ webservices/axiom/branches/AXIOM-201/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java Mon Apr 23 10:26:45 2012
@@ -28,9 +28,10 @@ import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMSourcedElement;
-import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.OMXMLStreamReaderConfiguration;
 import org.apache.axiom.om.impl.OMContainerEx;
+import org.apache.axiom.om.impl.OMElementEx;
 import org.apache.axiom.om.impl.OMNodeEx;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.impl.common.NamespaceIterator;
@@ -39,7 +40,9 @@ import org.apache.axiom.om.impl.common.O
 import org.apache.axiom.om.impl.common.OMChildrenLocalNameIterator;
 import org.apache.axiom.om.impl.common.OMChildrenNamespaceIterator;
 import org.apache.axiom.om.impl.common.OMChildrenQNameIterator;
+import org.apache.axiom.om.impl.common.OMContainerHelper;
 import org.apache.axiom.om.impl.common.OMDescendantsIterator;
+import org.apache.axiom.om.impl.common.OMElementImplUtil;
 import org.apache.axiom.om.impl.common.OMNamespaceImpl;
 import org.apache.axiom.om.impl.jaxp.OMSource;
 import org.apache.axiom.om.impl.llom.factory.OMLinkedListImplFactory;
@@ -50,6 +53,7 @@ import org.apache.axiom.om.util.StAXUtil
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
+import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
@@ -57,20 +61,32 @@ import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.sax.SAXSource;
 
+import java.io.IOException;
+import java.io.Reader;
 import java.io.StringWriter;
+import java.io.Writer;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.LinkedHashMap;
 
 /** Class OMElementImpl */
 public class OMElementImpl extends OMNodeImpl
-        implements OMElement, OMConstants, OMContainerEx {
+        implements OMElementEx, OMConstants, OMContainerEx {
 
     private static final Log log = LogFactory.getLog(OMElementImpl.class);
     
-    public static final OMNamespace DEFAULT_DEFAULT_NS_OBJECT = new OMNamespaceImpl("", "");
-
-    /** Field ns */
+    /**
+     * The namespace of this element. Possible values:
+     * <ul>
+     * <li><code>null</code> (if the element has no namespace)
+     * <li>any {@link OMNamespace} instance, with the following exceptions:
+     * <ul>
+     * <li>an {@link OMNamespace} instance with a <code>null</code> prefix
+     * <li>an {@link OMNamespace} instance with both prefix and namespace URI set to the empty
+     * string
+     * </ul>
+     * </ul>
+     */
     protected OMNamespace ns;
 
     /** Field localName */
@@ -87,8 +103,6 @@ public class OMElementImpl extends OMNod
     /** Field attributes */
     protected HashMap attributes = null;
 
-    /** Field noPrefixNamespaceCounter */
-    protected int noPrefixNamespaceCounter = 0;
     protected OMNode lastChild;
     private int lineNumber;
     private static final EmptyIterator EMPTY_ITERATOR = new EmptyIterator();
@@ -131,9 +145,7 @@ public class OMElementImpl extends OMNod
             throw new OMException("localname can not be null or empty");
         }
         this.localName = localName;
-        if (ns != null) {
-            setNamespace(ns);
-        }
+        setNamespace(ns);
     }
 
     /**
@@ -144,7 +156,8 @@ public class OMElementImpl extends OMNod
      */
     public OMElementImpl(QName qname, OMContainer parent, OMFactory factory)
             throws OMException {
-        this(qname.getLocalPart(), null, parent, factory);
+        super(parent, factory, true);
+        localName = qname.getLocalPart();
         this.ns = handleNamespace(qname);
     }
 
@@ -154,10 +167,9 @@ public class OMElementImpl extends OMNod
 
         // first try to find a namespace from the scope
         String namespaceURI = qname.getNamespaceURI();
-        if (namespaceURI != null && namespaceURI.length() > 0) {
+        if (namespaceURI.length() > 0) {
             String prefix = qname.getPrefix();
-            ns = findNamespace(qname.getNamespaceURI(),
-                               prefix);
+            ns = findNamespace(namespaceURI, prefix);
 
             /**
              * What is left now is
@@ -170,9 +182,6 @@ public class OMElementImpl extends OMNod
                 }
                 ns = declareNamespace(namespaceURI, prefix);
             }
-            if (ns != null) {
-                this.ns = ns;
-            }
         } else if (qname.getPrefix().length() > 0) {
             throw new IllegalArgumentException("Cannot create a prefixed element with an empty namespace name");
         }
@@ -180,16 +189,26 @@ public class OMElementImpl extends OMNod
     }
 
     private OMNamespace handleNamespace(OMNamespace ns) {
-        String namespaceURI = ns.getNamespaceURI();
-        String prefix = ns.getPrefix();
+        String namespaceURI = ns == null ? "" : ns.getNamespaceURI();
+        String prefix = ns == null ? "" : ns.getPrefix();
         if (namespaceURI.length() == 0 && prefix != null && prefix.length() > 0) {
             throw new IllegalArgumentException("Cannot create a prefixed element with an empty namespace name");
         }
-        OMNamespace namespace = findNamespace(namespaceURI, prefix);
-        if (namespace == null) {
-            namespace = declareNamespace(ns);
+        if (namespaceURI.length() == 0) {
+            // Special case: no namespace; we need to generate a namespace declaration only if
+            // there is a conflicting namespace declaration (i.e. a declaration for the default
+            // namespace with a non empty URI) is in scope
+            if (getDefaultNamespace() != null) {
+                declareDefaultNamespace("");
+            }
+            return null;
+        } else {
+            OMNamespace namespace = findNamespace(namespaceURI, prefix);
+            if (namespace == null) {
+                namespace = declareNamespace(ns);
+            }
+            return namespace;
         }
-        return namespace;
     }
 
     OMNamespace handleNamespace(String namespaceURI, String prefix) {
@@ -287,19 +306,17 @@ public class OMElementImpl extends OMNod
 
     /** Method addChild. */
     private void addChild(OMNodeImpl child) {
-        if (child.parent == this &&
-            child == lastChild) {
+        if (child.parent == this && child == lastChild && done) {
             // The child is already the last node. 
             // We don't need to detach and re-add it.
         } else {
             // Normal Case
             
-            // The order of these statements is VERY important
-            // Since setting the parent has a detach method inside
-            // it strips down all the rerefences to siblings.
-            // setting the siblings should take place AFTER setting the parent
-
-            child.setParent(this);
+            if (child.parent != null) {
+                child.detach();
+            }
+            
+            child.parent = this;
 
             if (firstChild == null) {
                 firstChild = child;
@@ -369,11 +386,6 @@ public class OMElementImpl extends OMNod
         return new OMChildElementIterator(getFirstElement());
     }
 
-    /**
-     * Creates a namespace in the current element scope.
-     *
-     * @return Returns namespace.
-     */
     public OMNamespace declareNamespace(String uri, String prefix) {
         if ("".equals(prefix)) {
             log.warn("Deprecated usage of OMElement#declareNamespace(String,String) with empty prefix");
@@ -383,13 +395,12 @@ public class OMElementImpl extends OMNod
         return declareNamespace(ns);
     }
 
-    /**
-     * We use "" to store the default namespace of this element. As one can see user can not give ""
-     * as the prefix, when he declare a usual namespace.
-     *
-     * @param uri
-     */
     public OMNamespace declareDefaultNamespace(String uri) {
+        if (ns == null && uri.length() > 0
+                || ns != null && ns.getPrefix().length() == 0 && !ns.getNamespaceURI().equals(uri)) {
+            throw new OMException("Attempt to add a namespace declaration that conflicts with " +
+            		"the namespace information of the element");
+        }
 
         OMNamespaceImpl namespace = new OMNamespaceImpl(uri == null ? "" : uri, "");
 
@@ -397,17 +408,13 @@ public class OMElementImpl extends OMNod
             this.namespaces = new HashMap(5);
         }
         namespaces.put("", namespace);
-        if (ns == null || "".equals(ns.getPrefix())) {
-            ns = namespace;
-            this.qName = null;
-        }
         return namespace;
     }
 
     public OMNamespace getDefaultNamespace() {
         OMNamespace defaultNS;
         if (namespaces != null && (defaultNS = (OMNamespace) namespaces.get("")) != null) {
-            return defaultNS;
+            return defaultNS.getNamespaceURI().length() == 0 ? null : defaultNS;
         }
         if (parent instanceof OMElementImpl) {
             return ((OMElementImpl) parent).getDefaultNamespace();
@@ -416,6 +423,15 @@ public class OMElementImpl extends OMNod
         return null;
     }
 
+    public OMNamespace addNamespaceDeclaration(String uri, String prefix) {
+        if (namespaces == null) {
+            this.namespaces = new HashMap(5);
+        }
+        OMNamespace ns = new OMNamespaceImpl(uri, prefix);
+        namespaces.put(prefix, ns);
+        return ns;
+    }
+
     /** @return Returns namespace. */
     public OMNamespace declareNamespace(OMNamespace namespace) {
         if (namespaces == null) {
@@ -460,6 +476,10 @@ public class OMElementImpl extends OMNod
             //element should be enough.
             if (parent instanceof OMElement) {
                 namespace = ((OMElementImpl) parent).findNamespace(uri, prefix);
+                // If the prefix has been redeclared, then ignore the binding found on the ancestors
+                if (prefix == null && namespace != null && findDeclaredNamespace(null, namespace.getPrefix()) != null) {
+                    namespace = null;
+                }
             }
         }
 
@@ -555,6 +575,10 @@ public class OMElementImpl extends OMNod
         return new NamespaceIterator(this);
     }
 
+    public NamespaceContext getNamespaceContext(boolean detached) {
+        return OMElementImplUtil.getNamespaceContext(this, detached);
+    }
+
     /**
      * Returns a List of OMAttributes.
      *
@@ -641,13 +665,13 @@ public class OMElementImpl extends OMNod
         return attr;
     }
 
-    /** Method removeAttribute. */
     public void removeAttribute(OMAttribute attr) {
-        if (attributes != null) {
-            // Remove the owner from this attribute
-            ((OMAttributeImpl)attr).owner = null;
-            attributes.remove(attr.getQName());
+        if (attr.getOwner() != this) {
+            throw new OMException("The attribute is not owned by this element");
         }
+        // Remove the owner from this attribute
+        ((OMAttributeImpl)attr).owner = null;
+        attributes.remove(attr.getQName());
     }
 
     public OMAttribute addAttribute(String attributeName, String value,
@@ -766,132 +790,49 @@ public class OMElementImpl extends OMNod
         return OMContainerHelper.getXMLStreamReader(this, cache);
     }
 
-    /**
-     * Sets the text of the given element. caution - This method will wipe out all the text elements
-     * (and hence any mixed content) before setting the text.
-     */
-    public void setText(String text) {
+    public XMLStreamReader getXMLStreamReader(boolean cache, OMXMLStreamReaderConfiguration configuration) {
+        return OMContainerHelper.getXMLStreamReader(this, cache, configuration);
+    }
 
-        OMNode child = this.getFirstOMChild();
-        while (child != null) {
-            if (child.getType() == OMNode.TEXT_NODE) {
-                child.detach();
-            }
-            child = child.getNextOMSibling();
+    public void setText(String text) {
+        // Remove all existing children
+        OMNode child;
+        while ((child = getFirstOMChild()) != null) {
+            child.detach();
+        }
+        // Add a new text node
+        if (text != null && text.length() > 0) {
+            getOMFactory().createOMText(this, text);
         }
-
-        getOMFactory().createOMText(this, text);
     }
 
-    /**
-     * Sets the text, as a QName, of the given element. caution - This method will wipe out all the
-     * text elements (and hence any mixed content) before setting the text.
-     */
-    public void setText(QName text) {
-
-        OMNode child = this.getFirstOMChild();
-        while (child != null) {
-            if (child.getType() == OMNode.TEXT_NODE) {
-                child.detach();
-            }
-            child = child.getNextOMSibling();
+    public void setText(QName qname) {
+        // Remove all existing children
+        OMNode child;
+        while ((child = getFirstOMChild()) != null) {
+            child.detach();
+        }
+        // Add a new text node
+        if (qname != null) {
+            getOMFactory().createOMText(this, qname);
         }
-
-        getOMFactory().createOMText(this, text);
     }
 
-    /**
-     * Selects all the text children and concatenates them to a single string.
-     *
-     * @return Returns String.
-     */
     public String getText() {
-        String childText = null;
-        StringBuffer buffer = null;
-        OMNode child = this.getFirstOMChild();
-
-        while (child != null) {
-            final int type = child.getType();
-            if (type == OMNode.TEXT_NODE || type == OMNode.CDATA_SECTION_NODE) {
-                OMText textNode = (OMText) child;
-                String textValue = textNode.getText();
-                if (textValue != null && textValue.length() != 0) {
-                    if (childText == null) {
-                        // This is the first non empty text node. Just save the string.
-                        childText = textValue;
-                    } else {
-                        // We've already seen a non empty text node before. Concatenate using
-                        // a StringBuffer.
-                        if (buffer == null) {
-                            // This is the first text node we need to append. Initialize the
-                            // StringBuffer.
-                            buffer = new StringBuffer(childText);
-                        }
-                        buffer.append(textValue);
-                    }
-                }
-            }
-            child = child.getNextOMSibling();
-        }
+        return OMElementImplUtil.getText(this);
+    }
 
-        if (childText == null) {
-            // We didn't see any text nodes. Return an empty string.
-            return "";
-        } else if (buffer != null) {
-            return buffer.toString();
-        } else {
-            return childText;
-        }
+    public Reader getTextAsStream(boolean cache) {
+        return OMElementImplUtil.getTextAsStream(this, cache);
     }
 
     public QName getTextAsQName() {
-        String childText = getTrimmedText();
-        if (childText != null) {
-            return resolveQName(childText);
-        }
-        return null;
+        String childText = getText().trim();
+        return childText.length() == 0 ? null : resolveQName(childText);
     }
 
-    /**
-     * Returns the concatination string of TRIMMED values of all OMText  child nodes of this
-     * element. This is included purely to improve usability.
-     */
-    public String getTrimmedText() {
-        String childText = null;
-        StringBuffer buffer = null;
-        OMNode child = this.getFirstOMChild();
-
-        while (child != null) {
-            if (child.getType() == OMNode.TEXT_NODE) {
-                OMText textNode = (OMText) child;
-                String textValue = textNode.getText();
-                if (textValue != null && textValue.length() != 0) {
-                    if (childText == null) {
-                        // This is the first non empty text node. Just save the string.
-                        childText = textValue.trim();
-                    } else {
-                        // We've already seen a non empty text node before. Concatenate using
-                        // a StringBuffer.
-                        if (buffer == null) {
-                            // This is the first text node we need to append. Initialize the
-                            // StringBuffer.
-                            buffer = new StringBuffer(childText);
-                        }
-                        buffer.append(textValue.trim());
-                    }
-                }
-            }
-            child = child.getNextOMSibling();
-        }
-
-        if (childText == null) {
-            // We didn't see any text nodes. Return an empty string.
-            return "";
-        } else if (buffer != null) {
-            return buffer.toString();
-        } else {
-            return childText;
-        }
+    public void writeTextTo(Writer out, boolean cache) throws IOException {
+        OMElementImplUtil.writeTextTo(this, out, cache);
     }
 
 ///////////////////////////////////////////////////////////////////////////////////////////////
@@ -945,20 +886,17 @@ public class OMElementImpl extends OMNod
     }
 
     public OMNamespace getNamespace() {
-//        return ns != null ? ns : DEFAULT_DEFAULT_NS_OBJECT;
+        return ns;
+    }
+
+    public String getPrefix() {
+        OMNamespace ns = getNamespace();
         if (ns == null) {
-            // User wants to keep this element in the default default namespace. Let's try to see the default namespace
-            // is overriden by some one up in the tree
-            OMNamespace parentDefaultNS = this.findNamespaceURI("");
-
-            if (parentDefaultNS != null && !"".equals(parentDefaultNS.getNamespaceURI())) {
-                // if it was overriden, then we must explicitly declare default default namespace as the namespace
-                // of this element
-                ns = DEFAULT_DEFAULT_NS_OBJECT;
-                this.qName = null;
-            }
+            return null;
+        } else {
+            String prefix = ns.getPrefix();
+            return prefix.length() == 0 ? null : prefix;
         }
-        return ns;
     }
 
     public String getNamespaceURI() {
@@ -972,10 +910,7 @@ public class OMElementImpl extends OMNod
     }
 
     public void setNamespace(OMNamespace namespace) {
-        if (namespace != null) {
-            namespace = handleNamespace(namespace);
-        }
-        this.ns = namespace;
+        this.ns = handleNamespace(namespace);
         this.qName = null;
     }
 
@@ -995,11 +930,7 @@ public class OMElementImpl extends OMNod
         }
 
         if (ns != null) {
-            if (ns.getPrefix() != null) {
-                qName = new QName(ns.getNamespaceURI(), localName, ns.getPrefix());
-            } else {
-                qName = new QName(ns.getNamespaceURI(), localName);
-            }
+            qName = new QName(ns.getNamespaceURI(), localName, ns.getPrefix());
         } else {
             qName = new QName(localName);
         }
@@ -1108,7 +1039,7 @@ public class OMElementImpl extends OMNod
     }
 
     /** This method will be called when one of the children becomes complete. */
-    protected void notifyChildComplete() {
+    void notifyChildComplete() {
         if (!this.done && builder == null) {
             Iterator iterator = getChildren();
             while (iterator.hasNext()) {