You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by Norman Maurer <nm...@byteaction.de> on 2006/09/05 21:22:17 UTC

Folder interface and UID ! [was: Re: [jira] Commented: (JAMES-607) Rewrite MBoxMailRepository to use mstor]

Here is what Ben was answer:

Read and respond to this message at: 
https://sourceforge.net/forum/message.php?msg_id=3899074
By: fortuna

Hi Norman,

I would assume the best place to store the message UID would be as a
custom
header in the message. eg:

X-Apache-James-UID: JVBERi0xLjQKMyAwIG9iaiA8PA

Then to retrieve a messages you could use a search term like this:

HeaderTerm uidSearch = new HeaderTerm("X-Apache-James-UID",
"JVBERi0xLjQKMyAwIG9iaiA8PA");

// messages should contain only one (1) message..
Message[] messages = folder.search(uidSearch);

Your implementation of UIDPlusFolder could encapsulate this
functionality along
with a way to generate the unique UIDs. The benefit of using the
standard JavaMail
APIs like this is that you wouldn't be tied to any particular mail store
provider,
so you could choose to use mbox, MailDir, etc. without needing code
changes.

Let me know if this is not what you meant.

regards,
ben

ps. I've used strings for the UID, but longs would also work here.


After talk to Stefano the idea raise to adapt this idea but use FLAGS to
do the UID storing. I did a fast check of the javamail apidocs and ti
seems to be possible. 

Any comments, feedback or somthing else ?

bye
Norman

Am Montag, den 04.09.2006, 20:44 +0200 schrieb Norman Maurer:
> Am Montag, den 04.09.2006, 19:24 +0200 schrieb Norman Maurer:
> <snip>
> > > The HashJavamailStoreMailRepository is not so performant but we may try 
> > > to find out how to make the mstor folder to implement the UidPlusFolder 
> > > interface later. (maybe this is not easy, maybe we should talk with Ben 
> > > Fortuna about this).
> > > 
> > > +1 !!!
> > > Stefano
> > 
> > I will ask Ben to join us.
> 
> I posted this message to the mstor mailinglist. Let us see what Ben
> answer:
> 
> Unique id per message when stored 
> 2006-09-04 20:38  Hi Ben, 
> 
> we develop a java mail server named james ( james.apache.org ). We
> thought about to use mstor to provide a backend for mbox. We need to
> have a persist unique uid (key) per message we add to retrieve the mail
> later by using the "unique" id. Any idea how to adapted this ? 
> 
> Here his the interface we using for such needs: 
> 
> package org.apache.james.mailrepository.javamail; 
> 
> import javax.mail.Message; 
> import javax.mail.MessagingException; 
> import javax.mail.UIDFolder; 
> 
> /** 
> * Interim interface to provide access to UID PLUS methods reflecting RFC
> 2359, 
> * until official Javamail API offers this. 
> */ 
> 
> public interface UIDPlusFolder extends UIDFolder, FolderInterface { 
> /** 
> * Appends the given messages to the folder and returns corresponding
> uids.<br> 
> * Implementations may require the folder to be open. 
> * 
> * @see javax.mail.Folder#appendMessages(javax.mail.Message[]) 
> * 
> * @param msgs 
> * messages to append 
> * @return array of same size and sequenze of msgs containing
> corresponding 
> * uids or -1, if something went wrong 
> * @throws MessagingException 
> * @throws IllegalStateException when folder has to be open 
> */ 
> public long[] addUIDMessages(Message[] msgs) throws MessagingException; 
> 
> /** 
> * Appends the given messages to the folder and returns corresponding 
> * instances of the appended messages.<br> 
> * Implementations may require the folder to be open. 
> * 
> * @see javax.mail.Folder#appendMessages(javax.mail.Message[]) 
> * 
> * @param msgs 
> * messages to append 
> * @return array of same size and sequenze of msgs containing
> corresponding 
> * added messages or null, if something went wrong 
> * @throws MessagingException 
> * @throws IllegalStateException when folder has to be open 
> */ 
> public Message[] addMessages(Message[] msgs) throws MessagingException; 
> 
> }
> 
> bye
> Norman