From e2e4f0b6477b7738cd278cbd62b64692b5d00066 Mon Sep 17 00:00:00 2001
From: benwa <btellier@linagora.com>
Date: Mon, 13 Apr 2015 10:54:35 +0200
Subject: [PATCH] PROTOCOLS-110 Update ACL MAILBOX API for ACL related command
 --  update james-related projects to SNAPSHOT versions

---
 .../james/imap/processor/DeleteACLProcessor.java   | 18 ++++++----
 .../james/imap/processor/GetACLProcessor.java      | 10 +++---
 .../james/imap/processor/ListRightsProcessor.java  | 12 ++++---
 .../james/imap/processor/MyRightsProcessor.java    |  8 +++--
 .../james/imap/processor/SetACLProcessor.java      | 17 +++++----
 .../imap/processor/fetch/EnvelopeBuilder.java      |  4 +--
 .../imap/processor/DeleteACLProcessorTest.java     | 15 ++++----
 .../james/imap/processor/GetACLProcessorTest.java  | 12 ++++---
 .../imap/processor/ListRightsProcessorTest.java    | 14 ++++----
 .../james/imap/processor/SetACLProcessorTest.java  | 16 +++++----
 .../processor/base/MailboxEventAnalyserTest.java   | 40 ++++++++++++----------
 pom.xml                                            |  7 ++--
 12 files changed, 99 insertions(+), 74 deletions(-)

diff --git a/imap/src/main/java/org/apache/james/imap/processor/DeleteACLProcessor.java b/imap/src/main/java/org/apache/james/imap/processor/DeleteACLProcessor.java
index 93d476a..9a7f889 100644
--- a/imap/src/main/java/org/apache/james/imap/processor/DeleteACLProcessor.java
+++ b/imap/src/main/java/org/apache/james/imap/processor/DeleteACLProcessor.java
@@ -32,12 +32,13 @@ import org.apache.james.imap.api.process.ImapSession;
 import org.apache.james.imap.message.request.DeleteACLRequest;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.exception.UnsupportedRightException;
 import org.apache.james.mailbox.model.MailboxACL.EditMode;
 import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.model.SimpleMailboxACL;
 import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights;
 import org.apache.james.mailbox.model.SimpleMailboxACL.SimpleMailboxACLEntryKey;
 import org.slf4j.Logger;
