ws-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From veit...@apache.org
Subject svn commit: r1481554 - in /webservices/axiom/trunk/modules: axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/ axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/ axiom-testsuite/src/main/java/org/apache/axiom/ts/soap1...
Date Sun, 12 May 2013 13:26:20 GMT
Author: veithen
Date: Sun May 12 13:26:19 2013
New Revision: 1481554

URL: http://svn.apache.org/r1481554
Log:
AXIOM-288: Fixed an issue with the DataHandlerReader extension.

Modified:
    webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/StreamSwitch.java
    webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/SwitchingWrapper.java
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
    webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/mtom/TestGetXMLStreamReaderMTOMEncoded.java

Modified: webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/StreamSwitch.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/StreamSwitch.java?rev=1481554&r1=1481553&r2=1481554&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/StreamSwitch.java
(original)
+++ webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/StreamSwitch.java
Sun May 12 13:26:19 2013
@@ -18,20 +18,36 @@
  */
 package org.apache.axiom.om.impl.common.serializer.pull;
 
+import javax.activation.DataHandler;
 import javax.xml.stream.XMLStreamConstants;
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.util.StreamReaderDelegate;
 
+import org.apache.axiom.ext.stax.datahandler.DataHandlerProvider;
+import org.apache.axiom.ext.stax.datahandler.DataHandlerReader;
 import org.apache.axiom.om.OMDataSource;
+import org.apache.axiom.util.stax.XMLStreamReaderUtils;
 
-final class StreamSwitch extends StreamReaderDelegate {
+final class StreamSwitch extends StreamReaderDelegate implements DataHandlerReader {
     /**
      * Indicates if an OMSourcedElement with an OMDataSource should
      * be considered as an interior node or a leaf node.
      */
     private boolean isDataSourceALeaf;
 
+    /**
+     * The {@link DataHandlerReader} extension of the underlying parser, or <code>null</code>
+     * if the parser doesn't support this extension.
+     */
+    private DataHandlerReader dataHandlerReader;
+
+    public void setParent(XMLStreamReader reader) {
+        super.setParent(reader);
+        dataHandlerReader =
+                reader == null ? null : XMLStreamReaderUtils.getDataHandlerReader(reader);
+    }
+
     OMDataSource getDataSource() {
         XMLStreamReader parent = getParent();
         // Only SwitchingWrapper can produce OMDataSource "events"
@@ -107,4 +123,61 @@ final class StreamSwitch extends StreamR
             ///////////////////////////////////////////////////////////////
         }
     }
+
+    public Object getProperty(String name) {
+        Object value = XMLStreamReaderUtils.processGetProperty(this, name);
+        if (value != null) {
+            return value;
+        } else {
+            return super.getProperty(name);
+        }
+    }
+
+    public boolean isBinary() {
+        if (dataHandlerReader != null) {
+            return dataHandlerReader.isBinary();
+        } else {
+            return false;
+        }
+    }
+
+    public boolean isOptimized() {
+        if (dataHandlerReader != null) {
+            return dataHandlerReader.isOptimized();
+        } else {
+            throw new IllegalStateException();
+        }
+    }
+
+    public boolean isDeferred() {
+        if (dataHandlerReader != null) {
+            return dataHandlerReader.isDeferred();
+        } else {
+            throw new IllegalStateException();
+        }
+    }
+
+    public String getContentID() {
+        if (dataHandlerReader != null) {
+            return dataHandlerReader.getContentID();
+        } else {
+            throw new IllegalStateException();
+        }
+    }
+
+    public DataHandler getDataHandler() throws XMLStreamException {
+        if (dataHandlerReader != null) {
+            return dataHandlerReader.getDataHandler();
+        } else {
+            throw new IllegalStateException();
+        }
+    }
+
+    public DataHandlerProvider getDataHandlerProvider() {
+        if (dataHandlerReader != null) {
+            return dataHandlerReader.getDataHandlerProvider();
+        } else {
+            throw new IllegalStateException();
+        }
+    }
 }

Modified: webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/SwitchingWrapper.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/SwitchingWrapper.java?rev=1481554&r1=1481553&r2=1481554&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/SwitchingWrapper.java
(original)
+++ webservices/axiom/trunk/modules/axiom-common-impl/src/main/java/org/apache/axiom/om/impl/common/serializer/pull/SwitchingWrapper.java
Sun May 12 13:26:19 2013
@@ -95,12 +95,6 @@ class SwitchingWrapper extends AbstractX
     private XMLStreamReader parser;
     
     /**
-     * The {@link DataHandlerReader} extension of the underlying parser, or <code>null</code>
-     * if the parser doesn't support this extension.
-     */
-    private DataHandlerReader dataHandlerReader;
-
-    /**
      * The root node, i.e. the node from which the {@link XMLStreamReader} has been requested.
      */
     private final OMContainer rootNode;
