W3C home > Mailing lists > Public > www-validator-cvs@w3.org > October 2009

2006/unicorn/src/org/w3c/unicorn/util Mail.java,1.2,1.3

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Fri, 09 Oct 2009 11:13:12 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1MwDPM-0005Fs-6j@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/util
In directory hutz:/tmp/cvs-serv20186/src/org/w3c/unicorn/util

Modified Files:
	Mail.java 
Log Message:
changed named from AttachmentOutputFormater to FileOutputFormater
+ cleaned up
+ utf-8 support

Index: Mail.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/util/Mail.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Mail.java	9 Oct 2009 06:43:56 -0000	1.2
+++ Mail.java	9 Oct 2009 11:13:10 -0000	1.3
@@ -1,13 +1,12 @@
+// $Id$
+// Author: Thomas Gambet
+// (c) COPYRIGHT MIT, ERCIM and Keio, 2009.
+// Please first read the full copyright statement in file COPYRIGHT.html
 package org.w3c.unicorn.util;
 
 import java.io.ByteArrayOutputStream;
-import java.io.CharArrayWriter;
-import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.io.StringWriter;
 import java.io.UnsupportedEncodingException;
 import java.util.ArrayList;
 import java.util.List;
@@ -17,7 +16,6 @@
 import javax.mail.Address;
 import javax.mail.Authenticator;
 import javax.mail.MessagingException;
-import javax.mail.Multipart;
 import javax.mail.Session;
 import javax.mail.Transport;
 import javax.mail.internet.InternetAddress;
@@ -25,9 +23,8 @@
 import javax.mail.internet.MimeMessage;
 import javax.mail.internet.MimeMultipart;
 
-import org.apache.commons.lang.StringEscapeUtils;
 import org.w3c.unicorn.exceptions.UnicornException;
-import org.w3c.unicorn.output.AttachmentOutputFormater;
+import org.w3c.unicorn.output.FileOutputFormater;
 import org.w3c.unicorn.output.OutputFormater;
 
 public class Mail {
@@ -63,16 +60,12 @@
 				MimeMultipart mp = new MimeMultipart();
 				for (OutputFormater outputFormater : outputFormaters) {		
 					MimeBodyPart bodyPart = new MimeBodyPart();
-					if (outputFormater instanceof AttachmentOutputFormater)
-						bodyPart.setFileName(((AttachmentOutputFormater) outputFormater).getFileName());
+					if (outputFormater instanceof FileOutputFormater)
+						bodyPart.setFileName(((FileOutputFormater) outputFormater).getFileName());
 
 					ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
 					OutputStreamWriter outputStreamWriter = new OutputStreamWriter(byteArrayOutputStream, "UTF-8");
-					
 					outputFormater.produceOutput(contextObjects, outputStreamWriter);
-					
-					
-					
 					try {
 						outputStreamWriter.close();
 						byteArrayOutputStream.close();
@@ -81,41 +74,26 @@
 						e.printStackTrace();
 					}
 					
-					
-					
-					bodyPart.setContent(byteArrayOutputStream.toString("UTF-8"), outputFormater.getMimeType());
-					
-					bodyPart.setHeader("Content-Type", outputFormater.getMimeType() + "; charset=UTF-8");
-					bodyPart.setHeader("Content-Transfer-Encoding", "8bit");
+					bodyPart.setContent(byteArrayOutputStream.toString("UTF-8"), outputFormater.getMimeType() + "; charset=UTF-8");
+					bodyPart.setHeader("Content-Transfer-Encoding", "7bit");
 					mp.addBodyPart(bodyPart);
 				}
 				msg.setContent(mp);
 			} else {
 				ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
 				OutputStreamWriter outputStreamWriter = new OutputStreamWriter(byteArrayOutputStream, "UTF-8");
-				//CharArrayWriter wr = new CharArrayWriter();
-				
 				outputFormaters.get(0).produceOutput(contextObjects, outputStreamWriter);
-				
-				//outputStreamWriter.write("んのこと仲介手数料もなし");
-				
 				try {
 					outputStreamWriter.close();
 					byteArrayOutputStream.close();
 				} catch (IOException e) {
 					// TODO Auto-generated catch block
 					e.printStackTrace();
-				}
-				System.out.println(byteArrayOutputStream.toString("UTF-8"));
-				
-				
+				}				
 				msg.setContent(byteArrayOutputStream.toString("UTF-8"), outputFormaters.get(0).getMimeType() + "; charset=UTF-8");
-				msg.writeTo(new FileOutputStream(new File(Property.get("UPLOADED_FILES_REPOSITORY") + "/test1.txt")));
-				msg.setHeader("Content-Type", outputFormaters.get(0).getMimeType() + "; charset=UTF-8");
 				msg.setHeader("Content-Transfer-Encoding", "7bit");
-				
 			}
-			msg.writeTo(new FileOutputStream(new File(Property.get("UPLOADED_FILES_REPOSITORY") + "/test.txt")));
+			
 			Transport.send(msg);
 		} catch (UnsupportedEncodingException e) {
 			// TODO Auto-generated catch block
@@ -123,9 +101,6 @@
 		} catch (MessagingException e) {
 			// TODO Auto-generated catch block
 			e.printStackTrace();
-		} catch (IOException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
 		}
 	}
 	
Received on Friday, 9 October 2009 11:13:13 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:17:39 UTC