You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ch...@apache.org on 2005/09/07 08:35:40 UTC

svn commit: r279260 - /webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/mtom/MTOMStAXSOAPModelBuilder.java

Author: chinthaka
Date: Tue Sep  6 23:35:33 2005
New Revision: 279260

URL: http://svn.apache.org/viewcvs?rev=279260&view=rev
Log:
Fixing Axis2-209. Fixing URI encoding for CID.

Modified:
    webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/mtom/MTOMStAXSOAPModelBuilder.java

Modified: webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/mtom/MTOMStAXSOAPModelBuilder.java
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/mtom/MTOMStAXSOAPModelBuilder.java?rev=279260&r1=279259&r2=279260&view=diff
==============================================================================
--- webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/mtom/MTOMStAXSOAPModelBuilder.java (original)
+++ webservices/axis2/trunk/java/modules/xml/src/org/apache/axis2/om/impl/llom/mtom/MTOMStAXSOAPModelBuilder.java Tue Sep  6 23:35:33 2005
@@ -1,4 +1,4 @@
-/**  
+/**
  * Copyright 2001-2004 The Apache Software Foundation.
  * <p/>
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -28,6 +28,8 @@
 
 import javax.activation.DataHandler;
 import javax.xml.stream.XMLStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
 
 public class MTOMStAXSOAPModelBuilder extends StAXSOAPModelBuilder implements MTOMConstants {
 
@@ -58,7 +60,7 @@
 
     protected OMNode createOMElement() throws OMException {
 
-    	elementLevel++;
+        elementLevel++;
         String elementName = parser.getLocalName();
 
         String namespaceURI = parser.getNamespaceURI();
@@ -86,8 +88,15 @@
                 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("")))) {
+                        & (!contentID.equals("")))) {
                     throw new OMException(
                             "contentID not Found in XOP:Include element");
                 }
@@ -105,7 +114,7 @@
             } catch (ClassCastException e) {
                 throw new OMException(
                         "Last Node & Parent of an OMText should be an Element" +
-                        e);
+                                e);
             }
 
             return node;