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 "Martin.Bergljung" <Ma...@opsera.com> on 2009/05/01 11:29:19 UTC

IMAP Protocol implementation comments

Hi,

 

First, thanks for all the work that has been done to develop a new IMAP
protocol implementation.

 

I am developing an IMAP Mailbox Manager backed by Alfresco and has been
using the old IMAP implementation since 2008-01. Last month I have
upgraded the implementation to use the new IMAP Protocol implementation.
It has been successful and I have done extensive testing with MS Outlook
2007 and Mozilla Thunderbird 2.0. Will do more testing with Lotus Notes
8 in the coming weeks.

 

I have some comments though, about the new implementation:

 

*         The new change to include the username in the MailboxSession
is a good idea. Unfortunately I still have to prepend the username to
all mailboxnames (e.g. #mail.mbergljung.INBOX/Company Home) in the
MailboxManager.resolve method as not all methods in the MailboxManager
takes the MailboxSession parameter. I then use the mailboxname to
extract username in all MailboxManager methods to get to a Person object
with more info. A couple of reasons why I need to access the username in
all methods are:

o   I need to check user permissions for the particular operation (i.e.
does user have permission to create mailbox, does user have permission
to update flag etc)

o   I need to get to an Alfresco Person object with more user
information such as Home folder, Locale etc 

o   I need the username for logging

*         I have to change hierarchy delimiter from '.' to '/' in
MailboxManager, LSubProcessor, and ListProcessor. Would be good if there
was a way for me to just tell the IMAP layer that I would like to use
the '/' as delimiter. I know that each command response usually contains
the hierarchy delimiter that is to be assumed but it does not cover the
complete IMAP implementation.

*         The EXPUNGE command does not work correctly:

o   The EXPUNGE can be executed and the server side will physically
delete all emails marked for deletion

o   However, whatever is sent back to the client is not correct as it
does not remove the emails from the UI (used to work fine in old
implementation)

o   If I click on other mailbox and then back on mailbox that had emails
expunged they are gone (so a workaround exists for the moment)

*         The SELECT command is too chatty at the moment I think. I get
loads of calls to MailboxManager for the Mailbox just to put together a
SELECT response.

o   The Mailbox object is requested several times (4) when it should
only be requested once and then you could get the values needed for the
response

 

Cheers,

 

Martin Bergljung

 


Re: IMAP Protocol implementation comments

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Fri, May 1, 2009 at 10:29 AM, Martin.Bergljung
<Ma...@opsera.com> wrote:

<snip>

> *         The EXPUNGE command does not work correctly:
>
> o   The EXPUNGE can be executed and the server side will physically
> delete all emails marked for deletion
>
> o   However, whatever is sent back to the client is not correct as it
> does not remove the emails from the UI (used to work fine in old
> implementation)
>
> o   If I click on other mailbox and then back on mailbox that had emails
> expunged they are gone (so a workaround exists for the moment)

EXPUNGE was missing integration tests. i've added one based on Dovecot
responses. this implementation's are reasonably close to Dovecot.

i could do with some more information. if you contribute interaction
scripts (using dummy emails that you're willing to contribute to
Apache) recording the input and output of sessions with issues against
this implementation and against dovecot then i'll be able to find out
why the clients aren't working as expected. if you could attach them
to https://issues.apache.org/jira/browse/IMAP-78 that'd be great.

- robert

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


Re: IMAP Protocol implementation comments

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Tue, May 12, 2009 at 12:35 PM,  <ma...@opsera.com> wrote:
> Sorry,
>
> Should have pointed out that I had already marked the emails for delete from Outlook before doing the Telnet.

added support for flags on APPEND and a couple of functional tests for this case

if EXPUNGE still isn't fixed then please turn on streamdump then try
replicating with Outlook. this will record a transcript of the input
and output streams.

- robert

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


Re: IMAP Protocol implementation comments

Posted by ma...@opsera.com.
Sorry,

Should have pointed out that I had already marked the emails for delete from Outlook before doing the Telnet.

Martin
Sent from my BlackBerry® wireless device

-----Original Message-----
From: "Robert Burrell Donkin" <ro...@gmail.com>

Date: Tue, 12 May 2009 12:21:50 
To: James Developers List<se...@james.apache.org>
Subject: Re: IMAP Protocol implementation comments


On Tue, May 12, 2009 at 12:06 PM, Martin.Bergljung
<Ma...@opsera.com> wrote:
> Hi,
>
> The bug is still there I think.
>
> If I telnet the old version of Apache James IMAP that I am using I get the following result on an EXPUNGE:
>
> * OK JAMES IMAP4rev1 Server 3.0-SNAPSHOT Server 127.0.1.1 ready
> a0 login gravitonian xxxxxxxxxx
> a0 OK LOGIN completed.
> a1 SELECT "INBOX/Company Home/User Homes/gravitonian/test"
> * FLAGS (\Answered \Deleted \Draft \Flagged \Recent \Seen)
> * 2 RECENT
> * OK [UIDVALIDITY 54]
> * 28 EXISTS
> * OK [UNSEEN 17] Message 17 is the first unseen
> * OK [PERMANENTFLAGS (\Answered \Deleted \Draft \Flagged \Recent \Seen)]
> a1 OK [READ-WRITE] SELECT completed.
> a2 EXPUNGE
> * 23 EXPUNGE
> * 23 EXPUNGE
> * 26 EXPUNGE
> a2 OK EXPUNGE completed.
>
> If I do the same with the new implementation I see the following:
>
>
> * OK JAMES IMAP4rev1 Server 3.0-SNAPSHOT Server 192.168.2.3 is ready.
> a0 login mbergljung xxxxxxxxx
> a0 OK LOGIN completed.
> a1 SELECT "INBOX/Company Home/User Homes/mbergljung"
> * FLAGS (\Answered \Deleted \Draft \Flagged \Seen)
> * 7 EXISTS
> * 1 RECENT
> * OK [UIDVALIDITY 34]
> * OK [UNSEEN 4]
> * OK [PERMANENTFLAGS (\Answered \Deleted \Draft \Flagged \Recent \Seen)]
> * OK [UIDNEXT 8]
> a1 OK [READ-WRITE] SELECT completed.
> a2 EXPUNGE
> a2 OK EXPUNGE completed.
>
> So the expunge response does not look to be complete.

i note that the expunge is done directly after select. is:

 User A
  1. Login
  2. Select mailbox alpha
  3. Mark some messages as deleted

User B
  4. Login
  5. Select mailbox alpha
  6. Expunge

the sequence required to reproduce?

- robert

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



Re: IMAP Protocol implementation comments

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Tue, May 12, 2009 at 12:06 PM, Martin.Bergljung
<Ma...@opsera.com> wrote:
> Hi,
>
> The bug is still there I think.
>
> If I telnet the old version of Apache James IMAP that I am using I get the following result on an EXPUNGE:
>
> * OK JAMES IMAP4rev1 Server 3.0-SNAPSHOT Server 127.0.1.1 ready
> a0 login gravitonian xxxxxxxxxx
> a0 OK LOGIN completed.
> a1 SELECT "INBOX/Company Home/User Homes/gravitonian/test"
> * FLAGS (\Answered \Deleted \Draft \Flagged \Recent \Seen)
> * 2 RECENT
> * OK [UIDVALIDITY 54]
> * 28 EXISTS
> * OK [UNSEEN 17] Message 17 is the first unseen
> * OK [PERMANENTFLAGS (\Answered \Deleted \Draft \Flagged \Recent \Seen)]
> a1 OK [READ-WRITE] SELECT completed.
> a2 EXPUNGE
> * 23 EXPUNGE
> * 23 EXPUNGE
> * 26 EXPUNGE
> a2 OK EXPUNGE completed.
>
> If I do the same with the new implementation I see the following:
>
>
> * OK JAMES IMAP4rev1 Server 3.0-SNAPSHOT Server 192.168.2.3 is ready.
> a0 login mbergljung xxxxxxxxx
> a0 OK LOGIN completed.
> a1 SELECT "INBOX/Company Home/User Homes/mbergljung"
> * FLAGS (\Answered \Deleted \Draft \Flagged \Seen)
> * 7 EXISTS
> * 1 RECENT
> * OK [UIDVALIDITY 34]
> * OK [UNSEEN 4]
> * OK [PERMANENTFLAGS (\Answered \Deleted \Draft \Flagged \Recent \Seen)]
> * OK [UIDNEXT 8]
> a1 OK [READ-WRITE] SELECT completed.
> a2 EXPUNGE
> a2 OK EXPUNGE completed.
>
> So the expunge response does not look to be complete.

i note that the expunge is done directly after select. is:

 User A
  1. Login
  2. Select mailbox alpha
  3. Mark some messages as deleted

User B
  4. Login
  5. Select mailbox alpha
  6. Expunge

the sequence required to reproduce?

- robert

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


RE: IMAP Protocol implementation comments

Posted by "Martin.Bergljung" <Ma...@opsera.com>.
Hi,

The bug is still there I think.

If I telnet the old version of Apache James IMAP that I am using I get the following result on an EXPUNGE:

* OK JAMES IMAP4rev1 Server 3.0-SNAPSHOT Server 127.0.1.1 ready
a0 login gravitonian xxxxxxxxxx
a0 OK LOGIN completed.
a1 SELECT "INBOX/Company Home/User Homes/gravitonian/test"
* FLAGS (\Answered \Deleted \Draft \Flagged \Recent \Seen)
* 2 RECENT
* OK [UIDVALIDITY 54]
* 28 EXISTS
* OK [UNSEEN 17] Message 17 is the first unseen
* OK [PERMANENTFLAGS (\Answered \Deleted \Draft \Flagged \Recent \Seen)]
a1 OK [READ-WRITE] SELECT completed.
a2 EXPUNGE
* 23 EXPUNGE
* 23 EXPUNGE
* 26 EXPUNGE
a2 OK EXPUNGE completed.

If I do the same with the new implementation I see the following:


* OK JAMES IMAP4rev1 Server 3.0-SNAPSHOT Server 192.168.2.3 is ready.
a0 login mbergljung xxxxxxxxx
a0 OK LOGIN completed.
a1 SELECT "INBOX/Company Home/User Homes/mbergljung"
* FLAGS (\Answered \Deleted \Draft \Flagged \Seen)
* 7 EXISTS
* 1 RECENT
* OK [UIDVALIDITY 34]
* OK [UNSEEN 4]
* OK [PERMANENTFLAGS (\Answered \Deleted \Draft \Flagged \Recent \Seen)]
* OK [UIDNEXT 8]
a1 OK [READ-WRITE] SELECT completed.
a2 EXPUNGE
a2 OK EXPUNGE completed.

So the expunge response does not look to be complete.

Cheers,
Martin

PS. I have debugged into the new IMAP implementation and it looks like it is receiving the expunged ids correctly from the mailbox.expunge call.


-----Original Message-----
From: Robert Burrell Donkin [mailto:robertburrelldonkin@gmail.com] 
Sent: 09 May 2009 14:26
To: James Developers List
Subject: Re: IMAP Protocol implementation comments

On Fri, May 1, 2009 at 10:29 AM, Martin.Bergljung
<Ma...@opsera.com> wrote:
> Hi,

<snip>

> *         The EXPUNGE command does not work correctly:
>
> o   The EXPUNGE can be executed and the server side will physically
> delete all emails marked for deletion
>
> o   However, whatever is sent back to the client is not correct as it
> does not remove the emails from the UI (used to work fine in old
> implementation)
>
> o   If I click on other mailbox and then back on mailbox that had emails
> expunged they are gone (so a workaround exists for the moment)

i think i've found and fixed the bug

- robert

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


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


Re: IMAP Protocol implementation comments

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Fri, May 1, 2009 at 10:29 AM, Martin.Bergljung
<Ma...@opsera.com> wrote:
> Hi,

<snip>

> *         The EXPUNGE command does not work correctly:
>
> o   The EXPUNGE can be executed and the server side will physically
> delete all emails marked for deletion
>
> o   However, whatever is sent back to the client is not correct as it
> does not remove the emails from the UI (used to work fine in old
> implementation)
>
> o   If I click on other mailbox and then back on mailbox that had emails
> expunged they are gone (so a workaround exists for the moment)

i think i've found and fixed the bug

- robert

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


Re: IMAP Protocol implementation comments

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Fri, May 1, 2009 at 6:49 PM,  <ma...@opsera.com> wrote:
> Hi,
>
> Regarding the MailboxSession with username etc.
>
> To pass the MailboxSession to each method in the MailboxManager would work when it comes to accessing the username.
>
> However, I think that we could do even better. The thing is that in my current implementation I keep a cache of 'Person' objects for authenticated users (I.e. So when I have the username from MailboxSession I can get to more data for the user such as Locale, preferences, possible useragent/device, store, home folder etc).
>
> We already keep one object, the MailboxSession, for an authenticated user and should be able to use it to store arbitrary user data.
> I am thinking that if MailboxSession stores a UserData object that is set in MailboxManager.createSession that would be a nice solution:
>
> public class MailboxSession {
>    private UserData user;
>    public MailboxSession(UserData user,...) {
>        this.user = user;
>   }
>   Public String getUsername() {
>        Return user.getUsername();
>   }
>   Public UserData getUser() {
>       Return user;
>   }
> }
>
> public interface UserData {
>    public String getUsername();
> }
>
> In my implementation I would then have a user data object such as for example:
>
> Public class AlfrescoUserData implements UserData {
>    Private String username;
>    Private Locale locale;
>    Private string homefolder;
>    Private String useragent;
> Etc...
>    Public string getUsername() {
>        Return username;
>    }
> }
>
> And in the AlfrescoMailboxManager I would get to the Alfresco userdata as follows:
>
> AlfrescoUserdata userdata = (AlfrescoUserData) mailboxSession.getUser();

i sometimes try to avoid this kind of construction but i think this is
one of those occasions when it's justified

- robert

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


Re: IMAP Protocol implementation comments

Posted by ma...@opsera.com.
Hi,

Regarding the MailboxSession with username etc.

To pass the MailboxSession to each method in the MailboxManager would work when it comes to accessing the username. 

However, I think that we could do even better. The thing is that in my current implementation I keep a cache of 'Person' objects for authenticated users (I.e. So when I have the username from MailboxSession I can get to more data for the user such as Locale, preferences, possible useragent/device, store, home folder etc).

We already keep one object, the MailboxSession, for an authenticated user and should be able to use it to store arbitrary user data.
I am thinking that if MailboxSession stores a UserData object that is set in MailboxManager.createSession that would be a nice solution:

public class MailboxSession {
    private UserData user;
    public MailboxSession(UserData user,...) {
        this.user = user;
   }
   Public String getUsername() {
        Return user.getUsername();
   }
   Public UserData getUser() {
       Return user;
   }
}

public interface UserData {
    public String getUsername();
}

In my implementation I would then have a user data object such as for example:

Public class AlfrescoUserData implements UserData {
    Private String username;
    Private Locale locale;
    Private string homefolder;
    Private String useragent;
Etc...
    Public string getUsername() {
        Return username;
    }
}

And in the AlfrescoMailboxManager I would get to the Alfresco userdata as follows:

AlfrescoUserdata userdata = (AlfrescoUserData) mailboxSession.getUser();

Cheers,
Martin
Sent from my BlackBerry® wireless device

-----Original Message-----
From: Robert Burrell Donkin <ro...@gmail.com>

Date: Fri, 1 May 2009 18:07:55 
To: James Developers List<se...@james.apache.org>
Subject: Re: IMAP Protocol implementation comments


On Fri, May 1, 2009 at 10:29 AM, Martin.Bergljung
<Ma...@opsera.com> wrote:
> Hi,
>
>
>
> First, thanks for all the work that has been done to develop a new IMAP
> protocol implementation.
>
>
>
> I am developing an IMAP Mailbox Manager backed by Alfresco and has been
> using the old IMAP implementation since 2008-01. Last month I have
> upgraded the implementation to use the new IMAP Protocol implementation.
> It has been successful and I have done extensive testing with MS Outlook
> 2007 and Mozilla Thunderbird 2.0. Will do more testing with Lotus Notes
> 8 in the coming weeks.

great :-)

