[ 
https://issues.apache.org/jira/browse/JAMES-1433?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13439817#comment-13439817
 ] 

Idea Harness commented on JAMES-1433:
-------------------------------------

Eric,

FWIW - after completing switching to Geronimo JavaMail and removing Oracle 
JavaMail and going through (and fixing) my unit tests I found these issues with 
Geronimo JavaMail implementation (vers. 1.8.3), which all previouslly worked 
with Oracle Java Mail.

1.      In a nested MimeMessage (Root MimeMessage), that contains another 
forwarded as attachment MimeMessage (Forwarded MimeMessage), 
MimeBodyPart within the Forwarded MimeMessage always INCORRECTLY has 
MimeBodyPart.getParent() returning null (under Oracle JavaMail with same
test case, MimeBodyPart.getParent() correctly returned non-null parent 
MimeMultipart).

2.      For both text/html and binary attachments, setting content, 
dataHandler, and fileName into MimeBodyPart DOES NOT automatically 
set the Content-Type header as well (after enclosing MimeMessage.saveChanges() 
is called), and hence it needs to be manually set 
(Oracle JavaMail was automatically set the Content-Type header (after enclosing 
MimeMessage.saveChanges() is called) which was nice) :

a.      Text:

String charset                                          = "UTF-8";
String fileName                                         = "fooBar.html";
// getTextContentsOfFile() returns String contents of fileName with passed 
charset
String textContentsOfFile = getTextContentsOfFile( fileName, charset );
String contentTypeOfFile        = "text/plain; charset=UTF-8; 
name=\"fooBar.html\"";
mimePart.setContent( textContentsOfFile, contentTypeOfFile );
mimePart.setDataHandler( new DataHandler( new ByteArrayDataSource( 
textContentsOfFile, contentTypeOfFile ) ) );
mimePart.setFileName( fileName ); 

b.      Binary

String fileName                                         = "fooBar.pdf";
// getBinaryContentsOfFile() returns base64 contents (as byte[]) of fileName
byte[] binaryContentsOfFile = getBinaryContentsOfFile( fileName );
String contentTypeOfFile        = "application/pdf; name=\"fooBar.pdf\"";
mimePart.setContent( binaryContentsOfFile, contentTypeOfFile );
mimePart.setDataHandler( new DataHandler( new ByteArrayDataSource( 
binaryContentsOfFile, contentTypeOfFile ) ) );
mimePart.setFileName( fileName ); 

...

mimeMessage.saveChanges();

mimePart.getContentType() INCORRECTLY returns for

        a.      "text/plain; charset=UTF-8; name=\"fooBar.html\"" (rather than 
"text/html; charset=UTF-8; name=\"fooBar.html\"" as it should (and as done 
under Oracle JavaMail))
        b.      "text/plain; name=\"fooBar.pdf\"" (rather than 
"application/pdf; name=\"fooBar.pdf\"" as it should (and as done under Oracle 
JavaMail))

to have the correct ContentType to be returned under Geronimo I had to manually 
add the Content-Type header into mimePart like so :

mimePart.addHeader( RFC2822Headers.CONTENT_TYPE, contentTypeOfFile );

3.      (Mentioned in my earlier post from today) MimeBodyPart.setText( String 
text, String charset, String subtype ) behaves INCORRECTLY when subtype passed 
in is anything but "plain"
(specifically if subType = "html" ). After enclosing MimeMessage.saveChanges() 
is called, MimeBodyPart.getContentType() still returns String starting with 
"text/plain", rather with 
other correct ContentType depending on subType (such as "text/html"). This 
might be a dup of issue 2. above (under Oracle JavaMail with same test case, 
MimeBodyPart.getContentType() 
correctly returns (after enclosing MimeMessage.saveChanges() is called) 
"text/html", if subtype="html").

Regards,
IH
                
> Upgrade to geronimo-javamail_1.4 1.8.3 and exclude oracle mail
> --------------------------------------------------------------
>
>                 Key: JAMES-1433
>                 URL: https://issues.apache.org/jira/browse/JAMES-1433
>             Project: JAMES Server
>          Issue Type: Bug
>    Affects Versions: 3.0-beta5
>            Reporter: Eric Charles
>            Assignee: Eric Charles
>            Priority: Minor
>             Fix For: 3.0-beta5
>
>
> See JAMES-1431

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to