Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id B3EF5D158 for ; Thu, 25 Oct 2012 14:56:02 +0000 (UTC) Received: (qmail 25402 invoked by uid 500); 25 Oct 2012 14:56:02 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 25271 invoked by uid 500); 25 Oct 2012 14:56:02 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 25261 invoked by uid 99); 25 Oct 2012 14:56:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Oct 2012 14:56:02 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 25 Oct 2012 14:55:59 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id EB19923888FE; Thu, 25 Oct 2012 14:55:14 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121025145514.EB19923888FE@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 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 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() : 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);