Author: dkulp
Date: Fri Apr 17 19:01:53 2009
New Revision: 766119
URL: http://svn.apache.org/viewvc?rev=766119&view=rev
Log:
Merged revisions 766101 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r766101 | dkulp | 2009-04-17 13:56:29 -0400 (Fri, 17 Apr 2009) | 2 lines
CHange boundary to be a uuid
........
Modified:
cxf/branches/2.1.x-fixes/ (props changed)
cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
cxf/branches/2.1.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/AttachmentProviderXMLClientServerTest.java
Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Apr 17 19:01:53 2009
@@ -1 +1 @@
-/cxf/trunk:743446,753380,753397,753421,754585,755365,757499,757859,757899,757935,757951,758195,758303,758308,758378,758690,758910,759890,759961,759963-759964,759966,760029,760073,760150,760171,760178,760198,760212,760456,760468,760582,760938,761094,761113,761120,761317,761759,761789,762393,762518,762567,763200,763272,763495,763854,763931,763942,763953,764033-764034,764581,764599-764606,764887,765357,766013,766058,766100
+/cxf/trunk:743446,753380,753397,753421,754585,755365,757499,757859,757899,757935,757951,758195,758303,758308,758378,758690,758910,759890,759961,759963-759964,759966,760029,760073,760150,760171,760178,760198,760212,760456,760468,760582,760938,761094,761113,761120,761317,761759,761789,762393,762518,762567,763200,763272,763495,763854,763931,763942,763953,764033-764034,764581,764599-764606,764887,765357,766013,766058,766100-766101
Propchange: cxf/branches/2.1.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java?rev=766119&r1=766118&r2=766119&view=diff
==============================================================================
---
cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
(original)
+++
cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentDeserializer.java
Fri Apr 17 19:01:53 2009
@@ -52,7 +52,7 @@
// TODO: Is there a better way to detect boundaries in the message content?
// It seems constricting to assume the boundary will start with ----=_Part_
private static final Pattern INPUT_STREAM_BOUNDARY_PATTERN =
- Pattern.compile("^--(----=_Part_\\S*)", Pattern.MULTILINE);
+ Pattern.compile("^--(\\S*)");
private boolean lazyLoading = true;
Modified:
cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java?rev=766119&r1=766118&r2=766119&view=diff
==============================================================================
---
cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
(original)
+++
cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentSerializer.java
Fri Apr 17 19:01:53 2009
@@ -48,8 +48,8 @@
*/
public void writeProlog() throws IOException {
// Create boundary for body
- bodyBoundary = AttachmentUtil.getUniqueBoundaryValue(0);
-
+ bodyBoundary = AttachmentUtil.getUniqueBoundaryValue();
+
String bodyCt = (String) message.get(Message.CONTENT_TYPE);
bodyCt = bodyCt.replaceAll("\"", "\\\"");
Modified:
cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java?rev=766119&r1=766118&r2=766119&view=diff
==============================================================================
---
cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
(original)
+++
cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/attachment/AttachmentUtil.java
Fri Apr 17 19:01:53 2009
@@ -32,6 +32,7 @@
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
+import java.util.Random;
import java.util.UUID;
import javax.activation.DataHandler;
@@ -46,6 +47,8 @@
private static volatile int counter;
private static final String ATT_UUID = UUID.randomUUID().toString();
+ private static final Random BOUND_RANDOM = new Random();
+
private AttachmentUtil() {
}
@@ -73,12 +76,27 @@
return URLEncoder.encode(name, "UTF-8") + "@" + URLEncoder.encode(cid,
"UTF-8");
}
- public static String getUniqueBoundaryValue(int part) {
- StringBuffer s = new StringBuffer();
- // Unique string is ----=_Part_<part>_<hashcode>.<currentTime>
-
s.append("----=_Part_").append(part++).append("_").append(s.hashCode()).append('.').append(
- System.currentTimeMillis());
- return s.toString();
+ public static String getUniqueBoundaryValue() {
+ //generate a random UUID.
+ //we don't need the cryptographically secure random uuid that
+ //UUID.randomUUID() will produce. Thus, use a faster
+ //pseudo-random thing
+ long leastSigBits = 0;
+ long mostSigBits = 0;
+ synchronized (BOUND_RANDOM) {
+ mostSigBits = BOUND_RANDOM.nextLong();
+ leastSigBits = BOUND_RANDOM.nextLong();
+ }
+
+ mostSigBits &= 0xFFFFFFFFFFFF0FFFL; //clear version
+ mostSigBits |= 0x0000000000004000L; //set version
+
+ leastSigBits &= 0x3FFFFFFFFFFFFFFFL; //clear the variant
+ leastSigBits |= 0x8000000000000000L; //set to IETF variant
+
+ UUID result = new UUID(mostSigBits, leastSigBits);
+
+ return "uuid:" + result.toString();
}
public static String getAttchmentPartHeader(Attachment att) {
@@ -88,7 +106,11 @@
if (att.isXOP()) {
buffer.append("Content-Transfer-Encoding: binary\r\n");
}
- buffer.append("Content-ID: <" + att.getId() + ">\r\n\r\n");
+ String id = att.getId();
+ if (id.charAt(0) == '<') {
+ id = id.substring(1, id.length() - 1);
+ }
+ buffer.append("Content-ID: <" + id + ">\r\n\r\n");
return buffer.toString();
}
Modified:
cxf/branches/2.1.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java?rev=766119&r1=766118&r2=766119&view=diff
==============================================================================
---
cxf/branches/2.1.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
(original)
+++
cxf/branches/2.1.x-fixes/rt/core/src/test/java/org/apache/cxf/attachment/AttachmentDeserializerTest.java
Fri Apr 17 19:01:53 2009
@@ -240,6 +240,8 @@
assertTrue(attIs.read() == 'a');
assertTrue(attIs.read() == 'r');
assertTrue(attIs.read() == -1);
+
+ assertFalse(itr.hasNext());
}
@Test
Modified:
cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/AttachmentProviderXMLClientServerTest.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/AttachmentProviderXMLClientServerTest.java?rev=766119&r1=766118&r2=766119&view=diff
==============================================================================
---
cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/AttachmentProviderXMLClientServerTest.java
(original)
+++
cxf/branches/2.1.x-fixes/systests/src/test/java/org/apache/cxf/systest/provider/AttachmentProviderXMLClientServerTest.java
Fri Apr 17 19:01:53 2009
@@ -64,8 +64,8 @@
assertTrue("wrong content type",
connection.getContentType().contains("multipart/related"));
String input = IOUtils.toString(connection.getInputStream());
- int idx = input.indexOf("-----");
- int idx2 = input.indexOf("-----", idx + 5);
+ int idx = input.indexOf("--uuid");
+ int idx2 = input.indexOf("--uuid", idx + 5);
String root = input.substring(idx, idx2);
idx = root.indexOf("\r\n\r\n");
root = root.substring(idx).trim();