cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1402173 - in /cxf/branches/2.5.x-fixes/rt: bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/ core/src/main/java/org/apache/cxf/attachment/
Date Thu, 25 Oct 2012 14:55:14 GMT
Author: dkulp
Date: Thu Oct 25 14:55:14 2012
New Revision: 1402173

URL: http://svn.apache.org/viewvc?rev=1402173&view=rev
Log:
Merged revisions 1399304 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

........
  r1399304 | dkulp | 2012-10-17 11:23:25 -0400 (Wed, 17 Oct 2012) | 10 lines

  Merged revisions 1399301 via  git cherry-pick from
  https://svn.apache.org/repos/asf/cxf/trunk

  ........
    r1399301 | dkulp | 2012-10-17 11:13:17 -0400 (Wed, 17 Oct 2012) | 2 lines

    [CXF-4570] Some minor cleanup around the content-id and saaj

  ........

........

Modified:
    cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
    cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
    cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java

Modified: cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java?rev=1402173&r1=1402172&r2=1402173&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java
Thu Oct 25 14:55:14 2012
@@ -54,6 +54,7 @@ import org.apache.cxf.binding.soap.inter
 import org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor;
 import org.apache.cxf.common.i18n.BundleUtils;
 import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.databinding.DataBinding;
 import org.apache.cxf.headers.Header;
 import org.apache.cxf.headers.HeaderManager;
@@ -201,13 +202,15 @@ public class SAAJInInterceptor extends A
                         }
                     }
                     AttachmentPart ap = soapMessage.createAttachmentPart(a.getDataHandler());
-                    ap.setContentId(a.getId());
                     Iterator<String> i = a.getHeaderNames();
                     while (i != null && i.hasNext()) {
                         String h = i.next();
                         String val = a.getHeader(h);
                         ap.addMimeHeader(h, val);
                     }
+                    if (StringUtils.isEmpty(ap.getContentId())) {
+                        ap.setContentId(a.getId());
+                    }
                     soapMessage.addAttachmentPart(ap);
                 }
             }

Modified: cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java?rev=1402173&r1=1402172&r2=1402173&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java
Thu Oct 25 14:55:14 2012
@@ -40,6 +40,7 @@ import org.w3c.dom.Node;
 
 
 import org.apache.cxf.attachment.AttachmentImpl;
+import org.apache.cxf.attachment.AttachmentUtil;
 import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.binding.soap.Soap12;
 import org.apache.cxf.binding.soap.SoapFault;
@@ -187,7 +188,8 @@ public class SAAJOutInterceptor extends 
                     Iterator<AttachmentPart> it = CastUtils.cast(soapMessage.getAttachments());
                     while (it.hasNext()) {
                         AttachmentPart part = it.next();
-                        AttachmentImpl att = new AttachmentImpl(part.getContentId());
+                        String id = AttachmentUtil.cleanContentId(part.getContentId());
+                        AttachmentImpl att = new AttachmentImpl(id);
                         try {
                             att.setDataHandler(part.getDataHandler());
                         } catch (SOAPException e) {

Modified: cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java?rev=1402173&r1=1402172&r2=1402173&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
Thu Oct 25 14:55:14 2012
@@ -190,10 +190,7 @@ public final class AttachmentUtil {
         return dataHandlers == null ? new LinkedHashMap<String, DataHandler>() : dataHandlers;
     }
     
-    public static Attachment createAttachment(InputStream stream, InternetHeaders headers)

-        throws IOException {
-     
-        String id = headers.getHeader("Content-ID", null);
+    public static String cleanContentId(String id) {
         if (id != null) {
             if (id.startsWith("<")) {
                 // strip <>
@@ -204,13 +201,24 @@ public final class AttachmentUtil {
                 id = id.substring(4);
             }
             // urldecode. Is this bad even without cid:? What does decode do with malformed
%-signs, anyhow?
-            id = URLDecoder.decode(id, "UTF-8");
+            try {
+                id = URLDecoder.decode(id, "UTF-8");
+            } catch (UnsupportedEncodingException e) {
+                //ignore, keep id as is
+            }
         }
         if (id == null) {
             //no Content-ID, set cxf default ID
             id = "root.message@cxf.apache.org";
         }
-
+        return id;
+    }
+    
+    
+    public static Attachment createAttachment(InputStream stream, InternetHeaders headers)

+        throws IOException {
+     
+        String id = cleanContentId(headers.getHeader("Content-ID", null));
 
         AttachmentImpl att = new AttachmentImpl(id);
         



Mime
View raw message