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 A6BF2DC8F for ; Wed, 17 Oct 2012 15:24:10 +0000 (UTC) Received: (qmail 35522 invoked by uid 500); 17 Oct 2012 15:24:10 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 35458 invoked by uid 500); 17 Oct 2012 15:24:10 -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 35451 invoked by uid 99); 17 Oct 2012 15:24:10 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 17 Oct 2012 15:24:10 +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; Wed, 17 Oct 2012 15:24:09 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 0FBD723888CD; Wed, 17 Oct 2012 15:23:26 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1399304 - in /cxf/branches/2.6.x-fixes: api/src/main/java/org/apache/cxf/attachment/ rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/ Date: Wed, 17 Oct 2012 15:23:25 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8-patched Message-Id: <20121017152326.0FBD723888CD@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: dkulp Date: Wed Oct 17 15:23:25 2012 New Revision: 1399304 URL: http://svn.apache.org/viewvc?rev=1399304&view=rev Log: 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.6.x-fixes/api/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java Modified: cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java?rev=1399304&r1=1399303&r2=1399304&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java (original) +++ cxf/branches/2.6.x-fixes/api/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java Wed Oct 17 15:23:25 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); Modified: cxf/branches/2.6.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.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java?rev=1399304&r1=1399303&r2=1399304&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java (original) +++ cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJInInterceptor.java Wed Oct 17 15:23:25 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; @@ -203,13 +204,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.6.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.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java?rev=1399304&r1=1399303&r2=1399304&view=diff ============================================================================== --- cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java (original) +++ cxf/branches/2.6.x-fixes/rt/bindings/soap/src/main/java/org/apache/cxf/binding/soap/saaj/SAAJOutInterceptor.java Wed Oct 17 15:23:25 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) {