> I have some comments though, about the new implementation:

i've been looking forward to these :-)

> *         The new change to include the username in the MailboxSession
> is a good idea. Unfortunately I still have to prepend the username to
> all mailboxnames (e.g. #mail.mbergljung.INBOX/Company Home) in the
> MailboxManager.resolve method as not all methods in the MailboxManager
> takes the MailboxSession parameter. I then use the mailboxname to
> extract username in all MailboxManager methods to get to a Person object
> with more info. A couple of reasons why I need to access the username in
> all methods are:
>
> o   I need to check user permissions for the particular operation (i.e.
> does user have permission to create mailbox, does user have permission
> to update flag etc)
>
> o   I need to get to an Alfresco Person object with more user
> information such as Home folder, Locale etc
>
> o   I need the username for logging

i agree

i plan to push the final name resolution into the mailbox layer and
pass the MailboxSession into every method. would that work for you?

> *         I have to change hierarchy delimiter from '.' to '/' in
> MailboxManager, LSubProcessor, and ListProcessor. Would be good if there
> was a way for me to just tell the IMAP layer that I would like to use
> the '/' as delimiter. I know that each command response usually contains
> the hierarchy delimiter that is to be assumed but it does not cover the
> complete IMAP implementation.

i agree

my current thinking is to make the IMAP hierarchy delimiter
configurable (by injection) at assembly time (probably hanging off
some sort of configuration object)

i suspect that the most elegant way to do this would be to introduce a
MailboxName object whose path is fully parsed. the mailbox
implementation could then rebuild a suitable name for it's storage.

opinions?

> *         The EXPUNGE command does not work correctly:
>
> o   The EXPUNGE can be executed and the server side will physically
> delete all emails marked for deletion
>
> o   However, whatever is sent back to the client is not correct as it
> does not remove the emails from the UI (used to work fine in old
> implementation)
>
> o   If I click on other mailbox and then back on mailbox that had emails
> expunged they are gone (so a workaround exists for the moment)

EXPUNGE is a funny old command, specification wise. i need to take a
look into this. i've created
https://issues.apache.org/jira/browse/IMAP-78

> *         The SELECT command is too chatty at the moment I think. I get
> loads of calls to MailboxManager for the Mailbox just to put together a
> SELECT response.
>
> o   The Mailbox object is requested several times (4) when it should
> only be requested once and then you could get the values needed for the
> response

SELECT is a major PITA, and yes something needs to be done. the torque
implementation is ok speed-wise but that's probably luck. i've created
a issue https://issues.apache.org/jira/browse/IMAP-79 to track this

- robert

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


Re: IMAP Protocol implementation comments

Posted by Robert Burrell Donkin <ro...@gmail.com>.
On Fri, May 1, 2009 at 10:29 AM, Martin.Bergljung
<Ma...@opsera.com> wrote:
> Hi,
>
>
>
> First, thanks for all the work that has been done to develop a new IMAP
> protocol implementation.
>
>
>
> I am developing an IMAP Mailbox Manager backed by Alfresco and has been
> using the old IMAP implementation since 2008-01. Last month I have
> upgraded the implementation to use the new IMAP Protocol implementation.
> It has been successful and I have done extensive testing with MS Outlook
> 2007 and Mozilla Thunderbird 2.0. Will do more testing with Lotus Notes
> 8 in the coming weeks.

great :-)

