ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1337823 - in /webservices/axiom/branches/CLONE/modules: axiom-api/src/main/java/org/apache/axiom/om/ axiom-api/src/main/java/org/apache/axiom/om/util/ axiom-api/src/main/java/org/apache/axiom/soap/ axiom-impl/src/main/java/org/apache/axiom...
Date Sun, 13 May 2012 09:38:35 GMT
Author: veithen
Date: Sun May 13 09:38:34 2012
New Revision: 1337823

URL: http://svn.apache.org/viewvc?rev=1337823&view=rev
Log:
Some unfinished changes.

Added:
    webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/om/OMCloneOptions.java   (with props)
    webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPCloneOptions.java   (with props)
Modified:
    webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
    webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/om/util/CopyUtils.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMCommentImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocTypeImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMProcessingInstructionImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPBodyImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultCodeImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultDetailImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultNodeImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultReasonImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultRoleImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultSubCodeImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultTextImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultValueImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java
    webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderImpl.java

Added: webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/om/OMCloneOptions.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/om/OMCloneOptions.java?rev=1337823&view=auto
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/om/OMCloneOptions.java (added)
+++ webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/om/OMCloneOptions.java Sun May 13 09:38:34 2012
@@ -0,0 +1,115 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.om;
+
+import org.apache.axiom.ext.stax.datahandler.DataHandlerProvider;
+
+public class OMCloneOptions {
+    private boolean fetchDataHandlers;
+    private boolean copyOMDataSources;
+    private boolean preserveModel;
+
+    /**
+     * Determine whether {@link DataHandler} objects should be fetched when cloning {@link OMText}
+     * nodes. See {@link #setFetchDataHandlers(boolean)} for more information about this option.
+     * 
+     * @return the current value of this option
+     */
+    public boolean isFetchDataHandlers() {
+        return fetchDataHandlers;
+    }
+
+    /**
+     * Specify whether {@link DataHandler} objects should be fetched when cloning {@link OMText}
+     * nodes. If this option is set to <code>false</code> (default) then an {@link OMText} node
+     * backed by a {@link DataHandlerProvider} will be cloned by copying the reference to that
+     * {@link DataHandlerProvider} to the cloned {@link OMText} node. This implies that if the
+     * original tree was constructed from an XOP encoded stream, then the clone may become unusable
+     * if that stream is closed. If this option is set to <code>true</code>, then
+     * {@link DataHandlerProvider} references will be replaced by {@link DataHandler} references. In
+     * addition, the necessary actions are taken to ensure that the content of these
+     * {@link DataHandler} instances is fetched into memory or temporary storage, so that the clones
+     * remain usable even after the underlying stream is closed.
+     * 
+     * @param fetchDataHandlers
+     *            the value to set for this option
+     */
+    public void setFetchDataHandlers(boolean fetchDataHandlers) {
+        this.fetchDataHandlers = fetchDataHandlers;
+    }
+
+    /**
+     * Determine whether {@link OMSourcedElement} nodes should be cloned as {@link OMSourcedElement}
+     * nodes by copying the corresponding {@link OMDataSource} objects. See
+     * {@link #setCopyOMDataSources(boolean)} for more information about this option.
+     * 
+     * @return the current value of this option
+     */
+    public boolean isCopyOMDataSources() {
+        return copyOMDataSources;
+    }
+
+    /**
+     * Specify whether {@link OMSourcedElement} nodes should be cloned as {@link OMSourcedElement}
+     * nodes by copying the corresponding {@link OMDataSource} objects. If this option is set to
+     * <code>false</code> (default), then all {@link OMSourcedElement} nodes will be cloned as
+     * simple {@link OMElement} instances, which implies that the original {@link OMSourcedElement}
+     * nodes will be expanded. If this option is set to <code>true</code>, then an attempt is made
+     * to clone {@link OMSourcedElement} nodes as {@link OMSourcedElement} nodes by copying the
+     * corresponding {@link OMDataSource} instances. Note that there are several cases where this is
+     * not possible:
+     * <ul>
+     * <li>There is no {@link OMDataSource} set.
+     * <li>The {@link OMDataSource} is destructive (or doesn't implement {@link OMDataSourceExt}.
+     * <li>The {@link OMSourcedElement} is expanded.
+     * </ul>
+     * <p>
+     * In these cases, {@link OMSourcedElement} nodes will always be cloned as simple
+     * {@link OMElement} instances.
+     * 
+     * @param copyOMDataSources
+     *            the value to set for this option
+     */
+    public void setCopyOMDataSources(boolean copyOMDataSources) {
+        this.copyOMDataSources = copyOMDataSources;
+    }
+
+    /**
+     * Determine whether domain specific extensions to the object model should be preserved. See
+     * {@link #setPreserveModel(boolean)} for more information about this option.
+     * 
+     * @return the current value of this option
+     */
+    public boolean isPreserveModel() {
+        return preserveModel;
+    }
+    
+    /**
+     * Specify whether domain specific extensions to the object model should be preserved. If this
+     * option is set to <code>false</code> (default), then the object model is always cloned as
+     * plain XML even if the original uses domain specific extensions such as SOAP. If this option
+     * is set to <code>true</code>, then domain specific extensions are preserved.
+     * 
+     * @param preserveModel
+     *            the value to set for this option
+     */
+    public void setPreserveModel(boolean preserveModel) {
+        this.preserveModel = preserveModel;
+    }
+}

Propchange: webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/om/OMCloneOptions.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/om/OMElement.java Sun May 13 09:38:34 2012
@@ -565,13 +565,27 @@ public interface OMElement extends OMNod
     QName resolveQName(String qname);
 
     /**
-     * Clones this element. Since both elements are build compleletely, you will lose the differed
-     * building capability.
-     *
-     * @return Returns OMElement.
+     * Clones this element and its descendants using default options. This method has the same
+     * effect as {@link #cloneOMElement(OMCloneOptions)} with default options.
+     * 
+     * @return the cloned element
      */
     OMElement cloneOMElement();
 
