geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject svn commit: r756013 - in /geronimo/specs/trunk/geronimo-javamail_1.4_spec/src: main/java/javax/mail/internet/MimeMessage.java main/java/javax/mail/internet/MimePartDataSource.java test/java/javax/mail/internet/MimeTest.java
Date Thu, 19 Mar 2009 14:15:46 GMT
Author: gnodet
Date: Thu Mar 19 14:15:45 2009
New Revision: 756013

URL: http://svn.apache.org/viewvc?rev=756013&view=rev
Log:
GERONIMO-4591: Email attachments name can not be retrieved

Modified:
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeMessage.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimePartDataSource.java
    geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/test/java/javax/mail/internet/MimeTest.java

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeMessage.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeMessage.java?rev=756013&r1=756012&r2=756013&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeMessage.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimeMessage.java
Thu Mar 19 14:15:45 2009
@@ -1337,7 +1337,7 @@
     /**
      * Set or clear a flag value.
      *
-     * @param flags  The set of flags to effect.
+     * @param flag   The set of flags to effect.
      * @param set    The value to set the flag to (true or false).
      *
      * @exception MessagingException

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimePartDataSource.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimePartDataSource.java?rev=756013&r1=756012&r2=756013&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimePartDataSource.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/main/java/javax/mail/internet/MimePartDataSource.java
Thu Mar 19 14:15:45 2009
@@ -111,6 +111,13 @@
     }
 
     public String getName() {
+        try {
+            if (part instanceof MimeBodyPart) {
+                return ((MimeBodyPart) part).getFileName();
+            }
+        } catch (MessagingException mex) {
+            // ignore it
+        }
         return "";
     }
 

Modified: geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/test/java/javax/mail/internet/MimeTest.java
URL: http://svn.apache.org/viewvc/geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/test/java/javax/mail/internet/MimeTest.java?rev=756013&r1=756012&r2=756013&view=diff
==============================================================================
--- geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/test/java/javax/mail/internet/MimeTest.java
(original)
+++ geronimo/specs/trunk/geronimo-javamail_1.4_spec/src/test/java/javax/mail/internet/MimeTest.java
Thu Mar 19 14:15:45 2009
@@ -31,10 +31,13 @@
 import javax.mail.Session;
 
 import junit.framework.TestCase;
+import org.apache.geronimo.mail.util.Base64;
 
 public class MimeTest extends TestCase {
 
     public void testWriteRead() throws Exception {
+        System.setProperty("mail.mime.decodefilename", "true");
+
         Session session = Session.getDefaultInstance(new Properties(), null);
         MimeMessage mime = new MimeMessage(session);
         MimeMultipart parts = new MimeMultipart("related; type=\"text/xml\"; start=\"<xml>\"");
@@ -44,6 +47,9 @@
         parts.addBodyPart(xmlPart);
         MimeBodyPart jpegPart = new MimeBodyPart();
         jpegPart.setContentID("<jpeg>");
+        String filename = "filename";
+        String encodedFilename = "=?UTF-8?B?" + new String(Base64.encode(filename.getBytes()))
+ "?=";
+        jpegPart.setFileName(encodedFilename);
         jpegPart.setDataHandler(new DataHandler(new ByteArrayDataSource(new byte[] { 0, 1,
2, 3, 4, 5 }, "image/jpeg")));
         parts.addBodyPart(jpegPart);
         mime.setContent(parts);
@@ -70,6 +76,8 @@
 
         MimeBodyPart jpegPart2 = (MimeBodyPart) parts2.getBodyPart(1);
         assertEquals(jpegPart.getContentID(), jpegPart2.getContentID());
+        assertEquals(jpegPart.getFileName(), jpegPart2.getDataHandler().getName());
+        assertEquals(filename, jpegPart2.getDataHandler().getName());
         ByteArrayOutputStream jpegBaos = new ByteArrayOutputStream();
         copyInputStream(jpegPart.getDataHandler().getInputStream(), jpegBaos);
         ByteArrayOutputStream jpegBaos2 = new ByteArrayOutputStream();



Mime
View raw message