> I have some comments though, about the new implementation:

i've been looking forward to these :-)

> *         The new change to include the username in the MailboxSession
> is a good idea. Unfortunately I still have to prepend the username to
> all mailboxnames (e.g. #mail.mbergljung.INBOX/Company Home) in the
> MailboxManager.resolve method as not all methods in the MailboxManager
> takes the MailboxSession parameter. I then use the mailboxname to
> extract username in all MailboxManager methods to get to a Person object
> with more info. A couple of reasons why I need to access the username in
> all methods are:
>
> o   I need to check user permissions for the particular operation (i.e.
> does user have permission to create mailbox, does user have permission
> to update flag etc)
>
> o   I need to get to an Alfresco Person object with more user
> information such as Home folder, Locale etc
>
> o   I need the username for logging

i agree

i plan to push the final name resolution into the mailbox layer and
pass the MailboxSession into every method. would that work for you?

> *         I have to change hierarchy delimiter from '.' to '/' in
> MailboxManager, LSubProcessor, and ListProcessor. Would be good if there
> was a way for me to just tell the IMAP layer that I would like to use
> the '/' as delimiter. I know that each command response usually contains
> the hierarchy delimiter that is to be assumed but it does not cover the
> complete IMAP implementation.

i agree

my current thinking is to make the IMAP hierarchy delimiter
configurable (by injection) at assembly time (probably hanging off
some sort of configuration object)

i suspect that the most elegant way to do this would be to introduce a
MailboxName object whose path is fully parsed. the mailbox
implementation could then rebuild a suitable name for it's storage.

opinions?

> *         The EXPUNGE command does not work correctly:
>
> o   The EXPUNGE can be executed and the server side will physically
> delete all emails marked for deletion
>
> o   However, whatever is sent back to the client is not correct as it
> does not remove the emails from the UI (used to work fine in old
> implementation)
>
> o   If I click on other mailbox and then back on mailbox that had emails
> expunged they are gone (so a workaround exists for the moment)

EXPUNGE is a funny old command, specification wise. i need to take a
look into this. i've created
https://issues.apache.org/jira/browse/IMAP-78

> *         The SELECT command is too chatty at the moment I think. I get
> loads of calls to MailboxManager for the Mailbox just to put together a
> SELECT response.
>
> o   The Mailbox object is requested several times (4) when it should
> only be requested once and then you could get the values needed for the
> response

SELECT is a major PITA, and yes something needs to be done. the torque
implementation is ok speed-wise but that's probably luck. i've created
a issue https://issues.apache.org/jira/browse/IMAP-79 to track this

- robert

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