+    /**
+     * Clones this element and its descendants. Note that this method will traverse the descendants
+     * and create clones immediately. It will also preserve the original nodes. This means that
+     * after the execution of this method, both the returned clone and the original element will be
+     * completely built.
+     * 
+     * @param options
+     *            the options to use when cloning this element and its descendants; for object
+     *            models with domain specific extensions (such as SOAP), this may be a subclass of
+     *            {@link OMCloneOptions}
+     * @return the cloned element
+     */
+    OMElement cloneOMElement(OMCloneOptions options);
+    
     void setLineNumber(int lineNumber);
 
     int getLineNumber();

Modified: webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/om/util/CopyUtils.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/om/util/CopyUtils.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/om/util/CopyUtils.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/om/util/CopyUtils.java Sun May 13 09:38:34 2012
@@ -18,35 +18,11 @@
  */
 package org.apache.axiom.om.util;
 
-import org.apache.axiom.om.OMAttribute;
-import org.apache.axiom.om.OMComment;
-import org.apache.axiom.om.OMContainer;
-import org.apache.axiom.om.OMDataSource;
-import org.apache.axiom.om.OMDataSourceExt;
 import org.apache.axiom.om.OMDocument;
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.OMException;
-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.impl.builder.StAXOMBuilder;
-import org.apache.axiom.soap.SOAPBody;
+import org.apache.axiom.soap.SOAPCloneOptions;
 import org.apache.axiom.soap.SOAPEnvelope;
