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 00FCE17442 for ; Thu, 9 Apr 2015 16:25:57 +0000 (UTC) Received: (qmail 5464 invoked by uid 500); 9 Apr 2015 16:25:56 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 5405 invoked by uid 500); 9 Apr 2015 16:25:56 -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 5396 invoked by uid 99); 9 Apr 2015 16:25:56 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Apr 2015 16:25:56 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9E64DE000A; Thu, 9 Apr 2015 16:25:56 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: asoldano@apache.org To: commits@cxf.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: cxf git commit: Few minor optimizations in AttachmentSerializer Date: Thu, 9 Apr 2015 16:25:56 +0000 (UTC) Repository: cxf Updated Branches: refs/heads/master 3c1a37d7a -> d9f4142e8 Few minor optimizations in AttachmentSerializer Project: http://git-wip-us.apache.org/repos/asf/cxf/repo Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/d9f4142e Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/d9f4142e Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/d9f4142e Branch: refs/heads/master Commit: d9f4142e87bc8a4f31c1bd1560a01a18b5c66407 Parents: 3c1a37d Author: Alessio Soldano Authored: Thu Apr 9 18:23:50 2015 +0200 Committer: Alessio Soldano Committed: Thu Apr 9 18:23:50 2015 +0200 ---------------------------------------------------------------------- .../cxf/attachment/AttachmentSerializer.java | 33 +++++++------------- 1 file changed, 12 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cxf/blob/d9f4142e/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java b/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java index 408db87..24b4766 100644 --- a/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java +++ b/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java @@ -72,7 +72,6 @@ public class AttachmentSerializer { bodyBoundary = AttachmentUtil.getUniqueBoundaryValue(); String bodyCt = (String) message.get(Message.CONTENT_TYPE); - bodyCt = bodyCt.replaceAll("\"", "\\\""); // The bodyCt string is used enclosed within "", so if it contains the character ", it // should be adjusted, like in the following case: @@ -107,17 +106,15 @@ public class AttachmentSerializer { // type is a required parameter for multipart/related only if (xopOrMultipartRelated && requestMimeType.indexOf("type=") == -1) { - ct.append("; "); if (xop) { - ct.append("type=\"application/xop+xml\""); + ct.append("; type=\"application/xop+xml\""); } else { - ct.append("type=\"").append(bodyCt).append("\""); + ct.append("; type=\"").append(bodyCt).append("\""); } } // boundary - ct.append("; ") - .append("boundary=\"") + ct.append("; boundary=\"") .append(bodyBoundary) .append("\""); @@ -127,8 +124,7 @@ public class AttachmentSerializer { // for simpler multipart/related payloads but is not needed for // multipart/mixed, multipart/form-data if (xopOrMultipartRelated) { - ct.append("; ") - .append("start=\"<") + ct.append("; start=\"<") .append(checkAngleBrackets(rootContentId)) .append(">\""); } @@ -136,8 +132,7 @@ public class AttachmentSerializer { // start-info is a required parameter for XOP/MTOM, may be needed for // other WS cases but is redundant in simpler multipart/related cases if (writeOptionalTypeParameters || xop) { - ct.append("; ") - .append("start-info=\"") + ct.append("; start-info=\"") .append(bodyCt) .append("\""); } @@ -159,7 +154,7 @@ public class AttachmentSerializer { StringBuilder mimeBodyCt = new StringBuilder(); String bodyType = getHeaderValue("Content-Type", null); if (bodyType == null) { - mimeBodyCt.append((xop ? "application/xop+xml" : "text/xml") + "; charset=") + mimeBodyCt.append(xop ? "application/xop+xml; charset=" : "text/xml; charset=") .append(encoding) .append("; type=\"") .append(bodyCt) @@ -189,12 +184,9 @@ public class AttachmentSerializer { private static void writeHeaders(String contentType, String attachmentId, Map> headers, Writer writer) throws IOException { - writer.write("\r\n"); - writer.write("Content-Type: "); + writer.write("\r\nContent-Type: "); writer.write(contentType); - writer.write("\r\n"); - - writer.write("Content-Transfer-Encoding: binary\r\n"); + writer.write("\r\nContent-Transfer-Encoding: binary\r\n"); if (attachmentId != null) { attachmentId = checkAngleBrackets(attachmentId); @@ -209,7 +201,8 @@ public class AttachmentSerializer { || "Content-Transfer-Encoding".equalsIgnoreCase(name)) { continue; } - writer.write(name + ": "); + writer.write(name); + writer.write(": "); List values = entry.getValue(); for (int i = 0; i < values.size(); i++) { writer.write(values.get(i)); @@ -238,8 +231,7 @@ public class AttachmentSerializer { if (message.getAttachments() != null) { for (Attachment a : message.getAttachments()) { StringWriter writer = new StringWriter(); - writer.write("\r\n"); - writer.write("--"); + writer.write("\r\n--"); writer.write(bodyBoundary); Map> headers = null; @@ -265,8 +257,7 @@ public class AttachmentSerializer { } } StringWriter writer = new StringWriter(); - writer.write("\r\n"); - writer.write("--"); + writer.write("\r\n--"); writer.write(bodyBoundary); writer.write("--"); out.write(writer.getBuffer().toString().getBytes(encoding));