[jboss-dev-forums] [Design of JBoss Collaboration Server] - Re: MessageData Bug (only in special case)

sappenin do-not-reply at jboss.com
Fri Aug 18 10:10:04 EDT 2006


Ok, after a little bit of investigation, I was able to figure out that the "boundary" is for MIME messages.  Essentially, each MIME part is separated by a boundary with a boundary id.  So, "getBoundary()" is simply trying to detect if there are any MIME boundary parts.  

So, I discovered a similar looking function to MessageData's getBoundary() function (with the same name) in the MailHeadersImpl class.  It looks like the following:

/**
  |      * Find the mime boundry string in the content-type header
  |      * @param header from ih which contains "boundary" potentially
  |      * @return null if there is NO boundary entry or the actual boundry entry.
  |      */
  |     public String getBoundary() {
  |         
  |         String retval = null;
  |         String[] header = getHeader("Content-Type");
  |         
  |         try {
  |             for (int i = 0; header != null && i < header.length; i++) {
  |                 if( header.indexOf("boundary=\"") >-1) {
  |                     String[] temp =  header.split("boundary\\=\\\"");
  |                     String boundary = temp[temp.length-1];
  |                     boundary = "--"+boundary.split("\\\"")[0];
  |                     retval = boundary;
  |                     break;
  |                 }
  |             }
  |         } catch (Exception e) {
  |             //don't do anything we'll just NOT parse the mime.
  |         }
  |         return retval;
  |     }

Notice that it checks for a null string.  So, I proprose that the fix for the issue above simply be using the function syntax in the MessageData class.

One question remains:  Would it make sense to adjust the design of the MessageData class to be backed by a Mail object?  That way, the "getBoundary" function (and other shared functions) would only need to be coded/maintained once (inside the Mail class).  All of the "getter"/setter functions in the MessageData could just forward to the internal Mail object (which is passed in via the public constructor).  I know this is probably not a crucial tweak to perform, but it might be worth considering as a future goal?

In the meantime, I'll submit a JIRA issue for this change.

Thanks!

David

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3966052#3966052

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3966052



More information about the jboss-dev-forums mailing list