-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;
-import org.apache.axiom.soap.SOAPFaultSubCode;
-import org.apache.axiom.soap.SOAPFaultText;
-import org.apache.axiom.soap.SOAPFaultValue;
-import org.apache.axiom.soap.SOAPHeader;
-import org.apache.axiom.soap.SOAPHeaderBlock;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
@@ -63,10 +39,6 @@ import java.util.Iterator;
  * example, a SOAPFault in the source tree will have a SOAPFault in the target tree.
  */
 public class CopyUtils {
-
-    private static final Log log = LogFactory.getLog(CopyUtils.class);
-    
-    
     /**
      * Private Constructor
      */
@@ -83,50 +55,11 @@ public class CopyUtils {
      * @return targetEnv
      */
     public static SOAPEnvelope copy(SOAPEnvelope sourceEnv) {
-
-        // Make sure to build the whole sourceEnv
-        if (log.isDebugEnabled()) {
-            log.debug("start copy SOAPEnvelope");
-        }
-        
-        SOAPFactory factory = (SOAPFactory) sourceEnv.getOMFactory();
-        // Create envelope with the same prefix
-        SOAPEnvelope targetEnv = factory.createSOAPEnvelope(sourceEnv.getNamespace());
-
-        // Copy the attributes and namespaces from the source
-        // envelope to the target envelope.
-        copyTagData(sourceEnv, targetEnv);
-
-        Iterator i = sourceEnv.getChildren();
-        while (i.hasNext()) {
-            OMNode node = (OMNode) i.next();
-            if (node instanceof SOAPHeader) {
-                // Copy the SOAPHeader tree
-                SOAPHeader targetHeader = factory.createSOAPHeader(targetEnv);
-                Iterator j = ((SOAPHeader)node).getChildren();
-                while (j.hasNext()) {
-                    OMNode child = (OMNode) j.next();
-                    copy(factory, targetHeader, child);
-                }
-            } else if (node instanceof SOAPBody) {
-                // Copy the SOAPBody tree
-                SOAPBody targetBody = factory.createSOAPBody(targetEnv);
-                Iterator j = ((SOAPBody)node).getChildren();
-                while (j.hasNext()) {
-                    OMNode child = (OMNode) j.next();
-                    copy(factory, targetBody, child);
-                }
-                
-            } else {
-                // Comments, text, etc.
-                copy(factory, targetEnv, node);
-            }  
-        }
-
-        if (log.isDebugEnabled()) {
-            log.debug("end copy SOAPEnvelope");
-        }
-        return targetEnv;
+        SOAPCloneOptions options = new SOAPCloneOptions();
+        options.setFetchDataHandlers(true);
+        options.setPreserveModel(true);
+        options.setCopyOMDataSources(true);
+        return (SOAPEnvelope)sourceEnv.cloneOMElement(options);
     }
 
     /**
@@ -152,422 +85,4 @@ public class CopyUtils {
             builder.close();
         }
     }
-
-    /**
-     * Create a copy of the sourceNode and attach it to the targetParent
-     * @param factory OMFactory
-     * @param targetParent
-     * @param sourceNode
-     */
-    private static void copy(SOAPFactory factory, 
-                             OMContainer targetParent, 
-                             OMNode sourceNode) {
-
-        // Create and attach a node of the same class
-        // TODO It would be nice if you could do this directly from the
-        // OMNode, but OMNode.clone() does not gurantee that an object of the correct
-        // class is created.
-        if (sourceNode instanceof SOAPHeaderBlock) {
-            copySOAPHeaderBlock(factory, targetParent, (SOAPHeaderBlock) sourceNode);
-        } else if (sourceNode instanceof SOAPFault) {
-            copySOAPFault(factory, targetParent, (SOAPFault) sourceNode);
-        } else if (sourceNode instanceof OMSourcedElement) {
-            copyOMSourcedElement(factory, targetParent, (OMSourcedElement) sourceNode);
-        } else if (sourceNode instanceof OMElement) {
-            copyOMElement(factory, targetParent, (OMElement) sourceNode);
-        } else if (sourceNode instanceof OMText) {
-            copyOMText(factory, targetParent, (OMText) sourceNode);
-        } else if (sourceNode instanceof OMComment) {
-            copyOMComment(factory, targetParent, (OMComment) sourceNode);
-        } else {
-            throw new OMException("Internal Failure: Cannot make a copy of "
-                    + sourceNode.getClass().getName());
-        }
-    }
-
-    /**
-     * Create a copy of the source OMComment
-     * @param factory
-     * @param targetParent
-     * @param sourceComment
-     */
-    private static void copyOMComment(SOAPFactory factory, 
-                                      OMContainer targetParent, 
-                                      OMComment sourceComment) {
-        // Create and attach the comment
-        factory.createOMComment(targetParent, sourceComment.getValue());
-    }
-
-    /**
-     * Create a copy of the OM Text
-     * @param factory
-     * @param targetParent
-     * @param sourceText
-     */
-    private static void copyOMText(SOAPFactory factory, 
-                                   OMContainer targetParent, 
-                                   OMText sourceText) {
-        if (log.isDebugEnabled()) {
-            log.debug("start copyOMText");
-        }
-        if (sourceText.isBinary()) {
-            // This forces a load of the datahandler so that it is saved on the copy.
-            Object dh = sourceText.getDataHandler();
-            if (log.isDebugEnabled()) {
-                String dhclass = (dh == null) ? "null" : dh.getClass().toString();
-                log.debug("The source text's binary data handler is " + dhclass);
-            }
-        }
-        factory.createOMText(targetParent, sourceText);
-        if (log.isDebugEnabled()) {
-            log.debug("end copyOMText");
-        }
-    }
-
-    /**
-     * Create a copy of an ordinary OMElement
-     * @param factory
-     * @param targetParent
-     * @param sourceElement
-     */
-    private static void copyOMElement(SOAPFactory factory, 
-                                      OMContainer targetParent, 
-                                      OMElement sourceElement) {
-        // Clone and attach the OMElement.
-        // REVIEW This clone will expand the underlying tree.  We may want consider traversing
-        // a few levels deeper to see if there are any additional OMSourcedElements.
-        targetParent.addChild(sourceElement.cloneOMElement());
-    }
-
-    /**
-     * Create a copy of the OMSourcedElement
-     * @param factory
-     * @param targetParent
-     * @param sourceOMSE
-     */
-    private static void copyOMSourcedElement(SOAPFactory factory, 
-                                             OMContainer targetParent,
-                                             OMSourcedElement sourceOMSE) {
-        // If already expanded or this is not an OMDataSourceExt, then
-        // create a copy of the OM Tree
-        OMDataSource ds = sourceOMSE.getDataSource();
-        if (ds == null || 
-            sourceOMSE.isExpanded() || 
-            !(ds instanceof OMDataSourceExt)) {
-            copyOMElement(factory, targetParent, sourceOMSE);
-            return;
-        }
-        
-        // If copying is destructive, then copy the OM tree
-        OMDataSourceExt sourceDS = (OMDataSourceExt) ds;
-        if (sourceDS.isDestructiveRead() ||
-            sourceDS.isDestructiveWrite()) {
-            copyOMElement(factory, targetParent, sourceOMSE);
-            return;
-        }
-        OMDataSourceExt targetDS = ((OMDataSourceExt) ds).copy();
-        if (targetDS == null) {
-            copyOMElement(factory, targetParent, sourceOMSE);
-            return;
-        }
-        // Otherwise create a target OMSE with the copied DataSource
-        OMSourcedElement targetOMSE =
-            factory.createOMElement(targetDS, 
-                                    sourceOMSE.getLocalName(), 
-                                    sourceOMSE.getNamespace());
-        targetParent.addChild(targetOMSE);
-
-    }
-
-    /**
-     * Create a copy of the SOAPHeaderBlock
-     * @param factory
-     * @param targetParent
-     * @param sourceSHB
-     */
-    private static void copySOAPHeaderBlock(SOAPFactory factory, 
-                                            OMContainer targetParent,
-                                            SOAPHeaderBlock sourceSHB) {
-        // If already expanded or this is not an OMDataSourceExt, then
-        // create a copy of the OM Tree
-        OMDataSource ds = sourceSHB.getDataSource();
-        if (ds == null || 
-            sourceSHB.isExpanded() || 
-            !(ds instanceof OMDataSourceExt)) {
-            copySOAPHeaderBlock_NoDataSource(factory, targetParent, sourceSHB);
-            return;
-        }
-        
-        // If copying is destructive, then copy the OM tree
-        OMDataSourceExt sourceDS = (OMDataSourceExt) ds;
-        if (sourceDS.isDestructiveRead() ||
-            sourceDS.isDestructiveWrite()) {
-            copySOAPHeaderBlock_NoDataSource(factory, targetParent, sourceSHB);
-            return;
-        }
-        
-        // Otherwise create a copy of the OMDataSource
-        OMDataSourceExt targetDS = ((OMDataSourceExt) ds).copy();
-        SOAPHeaderBlock targetSHB =
-            factory.createSOAPHeaderBlock(sourceSHB.getLocalName(), 
-                                          sourceSHB.getNamespace(), 
-                                          targetDS);
-        targetParent.addChild(targetSHB);
-        copySOAPHeaderBlockData(sourceSHB, targetSHB);
-    }
-    
-    /**
-     * Create a copy of the SOAPHeaderBlock
-     * @param factory
-     * @param targetParent
-     * @param sourceSHB
-     */
-    private static void copySOAPHeaderBlock_NoDataSource(SOAPFactory factory, 
-                                            OMContainer targetParent,
-                                            SOAPHeaderBlock sourceSHB) {
-        
-        
-        SOAPHeader header = (SOAPHeader) targetParent;
-        String localName = sourceSHB.getLocalName();
-        OMNamespace ns = sourceSHB.getNamespace();
-        SOAPHeaderBlock targetSHB = factory.createSOAPHeaderBlock(localName, ns, header);
-        
-        // A SOAPHeaderBlock has tag data, plus extra header processing flags
-        copyTagData(sourceSHB, targetSHB);
-        copySOAPHeaderBlockData(sourceSHB, targetSHB);
-        Iterator i = sourceSHB.getChildren();
-        while (i.hasNext()) {
-            OMNode node = (OMNode) i.next();
-            copy(factory, targetSHB, node);
-        }
-    }
-
-    /**
-     * Create a copy of a SOAPFault
-     * @param factory
-     * @param targetParent
-     * @param sourceSOAPFault
-     */
-    private static void copySOAPFault(SOAPFactory factory, 
-                                      OMContainer targetParent,
-                                      SOAPFault sourceSOAPFault) {
-        Exception e = sourceSOAPFault.getException();
-        
-        SOAPFault newSOAPFault = (e == null) ?
-                    factory.createSOAPFault((SOAPBody) targetParent):
-                    factory.createSOAPFault((SOAPBody) targetParent, e);
-                                        
-        copyTagData(sourceSOAPFault, newSOAPFault);
-        Iterator i = sourceSOAPFault.getChildren();
-        while (i.hasNext()) {
-            OMNode node = (OMNode) i.next();
-            // Copy the tree under the SOAPFault
-            copyFaultData(factory, newSOAPFault, node);
-        }
-    }
-
-    /**
-     * Copy the source Node, which is a child fo a SOAPFault,
-     * to the target SOAPFault
-     * @param factory
-     * @param targetFault
-     * @param sourceNode
-     */
-    private static void copyFaultData(SOAPFactory factory, 
-                                      SOAPFault targetFault, 
-                                      OMNode sourceNode) {
-
-        if (sourceNode instanceof SOAPFaultCode) {
-            copySOAPFaultCode(factory, targetFault, (SOAPFaultCode) sourceNode);
-        } else if (sourceNode instanceof SOAPFaultDetail) {
-            copySOAPFaultDetail(factory, targetFault, (SOAPFaultDetail) sourceNode);
-        } else if (sourceNode instanceof SOAPFaultNode) {
-            copySOAPFaultNode(factory, targetFault, (SOAPFaultNode) sourceNode);
-        } else if (sourceNode instanceof SOAPFaultReason) {
-            copySOAPFaultReason(factory, targetFault, (SOAPFaultReason) sourceNode);
-        } else if (sourceNode instanceof SOAPFaultRole) {
-            copySOAPFaultRole(factory, targetFault, (SOAPFaultRole) sourceNode);
-        } else if (sourceNode instanceof OMText) {
-            copyOMText(factory, targetFault, (OMText) sourceNode);
-        } else if (sourceNode instanceof OMComment) {
-            copyOMComment(factory, targetFault, (OMComment) sourceNode);
-        } else {
-            throw new OMException("Internal Failure: Cannot make a copy of "
-                    + sourceNode.getClass().getName() + " object found in a SOAPFault.");
-        }
-    }
-
-    /**
-     * Create a copy of a SOAPFaultRole
-     * @param factory
-     * @param targetFault
-     * @param sourceRole
-     */
-    private static void copySOAPFaultRole(SOAPFactory factory, 
-                                          SOAPFault targetFault, 
-                                          SOAPFaultRole sourceRole) {
-        SOAPFaultRole targetRole = factory.createSOAPFaultRole(targetFault);
-        copyTagData(sourceRole, targetRole);
-        targetRole.setRoleValue(sourceRole.getRoleValue());
-    }
-
-    /**
-     * Create a copy of a SOAPFaultNode
-     * @param factory
-     * @param targetFault
-     * @param sourceNode
-     */
-    private static void copySOAPFaultNode(SOAPFactory factory, 
-                                          SOAPFault targetFault, 
-                                          SOAPFaultNode sourceNode) {
-        SOAPFaultNode targetNode = factory.createSOAPFaultNode(targetFault);
-        copyTagData(sourceNode, targetNode);
-        targetNode.setFaultNodeValue(sourceNode.getFaultNodeValue());
-    }
-
-    /**
-     * Create a copy of a SOAPFaultDetail
-     * @param factory
-     * @param targetFault
-     * @param sourceDetail
-     */
-    private static void copySOAPFaultDetail(SOAPFactory factory, 
-                                            SOAPFault targetFault,
-                                            SOAPFaultDetail sourceDetail) {
-        SOAPFaultDetail targetDetail = factory.createSOAPFaultDetail(targetFault);
-        copyTagData(sourceDetail, targetDetail);
-        
-        // Copy the detail entries
-        Iterator i = sourceDetail.getChildren();
-        while (i.hasNext()) {
-            OMNode node = (OMNode) i.next();
-            copy(factory, targetDetail, node);
-        }
-    }
-
-    /**
-     * Create a copy of the SOAPFaultReason
-     * @param factory
-     * @param targetFault
-     * @param sourceReason
-     */
-    private static void copySOAPFaultReason(SOAPFactory factory, 
-                                            SOAPFault targetFault,
-                                            SOAPFaultReason sourceReason) {
-        SOAPFaultReason targetReason = factory.createSOAPFaultReason(targetFault);
-        copyTagData(sourceReason, targetReason);
-        Iterator i = sourceReason.getChildren();
-        while (i.hasNext()) {
-            OMNode node = (OMNode) i.next();
-            if (node instanceof SOAPFaultText) {
-                SOAPFaultText oldText = (SOAPFaultText) node;
-                SOAPFaultText newText = factory.createSOAPFaultText(targetReason);
-                copyTagData(oldText, newText); // The lang is copied as an attribute
-            } else {
-                // Copy any comments or child nodes
-                copy(factory, targetReason, node);
-            }
-        }
-    }
-
-    /**
-     * Copy the SOAPFaultCode tree
-     * @param factory
-     * @param targetFault
-     * @param sourceCode
-     */
-    private static void copySOAPFaultCode(SOAPFactory factory, 
-                                          SOAPFault targetFault, 
-                                          SOAPFaultCode sourceCode) {
-        SOAPFaultCode targetCode = factory.createSOAPFaultCode(targetFault);
-        copyTagData(sourceCode, targetCode);
-
-        // Create the Value
-        SOAPFaultValue sourceValue = sourceCode.getValue();
-        SOAPFaultValue targetValue = factory.createSOAPFaultValue(targetCode);
-        copyTagData(sourceValue, targetValue);
-        
-        // There should only be a text node for the value, but in case there is more
-        Iterator i = sourceValue.getChildren();
-        while (i.hasNext()) {
-            OMNode node = (OMNode) i.next();
-            copy(factory, targetValue, node);
-        }
-
-        // Now get process the SubCode
-        SOAPFaultSubCode sourceSubCode = sourceCode.getSubCode();
-        if (sourceSubCode != null) {
-            copySOAPFaultSubCode(factory, targetCode, sourceSubCode);
-        }
-    }
-
-    /**
-     * Copy the SOAPFaultSubCode tree
-     * @param factory
-     * @param targetParent (SOAPFaultCode or SOAPFaultSubCode)
-     * @param sourceSubCode
-     */
-    private static void copySOAPFaultSubCode(SOAPFactory factory, 
-                                             OMElement targetParent,
-                                             SOAPFaultSubCode sourceSubCode) {
-        SOAPFaultSubCode targetSubCode;
-        if (targetParent instanceof SOAPFaultSubCode) {
-            targetSubCode = factory.createSOAPFaultSubCode((SOAPFaultSubCode) targetParent);
-        } else {
-            targetSubCode = factory.createSOAPFaultSubCode((SOAPFaultCode) targetParent);
-        }
-        copyTagData(sourceSubCode, targetSubCode);
-
-        // Process the SOAP FaultValue
-        SOAPFaultValue sourceValue = sourceSubCode.getValue();
-        SOAPFaultValue targetValue = factory.createSOAPFaultValue(targetSubCode);
-        copyTagData(sourceValue, targetValue);
-        // There should only be a text node for the value, but in case there is more
-        Iterator i = sourceValue.getChildren();
-        while (i.hasNext()) {
-            OMNode node = (OMNode) i.next();
-            copy(factory, targetValue, node);
-        }
-
-        // Now process the SubCode of the SubCode
-        SOAPFaultSubCode sourceSubSubCode = sourceSubCode.getSubCode();
-        if (sourceSubSubCode != null) {
-            copySOAPFaultSubCode(factory, targetSubCode, sourceSubSubCode);
-        }
-    }
-
-
-    /**
-     * Copy the tag data (attributes and namespaces) from the source
-     * element to the target element.
-     * @param sourceElement
-     * @param targetElement
-     */
-    private static void copyTagData(OMElement sourceElement, 
-                                    OMElement targetElement) {
-        for (Iterator i = sourceElement.getAllDeclaredNamespaces(); i.hasNext();) {
-            OMNamespace ns = (OMNamespace) i.next();
-            targetElement.declareNamespace(ns);
-        }
-
-        for (Iterator i = sourceElement.getAllAttributes(); i.hasNext();) {
-            OMAttribute attr = (OMAttribute) i.next();
-            targetElement.addAttribute(attr);
-        }
-    }
-
-    /**
-     * Copy Header data (currently only the processed flag) from the
-     * source SOAPHeaderBlock to the target SOAPHeaderBlock
-     * @param sourceSHB
-     * @param targetSHB
-     */
-    private static void copySOAPHeaderBlockData(SOAPHeaderBlock sourceSHB, 
-                                                SOAPHeaderBlock targetSHB) {
-        // Copy the processed flag.  The other SOAPHeaderBlock information 
-        //(e.g. role, mustUnderstand) are attributes on the tag and are copied in copyTagData.
-        if (sourceSHB.isProcessed()) {
-            targetSHB.setProcessed();
-        }
-    }
 }

Added: webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPCloneOptions.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPCloneOptions.java?rev=1337823&view=auto
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPCloneOptions.java (added)
+++ webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPCloneOptions.java Sun May 13 09:38:34 2012
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.axiom.soap;
+
+import org.apache.axiom.om.OMCloneOptions;
+
+public class SOAPCloneOptions extends OMCloneOptions {
+    private Boolean processedFlag;
+
+    /**
+     * Determine how the {@link SOAPHeaderBlock#isProcessed()} flag should be set on cloned
+     * {@link SOAPHeaderBlock} nodes. See {@link #setProcessedFlag(Boolean)} for more information
+     * about this option.
+     * 
+     * @return the current value of this option
+     */
+    public Boolean getProcessedFlag() {
+        return processedFlag;
+    }
+
+    /**
+     * Specify how the {@link SOAPHeaderBlock#isProcessed()} flag should be set on cloned
+     * {@link SOAPHeaderBlock} nodes. If this option is set to <code>null</code> (default), the flag
+     * will be copied from the original node. Otherwise, the flag will have the value determined by
+     * the option value.
+     * 
+     * @param processedFlag
+     *            the value to set for this option
+     */
+    public void setProcessedFlag(Boolean processedFlag) {
+        this.processedFlag = processedFlag;
+    }
+}

Propchange: webservices/axiom/branches/CLONE/modules/axiom-api/src/main/java/org/apache/axiom/soap/SOAPCloneOptions.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMCommentImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMCommentImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMCommentImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMCommentImpl.java Sun May 13 09:38:34 2012
@@ -19,6 +19,7 @@
 
 package org.apache.axiom.om.impl.llom;
 
+import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMComment;
 import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMException;
@@ -85,4 +86,8 @@ public class OMCommentImpl extends OMNod
             this.detach();
         } 
     }
