You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-dev@ws.apache.org by di...@apache.org on 2006/08/24 17:07:07 UTC

svn commit: r434401 - in /webservices/commons/trunk/modules/axiom/modules: axiom-api/src/main/java/org/apache/axiom/om/impl/mtom/ axiom-api/src/main/java/org/apache/axiom/om/util/ axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/

Author: dims
Date: Thu Aug 24 08:07:04 2006
New Revision: 434401

URL: http://svn.apache.org/viewvc?rev=434401&view=rev
Log:
One more fix for (AXIS2-1065) ADB / MTOM databinding is broken - Need access to the underlying OMXMLParserWrapper. extracted some code for the contentid to the helper class

Modified:
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilder.java
    webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/ElementHelper.java
    webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilder.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilder.java?rev=434401&r1=434400&r2=434401&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilder.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/impl/mtom/MTOMStAXSOAPModelBuilder.java Thu Aug 24 08:07:04 2006
@@ -21,6 +21,7 @@
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMText;
+import org.apache.axiom.om.util.ElementHelper;
 import org.apache.axiom.om.impl.MTOMConstants;
 import org.apache.axiom.om.impl.OMNodeEx;
 import org.apache.axiom.soap.SOAPFactory;
@@ -74,36 +75,13 @@
 
 
             OMText node;
-            String contentID = null;
-            String contentIDName = null;
             if (lastNode == null) {
                 // Decide whether to ckeck the level >3 or not
                 throw new OMException(
                         "XOP:Include element is not supported here");
             }
-            if (parser.getAttributeCount() > 0) {
-                contentID = parser.getAttributeValue(0);
-                contentID = contentID.trim();
-                contentIDName = parser.getAttributeLocalName(0);
-                if (contentIDName.equalsIgnoreCase("href")
-                        & contentID.substring(0, 3).equalsIgnoreCase("cid")) {
-                    contentID = contentID.substring(4);
-                    String charsetEncoding = getDocument().getCharsetEncoding();
-                    String charEnc = charsetEncoding == null || "".equals(charsetEncoding) ? "UTF-8" : charsetEncoding;
-                    try {
-                        contentID = URLDecoder.decode(contentID, charEnc);
-                    } catch (UnsupportedEncodingException e) {
-                        throw new OMException("Unsupported Character Encoding Found", e);
-                    }
-                } else if (!(contentIDName.equalsIgnoreCase("href")
-                        & (!contentID.equals("")))) {
-                    throw new OMException(
-                            "contentID not Found in XOP:Include element");
-                }
-            } else {
-                throw new OMException(
-                        "Href attribute not found in XOP:Include element");
-            }
+            
+            String contentID = ElementHelper.getContentID(parser, getDocument().getCharsetEncoding());
 
             // This cannot happen. XOP:Include is always the only child of an parent element
             // cause it is same as having some text

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/ElementHelper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/ElementHelper.java?rev=434401&r1=434400&r2=434401&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/ElementHelper.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-api/src/main/java/org/apache/axiom/om/util/ElementHelper.java Thu Aug 24 08:07:04 2006
@@ -18,10 +18,13 @@
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNamespace;
 import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMException;
 
 import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamReader;
 import java.util.Iterator;
-
+import java.net.URLDecoder;
+import java.io.UnsupportedEncodingException;
 /**
  * Helper class to provide extra utility stuff against elements.
  * The code is designed to work with any element implementation.
@@ -105,4 +108,33 @@
         }
         return null;
     }
+
+    public static String getContentID(XMLStreamReader parser, String charsetEncoding) {
+        String contentID;
+        String contentIDName;
+        if (parser.getAttributeCount() > 0) {
+            contentID = parser.getAttributeValue(0);
+            contentID = contentID.trim();
+            contentIDName = parser.getAttributeLocalName(0);
+            if (contentIDName.equalsIgnoreCase("href")
+                    & contentID.substring(0, 3).equalsIgnoreCase("cid")) {
+                contentID = contentID.substring(4);
+                String charEnc = charsetEncoding == null || "".equals(charsetEncoding) ? "UTF-8" : charsetEncoding;
+                try {
+                    contentID = URLDecoder.decode(contentID, charEnc);
+                } catch (UnsupportedEncodingException e) {
+                    throw new OMException("Unsupported Character Encoding Found", e);
+                }
+            } else if (!(contentIDName.equalsIgnoreCase("href")
+                    & (!contentID.equals("")))) {
+                throw new OMException(
+                        "contentID not Found in XOP:Include element");
+            }
+        } else {
+            throw new OMException(
+                    "Href attribute not found in XOP:Include element");
+        }
+        return contentID;
+    }
+
 }

Modified: webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java
URL: http://svn.apache.org/viewvc/webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java?rev=434401&r1=434400&r2=434401&view=diff
==============================================================================
--- webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java (original)
+++ webservices/commons/trunk/modules/axiom/modules/axiom-impl/src/main/java/org/apache/axiom/om/impl/llom/OMStAXWrapper.java Thu Aug 24 08:07:04 2006
@@ -1311,4 +1311,7 @@
             map.put(ns.getPrefix(), ns.getNamespaceURI());
         }
     }
+    public OMXMLParserWrapper getBuilder() {
+        return builder;
+    }
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: commons-dev-help@ws.apache.org