@@ -980,96 +974,48 @@ class SwitchingWrapper extends AbstractX
      */
 
     public boolean isBinary() {
-        if (parser != null) {
-            if (dataHandlerReader != null) {
-                return dataHandlerReader.isBinary();
-            } else {
-                return false;
-            }
+        if (node instanceof OMText) {
+            return ((OMText)node).isBinary();
         } else {
-            if (node instanceof OMText) {
-                return ((OMText)node).isBinary();
-            } else {
-                return false;
-            }
+            return false;
         }
     }
 
     public boolean isOptimized() {
-        if (parser != null) {
-            if (dataHandlerReader != null) {
-                return dataHandlerReader.isOptimized();
-            } else {
-                throw new IllegalStateException();
-            }
+        if (node instanceof OMText) {
+            return ((OMText)node).isOptimized();
         } else {
-            if (node instanceof OMText) {
-                return ((OMText)node).isOptimized();
-            } else {
-                throw new IllegalStateException();
-            }
+            throw new IllegalStateException();
         }
     }
 
     public boolean isDeferred() {
-        if (parser != null) {
-            if (dataHandlerReader != null) {
-                return dataHandlerReader.isDeferred();
-            } else {
-                throw new IllegalStateException();
-            }
+        if (node instanceof OMText) {
+            // TODO: we should support deferred building of the DataHandler
+            return false;
         } else {
-            if (node instanceof OMText) {
-                // TODO: we should support deferred building of the DataHandler
-                return false;
-            } else {
-                throw new IllegalStateException();
-            }
+            throw new IllegalStateException();
         }
     }
 
     public String getContentID() {
-        if (parser != null) {
-            if (dataHandlerReader != null) {
-                return dataHandlerReader.getContentID();
-            } else {
-                throw new IllegalStateException();
-            }
+        if (node instanceof OMText) {
+            return ((OMText)node).getContentID();
         } else {
-            if (node instanceof OMText) {
-                return ((OMText)node).getContentID();
-            } else {
-                throw new IllegalStateException();
-            }
+            throw new IllegalStateException();
         }
     }
 
     public DataHandler getDataHandler() throws XMLStreamException {
-        if (parser != null) {
-            if (dataHandlerReader != null) {
-                return dataHandlerReader.getDataHandler();
-            } else {
-                throw new IllegalStateException();
-            }
+        if (node instanceof OMText) {
+            return (DataHandler)((OMText)node).getDataHandler();
         } else {
-            if (node instanceof OMText) {
-                return (DataHandler)((OMText)node).getDataHandler();
-            } else {
-                throw new IllegalStateException();
-            }
+            throw new IllegalStateException();
         }
     }
 
     public DataHandlerProvider getDataHandlerProvider() {
-        if (parser != null) {
-            if (dataHandlerReader != null) {
-                return dataHandlerReader.getDataHandlerProvider();
-            } else {
-                throw new IllegalStateException();
-            }
-        } else {
-            throw new IllegalStateException();
-        }
+        throw new IllegalStateException();
     }
 
     /*
@@ -1101,8 +1047,6 @@ class SwitchingWrapper extends AbstractX
 
     private void setParser(XMLStreamReader parser) {
         this.parser = parser;
-        dataHandlerReader =
-                parser == null ? null : XMLStreamReaderUtils.getDataHandlerReader(parser);
     }
 
     private Map getAllNamespaces(OMSerializable contextNode) {

Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java?rev=1481554&r1=1481553&r2=1481554&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
(original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap/SOAPTestSuiteBuilder.java
Sun May 12 13:26:19 2013
@@ -304,6 +304,7 @@ public class SOAPTestSuiteBuilder extend
         addTest(new org.apache.axiom.ts.soap12.header.TestExamineMustUnderstandHeaderBlocksWithParser(metaFactory));
         addTest(new org.apache.axiom.ts.soap12.header.TestGetHeaderBlocksWithNSURIWithParser(metaFactory));
         addTest(new org.apache.axiom.ts.soap12.header.TestGetHeadersToProcessWithParser(metaFactory));
-        addTest(new org.apache.axiom.ts.soap12.mtom.TestGetXMLStreamReaderMTOMEncoded(metaFactory));
+        addTest(new org.apache.axiom.ts.soap12.mtom.TestGetXMLStreamReaderMTOMEncoded(metaFactory,
true));
+        addTest(new org.apache.axiom.ts.soap12.mtom.TestGetXMLStreamReaderMTOMEncoded(metaFactory,
false));
     }
 }

Modified: webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/mtom/TestGetXMLStreamReaderMTOMEncoded.java
URL: http://svn.apache.org/viewvc/webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/mtom/TestGetXMLStreamReaderMTOMEncoded.java?rev=1481554&r1=1481553&r2=1481554&view=diff
==============================================================================
--- webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/mtom/TestGetXMLStreamReaderMTOMEncoded.java
(original)
+++ webservices/axiom/trunk/modules/axiom-testsuite/src/main/java/org/apache/axiom/ts/soap12/mtom/TestGetXMLStreamReaderMTOMEncoded.java
Sun May 12 13:26:19 2013
@@ -38,8 +38,12 @@ public class TestGetXMLStreamReaderMTOME
     private final static QName XOP_INCLUDE = 
             new QName("http://www.w3.org/2004/08/xop/include", "Include");
 
-    public TestGetXMLStreamReaderMTOMEncoded(OMMetaFactory metaFactory) {
+    private final boolean cache;
+    
+    public TestGetXMLStreamReaderMTOMEncoded(OMMetaFactory metaFactory, boolean cache) {
         super(metaFactory);
+        this.cache = cache;
+        addTestParameter("cache", String.valueOf(cache));
     }
 
     protected void runTest() throws Throwable {
@@ -47,12 +51,9 @@ public class TestGetXMLStreamReaderMTOME
         Attachments attachments = new Attachments(inStream, TestConstants.MTOM_MESSAGE_2.getContentType());
         OMElement root = OMXMLBuilderFactory.createSOAPModelBuilder(metaFactory, attachments).getDocumentElement();
         
-        // Build tree
-        root.build();
-        
         // Use tree as input to XMLStreamReader
         // Issue XOP:Include events for optimized MTOM text nodes
-        XOPEncodedStream xopEncodedStream = XOPUtils.getXOPEncodedStream(root.getXMLStreamReader());
+        XOPEncodedStream xopEncodedStream = XOPUtils.getXOPEncodedStream(root.getXMLStreamReader(cache));
         XMLStreamReader xmlStreamReader = xopEncodedStream.getReader();
         
         DataHandler dh = null;



Mime
View raw message