RequestContext request, InputStream requestData)
throws IOException, ParseException, MessagingException {
// NOTE: because request.getInputStream() has already been read
// we pass in a seperate input stream containing the request data
MultipartInputStream stream = getMultipartStream(request, requestData);
List<MultipartRelatedPost> result = new LinkedList<MultipartRelatedPost>();
stream.skipBoundary();
String start = request.getContentType().getParameter(START_PARAM);
Document<Source> source = null;
Map<String, String> entryHeaders = new HashMap<String, String>();
InputStream data = null;
Map<String, String> dataHeaders = new HashMap<String, String>();
Map<String, String> headers = getHeaders(stream);
// first part is required to be the feed or entry
if (start == null
|| start.length() == 0
|| (headers.containsKey(CONTENT_ID_HEADER) && start
.equals(headers.get(CONTENT_ID_HEADER)))
|| (headers.containsKey(CONTENT_TYPE_HEADER) && MimeTypeHelper
.isAtom(headers.get(CONTENT_TYPE_HEADER)))) {
source = getEntry(stream, request);
entryHeaders.putAll(headers);
} else {
throw new ParseException("First part was not a feed or entry: "
+ headers);
// data = getDataInputStream(multipart);
// dataHeaders.putAll(headers);
}
try {
while (stream.available() > 0) {
stream.skipBoundary();
headers = getHeaders(stream);
if (start != null
&& (headers.containsKey(CONTENT_ID_HEADER) && start
.equals(headers.get(CONTENT_ID_HEADER)))
&& (headers.containsKey(CONTENT_TYPE_HEADER) && MimeTypeHelper