Hi Andreas, Thanks for the comments....
On Thu, Mar 20, 2008 at 1:45 AM, Andreas Veithen <[EMAIL PROTECTED]> wrote: > Ruwan, > > I think there are some other things that should be cleaned up in this > piece of code: > > * The condition mbp != null is useless: if mbp is null, the expression > mbp.getContentType() will cause a NPE before reaching the if > statement. Anyway, the result of MimeBodyPart#getBodyPart is never null. Yeah, you are correct. > > * plain/text is not a valid content type, so this condition is > confusing and should be removed. I thought it is a valid contentType because it is the one which is already there in the code but found that gmail sends text/plain when I debugged the issue, so to do a lesser harm :) I added the text/plain without removing the existing plain/text. I wonder how this was working then??? > > * The first if statement contains contType != null. If contType is > null, the expression contType.indexOf(...) in the second if statement > will always throw a NPE. Anyway, the result of getContentType is never > null. OK... > > * After the for loop, the variable firstTextPart will actually store a > reference to the *last* text part. Shall we change it to first text part, or do we need to merge all the text parts, Asankha WDYT? Thanks, Ruwan > > > Andreas > > On 19 Mar 2008, at 20:33, [EMAIL PROTECTED] wrote: > > Author: ruwan > > Date: Wed Mar 19 12:33:50 2008 > > New Revision: 638978 > > > > URL: http://svn.apache.org/viewvc?rev=638978&view=rev > > Log: > > Fixing issue SYNAPSE-256, (it seems gmail send the contentType as > > text/plain rather than plain/text) > > > > Modified: > > synapse/trunk/java/modules/transports/src/main/java/org/apache/ > > synapse/transport/mail/MailUtils.java > > > > Modified: synapse/trunk/java/modules/transports/src/main/java/org/ > > apache/synapse/transport/mail/MailUtils.java > > URL: > http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/main/java/org/apache/synapse/transport/mail/MailUtils.java?rev=638978&r1=638977&r2=638978&view=diff > > = > > = > > = > > = > > = > > = > > = > > = > > ====================================================================== > > --- synapse/trunk/java/modules/transports/src/main/java/org/apache/ > > synapse/transport/mail/MailUtils.java (original) > > +++ synapse/trunk/java/modules/transports/src/main/java/org/apache/ > > synapse/transport/mail/MailUtils.java Wed Mar 19 12:33:50 2008 > > @@ -79,12 +79,15 @@ > > > > contType.indexOf(SOAP12Constants.SOAP_12_CONTENT_TYPE) != -1)) { > > // this part is a SOAP 11 or 12 payload, > > treat this as the message > > return mbp.getInputStream(); > > - } else if (mbp == null && > > contType.indexOf("plain/text") != -1) { > > + } else if (mbp != null && > > (contType.indexOf("plain/text") != -1 > > + || contType.indexOf("text/plain") ! > > = -1)) { > > firstTextPart = mbp; > > } > > } > > // if a soap 11 or soap12 payload was not found, > > treat first text part as message > > - return firstTextPart.getInputStream(); > > + if (firstTextPart != null) { > > + return firstTextPart.getInputStream(); > > + } > > > > } else { > > return ((Message) message).getInputStream(); > > @@ -94,6 +97,7 @@ > > handleException("Error creating an input stream to : " + > > ((Message) message).getMessageNumber(), e); > > } > > + > > return null; > > } > > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- Ruwan Linton http://www.wso2.org - "Oxygenating the Web Services Platform"
