abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From calav...@apache.org
Subject svn commit: r680981 - in /incubator/abdera/java/trunk/server: pom.xml src/main/java/org/apache/abdera/protocol/server/multipart/AbstractMultipartCollectionAdapter.java
Date Wed, 30 Jul 2008 11:21:55 GMT
Author: calavera
Date: Wed Jul 30 04:21:54 2008
New Revision: 680981

URL: http://svn.apache.org/viewvc?rev=680981&view=rev
Log:
Base64 implementation changed from sun implementation to commons-codec implementation

Modified:
    incubator/abdera/java/trunk/server/pom.xml
    incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/multipart/AbstractMultipartCollectionAdapter.java

Modified: incubator/abdera/java/trunk/server/pom.xml
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/pom.xml?rev=680981&r1=680980&r2=680981&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/pom.xml (original)
+++ incubator/abdera/java/trunk/server/pom.xml Wed Jul 30 04:21:54 2008
@@ -37,6 +37,10 @@
       <artifactId>junit</artifactId>
     </dependency>
     <dependency>
+  		<groupId>commons-codec</groupId>
+  		<artifactId>commons-codec</artifactId>
+  	</dependency>
+    <dependency>
       <groupId>org.apache.abdera</groupId>
       <artifactId>abdera-core</artifactId>
       <version>0.5.0-incubating-SNAPSHOT</version>

Modified: incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/multipart/AbstractMultipartCollectionAdapter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/multipart/AbstractMultipartCollectionAdapter.java?rev=680981&r1=680980&r2=680981&view=diff
==============================================================================
--- incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/multipart/AbstractMultipartCollectionAdapter.java
(original)
+++ incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/multipart/AbstractMultipartCollectionAdapter.java
Wed Jul 30 04:21:54 2008
@@ -18,6 +18,7 @@
 package org.apache.abdera.protocol.server.multipart;
 
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PushbackInputStream;
@@ -39,8 +40,7 @@
 import org.apache.abdera.protocol.server.impl.AbstractCollectionAdapter;
 import org.apache.abdera.util.Constants;
 import org.apache.abdera.util.MimeTypeHelper;
-
-import sun.misc.BASE64Decoder;
+import org.apache.commons.codec.binary.Base64;
 
 @SuppressWarnings("unchecked")
 public abstract class AbstractMultipartCollectionAdapter extends AbstractCollectionAdapter
@@ -96,8 +96,9 @@
 		if (!isContentTypeAccepted(dataHeaders.get("content-type"), request)) {
 			throw new ParseException("multipart/related stream invalid, content-type not accepted
into a multipart file");
 		}
-		ByteArrayInputStream data = new ByteArrayInputStream(new BASE64Decoder().decodeBuffer(multipart));;
	
-
+		
+		InputStream data = getDataInputStream(multipart);				
+		
 		return new MultipartRelatedPost(entry, data, entryHeaders, dataHeaders);
 	}
 	
@@ -148,6 +149,17 @@
 		}
 		return false;
 	}
+	
+	private InputStream getDataInputStream(InputStream stream) throws IOException {
+		Base64 base64 = new Base64();
+		ByteArrayOutputStream bo = new ByteArrayOutputStream();
+		
+		byte[] buffer = new byte[1024]; 
+		while (stream.read(buffer) != -1) {
+			bo.write(buffer);
+		}
+		return new ByteArrayInputStream(base64.decode(bo.toByteArray()));
+	}
 
 	private <T extends Element> Document<T> getEntry(InputStream stream,
 			RequestContext request) throws ParseException, IOException {		



Mime
View raw message