+
+    OMNode clone(OMCloneOptions options, OMContainer targetParent) {
+        return factory.createOMComment(targetParent, value);
+    }
 }

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocTypeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocTypeImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocTypeImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMDocTypeImpl.java Sun May 13 09:38:34 2012
@@ -19,6 +19,7 @@
 
 package org.apache.axiom.om.impl.llom;
 
+import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMDocType;
 import org.apache.axiom.om.OMException;
@@ -85,4 +86,8 @@ public class OMDocTypeImpl extends OMNod
             this.detach();
         } 
     }
+
+    OMNode clone(OMCloneOptions options, OMContainer targetParent) {
+        return factory.createOMDocType(targetParent, value);
+    }
 }

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMElementImpl.java Sun May 13 09:38:34 2012
@@ -20,6 +20,7 @@
 package org.apache.axiom.om.impl.llom;
 
 import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMConstants;
 import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMElement;
@@ -33,7 +34,6 @@ import org.apache.axiom.om.OMXMLStreamRe
 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;
 import org.apache.axiom.om.impl.common.OMChildElementIterator;
 import org.apache.axiom.om.impl.common.OMChildrenLegacyQNameIterator;
@@ -1015,24 +1015,38 @@ public class OMElementImpl extends OMNod
             log.debug(" isComplete = " + isComplete());
             log.debug("  builder = " + builder);
         }
