james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [5/9] james-project git commit: MAILBOX-310 Solve simple case: Duplicated mailbox in MailboxManager::search
Date Tue, 10 Oct 2017 15:17:57 GMT
MAILBOX-310 Solve simple case: Duplicated mailbox in MailboxManager::search


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/492cae3f
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/492cae3f
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/492cae3f

Branch: refs/heads/master
Commit: 492cae3f293c87fd428dc2add3cdfadd13e233ef
Parents: 4b1552d
Author: benwa <btellier@linagora.com>
Authored: Mon Oct 9 18:13:17 2017 +0700
Committer: benwa <btellier@linagora.com>
Committed: Mon Oct 9 18:14:24 2017 +0700

----------------------------------------------------------------------
 .../james/mailbox/MailboxManagerTest.java       | 23 ++++++++++++++++++++
 .../mailbox/store/StoreMailboxManager.java      |  1 +
 2 files changed, 24 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/492cae3f/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
index 7568ea7..1070d3d 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
@@ -436,6 +436,29 @@ public abstract class MailboxManagerTest {
     }
 
     @Test
+    public void searchShouldNotDuplicateMailboxWhenReportedAsUserMailboxesAndUserHasRightOnMailboxes()
throws MailboxException {
+        Assume.assumeTrue(mailboxManager.hasCapability(MailboxCapabilities.ACL));
+        MailboxSession session1 = mailboxManager.createSystemSession(USER_1);
+        MailboxPath inbox1 = MailboxPath.inbox(session1);
+        mailboxManager.createMailbox(inbox1, session1);
+        mailboxManager.setRights(inbox1,
+            MailboxACL.EMPTY.apply(MailboxACL.command()
+                .forUser(USER_1)
+                .rights(MailboxACL.Right.Read, MailboxACL.Right.Lookup)
+                .asAddition()),
+            session1);
+
+        MailboxQuery mailboxQuery = MailboxQuery.builder()
+            .matchesAllMailboxNames()
+            .build();
+
+        assertThat(mailboxManager.search(mailboxQuery, session1))
+            .extracting(MailboxMetaData::getPath)
+            .hasSize(1)
+            .containsOnly(inbox1);
+    }
+
+    @Test
     public void searchShouldIncludeDelegatedMailboxes() throws MailboxException {
         Assume.assumeTrue(mailboxManager.hasCapability(MailboxCapabilities.ACL));
         MailboxSession session1 = mailboxManager.createSystemSession(USER_1);

http://git-wip-us.apache.org/repos/asf/james-project/blob/492cae3f/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
index 5dd1890..6519bcb 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMailboxManager.java
@@ -684,6 +684,7 @@ public class StoreMailboxManager implements MailboxManager {
         Stream<Mailbox> delegatedMailboxes = getDelegatedMailboxes(mailboxMapper, mailboxExpression,
session);
         List<Mailbox> mailboxes = Stream.concat(baseMailboxes,
                 delegatedMailboxes)
+            .distinct()
             .filter(Throwing.predicate(mailbox -> isReadable(session, mailbox)))
             .collect(Guavate.toImmutableList());
 


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


Mime
View raw message