[ 
https://issues.apache.org/jira/browse/GERONIMO-4591?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12682701#action_12682701
 ] 

Guillaume Nodet commented on GERONIMO-4591:
-------------------------------------------

The following patch should work, but I'm waiting for a confirmation that it 
actually works before committing it.

{code}
Index: src/main/java/javax/mail/internet/MimePartDataSource.java
===================================================================
--- src/main/java/javax/mail/internet/MimePartDataSource.java   (revision 
755277)
+++ src/main/java/javax/mail/internet/MimePartDataSource.java   (working copy)
@@ -111,6 +111,13 @@
     }
 
     public String getName() {
+        try {
+            if (part instanceof MimeBodyPart) {
+                return ((MimeBodyPart) part).getFileName();
+            }
+        } catch (MessagingException mex) {
+            // ignore it
+        }
         return "";
     }
 
Index: src/main/java/javax/mail/internet/MimeBodyPart.java
===================================================================
--- src/main/java/javax/mail/internet/MimeBodyPart.java (revision 755277)
+++ src/main/java/javax/mail/internet/MimeBodyPart.java (working copy)
@@ -296,7 +296,7 @@
 
     public String getFileName() throws MessagingException {
         // see if there is a disposition.  If there is, parse off the filename 
parameter.
-        String disposition = getSingleHeader("Content-Disposition");
+        String disposition = getDisposition();
         String filename = null;
 
         if (disposition != null) {
@@ -306,7 +306,7 @@
         // if there's no filename on the disposition, there might be a name 
parameter on a
         // Content-Type header.
         if (filename == null) {
-            String type = getSingleHeader("Content-Type");
+            String type = getContentType();
             if (type != null) {
                 try {
                     filename = new ContentType(type).getParameter("name");
@@ -350,7 +350,7 @@
         contentDisposition.setParameter("filename", name);
 
         // serialize this back out and reset.
-        setHeader("Content-Disposition", contentDisposition.toString());
+        setDisposition(contentDisposition.toString());
 
         // The Sun implementation appears to update the Content-type name 
parameter too, based on
         // another system property
{code}

> Email attachments name can not be retrieved
> -------------------------------------------
>
>                 Key: GERONIMO-4591
>                 URL: https://issues.apache.org/jira/browse/GERONIMO-4591
>             Project: Geronimo
>          Issue Type: Bug
>      Security Level: public(Regular issues) 
>          Components: specs
>            Reporter: Guillaume Nodet
>


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to