-        // Make sure the source (this node) is completed
-        if (!isComplete()) {
-            this.build();
+        return cloneOMElement(new OMCloneOptions());
+    }
+
+    public OMElement cloneOMElement(OMCloneOptions options) {
+        return (OMElement)clone(options, null);
+    }
+
+    OMNode clone(OMCloneOptions options, OMContainer targetParent) {
+        OMElement targetElement;
+        if (options.isPreserveModel()) {
+            targetElement = createClone(options, targetParent);
+        } else {
+            targetElement = factory.createOMElement(localName, ns, targetParent);
         }
-        
-        // Now get a parser for the full tree
-        XMLStreamReader xmlStreamReader = this.getXMLStreamReader(true);
-        if (log.isDebugEnabled()) {
-            log.debug("  reader = " + xmlStreamReader);
+        for (Iterator it = getAllDeclaredNamespaces(); it.hasNext(); ) {
+            OMNamespace ns = (OMNamespace)it.next();
+            targetElement.declareNamespace(ns);
         }
-        
-        // Build the (target) clonedElement from the parser
-        OMElement clonedElement =
-                new StAXOMBuilder(xmlStreamReader).getDocumentElement();
-        clonedElement.build();
-        return clonedElement;
+        for (Iterator it = getAllAttributes(); it.hasNext(); ) {
+            OMAttribute attr = (OMAttribute)it.next();
+            targetElement.addAttribute(attr);
+        }
+        for (Iterator it = getChildren(); it.hasNext(); ) {
+            ((OMNodeImpl)it.next()).clone(options, targetElement);
+        }
+        return targetElement;
     }
 
+    protected OMElement createClone(OMCloneOptions options, OMContainer targetParent) {
+        return factory.createOMElement(localName, ns, targetParent);
+    }
+    
     public void setLineNumber(int lineNumber) {
         this.lineNumber = lineNumber;
     }

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMNodeImpl.java Sun May 13 09:38:34 2012
@@ -22,6 +22,7 @@ package org.apache.axiom.om.impl.llom;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMComment;
 import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMDocType;
@@ -366,4 +367,6 @@ public abstract class OMNodeImpl extends
     public void internalSerializeAndConsume(XMLStreamWriter writer) throws XMLStreamException {
         internalSerialize(writer, false);
     }
+    
+    abstract OMNode clone(OMCloneOptions options, OMContainer targetParent);
 }

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMProcessingInstructionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMProcessingInstructionImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMProcessingInstructionImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMProcessingInstructionImpl.java Sun May 13 09:38:34 2012
@@ -19,6 +19,7 @@
 
 package org.apache.axiom.om.impl.llom;
 
