Author: norman
Date: Fri Jul 31 08:36:07 2009
New Revision: 799543
URL: http://svn.apache.org/viewvc?rev=799543&view=rev
Log:
correclty handle text / html attachments
Modified:
labs/hupa/src/main/java/org/apache/hupa/server/handler/ExposeMessageHandler.java
Modified:
labs/hupa/src/main/java/org/apache/hupa/server/handler/ExposeMessageHandler.java
URL:
http://svn.apache.org/viewvc/labs/hupa/src/main/java/org/apache/hupa/server/handler/ExposeMessageHandler.java?rev=799543&r1=799542&r2=799543&view=diff
==============================================================================
---
labs/hupa/src/main/java/org/apache/hupa/server/handler/ExposeMessageHandler.java
(original)
+++
labs/hupa/src/main/java/org/apache/hupa/server/handler/ExposeMessageHandler.java
Fri Jul 31 08:36:07 2009
@@ -86,15 +86,15 @@
}
MimeMessage message = (MimeMessage)
f.getMessageByUID(msg.getUid());
MessageContent content = new MessageContent();
-
+
+ boolean bodyFound = false;
boolean isHTML = false;
Object con = message.getContent();
if (con instanceof String) {
content.setText(StringEscapeUtils.escapeHtml((String)
con).replaceAll("\n", "<br>"));
content.setIsHTML(isHTML);
-
- //fullModel.setAttachments(new ArrayList<Attachment>());
+ bodyFound = true;
} else if (con instanceof Multipart) {
Multipart mp = (Multipart) con;
@@ -107,15 +107,15 @@
String contentType = part.getContentType().toLowerCase();
System.out.println("c: " + contentType);
- if (contentType.startsWith("text/plain") && isHTML ==
false) {
+ if ( bodyFound == false &&
contentType.startsWith("text/plain") && isHTML == false) {
sbPlain.append(StringEscapeUtils.escapeHtml((String)
part.getContent()).replaceAll("\n", "<br>"));
-
- } else if (contentType.startsWith("text/html")) {
+ bodyFound = true;
+ } else if (bodyFound == false &&
contentType.startsWith("text/html")) {
isHTML = true;
if (sbHTML.length() > 0) {
sbHTML.append("<HR/>");
}
-
+ bodyFound = true;
sbHTML.append((String) part.getContent());
} else {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]