@@ -63,9 +64,10 @@ public class DeleteACLProcessor extends AbstractMailboxProcessor<DeleteACLReques
         final String mailboxName = message.getMailboxName();
         final String identifier = message.getIdentifier();
         try {
-            
-            MessageManager messageManager = mailboxManager.getMailbox(buildFullPath(session, mailboxName), mailboxSession);
 
+            MailboxPath mailboxPath = buildFullPath(session, mailboxName);
+            // Check that mailbox exists
+            mailboxManager.getMailbox(mailboxPath, mailboxSession);
             /*
              * RFC 4314 section 6.
              * An implementation MUST make sure the ACL commands themselves do
@@ -76,11 +78,11 @@ public class DeleteACLProcessor extends AbstractMailboxProcessor<DeleteACLReques
              * would be used if the mailbox did not exist, thus revealing no
              * existence information, much less the mailbox’s ACL.
              */
-            if (!messageManager.hasRight(Rfc4314Rights.l_Lookup_RIGHT, mailboxSession)) {
+            if (!mailboxManager.hasRight(mailboxPath, Rfc4314Rights.l_Lookup_RIGHT, mailboxSession)) {
                 no(command, tag, responder, HumanReadableText.MAILBOX_NOT_FOUND);
             }
             /* RFC 4314 section 4. */
-            else if (!messageManager.hasRight(Rfc4314Rights.a_Administer_RIGHT, mailboxSession)) {
+            else if (!mailboxManager.hasRight(mailboxPath, Rfc4314Rights.a_Administer_RIGHT, mailboxSession)) {
                 Object[] params = new Object[] {
                         Rfc4314Rights.a_Administer_RIGHT.toString(),
                         command.getName(),
@@ -102,8 +104,10 @@ public class DeleteACLProcessor extends AbstractMailboxProcessor<DeleteACLReques
                 // the server MUST refuse to perform the command with a BAD response.
                 // Note that Section 6 recommends additional identifier’s verification
                 // steps.
-                
-                messageManager.setRights(key, EditMode.REPLACE, null);
+
+                mailboxManager.setRights(mailboxPath,
+                    new SimpleMailboxACL.SimpleMailboxACLCommand(key, EditMode.REPLACE, null), mailboxSession);
+
                 okComplete(command, tag, responder);
                 // FIXME should we send unsolicited responses here?
                 // unsolicitedResponses(session, responder, false);
diff --git a/imap/src/main/java/org/apache/james/imap/processor/GetACLProcessor.java b/imap/src/main/java/org/apache/james/imap/processor/GetACLProcessor.java
index 9c35a91..33a848c 100644
--- a/imap/src/main/java/org/apache/james/imap/processor/GetACLProcessor.java
+++ b/imap/src/main/java/org/apache/james/imap/processor/GetACLProcessor.java
@@ -38,6 +38,7 @@ import org.apache.james.mailbox.MessageManager.MetaData;
 import org.apache.james.mailbox.MessageManager.MetaData.FetchGroup;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
+import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights;
 import org.slf4j.Logger;
 
@@ -61,8 +62,9 @@ public class GetACLProcessor extends AbstractMailboxProcessor<GetACLRequest> imp
         final String mailboxName = message.getMailboxName();
         try {
 
-            MessageManager messageManager = mailboxManager.getMailbox(buildFullPath(session, mailboxName), mailboxSession);
-
+            MailboxPath mailboxPath = buildFullPath(session, mailboxName);
+            // Check that mailbox exists
+            MessageManager messageManager = mailboxManager.getMailbox(mailboxPath, mailboxSession);
             /*
              * RFC 4314 section 6.
              * An implementation MUST make sure the ACL commands themselves do
@@ -73,11 +75,11 @@ public class GetACLProcessor extends AbstractMailboxProcessor<GetACLRequest> imp
              * would be used if the mailbox did not exist, thus revealing no
              * existence information, much less the mailbox’s ACL.
              */
-            if (!messageManager.hasRight(Rfc4314Rights.l_Lookup_RIGHT, mailboxSession)) {
+            if (!mailboxManager.hasRight(mailboxPath, Rfc4314Rights.l_Lookup_RIGHT, mailboxSession)) {
                 no(command, tag, responder, HumanReadableText.MAILBOX_NOT_FOUND);
             }
             /* RFC 4314 section 4. */
-            else if (!messageManager.hasRight(Rfc4314Rights.a_Administer_RIGHT, mailboxSession)) {
+            else if (!mailboxManager.hasRight(mailboxPath, Rfc4314Rights.a_Administer_RIGHT, mailboxSession)) {
                 Object[] params = new Object[] {
                         Rfc4314Rights.a_Administer_RIGHT.toString(),
                         command.getName(),
diff --git a/imap/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java b/imap/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java
index 29665e7..da4e899 100644
--- a/imap/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java
+++ b/imap/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java
@@ -33,11 +33,11 @@ import org.apache.james.imap.message.request.ListRightsRequest;
 import org.apache.james.imap.message.response.ListRightsResponse;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey;
 import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights;
+import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights;
 import org.apache.james.mailbox.model.SimpleMailboxACL.SimpleMailboxACLEntryKey;
 import org.slf4j.Logger;
@@ -64,7 +64,9 @@ public class ListRightsProcessor extends AbstractMailboxProcessor<ListRightsRequ
         final String identifier = message.getIdentifier();
         try {
 
-            MessageManager messageManager = mailboxManager.getMailbox(buildFullPath(session, mailboxName), mailboxSession);
+            MailboxPath mailboxPath = buildFullPath(session, mailboxName);
+            // Check that mailbox exists
+            mailboxManager.getMailbox(mailboxPath, mailboxSession);
 
             /*
              * RFC 4314 section 6.
@@ -76,11 +78,11 @@ public class ListRightsProcessor extends AbstractMailboxProcessor<ListRightsRequ
              * would be used if the mailbox did not exist, thus revealing no
              * existence information, much less the mailbox’s ACL.
              */
-            if (!messageManager.hasRight(Rfc4314Rights.l_Lookup_RIGHT, mailboxSession)) {
+            if (!mailboxManager.hasRight(mailboxPath, Rfc4314Rights.l_Lookup_RIGHT, mailboxSession)) {
                 no(command, tag, responder, HumanReadableText.MAILBOX_NOT_FOUND);
             }
             /* RFC 4314 section 4. */
-            else if (!messageManager.hasRight(Rfc4314Rights.a_Administer_RIGHT, mailboxSession)) {
+            else if (!mailboxManager.hasRight(mailboxPath, Rfc4314Rights.a_Administer_RIGHT, mailboxSession)) {
                 Object[] params = new Object[] {
                         Rfc4314Rights.a_Administer_RIGHT.toString(),
                         command.getName(),
@@ -103,7 +105,7 @@ public class ListRightsProcessor extends AbstractMailboxProcessor<ListRightsRequ
                 // Note that Section 6 recommends additional identifier’s verification
                 // steps.
                 
-                MailboxACLRights[] rights = messageManager.listRigths(key, mailboxSession);
+                MailboxACLRights[] rights = mailboxManager.listRigths(mailboxPath, key, mailboxSession);
                 ListRightsResponse aclResponse = new ListRightsResponse(mailboxName, identifier, rights);
                 responder.respond(aclResponse);
                 okComplete(command, tag, responder);
diff --git a/imap/src/main/java/org/apache/james/imap/processor/MyRightsProcessor.java b/imap/src/main/java/org/apache/james/imap/processor/MyRightsProcessor.java
index a831ec5..48f7a36 100644
--- a/imap/src/main/java/org/apache/james/imap/processor/MyRightsProcessor.java
+++ b/imap/src/main/java/org/apache/james/imap/processor/MyRightsProcessor.java
@@ -33,10 +33,10 @@ import org.apache.james.imap.message.request.MyRightsRequest;
 import org.apache.james.imap.message.response.MyRightsResponse;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights;
+import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights;
 import org.slf4j.Logger;
 
@@ -61,8 +61,10 @@ public class MyRightsProcessor extends AbstractMailboxProcessor<MyRightsRequest>
         final String mailboxName = message.getMailboxName();
         try {
 
-            MessageManager messageManager = mailboxManager.getMailbox(buildFullPath(session, mailboxName), mailboxSession);
-            MailboxACLRights myRights = messageManager.myRights(mailboxSession);
+            MailboxPath mailboxPath = buildFullPath(session, mailboxName);
+            // Check that mailbox exists
+            mailboxManager.getMailbox(mailboxPath, mailboxSession);
+            MailboxACLRights myRights = mailboxManager.myRights(mailboxPath, mailboxSession);
 
             /*
              * RFC 4314 section 6. An implementation MUST make sure the ACL
diff --git a/imap/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java b/imap/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java
index 079a3b9..6b0c2a2 100644
--- a/imap/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java
+++ b/imap/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java
@@ -32,7 +32,6 @@ import org.apache.james.imap.api.process.ImapSession;
 import org.apache.james.imap.message.request.SetACLRequest;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
 import org.apache.james.mailbox.exception.UnsupportedRightException;
@@ -40,6 +39,8 @@ import org.apache.james.mailbox.model.MailboxACL;
 import org.apache.james.mailbox.model.MailboxACL.EditMode;
 import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey;
 import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.model.SimpleMailboxACL;
 import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights;
 import org.apache.james.mailbox.model.SimpleMailboxACL.SimpleMailboxACLEntryKey;
 import org.slf4j.Logger;
@@ -83,7 +84,9 @@ public class SetACLProcessor extends AbstractMailboxProcessor<SetACLRequest> imp
             }
             MailboxACLRights mailboxAclRights = new Rfc4314Rights(rights);
 
-            MessageManager messageManager = mailboxManager.getMailbox(buildFullPath(session, mailboxName), mailboxSession);
+            MailboxPath mailboxPath = buildFullPath(session, mailboxName);
+            // Check that mailbox exists
+            mailboxManager.getMailbox(mailboxPath, mailboxSession);
 
             /*
              * RFC 4314 section 6.
@@ -95,11 +98,11 @@ public class SetACLProcessor extends AbstractMailboxProcessor<SetACLRequest> imp
              * would be used if the mailbox did not exist, thus revealing no
              * existence information, much less the mailbox’s ACL.
              */
-            if (!messageManager.hasRight(Rfc4314Rights.l_Lookup_RIGHT, mailboxSession)) {
+            if (!mailboxManager.hasRight(mailboxPath, Rfc4314Rights.l_Lookup_RIGHT, mailboxSession)) {
                 no(command, tag, responder, HumanReadableText.MAILBOX_NOT_FOUND);
             }
             /* RFC 4314 section 4. */
-            else if (!messageManager.hasRight(Rfc4314Rights.a_Administer_RIGHT, mailboxSession)) {
+            else if (!mailboxManager.hasRight(mailboxPath, Rfc4314Rights.a_Administer_RIGHT, mailboxSession)) {
                 Object[] params = new Object[] {
                         Rfc4314Rights.a_Administer_RIGHT.toString(),
                         command.getName(),
@@ -121,8 +124,10 @@ public class SetACLProcessor extends AbstractMailboxProcessor<SetACLRequest> imp
                 // the server MUST refuse to perform the command with a BAD response.
                 // Note that Section 6 recommends additional identifier’s verification
                 // steps.
-                
-                messageManager.setRights(key, editMode, mailboxAclRights);
+
+                mailboxManager.setRights(mailboxPath,
+                    new SimpleMailboxACL.SimpleMailboxACLCommand(key, editMode, mailboxAclRights), mailboxSession);
+
                 okComplete(command, tag, responder);
                 // FIXME should we send unsolicited responses here?
                 // unsolicitedResponses(session, responder, false);
diff --git a/imap/src/main/java/org/apache/james/imap/processor/fetch/EnvelopeBuilder.java b/imap/src/main/java/org/apache/james/imap/processor/fetch/EnvelopeBuilder.java
index 6cab48c..85dddf6 100644
--- a/imap/src/main/java/org/apache/james/imap/processor/fetch/EnvelopeBuilder.java
+++ b/imap/src/main/java/org/apache/james/imap/processor/fetch/EnvelopeBuilder.java
@@ -39,7 +39,7 @@ import org.apache.james.mime4j.dom.address.AddressList;
 import org.apache.james.mime4j.dom.address.DomainList;
 import org.apache.james.mime4j.dom.address.Group;
 import org.apache.james.mime4j.dom.address.MailboxList;
-import org.apache.james.mime4j.field.address.LenientAddressBuilder;
+import org.apache.james.mime4j.field.address.LenientAddressParser;
 import org.slf4j.Logger;
 
 public final class EnvelopeBuilder {
@@ -131,7 +131,7 @@ public final class EnvelopeBuilder {
                 results = null;
             } else {
 
-                AddressList addressList = LenientAddressBuilder.DEFAULT.parseAddressList(value);
+                AddressList addressList = LenientAddressParser.DEFAULT.parseAddressList(value);
                 final int size = addressList.size();
                 final List<FetchResponse.Envelope.Address> addresses = new ArrayList<FetchResponse.Envelope.Address>(size);
                 for (int i = 0; i < size; i++) {
diff --git a/imap/src/test/java/org/apache/james/imap/processor/DeleteACLProcessorTest.java b/imap/src/test/java/org/apache/james/imap/processor/DeleteACLProcessorTest.java
index eb874de..b2292db 100644
--- a/imap/src/test/java/org/apache/james/imap/processor/DeleteACLProcessorTest.java
+++ b/imap/src/test/java/org/apache/james/imap/processor/DeleteACLProcessorTest.java
@@ -75,6 +75,7 @@ public class DeleteACLProcessorTest {
     DeleteACLProcessor subject;
     User user1Stub;
     MailboxACLEntryKey user1Key;
+    MailboxPath path;
 
     private Expectations prepareRightsExpectations() throws MailboxException {
         return new Expectations() {
@@ -104,6 +105,7 @@ public class DeleteACLProcessorTest {
 
     @Before
     public void setUp() throws Exception {
+        path = new MailboxPath("#private", USER_1, MAILBOX_NAME);
         statusResponseFactory = new UnpooledStatusResponseFactory();
         mailboxManagerStub = mockery.mock(MailboxManager.class);
         subject = new DeleteACLProcessor(mockery.mock(ImapProcessor.class), mailboxManagerStub, statusResponseFactory);
@@ -122,7 +124,8 @@ public class DeleteACLProcessorTest {
     public void testNoListRight() throws Exception {
 
         Expectations expectations = prepareRightsExpectations();
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(false));
 
         expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class)));
@@ -145,10 +148,10 @@ public class DeleteACLProcessorTest {
     public void testNoAdminRight() throws Exception {
 
         Expectations expectations = prepareRightsExpectations();
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(true));
 
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(false));
 
         expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class)));
@@ -196,13 +199,13 @@ public class DeleteACLProcessorTest {
         expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class)));
         expectations.will(Expectations.returnValue(messageManagerStub));
         
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(true));
         
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(true));
         
-        expectations.allowing(messageManagerStub).setRights(expectations.with(Expectations.equal(user1Key)), expectations.with(Expectations.equal(EditMode.REPLACE)), expectations.with(Expectations.aNull(MailboxACLRights.class)));
+        expectations.allowing(mailboxManagerStub).setRights(expectations.with(path), expectations.with(new SimpleMailboxACL.SimpleMailboxACLCommand(user1Key, EditMode.REPLACE, null)), expectations.with(mailboxSessionStub));
 
         expectations.allowing(metaDataStub).getACL();
         expectations.will(Expectations.returnValue(acl));
diff --git a/imap/src/test/java/org/apache/james/imap/processor/GetACLProcessorTest.java b/imap/src/test/java/org/apache/james/imap/processor/GetACLProcessorTest.java
index c8470b8..01fde43 100644
--- a/imap/src/test/java/org/apache/james/imap/processor/GetACLProcessorTest.java
+++ b/imap/src/test/java/org/apache/james/imap/processor/GetACLProcessorTest.java
@@ -70,6 +70,7 @@ public class GetACLProcessorTest {
     UnpooledStatusResponseFactory statusResponseFactory;
     GetACLProcessor subject;
     User user1Stub;
+    MailboxPath path;
 
     private Expectations prepareRightsExpectations() throws MailboxException {
         return new Expectations() {
@@ -99,6 +100,7 @@ public class GetACLProcessorTest {
 
     @Before
     public void setUp() throws Exception {
+        path = new MailboxPath("#private", USER_1, MAILBOX_NAME);
         statusResponseFactory = new UnpooledStatusResponseFactory();
         mailboxManagerStub = mockery.mock(MailboxManager.class);
         subject = new GetACLProcessor(mockery.mock(ImapProcessor.class), mailboxManagerStub, statusResponseFactory);
@@ -116,7 +118,7 @@ public class GetACLProcessorTest {
     public void testNoListRight() throws Exception {
 
         Expectations expectations = prepareRightsExpectations();
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(false));
 
         expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class)));
@@ -139,10 +141,10 @@ public class GetACLProcessorTest {
     public void testNoAdminRight() throws Exception {
 
         Expectations expectations = prepareRightsExpectations();
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(true));
 
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(false));
 
         expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class)));
@@ -190,10 +192,10 @@ public class GetACLProcessorTest {
         expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class)));
         expectations.will(Expectations.returnValue(messageManagerStub));
         
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(true));
         
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(true));
         
 
diff --git a/imap/src/test/java/org/apache/james/imap/processor/ListRightsProcessorTest.java b/imap/src/test/java/org/apache/james/imap/processor/ListRightsProcessorTest.java
index 73eafe6..736ff16 100644
--- a/imap/src/test/java/org/apache/james/imap/processor/ListRightsProcessorTest.java
+++ b/imap/src/test/java/org/apache/james/imap/processor/ListRightsProcessorTest.java
@@ -76,6 +76,7 @@ public class ListRightsProcessorTest {
     User user1Stub;
     MailboxACLEntryKey user1Key;
     MailboxACLRights[] listRights;
+    MailboxPath path;
 
     private Expectations prepareRightsExpectations() throws MailboxException {
         return new Expectations() {
@@ -105,6 +106,7 @@ public class ListRightsProcessorTest {
 
     @Before
     public void setUp() throws Exception {
+        path = new MailboxPath("#private", USER_1, MAILBOX_NAME);
         statusResponseFactory = new UnpooledStatusResponseFactory();
         mailboxManagerStub = mockery.mock(MailboxManager.class);
         subject = new ListRightsProcessor(mockery.mock(ImapProcessor.class), mailboxManagerStub, statusResponseFactory);
@@ -124,7 +126,7 @@ public class ListRightsProcessorTest {
     public void testNoListRight() throws Exception {
 
         Expectations expectations = prepareRightsExpectations();
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(false));
 
         expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class)));
@@ -147,10 +149,10 @@ public class ListRightsProcessorTest {
     public void testNoAdminRight() throws Exception {
 
         Expectations expectations = prepareRightsExpectations();
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(true));
 
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(false));
 
         expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class)));
@@ -198,13 +200,13 @@ public class ListRightsProcessorTest {
         expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class)));
         expectations.will(Expectations.returnValue(messageManagerStub));
         
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(true));
         
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(true));
         
-        expectations.allowing(messageManagerStub).listRigths(expectations.with(Expectations.equal(user1Key)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).listRigths(expectations.with(path), expectations.with(Expectations.equal(user1Key)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(listRights));
 
         expectations.allowing(metaDataStub).getACL();
diff --git a/imap/src/test/java/org/apache/james/imap/processor/SetACLProcessorTest.java b/imap/src/test/java/org/apache/james/imap/processor/SetACLProcessorTest.java
index 49d692f..47ce4ce 100644
--- a/imap/src/test/java/org/apache/james/imap/processor/SetACLProcessorTest.java
+++ b/imap/src/test/java/org/apache/james/imap/processor/SetACLProcessorTest.java
@@ -78,6 +78,7 @@ public class SetACLProcessorTest {
     User user1Stub;
     MailboxACLEntryKey user1Key;
     MailboxACLRights setRights;
+    MailboxPath path;
 
     private Expectations prepareRightsExpectations() throws MailboxException {
         return new Expectations() {
@@ -107,6 +108,7 @@ public class SetACLProcessorTest {
 
     @Before
     public void setUp() throws Exception {
+        path = new MailboxPath("#private", USER_1, MAILBOX_NAME);
         statusResponseFactory = new UnpooledStatusResponseFactory();
         mailboxManagerStub = mockery.mock(MailboxManager.class);
         subject = new SetACLProcessor(mockery.mock(ImapProcessor.class), mailboxManagerStub, statusResponseFactory);
@@ -126,7 +128,7 @@ public class SetACLProcessorTest {
     public void testUnsupportedRight() throws Exception {
 
         Expectations expectations = prepareRightsExpectations();
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(false));
 
         expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class)));
@@ -149,7 +151,7 @@ public class SetACLProcessorTest {
     public void testNoListRight() throws Exception {
 
         Expectations expectations = prepareRightsExpectations();
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(false));
 
         expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class)));
@@ -172,10 +174,10 @@ public class SetACLProcessorTest {
     public void testNoAdminRight() throws Exception {
 
         Expectations expectations = prepareRightsExpectations();
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(true));
 
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(false));
 
         expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class)));
@@ -226,13 +228,13 @@ public class SetACLProcessorTest {
         expectations.allowing(mailboxManagerStub).getMailbox(expectations.with(Expectations.any(MailboxPath.class)), expectations.with(Expectations.any(MailboxSession.class)));
         expectations.will(Expectations.returnValue(messageManagerStub));
         
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.l_Lookup_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(true));
         
-        expectations.allowing(messageManagerStub).hasRight(expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
+        expectations.allowing(mailboxManagerStub).hasRight(expectations.with(path), expectations.with(Expectations.equal(Rfc4314Rights.a_Administer_RIGHT)), expectations.with(Expectations.same(mailboxSessionStub)));
         expectations.will(Expectations.returnValue(true));
         
-        expectations.allowing(messageManagerStub).setRights(expectations.with(Expectations.equal(user1Key)), expectations.with(Expectations.equal(editMode)), expectations.with(Expectations.equal(setRights)));
+        expectations.allowing(mailboxManagerStub).setRights(expectations.with(path), expectations.with(Expectations.equal(new SimpleMailboxACL.SimpleMailboxACLCommand(user1Key, editMode, setRights))), expectations.with(mailboxSessionStub));
 
         expectations.allowing(metaDataStub).getACL();
         expectations.will(Expectations.returnValue(acl));
diff --git a/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java b/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
index 533e26b..00f22bf 100644
--- a/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
+++ b/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
@@ -35,6 +35,7 @@ import java.util.Map;
 
 import javax.mail.Flags;
 
+import org.apache.commons.lang.NotImplementedException;
 import org.apache.james.imap.api.ImapSessionState;
 import org.apache.james.imap.api.ImapSessionUtils;
 import org.apache.james.imap.api.process.ImapLineHandler;
@@ -46,10 +47,9 @@ import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
 import org.apache.james.mailbox.exception.BadCredentialsException;
 import org.apache.james.mailbox.exception.MailboxException;
-import org.apache.james.mailbox.exception.UnsupportedRightException;
 import org.apache.james.mailbox.model.Content;
 import org.apache.james.mailbox.model.Headers;
-import org.apache.james.mailbox.model.MailboxACL.EditMode;
+import org.apache.james.mailbox.model.MailboxACL.MailboxACLCommand;
 import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey;
 import org.apache.james.mailbox.model.MailboxACL.MailboxACLRight;
 import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights;
@@ -299,23 +299,6 @@ public class MailboxEventAnalyserTest {
                     throw new UnsupportedOperationException("Not implemented");
 
                 }
-                
-                public boolean hasRight(MailboxACLRight right, MailboxSession session) throws MailboxException {
-                    return true;
-                }
-
-                public MailboxACLRights myRights(MailboxSession session) throws MailboxException {
-                    throw new UnsupportedOperationException("Not implemented");
-                }
-
-                public MailboxACLRights[] listRigths(MailboxACLEntryKey identifier, MailboxSession session) throws UnsupportedRightException {
-                    throw new UnsupportedOperationException("Not implemented");
-                }
-
-                public void setRights(MailboxACLEntryKey mailboxACLEntryKey, EditMode editMode, MailboxACLRights mailboxAclRights) throws UnsupportedRightException {
-                    throw new UnsupportedOperationException("Not implemented");
-                }
-
             };
         }
         
@@ -350,7 +333,26 @@ public class MailboxEventAnalyserTest {
             throw new UnsupportedOperationException("Not implemented");
 
         }
+
+        public boolean hasRight(MailboxPath mailboxPath, MailboxACLRight mailboxACLRight, MailboxSession mailboxSession) throws MailboxException {
+            throw new NotImplementedException("Not implemented");
+        }
+
+        public MailboxACLRights myRights(MailboxPath mailboxPath, MailboxSession mailboxSession) throws MailboxException {
+            throw new NotImplementedException("Not implemented");
+        }
+
+        public MailboxACLRights[] listRigths(MailboxPath mailboxPath, MailboxACLEntryKey mailboxACLEntryKey, MailboxSession mailboxSession) throws MailboxException {
+            throw new NotImplementedException("Not implemented");
+        }
+
+        public void setRights(MailboxPath mailboxPath,
+                MailboxACLCommand mailboxACLCommand, MailboxSession session)
+                throws MailboxException {
+            throw new NotImplementedException("Not implemented");
+        }
     };
+    
     private final class MyMailboxSession implements MailboxSession {
         private long sessionId;
 
diff --git a/pom.xml b/pom.xml
index c4b1c5d..fe795f8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -23,8 +23,7 @@
     <parent>
         <artifactId>james-project</artifactId>
         <groupId>org.apache.james</groupId>
-        <version>1.8.1</version>
-        <relativePath />
+        <version>1.8.3-SNAPSHOT</version>
     </parent>
 
     <artifactId>protocols</artifactId>
@@ -49,8 +48,8 @@
         <target.jdk>1.6</target.jdk>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <netty.version>3.3.1.Final</netty.version>
-        <apache-mime4j.version>0.7.2</apache-mime4j.version>
-        <mailbox.version>0.5</mailbox.version>
+        <apache-mime4j.version>0.8.0-SNAPSHOT</apache-mime4j.version>
+        <mailbox.version>0.6-SNAPSHOT</mailbox.version>
         <commons-net.version>3.2</commons-net.version>
         <commons-lang.version>2.6</commons-lang.version>
         <commons-codec.version>1.7</commons-codec.version>
-- 
2.3.6