+import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
@@ -107,4 +108,8 @@ public class OMProcessingInstructionImpl
             this.detach();
         } 
     }
+
+    OMNode clone(OMCloneOptions options, OMContainer targetParent) {
+        return factory.createOMProcessingInstruction(targetParent, target, value);
+    }
 }

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMSourcedElementImpl.java Sun May 13 09:38:34 2012
@@ -20,6 +20,7 @@
 package org.apache.axiom.om.impl.llom;
 
 import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMDataSourceExt;
@@ -660,10 +661,54 @@ public class OMSourcedElementImpl extend
     }
 
     public OMElement cloneOMElement() {
-        forceExpand();
         return super.cloneOMElement();
     }
 
+    public OMElement cloneOMElement(OMCloneOptions options) {
+        return super.cloneOMElement(options);
+    }
+
+    OMNode clone(OMCloneOptions options, OMContainer targetParent) {
+        // If already expanded or this is not an OMDataSourceExt, then
+        // create a copy of the OM Tree
+        OMDataSource ds = getDataSource();
+        if (ds == null || 
+            isExpanded() || 
+            !(ds instanceof OMDataSourceExt)) {
+            return super.clone(options, targetParent);
+        }
+        
+        // If copying is destructive, then copy the OM tree
+        OMDataSourceExt sourceDS = (OMDataSourceExt) ds;
+        if (sourceDS.isDestructiveRead() ||
+            sourceDS.isDestructiveWrite()) {
+            return super.clone(options, targetParent);
+        }
+        OMDataSourceExt targetDS = ((OMDataSourceExt) ds).copy();
+        if (targetDS == null) {
+            return super.clone(options, targetParent);
+        }
+        // Otherwise create a target OMSE with the copied DataSource
+        OMSourcedElement targetOMSE;
+        if (options.isPreserveModel()) {
+            targetOMSE = createClone(options, targetDS, getLocalName(), getNamespace());
+        } else {
+            targetOMSE = factory.createOMElement(targetDS, 
+                                    getLocalName(), 
+                                    getNamespace());
+        }
+        targetParent.addChild(targetOMSE);
+        return targetOMSE;
+    }
+
+    protected OMElement createClone(OMCloneOptions options, OMContainer targetParent) {
+        return super.createClone(options, targetParent);
+    }
+    
+    protected OMSourcedElement createClone(OMCloneOptions options, OMDataSource ds, String localName, OMNamespace ns) {
+        return factory.createOMElement(ds, localName, ns);
+    }
+
     public void setLineNumber(int lineNumber) {
         // no need to expand the tree, just call base method directly
         super.setLineNumber(lineNumber);

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMTextImpl.java Sun May 13 09:38:34 2012
@@ -20,12 +20,14 @@
 package org.apache.axiom.om.impl.llom;
 
 import org.apache.axiom.ext.stax.datahandler.DataHandlerProvider;
+import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMConstants;
 import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMText;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.common.OMNamespaceImpl;
@@ -441,4 +443,12 @@ public class OMTextImpl extends OMNodeIm
         this.contentID = cid;
     }
 
