abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From calav...@apache.org
Subject svn commit: r705598 - /incubator/abdera/java/trunk/server/src/main/java/org/apache/abdera/protocol/server/multipart/AbstractMultipartCollectionAdapter.java
Date Fri, 17 Oct 2008 13:07:29 GMT
Author: calavera
Date: Fri Oct 17 06:07:29 2008
New Revision: 705598

URL: http://svn.apache.org/viewvc?rev=705598&view=rev
Log:
a little getMultipartRelatedData method refactor

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

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=705598&r1=705597&r2=705598&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
Fri Oct 17 06:07:29 2008
@@ -63,28 +63,10 @@
 			RequestContext request) throws IOException, ParseException,
 			MessagingException {
 
-		String boundary = request.getContentType().getParameter(BOUNDARY_PARAM);
-
-		if (boundary == null) {
-			throw new IllegalArgumentException("multipart/related stream invalid, boundary parameter
is missing.");
-		}
-
-		boundary = "--" + boundary;
-
-		String type = request.getContentType().getParameter(TYPE_PARAM);
-		if (!(type != null && MimeTypeHelper.isAtom(type))) {
-			throw new ParseException("multipart/related stream invalid, type parameter should be "
-							+ Constants.ATOM_MEDIA_TYPE);
-		}
+		MultipartInputStream multipart = getMultipartStream(request);
+		multipart.skipBoundary();
 		
 		String start = request.getContentType().getParameter(START_PARAM);
-
-		PushbackInputStream pushBackInput = new PushbackInputStream(request.getInputStream(), 2);
-		pushBackInput.unread("\r\n".getBytes());
-
-		MultipartInputStream multipart = new MultipartInputStream(pushBackInput, boundary.getBytes());
-
-		multipart.skipBoundary();
 		
 		Document<Entry> entry = null;
 		Map<String, String> entryHeaders = new HashMap<String, String>();
@@ -121,6 +103,28 @@
 		return new MultipartRelatedPost(entry, data, entryHeaders, dataHeaders);
 	}
 	
+	private MultipartInputStream getMultipartStream(RequestContext request) 
+			throws IOException, ParseException, IllegalArgumentException {
+		String boundary = request.getContentType().getParameter(BOUNDARY_PARAM);
+
+		if (boundary == null) {
+			throw new IllegalArgumentException("multipart/related stream invalid, boundary parameter
is missing.");
+		}
+
+		boundary = "--" + boundary;
+
+		String type = request.getContentType().getParameter(TYPE_PARAM);
+		if (!(type != null && MimeTypeHelper.isAtom(type))) {
+			throw new ParseException("multipart/related stream invalid, type parameter should be "
+							+ Constants.ATOM_MEDIA_TYPE);
+		}
+
+		PushbackInputStream pushBackInput = new PushbackInputStream(request.getInputStream(), 2);
+		pushBackInput.unread("\r\n".getBytes());
+
+		return new MultipartInputStream(pushBackInput, boundary.getBytes());
+	}
+	
 	private void checkMultipartContent(Document<Entry> entry, Map<String, String>
dataHeaders,
 			RequestContext request) throws ParseException {
 		if (entry == null) {



Mime
View raw message