+    OMNode clone(OMCloneOptions options, OMContainer targetParent) {
+        if (isBinary && options.isFetchDataHandlers()) {
+            // Force loading of the reference to the DataHandler and ensure that its content is
+            // completely fetched into memory (or temporary storage).
+            ((DataHandler)getDataHandler()).getDataSource();
+        }
+        return factory.createOMText(targetParent, this);
+    }
 }

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPBodyImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPBodyImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPBodyImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPBodyImpl.java Sun May 13 09:38:34 2012
@@ -19,7 +19,9 @@
 
 package org.apache.axiom.soap.impl.llom;
 
+import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMConstants;
+import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNamespace;
@@ -237,6 +239,8 @@ public abstract class SOAPBodyImpl exten
         this.enableLookAhead = false;
         super.addChild(child);
     }
-    
-    
+
+    protected OMElement createClone(OMCloneOptions options, OMContainer targetParent) {
+        return ((SOAPFactory)factory).createSOAPBody((SOAPEnvelope)targetParent);
+    }
 }

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPEnvelopeImpl.java Sun May 13 09:38:34 2012
@@ -21,7 +21,9 @@ package org.apache.axiom.soap.impl.llom;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMConstants;
+import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNamespace;
@@ -329,4 +331,8 @@ public class SOAPEnvelopeImpl extends SO
         }
         return null;
     }
+
+    protected OMElement createClone(OMCloneOptions options, OMContainer targetParent) {
+        return ((SOAPFactory)factory).createSOAPEnvelope(getNamespace());
+    }
 }

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultCodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultCodeImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultCodeImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultCodeImpl.java Sun May 13 09:38:34 2012
@@ -19,6 +19,9 @@
 
 package org.apache.axiom.soap.impl.llom;
 
+import org.apache.axiom.om.OMCloneOptions;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.util.ElementHelper;
@@ -74,4 +77,7 @@ public abstract class SOAPFaultCodeImpl 
         ElementHelper.setNewElement(this, getSubCode(), value);
     }
 
+    protected OMElement createClone(OMCloneOptions options, OMContainer targetParent) {
+        return ((SOAPFactory)factory).createSOAPFaultCode((SOAPFault)targetParent);
+    }
 }

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultDetailImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultDetailImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultDetailImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultDetailImpl.java Sun May 13 09:38:34 2012
@@ -19,6 +19,8 @@
 
 package org.apache.axiom.soap.impl.llom;
 
+import org.apache.axiom.om.OMCloneOptions;
+import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
@@ -67,4 +69,7 @@ public abstract class SOAPFaultDetailImp
         super.internalSerialize(writer, cache);
     }
 
+    protected OMElement createClone(OMCloneOptions options, OMContainer targetParent) {
+        return ((SOAPFactory)factory).createSOAPFaultDetail((SOAPFault)targetParent);
+    }
 }

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultImpl.java Sun May 13 09:38:34 2012
@@ -19,7 +19,9 @@
 
 package org.apache.axiom.soap.impl.llom;
 
+import org.apache.axiom.om.OMCloneOptions;
 import org.apache.axiom.om.OMConstants;
+import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNamespace;
@@ -187,5 +189,9 @@ public abstract class SOAPFaultImpl exte
 
     protected abstract void serializeFaultNode(XMLStreamWriter writer) throws XMLStreamException;
 
-
+    protected OMElement createClone(OMCloneOptions options, OMContainer targetParent) {
+        return e == null ?
+                ((SOAPFactory)factory).createSOAPFault((SOAPBody) targetParent):
+                ((SOAPFactory)factory).createSOAPFault((SOAPBody) targetParent, e);
+    }
 }

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultNodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultNodeImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultNodeImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultNodeImpl.java Sun May 13 09:38:34 2012
@@ -19,6 +19,9 @@
 
 package org.apache.axiom.soap.impl.llom;
 
+import org.apache.axiom.om.OMCloneOptions;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.soap.SOAP12Constants;
@@ -57,4 +60,8 @@ public abstract class SOAPFaultNodeImpl 
     public String getNodeValue() {
         return getFaultNodeValue();
     }
+
+    protected OMElement createClone(OMCloneOptions options, OMContainer targetParent) {
+        return ((SOAPFactory)factory).createSOAPFaultNode((SOAPFault)targetParent);
+    }
 }

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultReasonImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultReasonImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultReasonImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultReasonImpl.java Sun May 13 09:38:34 2012
@@ -19,6 +19,8 @@
 
 package org.apache.axiom.soap.impl.llom;
 
+import org.apache.axiom.om.OMCloneOptions;
+import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
@@ -86,4 +88,7 @@ public abstract class SOAPFaultReasonImp
         return null;
     }
 
+    protected OMElement createClone(OMCloneOptions options, OMContainer targetParent) {
+        return ((SOAPFactory)factory).createSOAPFaultReason((SOAPFault)targetParent);
+    }
 }

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultRoleImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultRoleImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultRoleImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultRoleImpl.java Sun May 13 09:38:34 2012
@@ -19,6 +19,9 @@
 
 package org.apache.axiom.soap.impl.llom;
 
+import org.apache.axiom.om.OMCloneOptions;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.soap.SOAPFactory;
@@ -56,4 +59,8 @@ public abstract class SOAPFaultRoleImpl 
     public String getRoleValue() {
         return this.getText();
     }
+
+    protected OMElement createClone(OMCloneOptions options, OMContainer targetParent) {
+        return ((SOAPFactory)factory).createSOAPFaultRole((SOAPFault)targetParent);
+    }
 }

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultSubCodeImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultSubCodeImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultSubCodeImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultSubCodeImpl.java Sun May 13 09:38:34 2012
@@ -19,12 +19,15 @@
 
 package org.apache.axiom.soap.impl.llom;
 
+import org.apache.axiom.om.OMCloneOptions;
+import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.util.ElementHelper;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPFaultCode;
 import org.apache.axiom.soap.SOAPFaultSubCode;
 import org.apache.axiom.soap.SOAPFaultValue;
 import org.apache.axiom.soap.SOAPProcessingException;
@@ -73,4 +76,12 @@ public abstract class SOAPFaultSubCodeIm
         }
         return subCode;
     }
+
+    protected OMElement createClone(OMCloneOptions options, OMContainer targetParent) {
+        if (targetParent instanceof SOAPFaultSubCode) {
+            return ((SOAPFactory)factory).createSOAPFaultSubCode((SOAPFaultSubCode)targetParent);
+        } else {
+            return ((SOAPFactory)factory).createSOAPFaultSubCode((SOAPFaultCode)targetParent);
+        }
+    }
 }

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultTextImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultTextImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultTextImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultTextImpl.java Sun May 13 09:38:34 2012
@@ -20,6 +20,9 @@
 package org.apache.axiom.soap.impl.llom;
 
 import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMCloneOptions;
+import org.apache.axiom.om.OMContainer;
+import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.llom.OMAttributeImpl;
@@ -85,4 +88,8 @@ public abstract class SOAPFaultTextImpl 
 
         return langAttr == null ? null : langAttr.getAttributeValue();
     }
+
+    protected OMElement createClone(OMCloneOptions options, OMContainer targetParent) {
+        return ((SOAPFactory)factory).createSOAPFaultText((SOAPFaultReason)targetParent);
+    }
 }

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultValueImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultValueImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultValueImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPFaultValueImpl.java Sun May 13 09:38:34 2012
@@ -19,11 +19,14 @@
 
 package org.apache.axiom.soap.impl.llom;
 
+import org.apache.axiom.om.OMCloneOptions;
+import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPFactory;
+import org.apache.axiom.soap.SOAPFaultCode;
 import org.apache.axiom.soap.SOAPFaultValue;
 import org.apache.axiom.soap.SOAPProcessingException;
 
@@ -60,4 +63,8 @@ public abstract class SOAPFaultValueImpl
         super(parent, localName, builder,
               factory);
     }
+
+    protected OMElement createClone(OMCloneOptions options, OMContainer targetParent) {
+        return ((SOAPFactory)factory).createSOAPFaultValue((SOAPFaultCode)targetParent);
+    }
 }

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderBlockImpl.java Sun May 13 09:38:34 2012
@@ -20,14 +20,18 @@
 package org.apache.axiom.soap.impl.llom;
 
 import org.apache.axiom.om.OMAttribute;
+import org.apache.axiom.om.OMCloneOptions;
+import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMDataSource;
 import org.apache.axiom.om.OMDataSourceExt;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.OMXMLParserWrapper;
 import org.apache.axiom.om.impl.common.OMNamespaceImpl;
 import org.apache.axiom.om.impl.llom.OMAttributeImpl;
 import org.apache.axiom.om.impl.llom.OMSourcedElementImpl;
+import org.apache.axiom.soap.SOAPCloneOptions;
 import org.apache.axiom.soap.SOAPConstants;
 import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.SOAPHeader;
@@ -150,4 +154,25 @@ public abstract class SOAPHeaderBlockImp
         }
         return false;
     }
+
+    protected OMElement createClone(OMCloneOptions options, OMContainer targetParent) {
+        SOAPHeaderBlock clone = ((SOAPFactory)factory).createSOAPHeaderBlock(localName, ns, (SOAPHeader)targetParent);
+        copyData(options, clone);
+        return clone;
+    }
+
+    protected OMSourcedElement createClone(OMCloneOptions options, OMDataSource ds, String localName, OMNamespace ns) {
+        SOAPHeaderBlock clone = ((SOAPFactory)factory).createSOAPHeaderBlock(localName, ns, ds);
+        copyData(options, clone);
+        return clone;
+    }
+
+    private void copyData(OMCloneOptions options, SOAPHeaderBlock targetSHB) {
+        // Copy the processed flag.  The other SOAPHeaderBlock information 
+        // (e.g. role, mustUnderstand) are attributes on the tag and are copied elsewhere.
+        Boolean processedFlag = options instanceof SOAPCloneOptions ? ((SOAPCloneOptions)options).getProcessedFlag() : null;
+        if ((processedFlag == null && isProcessed()) || (processedFlag != null && processedFlag.booleanValue())) {
+            targetSHB.setProcessed();
+        }
+    }
 }

Modified: webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderImpl.java
URL: http://svn.apache.org/viewvc/webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderImpl.java?rev=1337823&r1=1337822&r2=1337823&view=diff
==============================================================================
--- webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderImpl.java (original)
+++ webservices/axiom/branches/CLONE/modules/axiom-impl/src/main/java/org/apache/axiom/soap/impl/llom/SOAPHeaderImpl.java Sun May 13 09:38:34 2012
@@ -19,6 +19,8 @@
 
 package org.apache.axiom.soap.impl.llom;
 
+import org.apache.axiom.om.OMCloneOptions;
+import org.apache.axiom.om.OMContainer;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNamespace;
@@ -201,4 +203,8 @@ public abstract class SOAPHeaderImpl ext
         String text = sw.getBuffer().toString();
         return text;
     }
+
+    protected OMElement createClone(OMCloneOptions options, OMContainer targetParent) {
+        return ((SOAPFactory)factory).createSOAPHeader((SOAPEnvelope)targetParent);
+    }
 }



Mime
View raw message