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 ad...@apache.org on 2017/11/15 08:01:59 UTC
[01/11] james-project git commit: MAILBOX-316 New ACLDiff which
compare all kind of Entry and later on the PositiveUserACLDiff rely on that
Repository: james-project
Updated Branches:
refs/heads/master 5ceee7866 -> b539779b2
MAILBOX-316 New ACLDiff which compare all kind of Entry and later on the PositiveUserACLDiff rely on that
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/806a52bc
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/806a52bc
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/806a52bc
Branch: refs/heads/master
Commit: 806a52bc8626d412f7928cef54be10882f01a364
Parents: 8bd1d09
Author: quynhn <qn...@linagora.com>
Authored: Mon Nov 6 15:59:25 2017 +0700
Committer: quynhn <qn...@linagora.com>
Committed: Wed Nov 15 09:22:18 2017 +0700
----------------------------------------------------------------------
.../org/apache/james/mailbox/acl/ACLDiff.java | 96 ++++++++
.../james/mailbox/acl/PositiveUserACLDiff.java | 45 ++--
.../apache/james/mailbox/acl/ACLDiffTest.java | 235 +++++++++++++++++++
.../mailbox/acl/PositiveUserACLDiffTest.java | 133 +++++++++--
4 files changed, 460 insertions(+), 49 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/806a52bc/mailbox/api/src/main/java/org/apache/james/mailbox/acl/ACLDiff.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/acl/ACLDiff.java b/mailbox/api/src/main/java/org/apache/james/mailbox/acl/ACLDiff.java
new file mode 100644
index 0000000..7631261
--- /dev/null
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/acl/ACLDiff.java
@@ -0,0 +1,96 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+package org.apache.james.mailbox.acl;
+
+import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Stream;
+
+import org.apache.james.mailbox.model.MailboxACL;
+
+public class ACLDiff {
+
+ public static ACLDiff computeDiff(MailboxACL oldACL, MailboxACL newACL) {
+ return new ACLDiff(oldACL, newACL);
+ }
+
+ private final MailboxACL oldACL;
+ private final MailboxACL newACL;
+
+ public ACLDiff(MailboxACL oldACL, MailboxACL newACL) {
+ this.oldACL = oldACL;
+ this.newACL = newACL;
+ }
+
+ public Stream<MailboxACL.Entry> addedEntries() {
+ return newACL.getEntries()
+ .entrySet()
+ .stream()
+ .filter(entry -> !oldACL.getEntries().containsKey(entry.getKey()))
+ .map(entry -> new MailboxACL.Entry(entry.getKey(), entry.getValue()));
+ }
+
+ public Stream<MailboxACL.Entry> removedEntries() {
+ return oldACL.getEntries()
+ .entrySet()
+ .stream()
+ .filter(entry -> !newACL.getEntries().containsKey(entry.getKey()))
+ .map(entry -> new MailboxACL.Entry(entry.getKey(), entry.getValue()));
+ }
+
+ public Stream<MailboxACL.Entry> changedEntries() {
+ Map<MailboxACL.EntryKey, MailboxACL.Rfc4314Rights> oldEntries = oldACL.getEntries();
+
+ return newACL.getEntries()
+ .entrySet()
+ .stream()
+ .filter(entry -> hasKeyWithDifferentValue(oldEntries, entry))
+ .map(entry -> new MailboxACL.Entry(entry.getKey(), entry.getValue()));
+ }
+
+ private boolean hasKeyWithDifferentValue(Map<MailboxACL.EntryKey, MailboxACL.Rfc4314Rights> oldEntries,
+ Map.Entry<MailboxACL.EntryKey, MailboxACL.Rfc4314Rights> entry) {
+ return oldEntries.containsKey(entry.getKey())
+ && !oldEntries.get(entry.getKey()).equals(entry.getValue());
+ }
+
+ public MailboxACL getOldACL() {
+ return oldACL;
+ }
+
+ public MailboxACL getNewACL() {
+ return newACL;
+ }
+
+ @Override
+ public final boolean equals(Object o) {
+ if (o instanceof ACLDiff) {
+ ACLDiff aclDiff = (ACLDiff) o;
+
+ return Objects.equals(this.oldACL, aclDiff.oldACL)
+ && Objects.equals(this.newACL, aclDiff.newACL);
+ }
+ return false;
+ }
+
+ @Override
+ public final int hashCode() {
+ return Objects.hash(oldACL, newACL);
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/806a52bc/mailbox/api/src/main/java/org/apache/james/mailbox/acl/PositiveUserACLDiff.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/acl/PositiveUserACLDiff.java b/mailbox/api/src/main/java/org/apache/james/mailbox/acl/PositiveUserACLDiff.java
index 065ef67..062a6a1 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/acl/PositiveUserACLDiff.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/acl/PositiveUserACLDiff.java
@@ -18,53 +18,38 @@
****************************************************************/
package org.apache.james.mailbox.acl;
-import java.util.Map;
import java.util.stream.Stream;
import org.apache.james.mailbox.model.MailboxACL;
public class PositiveUserACLDiff {
+ private final ACLDiff aclDiff;
- public static PositiveUserACLDiff computeDiff(MailboxACL oldACL, MailboxACL newACL) {
- return new PositiveUserACLDiff(oldACL, newACL);
+ private PositiveUserACLDiff(ACLDiff aclDiff) {
+ this.aclDiff = aclDiff;
}
- private final MailboxACL oldACL;
- private final MailboxACL newACL;
-
- private PositiveUserACLDiff(MailboxACL oldACL, MailboxACL newACL) {
- this.oldACL = oldACL;
- this.newACL = newACL;
+ public static PositiveUserACLDiff computeDiff(MailboxACL oldACL, MailboxACL newACL) {
+ return new PositiveUserACLDiff(ACLDiff.computeDiff(oldACL, newACL));
}
public Stream<MailboxACL.Entry> addedEntries() {
- Map<MailboxACL.EntryKey, MailboxACL.Rfc4314Rights> oldEntries = oldACL.ofPositiveNameType(MailboxACL.NameType.user);
-
- return newACL.ofPositiveNameType(MailboxACL.NameType.user)
- .entrySet()
- .stream()
- .filter(entry -> !oldEntries.containsKey(entry.getKey()))
- .map(entry -> new MailboxACL.Entry(entry.getKey(), entry.getValue()));
+ return aclDiff.addedEntries()
+ .filter(this::hasPositiveUserKey);
}
public Stream<MailboxACL.Entry> removedEntries() {
- Map<MailboxACL.EntryKey, MailboxACL.Rfc4314Rights> newEntries = newACL.ofPositiveNameType(MailboxACL.NameType.user);
-
- return oldACL.ofPositiveNameType(MailboxACL.NameType.user)
- .entrySet()
- .stream()
- .filter(entry -> !newEntries.containsKey(entry.getKey()))
- .map(entry -> new MailboxACL.Entry(entry.getKey(), entry.getValue()));
+ return aclDiff.removedEntries()
+ .filter(this::hasPositiveUserKey);
}
public Stream<MailboxACL.Entry> changedEntries() {
- Map<MailboxACL.EntryKey, MailboxACL.Rfc4314Rights> oldEntries = oldACL.ofPositiveNameType(MailboxACL.NameType.user);
+ return aclDiff.changedEntries()
+ .filter(this::hasPositiveUserKey);
+ }
- return newACL.ofPositiveNameType(MailboxACL.NameType.user)
- .entrySet()
- .stream()
- .filter(entry -> oldEntries.containsKey(entry.getKey())
- && !oldEntries.get(entry.getKey()).equals(entry.getValue()))
- .map(entry -> new MailboxACL.Entry(entry.getKey(), entry.getValue()));
+ private boolean hasPositiveUserKey(MailboxACL.Entry entry) {
+ return !entry.getKey().isNegative()
+ && entry.getKey().getNameType().equals(MailboxACL.NameType.user);
}
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/806a52bc/mailbox/api/src/test/java/org/apache/james/mailbox/acl/ACLDiffTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/acl/ACLDiffTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/acl/ACLDiffTest.java
new file mode 100644
index 0000000..8a4ec8d
--- /dev/null
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/acl/ACLDiffTest.java
@@ -0,0 +1,235 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.mailbox.acl;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.james.mailbox.exception.UnsupportedRightException;
+import org.apache.james.mailbox.model.MailboxACL;
+import org.junit.Test;
+
+public class ACLDiffTest {
+ private static final MailboxACL.EntryKey ENTRY_KEY = MailboxACL.EntryKey.createGroupEntryKey("any", false);
+ private static final MailboxACL.Rfc4314Rights RIGHTS = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Administer);
+
+ @Test
+ public void addedEntriesShouldReturnEmptyWhenSameACL() {
+ ACLDiff aclDiff = ACLDiff.computeDiff(
+ MailboxACL.EMPTY,
+ MailboxACL.EMPTY);
+
+ assertThat(aclDiff.addedEntries()).isEmpty();
+ }
+
+ @Test
+ public void addedEntriesShouldReturnEmptyWhenSameNonEmptyACL() throws UnsupportedRightException {
+ MailboxACL mailboxACL = MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(ENTRY_KEY)
+ .rights(RIGHTS)
+ .asAddition());
+
+ ACLDiff aclDiff = ACLDiff.computeDiff(mailboxACL, mailboxACL);
+
+ assertThat(aclDiff.addedEntries()).isEmpty();
+ }
+
+ @Test
+ public void removedEntriesShouldReturnEmptyWhenSameACL() {
+ ACLDiff aclDiff = ACLDiff.computeDiff(
+ MailboxACL.EMPTY,
+ MailboxACL.EMPTY);
+
+ assertThat(aclDiff.removedEntries()).isEmpty();
+ }
+
+ @Test
+ public void removedEntriesShouldReturnEmptyWhenSameNonEmptyACL() throws UnsupportedRightException {
+ MailboxACL mailboxACL = MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(ENTRY_KEY)
+ .rights(RIGHTS)
+ .asAddition());
+
+ ACLDiff aclDiff = ACLDiff.computeDiff(mailboxACL, mailboxACL);
+
+ assertThat(aclDiff.removedEntries()).isEmpty();
+ }
+
+ @Test
+ public void changedEntriesShouldReturnEmptyWhenSameACL() {
+ ACLDiff aclDiff = ACLDiff.computeDiff(
+ MailboxACL.EMPTY,
+ MailboxACL.EMPTY);
+
+ assertThat(aclDiff.changedEntries()).isEmpty();
+ }
+
+ @Test
+ public void changedEntriesShouldReturnEmptyWhenSameNonEmptyACL() throws UnsupportedRightException {
+ MailboxACL mailboxACL = MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(ENTRY_KEY)
+ .rights(RIGHTS)
+ .asAddition());
+
+ ACLDiff acldiff = ACLDiff.computeDiff(mailboxACL, mailboxACL);
+
+ assertThat(acldiff.changedEntries()).isEmpty();
+ }
+ @Test
+ public void addedEntriesShouldReturnNewEntryWhenAddedEntry() throws Exception {
+ ACLDiff aclDiff = ACLDiff.computeDiff(
+ MailboxACL.EMPTY,
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(ENTRY_KEY)
+ .rights(RIGHTS)
+ .asAddition()));
+
+ assertThat(aclDiff.addedEntries())
+ .containsOnly(new MailboxACL.Entry(ENTRY_KEY, RIGHTS));
+ }
+
+ @Test
+ public void changedEntriesShouldReturnEmptyWhenAddedEntry() throws Exception {
+ ACLDiff aclDiff = ACLDiff.computeDiff(
+ MailboxACL.EMPTY,
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(ENTRY_KEY)
+ .rights(RIGHTS)
+ .asAddition()));
+
+ assertThat(aclDiff.changedEntries())
+ .isEmpty();
+ }
+
+ @Test
+ public void removedEntriesShouldReturnEmptyWhenAddedEntry() throws Exception {
+ ACLDiff aclDiff = ACLDiff.computeDiff(
+ MailboxACL.EMPTY,
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(ENTRY_KEY)
+ .rights(RIGHTS)
+ .asAddition()));
+
+ assertThat(aclDiff.removedEntries())
+ .isEmpty();
+ }
+
+ @Test
+ public void addedEntriesShouldReturnEmptyWhenRemovedEntry() throws Exception {
+ ACLDiff aclDiff = ACLDiff.computeDiff(
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(ENTRY_KEY)
+ .rights(RIGHTS)
+ .asAddition()),
+ MailboxACL.EMPTY);
+
+ assertThat(aclDiff.addedEntries())
+ .isEmpty();
+ }
+
+ @Test
+ public void changedEntriesShouldReturnEmptyWhenRemovedEntry() throws Exception {
+ ACLDiff aclDiff = ACLDiff.computeDiff(
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(ENTRY_KEY)
+ .rights(RIGHTS)
+ .asAddition()),
+ MailboxACL.EMPTY);
+
+ assertThat(aclDiff.changedEntries())
+ .isEmpty();
+ }
+
+ @Test
+ public void removedEntriesShouldReturnEntryWhenRemovedEntry() throws Exception {
+ ACLDiff aclDiff = ACLDiff.computeDiff(
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(ENTRY_KEY)
+ .rights(RIGHTS)
+ .asAddition()),
+ MailboxACL.EMPTY);
+
+ assertThat(aclDiff.removedEntries())
+ .containsOnly(new MailboxACL.Entry(ENTRY_KEY, RIGHTS));
+ }
+
+ @Test
+ public void removedEntriesShouldReturnEmptyWhenChangedEntry() throws Exception {
+ ACLDiff aclDiff = ACLDiff.computeDiff(
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(ENTRY_KEY)
+ .rights(RIGHTS)
+ .asAddition()),
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(ENTRY_KEY)
+ .rights(MailboxACL.Right.Lookup)
+ .asAddition()));
+
+ assertThat(aclDiff.removedEntries())
+ .isEmpty();
+ }
+
+ @Test
+ public void addedEntriesShouldReturnEmptyWhenChangedEntry() throws Exception {
+ ACLDiff aclDiff = ACLDiff.computeDiff(
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(ENTRY_KEY)
+ .rights(RIGHTS)
+ .asAddition()),
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(ENTRY_KEY)
+ .rights(MailboxACL.Right.Lookup)
+ .asAddition()));
+
+ assertThat(aclDiff.addedEntries())
+ .isEmpty();
+ }
+
+ @Test
+ public void changedEntriesShouldReturnEntryWhenChangedEntry() throws Exception {
+ ACLDiff aclDiff = ACLDiff.computeDiff(
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(ENTRY_KEY)
+ .rights(MailboxACL.Right.Administer)
+ .asAddition()),
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(ENTRY_KEY)
+ .rights(MailboxACL.Right.Lookup)
+ .asAddition()));
+
+ assertThat(aclDiff.changedEntries())
+ .containsOnly(new MailboxACL.Entry(ENTRY_KEY, new MailboxACL.Rfc4314Rights(MailboxACL.Right.Lookup)));
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/james-project/blob/806a52bc/mailbox/api/src/test/java/org/apache/james/mailbox/acl/PositiveUserACLDiffTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/acl/PositiveUserACLDiffTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/acl/PositiveUserACLDiffTest.java
index 1b81080..999f8c4 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/acl/PositiveUserACLDiffTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/acl/PositiveUserACLDiffTest.java
@@ -30,7 +30,9 @@ import org.junit.Test;
public class PositiveUserACLDiffTest {
- private static final EntryKey ENTRY_KEY = EntryKey.createUserEntryKey("user");
+ private static final EntryKey USER_ENTRY_KEY = EntryKey.createUserEntryKey("user");
+ private static final EntryKey NEGATIVE_USER_ENTRY_KEY = EntryKey.createUserEntryKey("user", true);
+ private static final EntryKey GROUP_ENTRY_KEY = EntryKey.createGroupEntryKey("group");
private static final Rfc4314Rights RIGHTS = new Rfc4314Rights(Right.Administer);
@Test
@@ -46,7 +48,7 @@ public class PositiveUserACLDiffTest {
public void addedEntriesShouldReturnEmptyWhenSameNonEmptyACL() throws UnsupportedRightException {
MailboxACL mailboxACL = MailboxACL.EMPTY.apply(
MailboxACL.command()
- .key(ENTRY_KEY)
+ .key(USER_ENTRY_KEY)
.rights(RIGHTS)
.asAddition());
@@ -68,7 +70,7 @@ public class PositiveUserACLDiffTest {
public void removedEntriesShouldReturnEmptyWhenSameNonEmptyACL() throws UnsupportedRightException {
MailboxACL mailboxACL = MailboxACL.EMPTY.apply(
MailboxACL.command()
- .key(ENTRY_KEY)
+ .key(USER_ENTRY_KEY)
.rights(RIGHTS)
.asAddition());
@@ -90,7 +92,7 @@ public class PositiveUserACLDiffTest {
public void changedEntriesShouldReturnEmptyWhenSameNonEmptyACL() throws UnsupportedRightException {
MailboxACL mailboxACL = MailboxACL.EMPTY.apply(
MailboxACL.command()
- .key(ENTRY_KEY)
+ .key(USER_ENTRY_KEY)
.rights(RIGHTS)
.asAddition());
@@ -98,18 +100,47 @@ public class PositiveUserACLDiffTest {
assertThat(positiveUserAclDiff.changedEntries()).isEmpty();
}
+
@Test
public void addedEntriesShouldReturnNewEntryWhenAddedEntry() throws Exception {
PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
MailboxACL.EMPTY,
MailboxACL.EMPTY.apply(
MailboxACL.command()
- .key(ENTRY_KEY)
+ .key(USER_ENTRY_KEY)
+ .rights(RIGHTS)
+ .asAddition()));
+
+ assertThat(positiveUserAclDiff.addedEntries())
+ .containsOnly(new Entry(USER_ENTRY_KEY, RIGHTS));
+ }
+
+ @Test
+ public void addedEntriesShouldFilterNonUserEntryKey() throws Exception {
+ PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
+ MailboxACL.EMPTY,
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(GROUP_ENTRY_KEY)
+ .rights(RIGHTS)
+ .asAddition()));
+
+ assertThat(positiveUserAclDiff.addedEntries())
+ .isEmpty();
+ }
+
+ @Test
+ public void addedEntriesShouldFilterNegativeUserEntryKey() throws Exception {
+ PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
+ MailboxACL.EMPTY,
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(NEGATIVE_USER_ENTRY_KEY)
.rights(RIGHTS)
.asAddition()));
assertThat(positiveUserAclDiff.addedEntries())
- .containsOnly(new Entry(ENTRY_KEY, RIGHTS));
+ .isEmpty();
}
@Test
@@ -118,7 +149,7 @@ public class PositiveUserACLDiffTest {
MailboxACL.EMPTY,
MailboxACL.EMPTY.apply(
MailboxACL.command()
- .key(ENTRY_KEY)
+ .key(USER_ENTRY_KEY)
.rights(RIGHTS)
.asAddition()));
@@ -132,7 +163,7 @@ public class PositiveUserACLDiffTest {
MailboxACL.EMPTY,
MailboxACL.EMPTY.apply(
MailboxACL.command()
- .key(ENTRY_KEY)
+ .key(USER_ENTRY_KEY)
.rights(RIGHTS)
.asAddition()));
@@ -145,7 +176,7 @@ public class PositiveUserACLDiffTest {
PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
MailboxACL.EMPTY.apply(
MailboxACL.command()
- .key(ENTRY_KEY)
+ .key(USER_ENTRY_KEY)
.rights(RIGHTS)
.asAddition()),
MailboxACL.EMPTY);
@@ -159,7 +190,7 @@ public class PositiveUserACLDiffTest {
PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
MailboxACL.EMPTY.apply(
MailboxACL.command()
- .key(ENTRY_KEY)
+ .key(USER_ENTRY_KEY)
.rights(RIGHTS)
.asAddition()),
MailboxACL.EMPTY);
@@ -173,13 +204,41 @@ public class PositiveUserACLDiffTest {
PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
MailboxACL.EMPTY.apply(
MailboxACL.command()
- .key(ENTRY_KEY)
+ .key(USER_ENTRY_KEY)
+ .rights(RIGHTS)
+ .asAddition()),
+ MailboxACL.EMPTY);
+
+ assertThat(positiveUserAclDiff.removedEntries())
+ .containsOnly(new Entry(USER_ENTRY_KEY, RIGHTS));
+ }
+
+ @Test
+ public void removedEntriesShouldFilterNonUserEntry() throws Exception {
+ PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(GROUP_ENTRY_KEY)
.rights(RIGHTS)
.asAddition()),
MailboxACL.EMPTY);
assertThat(positiveUserAclDiff.removedEntries())
- .containsOnly(new Entry(ENTRY_KEY, RIGHTS));
+ .isEmpty();
+ }
+
+ @Test
+ public void removedEntriesShouldFilterNegativeUserEntry() throws Exception {
+ PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(NEGATIVE_USER_ENTRY_KEY)
+ .rights(RIGHTS)
+ .asAddition()),
+ MailboxACL.EMPTY);
+
+ assertThat(positiveUserAclDiff.removedEntries())
+ .isEmpty();
}
@Test
@@ -187,12 +246,12 @@ public class PositiveUserACLDiffTest {
PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
MailboxACL.EMPTY.apply(
MailboxACL.command()
- .key(ENTRY_KEY)
+ .key(USER_ENTRY_KEY)
.rights(RIGHTS)
.asAddition()),
MailboxACL.EMPTY.apply(
MailboxACL.command()
- .key(ENTRY_KEY)
+ .key(USER_ENTRY_KEY)
.rights(Right.Lookup)
.asAddition()));
@@ -205,12 +264,12 @@ public class PositiveUserACLDiffTest {
PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
MailboxACL.EMPTY.apply(
MailboxACL.command()
- .key(ENTRY_KEY)
+ .key(USER_ENTRY_KEY)
.rights(RIGHTS)
.asAddition()),
MailboxACL.EMPTY.apply(
MailboxACL.command()
- .key(ENTRY_KEY)
+ .key(USER_ENTRY_KEY)
.rights(Right.Lookup)
.asAddition()));
@@ -223,16 +282,52 @@ public class PositiveUserACLDiffTest {
PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
MailboxACL.EMPTY.apply(
MailboxACL.command()
- .key(ENTRY_KEY)
+ .key(USER_ENTRY_KEY)
.rights(Right.Administer)
.asAddition()),
MailboxACL.EMPTY.apply(
MailboxACL.command()
- .key(ENTRY_KEY)
+ .key(USER_ENTRY_KEY)
.rights(Right.Lookup)
.asAddition()));
assertThat(positiveUserAclDiff.changedEntries())
- .containsOnly(new Entry(ENTRY_KEY, new Rfc4314Rights(MailboxACL.Right.Lookup)));
+ .containsOnly(new Entry(USER_ENTRY_KEY, new Rfc4314Rights(MailboxACL.Right.Lookup)));
+ }
+
+ @Test
+ public void changedEntriesShouldFilterNonUserEntry() throws Exception {
+ PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(GROUP_ENTRY_KEY)
+ .rights(Right.Administer)
+ .asAddition()),
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(GROUP_ENTRY_KEY)
+ .rights(Right.Lookup)
+ .asAddition()));
+
+ assertThat(positiveUserAclDiff.changedEntries())
+ .isEmpty();
+ }
+
+ @Test
+ public void changedEntriesShouldFilterNegativeUserEntry() throws Exception {
+ PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(NEGATIVE_USER_ENTRY_KEY)
+ .rights(Right.Administer)
+ .asAddition()),
+ MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(NEGATIVE_USER_ENTRY_KEY)
+ .rights(Right.Lookup)
+ .asAddition()));
+
+ assertThat(positiveUserAclDiff.changedEntries())
+ .isEmpty();
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[09/11] james-project git commit: MAILBOX-316 MailboxMapper should
return an aclDiff when setACL and later on we use aclDiff for listener
Posted by ad...@apache.org.
MAILBOX-316 MailboxMapper should return an aclDiff when setACL
and later on we use aclDiff for listener
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/93ad42bb
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/93ad42bb
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/93ad42bb
Branch: refs/heads/master
Commit: 93ad42bb39908630fe0e00bf86d874ccfc29b078
Parents: fdeaa5f
Author: quynhn <qn...@linagora.com>
Authored: Thu Nov 9 17:22:34 2017 +0700
Committer: quynhn <qn...@linagora.com>
Committed: Wed Nov 15 09:36:39 2017 +0700
----------------------------------------------------------------------
.../mailbox/caching/CachingMailboxMapper.java | 4 ++-
.../cassandra/mail/CassandraMailboxMapper.java | 4 +--
.../mailbox/hbase/mail/HBaseMailboxMapper.java | 4 ++-
.../mailbox/jcr/mail/JCRMailboxMapper.java | 4 ++-
.../mailbox/jpa/mail/JPAMailboxMapper.java | 4 ++-
.../jpa/mail/TransactionalMailboxMapper.java | 4 +--
.../maildir/mail/MaildirMailboxMapper.java | 4 ++-
.../inmemory/mail/InMemoryMailboxMapper.java | 4 ++-
.../james/mailbox/store/StoreRightManager.java | 4 +--
.../james/mailbox/store/mail/MailboxMapper.java | 2 +-
.../store/TestMailboxSessionMapperFactory.java | 2 +-
.../store/mail/model/MailboxMapperACLTest.java | 33 ++++++++++++++++++++
12 files changed, 58 insertions(+), 15 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/93ad42bb/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxMapper.java b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxMapper.java
index 3e8cb23..0d85d87 100644
--- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxMapper.java
+++ b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxMapper.java
@@ -117,8 +117,10 @@ public class CachingMailboxMapper implements MailboxMapper {
}
@Override
- public void setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException {
+ public ACLDiff setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException {
+ MailboxACL oldMailboxAcl = mailbox.getACL();
mailbox.setACL(mailboxACL);
+ return ACLDiff.computeDiff(oldMailboxAcl, mailboxACL);
}
private void invalidate(Mailbox mailbox) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/93ad42bb/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
index 05b9440..c9566f6 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
@@ -228,9 +228,9 @@ public class CassandraMailboxMapper implements MailboxMapper {
}
@Override
- public void setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException {
+ public ACLDiff setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException {
CassandraId cassandraId = (CassandraId) mailbox.getMailboxId();
- cassandraACLMapper.setACL(cassandraId, mailboxACL);
+ return cassandraACLMapper.setACL(cassandraId, mailboxACL);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/93ad42bb/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapper.java b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapper.java
index a58e01a..b5926e4 100644
--- a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapper.java
+++ b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapper.java
@@ -426,8 +426,10 @@ public class HBaseMailboxMapper extends HBaseNonTransactionalMapper implements M
}
@Override
- public void setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException {
+ public ACLDiff setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException {
+ MailboxACL oldMailboxAcl = mailbox.getACL();
mailbox.setACL(mailboxACL);
+ return ACLDiff.computeDiff(oldMailboxAcl, mailboxACL);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/93ad42bb/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMailboxMapper.java b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMailboxMapper.java
index 099178b..7f36287 100644
--- a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMailboxMapper.java
+++ b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMailboxMapper.java
@@ -263,8 +263,10 @@ public class JCRMailboxMapper extends AbstractJCRScalingMapper implements Mailbo
}
@Override
- public void setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException {
+ public ACLDiff setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException {
+ MailboxACL oldMailboxAcl = mailbox.getACL();
mailbox.setACL(mailboxACL);
+ return ACLDiff.computeDiff(oldMailboxAcl, mailboxACL);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/93ad42bb/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java
index 4077bc9..d3ba362 100644
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java
+++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java
@@ -232,8 +232,10 @@ public class JPAMailboxMapper extends JPATransactionalMapper implements MailboxM
}
@Override
- public void setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException {
+ public ACLDiff setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException {
+ MailboxACL oldMailboxAcl = mailbox.getACL();
mailbox.setACL(mailboxACL);
+ return ACLDiff.computeDiff(oldMailboxAcl, mailboxACL);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/93ad42bb/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java
index 6149f5c..c1ba844 100644
--- a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java
+++ b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java
@@ -86,8 +86,8 @@ public class TransactionalMailboxMapper implements MailboxMapper {
}
@Override
- public void setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException {
- wrapped.setACL(mailbox, mailboxACL);
+ public ACLDiff setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException {
+ return wrapped.setACL(mailbox, mailboxACL);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/93ad42bb/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
index d8c541f..e9b9e1d 100644
--- a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
+++ b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
@@ -347,10 +347,12 @@ public class MaildirMailboxMapper extends NonTransactionalMapper implements Mail
}
@Override
- public void setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException {
+ public ACLDiff setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException {
+ MailboxACL oldAcl = mailbox.getACL();
MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
folder.setACL(session, mailboxACL);
mailbox.setACL(mailboxACL);
+ return ACLDiff.computeDiff(oldAcl, mailboxACL);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/93ad42bb/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java
index de29e84..09fa357 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java
@@ -167,8 +167,10 @@ public class InMemoryMailboxMapper implements MailboxMapper {
}
@Override
- public void setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException {
+ public ACLDiff setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException {
+ MailboxACL oldMailboxAcl = mailbox.getACL();
mailboxesByPath.get(mailbox.generateAssociatedPath()).setACL(mailboxACL);
+ return ACLDiff.computeDiff(oldMailboxAcl, mailboxACL);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/93ad42bb/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
index 6ccff13..ef4a31b 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
@@ -45,7 +45,6 @@ import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.MailboxMapper;
import org.apache.james.mailbox.store.mail.model.Mailbox;
-import org.apache.james.mailbox.store.transaction.Mapper;
import com.github.fge.lambdas.Throwing;
import com.google.common.annotations.VisibleForTesting;
@@ -207,9 +206,8 @@ public class StoreRightManager implements RightManager {
}
private void setRights(MailboxACL mailboxACL, MailboxMapper mapper, Mailbox mailbox, MailboxSession session) throws MailboxException {
- mapper.execute(Mapper.toTransaction(() -> mapper.setACL(mailbox, mailboxACL)));
+ ACLDiff aclDiff = mapper.setACL(mailbox, mailboxACL);
- ACLDiff aclDiff = ACLDiff.computeDiff(mailbox.getACL(), mailboxACL);
dispatcher.aclUpdated(session, mailbox.generateAssociatedPath(), aclDiff);
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/93ad42bb/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/MailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/MailboxMapper.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/MailboxMapper.java
index d419e7a..8f68d5c 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/MailboxMapper.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/MailboxMapper.java
@@ -121,7 +121,7 @@ public interface MailboxMapper extends Mapper {
* @param mailbox Mailbox for whom we want to update ACL
* @param mailboxACL New value of the ACL for this mailbox
*/
- void setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException;
+ ACLDiff setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException;
/**
* Return a unmodifable {@link List} of all {@link Mailbox}
http://git-wip-us.apache.org/repos/asf/james-project/blob/93ad42bb/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestMailboxSessionMapperFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestMailboxSessionMapperFactory.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestMailboxSessionMapperFactory.java
index f82f66e..f356d94 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestMailboxSessionMapperFactory.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestMailboxSessionMapperFactory.java
@@ -144,7 +144,7 @@ public class TestMailboxSessionMapperFactory extends MailboxSessionMapperFactory
}
@Override
- public void setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException {
+ public ACLDiff setACL(Mailbox mailbox, MailboxACL mailboxACL) throws MailboxException {
throw new NotImplementedException("Not implemented");
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/93ad42bb/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java
index aba69b9..2232a7d 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java
@@ -20,7 +20,10 @@
package org.apache.james.mailbox.store.mail.model;
import static org.assertj.core.api.Assertions.assertThat;
+import static org.assertj.core.api.Assertions.assertThatThrownBy;
+import org.apache.james.mailbox.acl.ACLDiff;
+import org.apache.james.mailbox.acl.MailboxACLResolver;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.model.MailboxACL;
import org.apache.james.mailbox.model.MailboxACL.EntryKey;
@@ -412,4 +415,34 @@ public abstract class MailboxMapperACLTest {
.hasSize(1)
.containsEntry(key, rights);
}
+
+ @Test
+ public void setACLShouldReturnACLDiff() throws MailboxException {
+ EntryKey key = EntryKey.createUserEntryKey("user");
+ Rfc4314Rights rights = new Rfc4314Rights(Right.WriteSeenFlag, Right.CreateMailbox, Right.Administer, Right.PerformExpunge, Right.DeleteMessages);
+
+ ACLDiff expectAclDiff = ACLDiff.computeDiff(MailboxACL.EMPTY, MailboxACL.EMPTY.apply(
+ MailboxACL.command()
+ .key(key)
+ .rights(rights)
+ .asAddition()));
+
+ assertThat(mailboxMapper.setACL(benwaInboxMailbox,
+ new MailboxACL(ImmutableMap.of(key, rights)))).isEqualTo(expectAclDiff);
+ }
+
+ @Test
+ public void updateACLShouldReturnACLDiff() throws MailboxException {
+ EntryKey key = EntryKey.createUserEntryKey("user");
+ Rfc4314Rights rights = new Rfc4314Rights(Right.WriteSeenFlag, Right.CreateMailbox, Right.Administer, Right.PerformExpunge, Right.DeleteMessages);
+
+ MailboxACL.ACLCommand aclCommand = MailboxACL.command()
+ .key(key)
+ .rights(rights)
+ .asAddition();
+
+ ACLDiff expectAclDiff = ACLDiff.computeDiff(MailboxACL.EMPTY, MailboxACL.EMPTY.apply(aclCommand));
+
+ assertThat(mailboxMapper.updateACL(benwaInboxMailbox, aclCommand)).isEqualTo(expectAclDiff);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[08/11] james-project git commit: MAILBOX-316 MailboxMapper should
return an aclDiff when updateACL and later on we use aclDiff for listener
Posted by ad...@apache.org.
MAILBOX-316 MailboxMapper should return an aclDiff when updateACL
and later on we use aclDiff for listener
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/fdeaa5f1
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/fdeaa5f1
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/fdeaa5f1
Branch: refs/heads/master
Commit: fdeaa5f15ed0c2efcfafdc777c2268fd41e79734
Parents: 2462904
Author: quynhn <qn...@linagora.com>
Authored: Tue Nov 7 18:09:47 2017 +0700
Committer: quynhn <qn...@linagora.com>
Committed: Wed Nov 15 09:35:58 2017 +0700
----------------------------------------------------------------------
.../james/mailbox/acl/PositiveUserACLDiff.java | 2 +-
.../mailbox/caching/CachingMailboxMapper.java | 8 ++++--
.../cassandra/mail/CassandraACLMapper.java | 24 +++++++++--------
.../cassandra/mail/CassandraMailboxMapper.java | 5 ++--
.../mail/CassandraUserMailboxRightsDAO.java | 12 ++++-----
.../mail/CassandraUserMailboxRightsDAOTest.java | 27 ++++++++++++--------
.../mailbox/hbase/mail/HBaseMailboxMapper.java | 8 ++++--
.../mailbox/jcr/mail/JCRMailboxMapper.java | 8 ++++--
.../mailbox/jpa/mail/JPAMailboxMapper.java | 8 ++++--
.../jpa/mail/TransactionalMailboxMapper.java | 5 ++--
.../maildir/mail/MaildirMailboxMapper.java | 5 +++-
.../inmemory/mail/InMemoryMailboxMapper.java | 8 ++++--
.../james/mailbox/store/StoreRightManager.java | 3 +--
.../james/mailbox/store/mail/MailboxMapper.java | 3 ++-
.../store/TestMailboxSessionMapperFactory.java | 3 ++-
15 files changed, 82 insertions(+), 47 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/fdeaa5f1/mailbox/api/src/main/java/org/apache/james/mailbox/acl/PositiveUserACLDiff.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/acl/PositiveUserACLDiff.java b/mailbox/api/src/main/java/org/apache/james/mailbox/acl/PositiveUserACLDiff.java
index 062a6a1..bfe3aa7 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/acl/PositiveUserACLDiff.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/acl/PositiveUserACLDiff.java
@@ -25,7 +25,7 @@ import org.apache.james.mailbox.model.MailboxACL;
public class PositiveUserACLDiff {
private final ACLDiff aclDiff;
- private PositiveUserACLDiff(ACLDiff aclDiff) {
+ public PositiveUserACLDiff(ACLDiff aclDiff) {
this.aclDiff = aclDiff;
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/fdeaa5f1/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxMapper.java b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxMapper.java
index c368a75..3e8cb23 100644
--- a/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxMapper.java
+++ b/mailbox/caching/src/main/java/org/apache/james/mailbox/caching/CachingMailboxMapper.java
@@ -21,6 +21,7 @@ package org.apache.james.mailbox.caching;
import java.util.List;
+import org.apache.james.mailbox.acl.ACLDiff;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.exception.MailboxNotFoundException;
import org.apache.james.mailbox.model.MailboxACL;
@@ -108,8 +109,11 @@ public class CachingMailboxMapper implements MailboxMapper {
}
@Override
- public void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException {
- mailbox.setACL(mailbox.getACL().apply(mailboxACLCommand));
+ public ACLDiff updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException {
+ MailboxACL oldACL = mailbox.getACL();
+ MailboxACL newACL = mailbox.getACL().apply(mailboxACLCommand);
+ mailbox.setACL(newACL);
+ return ACLDiff.computeDiff(oldACL, newACL);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/fdeaa5f1/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapper.java
index cd92520..5503f4b 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapper.java
@@ -37,7 +37,7 @@ import org.apache.james.backends.cassandra.init.CassandraConfiguration;
import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor;
import org.apache.james.backends.cassandra.utils.FunctionRunnerWithRetry;
import org.apache.james.backends.cassandra.utils.LightweightTransactionException;
-import org.apache.james.mailbox.acl.PositiveUserACLChanged;
+import org.apache.james.mailbox.acl.ACLDiff;
import org.apache.james.mailbox.cassandra.ids.CassandraId;
import org.apache.james.mailbox.cassandra.table.CassandraACLTable;
import org.apache.james.mailbox.cassandra.table.CassandraMailboxTable;
@@ -126,23 +126,27 @@ public class CassandraACLMapper {
return deserializeACL(cassandraId, serializedACL);
}
- public void updateACL(CassandraId cassandraId, MailboxACL.ACLCommand command) throws MailboxException {
+ public ACLDiff updateACL(CassandraId cassandraId, MailboxACL.ACLCommand command) throws MailboxException {
MailboxACL replacement = MailboxACL.EMPTY.apply(command);
- PositiveUserACLChanged positiveUserAclChanged = updateAcl(cassandraId, aclWithVersion -> aclWithVersion.apply(command), replacement);
+ ACLDiff aclDiff = updateAcl(cassandraId, aclWithVersion -> aclWithVersion.apply(command), replacement);
- userMailboxRightsDAO.update(cassandraId, positiveUserAclChanged).join();
+ return userMailboxRightsDAO.update(cassandraId, aclDiff)
+ .thenApply(any -> aclDiff)
+ .join();
}
- public void setACL(CassandraId cassandraId, MailboxACL mailboxACL) throws MailboxException {
- PositiveUserACLChanged positiveUserAclChanged = updateAcl(cassandraId,
+ public ACLDiff setACL(CassandraId cassandraId, MailboxACL mailboxACL) throws MailboxException {
+ ACLDiff aclDiff = updateAcl(cassandraId,
acl -> new ACLWithVersion(acl.version, mailboxACL),
mailboxACL);
- userMailboxRightsDAO.update(cassandraId, positiveUserAclChanged).join();
+ return userMailboxRightsDAO.update(cassandraId, aclDiff)
+ .thenApply(any -> aclDiff)
+ .join();
}
- private PositiveUserACLChanged updateAcl(CassandraId cassandraId, Function<ACLWithVersion, ACLWithVersion> aclTransformation, MailboxACL replacement) throws MailboxException {
+ private ACLDiff updateAcl(CassandraId cassandraId, Function<ACLWithVersion, ACLWithVersion> aclTransformation, MailboxACL replacement) throws MailboxException {
try {
return new FunctionRunnerWithRetry(maxRetry)
.executeAndRetrieveObject(
@@ -151,9 +155,9 @@ public class CassandraACLMapper {
return getAclWithVersion(cassandraId)
.map(aclWithVersion ->
updateStoredACL(cassandraId, aclTransformation.apply(aclWithVersion))
- .map(newACL -> new PositiveUserACLChanged(aclWithVersion.mailboxACL, newACL)))
+ .map(newACL -> ACLDiff.computeDiff(aclWithVersion.mailboxACL, newACL)))
.orElseGet(() -> insertACL(cassandraId, replacement)
- .map(newACL -> new PositiveUserACLChanged(MailboxACL.EMPTY, newACL)));
+ .map(newACL -> ACLDiff.computeDiff(MailboxACL.EMPTY, newACL)));
});
} catch (LightweightTransactionException e) {
throw new MailboxException("Exception during lightweight transaction", e);
http://git-wip-us.apache.org/repos/asf/james-project/blob/fdeaa5f1/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
index 25723ff..05b9440 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
@@ -34,6 +34,7 @@ import javax.inject.Inject;
import org.apache.commons.lang3.StringUtils;
import org.apache.james.backends.cassandra.init.CassandraConfiguration;
+import org.apache.james.mailbox.acl.ACLDiff;
import org.apache.james.mailbox.cassandra.ids.CassandraId;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.exception.MailboxExistsException;
@@ -221,9 +222,9 @@ public class CassandraMailboxMapper implements MailboxMapper {
}
@Override
- public void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException {
+ public ACLDiff updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException {
CassandraId cassandraId = (CassandraId) mailbox.getMailboxId();
- cassandraACLMapper.updateACL(cassandraId, mailboxACLCommand);
+ return cassandraACLMapper.updateACL(cassandraId, mailboxACLCommand);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/fdeaa5f1/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAO.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAO.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAO.java
index 89173de..7f93150 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAO.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAO.java
@@ -38,7 +38,7 @@ import javax.inject.Inject;
import org.apache.commons.lang3.tuple.Pair;
import org.apache.james.backends.cassandra.utils.CassandraAsyncExecutor;
import org.apache.james.backends.cassandra.utils.CassandraUtils;
-import org.apache.james.mailbox.acl.PositiveUserACLChanged;
+import org.apache.james.mailbox.acl.ACLDiff;
import org.apache.james.mailbox.acl.PositiveUserACLDiff;
import org.apache.james.mailbox.cassandra.ids.CassandraId;
import org.apache.james.mailbox.exception.UnsupportedRightException;
@@ -98,12 +98,12 @@ public class CassandraUserMailboxRightsDAO {
.where(eq(USER_NAME, bindMarker(USER_NAME))));
}
- public CompletableFuture<Void> update(CassandraId cassandraId, PositiveUserACLChanged positiveUserAclChanged) {
- PositiveUserACLDiff positiveUserAclDiff = PositiveUserACLDiff.computeDiff(positiveUserAclChanged.getOldACL(), positiveUserAclChanged.getNewACL());
+ public CompletableFuture<Void> update(CassandraId cassandraId, ACLDiff aclDiff) {
+ PositiveUserACLDiff userACLDiff = new PositiveUserACLDiff(aclDiff);
return CompletableFuture.allOf(
- addAll(cassandraId, positiveUserAclDiff.addedEntries()),
- removeAll(cassandraId, positiveUserAclDiff.removedEntries()),
- addAll(cassandraId, positiveUserAclDiff.changedEntries()));
+ addAll(cassandraId, userACLDiff.addedEntries()),
+ removeAll(cassandraId, userACLDiff.removedEntries()),
+ addAll(cassandraId, userACLDiff.changedEntries()));
}
private CompletableFuture<Stream<Void>> removeAll(CassandraId cassandraId, Stream<MailboxACL.Entry> removedEntries) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/fdeaa5f1/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAOTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAOTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAOTest.java
index 6690eae..bb309cd 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAOTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraUserMailboxRightsDAOTest.java
@@ -23,7 +23,7 @@ import static org.assertj.core.api.Assertions.assertThat;
import org.apache.james.backends.cassandra.CassandraCluster;
import org.apache.james.backends.cassandra.DockerCassandraRule;
import org.apache.james.backends.cassandra.utils.CassandraUtils;
-import org.apache.james.mailbox.acl.PositiveUserACLChanged;
+import org.apache.james.mailbox.acl.ACLDiff;
import org.apache.james.mailbox.cassandra.ids.CassandraId;
import org.apache.james.mailbox.cassandra.modules.CassandraAclModule;
import org.apache.james.mailbox.model.MailboxACL;
@@ -63,9 +63,10 @@ public class CassandraUserMailboxRightsDAOTest {
@Test
public void saveShouldInsertNewEntry() throws Exception {
- testee.update(MAILBOX_ID, new PositiveUserACLChanged(
+ testee.update(MAILBOX_ID, ACLDiff.computeDiff(
MailboxACL.EMPTY,
- new MailboxACL(new Entry(ENTRY_KEY, RIGHTS)))).join();
+ new MailboxACL(new Entry(ENTRY_KEY, RIGHTS))))
+ .join();
assertThat(testee.retrieve(USER_NAME, MAILBOX_ID).join())
.contains(RIGHTS);
@@ -73,13 +74,15 @@ public class CassandraUserMailboxRightsDAOTest {
@Test
public void saveOnSecondShouldOverwrite() throws Exception {
- testee.update(MAILBOX_ID, new PositiveUserACLChanged(
+ testee.update(MAILBOX_ID, ACLDiff.computeDiff(
MailboxACL.EMPTY,
- new MailboxACL(new Entry(ENTRY_KEY, RIGHTS)))).join();
+ new MailboxACL(new Entry(ENTRY_KEY, RIGHTS))))
+ .join();
- testee.update(MAILBOX_ID, new PositiveUserACLChanged(
+ testee.update(MAILBOX_ID, ACLDiff.computeDiff(
new MailboxACL(new Entry(ENTRY_KEY, RIGHTS)),
- new MailboxACL(new Entry(ENTRY_KEY, OTHER_RIGHTS)))).join();
+ new MailboxACL(new Entry(ENTRY_KEY, OTHER_RIGHTS))))
+ .join();
assertThat(testee.retrieve(USER_NAME, MAILBOX_ID).join())
.contains(OTHER_RIGHTS);
@@ -93,14 +96,16 @@ public class CassandraUserMailboxRightsDAOTest {
@Test
public void deleteShouldDeleteWhenExisting() throws Exception {
- testee.update(MAILBOX_ID, new PositiveUserACLChanged(
+ testee.update(MAILBOX_ID, ACLDiff.computeDiff(
MailboxACL.EMPTY,
- new MailboxACL(new Entry(ENTRY_KEY, RIGHTS)))).join();
+ new MailboxACL(new Entry(ENTRY_KEY, RIGHTS))))
+ .join();
- testee.update(MAILBOX_ID, new PositiveUserACLChanged(
+ testee.update(MAILBOX_ID, ACLDiff.computeDiff(
new MailboxACL(new Entry(ENTRY_KEY, RIGHTS)),
- MailboxACL.EMPTY)).join();
+ MailboxACL.EMPTY))
+ .join();
assertThat(testee.retrieve(USER_NAME, MAILBOX_ID).join())
.isEmpty();
http://git-wip-us.apache.org/repos/asf/james-project/blob/fdeaa5f1/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapper.java b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapper.java
index 77244e2..a58e01a 100644
--- a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapper.java
+++ b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/HBaseMailboxMapper.java
@@ -49,6 +49,7 @@ import org.apache.hadoop.hbase.filter.SingleColumnValueFilter;
import org.apache.hadoop.hbase.filter.SubstringComparator;
import org.apache.hadoop.hbase.util.Bytes;
import org.apache.hadoop.io.IOUtils;
+import org.apache.james.mailbox.acl.ACLDiff;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.exception.MailboxNotFoundException;
import org.apache.james.mailbox.hbase.HBaseId;
@@ -417,8 +418,11 @@ public class HBaseMailboxMapper extends HBaseNonTransactionalMapper implements M
}
@Override
- public void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException {
- mailbox.setACL(mailbox.getACL().apply(mailboxACLCommand));
+ public ACLDiff updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException {
+ MailboxACL oldACL = mailbox.getACL();
+ MailboxACL newACL = mailbox.getACL().apply(mailboxACLCommand);
+ mailbox.setACL(newACL);
+ return ACLDiff.computeDiff(oldACL, newACL);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/fdeaa5f1/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMailboxMapper.java b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMailboxMapper.java
index 4eeb0f2..099178b 100644
--- a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMailboxMapper.java
+++ b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/JCRMailboxMapper.java
@@ -34,6 +34,7 @@ import org.apache.jackrabbit.commons.JcrUtils;
import org.apache.jackrabbit.util.ISO9075;
import org.apache.jackrabbit.util.Text;
import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.acl.ACLDiff;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.exception.MailboxNotFoundException;
import org.apache.james.mailbox.jcr.AbstractJCRScalingMapper;
@@ -254,8 +255,11 @@ public class JCRMailboxMapper extends AbstractJCRScalingMapper implements Mailbo
}
@Override
- public void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException {
- mailbox.setACL(mailbox.getACL().apply(mailboxACLCommand));
+ public ACLDiff updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException {
+ MailboxACL oldACL = mailbox.getACL();
+ MailboxACL newACL = mailbox.getACL().apply(mailboxACLCommand);
+ mailbox.setACL(newACL);
+ return ACLDiff.computeDiff(oldACL, newACL);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/fdeaa5f1/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java
index d103528..4077bc9 100644
--- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java
+++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/JPAMailboxMapper.java
@@ -27,6 +27,7 @@ import javax.persistence.NoResultException;
import javax.persistence.PersistenceException;
import javax.persistence.RollbackException;
+import org.apache.james.mailbox.acl.ACLDiff;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.exception.MailboxExistsException;
import org.apache.james.mailbox.exception.MailboxNotFoundException;
@@ -223,8 +224,11 @@ public class JPAMailboxMapper extends JPATransactionalMapper implements MailboxM
}
@Override
- public void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException {
- mailbox.setACL(mailbox.getACL().apply(mailboxACLCommand));
+ public ACLDiff updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException {
+ MailboxACL oldACL = mailbox.getACL();
+ MailboxACL newACL = mailbox.getACL().apply(mailboxACLCommand);
+ mailbox.setACL(newACL);
+ return ACLDiff.computeDiff(oldACL, newACL);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/fdeaa5f1/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java
index b1f2cca..6149f5c 100644
--- a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java
+++ b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/mail/TransactionalMailboxMapper.java
@@ -22,6 +22,7 @@ package org.apache.james.mailbox.jpa.mail;
import java.util.List;
import org.apache.commons.lang.NotImplementedException;
+import org.apache.james.mailbox.acl.ACLDiff;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.exception.MailboxNotFoundException;
import org.apache.james.mailbox.model.MailboxACL;
@@ -80,8 +81,8 @@ public class TransactionalMailboxMapper implements MailboxMapper {
}
@Override
- public void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException {
- wrapped.updateACL(mailbox, mailboxACLCommand);
+ public ACLDiff updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException {
+ return wrapped.updateACL(mailbox, mailboxACLCommand);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/fdeaa5f1/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
index 16ed62a..d8c541f 100644
--- a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
+++ b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/mail/MaildirMailboxMapper.java
@@ -27,6 +27,7 @@ import java.util.regex.Pattern;
import org.apache.commons.io.FileUtils;
import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.acl.ACLDiff;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.exception.MailboxExistsException;
import org.apache.james.mailbox.exception.MailboxNotFoundException;
@@ -336,11 +337,13 @@ public class MaildirMailboxMapper extends NonTransactionalMapper implements Mail
}
@Override
- public void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException {
+ public ACLDiff updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException {
MaildirFolder folder = maildirStore.createMaildirFolder(mailbox);
+ MailboxACL oldACL = mailbox.getACL();
MailboxACL newACL = mailbox.getACL().apply(mailboxACLCommand);
folder.setACL(session, newACL);
mailbox.setACL(newACL);
+ return ACLDiff.computeDiff(oldACL, newACL);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/fdeaa5f1/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java
index deca945..de29e84 100644
--- a/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java
+++ b/mailbox/memory/src/main/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxMapper.java
@@ -24,6 +24,7 @@ import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
+import org.apache.james.mailbox.acl.ACLDiff;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.exception.MailboxExistsException;
import org.apache.james.mailbox.exception.MailboxNotFoundException;
@@ -158,8 +159,11 @@ public class InMemoryMailboxMapper implements MailboxMapper {
}
@Override
- public void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException{
- mailboxesByPath.get(mailbox.generateAssociatedPath()).setACL(mailbox.getACL().apply(mailboxACLCommand));
+ public ACLDiff updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException{
+ MailboxACL oldACL = mailbox.getACL();
+ MailboxACL newACL = mailbox.getACL().apply(mailboxACLCommand);
+ mailboxesByPath.get(mailbox.generateAssociatedPath()).setACL(newACL);
+ return ACLDiff.computeDiff(oldACL, newACL);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/fdeaa5f1/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
index 66516c4..6ccff13 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
@@ -129,9 +129,8 @@ public class StoreRightManager implements RightManager {
assertSharesBelongsToUserDomain(mailboxPath.getUser(), mailboxACLCommand);
MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(session);
Mailbox mailbox = mapper.findMailboxByPath(mailboxPath);
- mapper.execute(Mapper.toTransaction(() -> mapper.updateACL(mailbox, mailboxACLCommand)));
+ ACLDiff aclDiff = mapper.updateACL(mailbox, mailboxACLCommand);
- ACLDiff aclDiff = ACLDiff.computeDiff(mailbox.getACL(), mailbox.getACL().apply(mailboxACLCommand));
dispatcher.aclUpdated(session, mailboxPath, aclDiff);
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/fdeaa5f1/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/MailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/MailboxMapper.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/MailboxMapper.java
index 0409f88..d419e7a 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/MailboxMapper.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/mail/MailboxMapper.java
@@ -20,6 +20,7 @@ package org.apache.james.mailbox.store.mail;
import java.util.List;
+import org.apache.james.mailbox.acl.ACLDiff;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.exception.MailboxNotFoundException;
import org.apache.james.mailbox.model.MailboxACL;
@@ -112,7 +113,7 @@ public interface MailboxMapper extends Mapper {
* @param mailbox Mailbox for whom we want to update ACL
* @param mailboxACLCommand Update to perform
*/
- void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException;
+ ACLDiff updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException;
/**
* Reset the ACL of the stored mailbox.
http://git-wip-us.apache.org/repos/asf/james-project/blob/fdeaa5f1/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestMailboxSessionMapperFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestMailboxSessionMapperFactory.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestMailboxSessionMapperFactory.java
index 66d3cf4..f82f66e 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestMailboxSessionMapperFactory.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/TestMailboxSessionMapperFactory.java
@@ -37,6 +37,7 @@ import org.apache.commons.lang3.NotImplementedException;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.MessageManager;
import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.acl.ACLDiff;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.exception.MailboxNotFoundException;
import org.apache.james.mailbox.exception.SubscriptionException;
@@ -138,7 +139,7 @@ public class TestMailboxSessionMapperFactory extends MailboxSessionMapperFactory
}
@Override
- public void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException {
+ public ACLDiff updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException {
throw new NotImplementedException("Not implemented");
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[05/11] james-project git commit: MAILBOX-316 StoreRightManager
dispatchs even to update 'l' right on parent when set right on child
Posted by ad...@apache.org.
MAILBOX-316 StoreRightManager dispatchs even to update 'l' right on
parent when set right on child
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/2aa77b5e
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/2aa77b5e
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/2aa77b5e
Branch: refs/heads/master
Commit: 2aa77b5e45b56affa733bf46ec7cf96d99a093dc
Parents: 75622f7
Author: quynhn <qn...@linagora.com>
Authored: Mon Nov 6 16:06:17 2017 +0700
Committer: quynhn <qn...@linagora.com>
Committed: Wed Nov 15 09:33:58 2017 +0700
----------------------------------------------------------------------
.../apache/james/mailbox/store/StoreRightManager.java | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/2aa77b5e/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
index 51c021f..66516c4 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
@@ -28,6 +28,7 @@ import javax.mail.Flags;
import org.apache.james.core.User;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.RightManager;
+import org.apache.james.mailbox.acl.ACLDiff;
import org.apache.james.mailbox.acl.GroupMembershipResolver;
import org.apache.james.mailbox.acl.MailboxACLResolver;
import org.apache.james.mailbox.exception.DifferentDomainException;
@@ -129,6 +130,9 @@ public class StoreRightManager implements RightManager {
MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(session);
Mailbox mailbox = mapper.findMailboxByPath(mailboxPath);
mapper.execute(Mapper.toTransaction(() -> mapper.updateACL(mailbox, mailboxACLCommand)));
+
+ ACLDiff aclDiff = ACLDiff.computeDiff(mailbox.getACL(), mailbox.getACL().apply(mailboxACLCommand));
+ dispatcher.aclUpdated(session, mailboxPath, aclDiff);
}
private void assertSharesBelongsToUserDomain(String user, ACLCommand mailboxACLCommand) throws DifferentDomainException {
@@ -183,7 +187,7 @@ public class StoreRightManager implements RightManager {
MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(session);
Mailbox mailbox = mapper.findMailboxByPath(mailboxPath);
- setRights(mailboxACL, mapper, mailbox);
+ setRights(mailboxACL, mapper, mailbox, session);
}
@VisibleForTesting
@@ -203,8 +207,11 @@ public class StoreRightManager implements RightManager {
return !domain.equals(otherDomain);
}
- private void setRights(MailboxACL mailboxACL, MailboxMapper mapper, Mailbox mailbox) throws MailboxException {
+ private void setRights(MailboxACL mailboxACL, MailboxMapper mapper, Mailbox mailbox, MailboxSession session) throws MailboxException {
mapper.execute(Mapper.toTransaction(() -> mapper.setACL(mailbox, mailboxACL)));
+
+ ACLDiff aclDiff = ACLDiff.computeDiff(mailbox.getACL(), mailboxACL);
+ dispatcher.aclUpdated(session, mailbox.generateAssociatedPath(), aclDiff);
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[06/11] james-project git commit: MAILBOX-316 New JMAP listener for
adding lookup right to parent mailbox when child mailbox has 'l' right
Posted by ad...@apache.org.
MAILBOX-316 New JMAP listener for adding lookup right to parent
mailbox when child mailbox has 'l' right
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/75622f7b
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/75622f7b
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/75622f7b
Branch: refs/heads/master
Commit: 75622f7b13c73b745f8bb812e206d83ce36ed0a2
Parents: ef4b79c
Author: quynhn <qn...@linagora.com>
Authored: Mon Nov 6 16:04:21 2017 +0700
Committer: quynhn <qn...@linagora.com>
Committed: Wed Nov 15 09:33:58 2017 +0700
----------------------------------------------------------------------
.../modules/mailbox/CassandraMailboxModule.java | 4 +
.../modules/mailbox/MemoryMailboxModule.java | 4 +
server/protocols/jmap/pom.xml | 4 +
.../event/PropagateLookupRightListener.java | 128 +++++++
.../event/PropagateLookupRightListenerTest.java | 340 +++++++++++++++++++
5 files changed, 480 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/75622f7b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
index 220f351..35e524c 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java
@@ -28,6 +28,7 @@ import org.apache.james.mailbox.BlobManager;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxPathLocker;
import org.apache.james.mailbox.MessageIdManager;
+import org.apache.james.mailbox.RightManager;
import org.apache.james.mailbox.SubscriptionManager;
import org.apache.james.mailbox.cassandra.CassandraMailboxManager;
import org.apache.james.mailbox.cassandra.CassandraMailboxSessionMapperFactory;
@@ -59,6 +60,7 @@ import org.apache.james.mailbox.store.NoMailboxPathLocker;
import org.apache.james.mailbox.store.StoreAttachmentManager;
import org.apache.james.mailbox.store.StoreBlobManager;
import org.apache.james.mailbox.store.StoreMessageIdManager;
+import org.apache.james.mailbox.store.StoreRightManager;
import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.AttachmentMapperFactory;
import org.apache.james.mailbox.store.mail.MailboxMapperFactory;
@@ -107,6 +109,7 @@ public class CassandraMailboxModule extends AbstractModule {
bind(CassandraUserMailboxRightsDAO.class).in(Scopes.SINGLETON);
bind(CassandraACLMapper.class).in(Scopes.SINGLETON);
bind(StoreBlobManager.class).in(Scopes.SINGLETON);
+ bind(StoreRightManager.class).in(Scopes.SINGLETON);
bind(BlobManager.class).to(StoreBlobManager.class);
bind(MessageMapperFactory.class).to(CassandraMailboxSessionMapperFactory.class);
@@ -125,6 +128,7 @@ public class CassandraMailboxModule extends AbstractModule {
bind(MessageId.Factory.class).to(CassandraMessageId.Factory.class);
bind(MessageIdManager.class).to(StoreMessageIdManager.class);
bind(AttachmentManager.class).to(StoreAttachmentManager.class);
+ bind(RightManager.class).to(StoreRightManager.class);
Multibinder<CassandraModule> cassandraDataDefinitions = Multibinder.newSetBinder(binder(), CassandraModule.class);
cassandraDataDefinitions.addBinding().to(org.apache.james.mailbox.cassandra.modules.CassandraAclModule.class);
http://git-wip-us.apache.org/repos/asf/james-project/blob/75622f7b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
index 204dbf3..32349e8 100644
--- a/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
+++ b/server/container/guice/memory-guice/src/main/java/org/apache/james/modules/mailbox/MemoryMailboxModule.java
@@ -28,6 +28,7 @@ import org.apache.james.mailbox.BlobManager;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxPathLocker;
import org.apache.james.mailbox.MessageIdManager;
+import org.apache.james.mailbox.RightManager;
import org.apache.james.mailbox.SubscriptionManager;
import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.extractor.TextExtractor;
@@ -49,6 +50,7 @@ import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
import org.apache.james.mailbox.store.StoreAttachmentManager;
import org.apache.james.mailbox.store.StoreBlobManager;
import org.apache.james.mailbox.store.StoreMessageIdManager;
+import org.apache.james.mailbox.store.StoreRightManager;
import org.apache.james.mailbox.store.StoreSubscriptionManager;
import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.AttachmentMapperFactory;
@@ -99,6 +101,7 @@ public class MemoryMailboxModule extends AbstractModule {
bind(MessageSearchIndex.class).to(SimpleMessageSearchIndex.class);
bind(TextExtractor.class).to(JsoupTextExtractor.class);
+ bind(RightManager.class).to(StoreRightManager.class);
bind(StoreBlobManager.class).in(Scopes.SINGLETON);
bind(InMemoryMailboxSessionMapperFactory.class).in(Scopes.SINGLETON);
@@ -113,6 +116,7 @@ public class MemoryMailboxModule extends AbstractModule {
bind(StoreMessageIdManager.class).in(Scopes.SINGLETON);
bind(MailboxEventDispatcher.class).in(Scopes.SINGLETON);
bind(StoreAttachmentManager.class).in(Scopes.SINGLETON);
+ bind(StoreRightManager.class).in(Scopes.SINGLETON);
Multibinder.newSetBinder(binder(), MailboxManagerDefinition.class)
.addBinding()
http://git-wip-us.apache.org/repos/asf/james-project/blob/75622f7b/server/protocols/jmap/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/pom.xml b/server/protocols/jmap/pom.xml
index 5cebbd0..f03b6e4 100644
--- a/server/protocols/jmap/pom.xml
+++ b/server/protocols/jmap/pom.xml
@@ -45,6 +45,10 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
+ <artifactId>apache-james-mailbox-store</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
<artifactId>apache-james-mailbox-memory</artifactId>
<scope>test</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/75622f7b/server/protocols/jmap/src/main/java/org/apache/james/jmap/event/PropagateLookupRightListener.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/event/PropagateLookupRightListener.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/event/PropagateLookupRightListener.java
new file mode 100644
index 0000000..fe12d68
--- /dev/null
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/event/PropagateLookupRightListener.java
@@ -0,0 +1,128 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.jmap.event;
+
+import java.util.stream.Stream;
+
+import javax.inject.Inject;
+
+import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.RightManager;
+import org.apache.james.mailbox.acl.ACLDiff;
+import org.apache.james.mailbox.exception.MailboxException;
+import org.apache.james.mailbox.model.MailboxACL;
+import org.apache.james.mailbox.model.MailboxACL.Entry;
+import org.apache.james.mailbox.model.MailboxACL.Right;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.base.Throwables;
+
+public class PropagateLookupRightListener implements MailboxListener {
+ private static final Logger LOGGER = LoggerFactory.getLogger(PropagateLookupRightListener.class);
+
+ private final RightManager rightManager;
+
+ @Inject
+ public PropagateLookupRightListener(RightManager rightManager) {
+ this.rightManager = rightManager;
+ }
+
+ @Override
+ public ListenerType getType() {
+ return ListenerType.ONCE;
+ }
+
+ @Override
+ public ExecutionMode getExecutionMode() {
+ return ExecutionMode.SYNCHRONOUS;
+ }
+
+ @Override
+ public void event(Event event) {
+ MailboxSession mailboxSession = event.getSession();
+
+ if (event instanceof MailboxACLUpdated) {
+ MailboxACLUpdated aclUpdateEvent = (MailboxACLUpdated) event;
+
+ updateLookupRightOnParent(mailboxSession, event.getMailboxPath(), aclUpdateEvent.getAclDiff());
+ } else if (event instanceof MailboxRenamed) {
+ MailboxRenamed renamedEvent = (MailboxRenamed) event;
+ updateLookupRightOnParent(mailboxSession, renamedEvent.getNewPath());
+ }
+ }
+
+ private void updateLookupRightOnParent(MailboxSession session, MailboxPath path) {
+ try {
+ MailboxACL acl = rightManager.listRights(path, session);
+ listAncestors(session, path)
+ .forEach(parentMailboxPath ->
+ updateLookupRight(
+ session,
+ parentMailboxPath,
+ acl.getEntries()
+ .entrySet()
+ .stream()
+ .map(entry -> new Entry(entry.getKey(), entry.getValue()))
+ ));
+ } catch (MailboxException e) {
+ Throwables.propagate(e);
+ }
+ }
+
+ private void updateLookupRightOnParent(MailboxSession mailboxSession, MailboxPath mailboxPath, ACLDiff aclDiff) {
+ listAncestors(mailboxSession, mailboxPath)
+ .forEach(path ->
+ updateLookupRight(
+ mailboxSession, path,
+ Stream.concat(aclDiff.addedEntries(), aclDiff.changedEntries())
+ ));
+ }
+
+ private void updateLookupRight(MailboxSession session, MailboxPath mailboxPath, Stream<Entry> entries) {
+ entries
+ .filter(entry -> !entry.getKey().isNegative())
+ .filter(entry -> entry.getValue().contains(Right.Lookup))
+ .forEach(entry -> applyLookupRight(session, mailboxPath, entry));
+ }
+
+ private Stream<MailboxPath> listAncestors(MailboxSession mailboxSession, MailboxPath mailboxPath) {
+ return mailboxPath.getHierarchyLevels(mailboxSession.getPathDelimiter())
+ .stream()
+ .filter(hierarchyMailboxPath -> !hierarchyMailboxPath.equals(mailboxPath));
+ }
+
+ private void applyLookupRight(MailboxSession session, MailboxPath mailboxPath, Entry entry) {
+ try {
+ rightManager.applyRightsCommand(mailboxPath,
+ MailboxACL.command()
+ .rights(Right.Lookup)
+ .key(entry.getKey())
+ .asAddition(),
+ session);
+ } catch (MailboxException e) {
+ LOGGER.error(String.format("Mailbox '%s' does not exist, user '%s' cannot share mailbox",
+ mailboxPath,
+ session.getUser().getUserName()), e);
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/james-project/blob/75622f7b/server/protocols/jmap/src/test/java/org/apache/james/jmap/event/PropagateLookupRightListenerTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/event/PropagateLookupRightListenerTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/event/PropagateLookupRightListenerTest.java
new file mode 100644
index 0000000..4cf96ad
--- /dev/null
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/event/PropagateLookupRightListenerTest.java
@@ -0,0 +1,340 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one *
+ * or more contributor license agreements. See the NOTICE file *
+ * distributed with this work for additional information *
+ * regarding copyright ownership. The ASF licenses this file *
+ * to you under the Apache License, Version 2.0 (the *
+ * "License"); you may not use this file except in compliance *
+ * with the License. You may obtain a copy of the License at *
+ * *
+ * http://www.apache.org/licenses/LICENSE-2.0 *
+ * *
+ * Unless required by applicable law or agreed to in writing, *
+ * software distributed under the License is distributed on an *
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY *
+ * KIND, either express or implied. See the License for the *
+ * specific language governing permissions and limitations *
+ * under the License. *
+ ****************************************************************/
+
+package org.apache.james.jmap.event;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import org.apache.james.mailbox.MailboxListener;
+import org.apache.james.mailbox.MailboxSession;
+import org.apache.james.mailbox.MessageManager;
+import org.apache.james.mailbox.acl.GroupMembershipResolver;
+import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
+import org.apache.james.mailbox.inmemory.manager.InMemoryIntegrationResources;
+import org.apache.james.mailbox.mock.MockMailboxSession;
+import org.apache.james.mailbox.model.MailboxACL;
+import org.apache.james.mailbox.model.MailboxACL.Entry;
+import org.apache.james.mailbox.model.MailboxACL.EntryKey;
+import org.apache.james.mailbox.model.MailboxACL.Rfc4314Rights;
+import org.apache.james.mailbox.model.MailboxACL.Right;
+import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
+import org.apache.james.mailbox.store.StoreMailboxManager;
+import org.apache.james.mailbox.store.StoreRightManager;
+import org.apache.james.mailbox.store.mail.model.Mailbox;
+import org.junit.Before;
+import org.junit.Test;
+
+public class PropagateLookupRightListenerTest {
+ private static final boolean RESET_RECENT = false;
+ private static final String OWNER_USER = "user";
+ private static final String SHARED_USER = "sharee";
+ private static final EntryKey SHARED_USER_KEY = EntryKey.createUserEntryKey(SHARED_USER);
+
+ private static final MailboxPath PARENT_MAILBOX = MailboxPath.forUser(OWNER_USER, "shared");
+ private static final MailboxPath CHILD_MAILBOX = MailboxPath.forUser(OWNER_USER, "shared.sub1");
+
+ private static final MailboxPath PARENT_MAILBOX1 = MailboxPath.forUser(OWNER_USER, "shared1");
+ private static final MailboxPath CHILD_MAILBOX1 = MailboxPath.forUser(OWNER_USER, "shared1.sub1");
+
+ private static final MailboxPath GRAND_CHILD_MAILBOX = MailboxPath.forUser(OWNER_USER, "shared.sub1.sub2");
+
+ private StoreRightManager storeRightManager;
+ private StoreMailboxManager storeMailboxManager;
+ private PropagateLookupRightListener testee;
+
+ private MailboxSession mailboxSession = new MockMailboxSession(OWNER_USER);
+
+ private MailboxId parentMailboxId;
+ private MailboxId parentMailboxId1;
+ private MailboxId childMailboxId;
+ private MailboxId childMailboxId1;
+ private MailboxId grandChildMailboxId;
+ private Entry lookupEntry;
+
+ private MailboxSessionMapperFactory mailboxMapper;
+
+ @Before
+ public void setup() throws Exception {
+ GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
+ storeMailboxManager = new InMemoryIntegrationResources()
+ .createMailboxManager(groupMembershipResolver);
+ storeRightManager = storeMailboxManager.getStoreRightManager();
+ mailboxMapper = storeMailboxManager.getMapperFactory();
+
+ testee = new PropagateLookupRightListener(storeRightManager);
+ storeMailboxManager.addGlobalListener(testee, mailboxSession);
+
+ parentMailboxId = storeMailboxManager.createMailbox(PARENT_MAILBOX, mailboxSession).get();
+ parentMailboxId1 = storeMailboxManager.createMailbox(PARENT_MAILBOX1, mailboxSession).get();
+ childMailboxId = storeMailboxManager.createMailbox(CHILD_MAILBOX, mailboxSession).get();
+ childMailboxId1 = storeMailboxManager.createMailbox(CHILD_MAILBOX1, mailboxSession).get();
+ grandChildMailboxId = storeMailboxManager.createMailbox(GRAND_CHILD_MAILBOX, mailboxSession).get();
+
+ lookupEntry = new Entry(SHARED_USER, "l");
+ }
+
+ @Test
+ public void getTypeShouldReturnOnce() throws Exception {
+ assertThat(testee.getType()).isEqualTo(MailboxListener.ListenerType.ONCE);
+ }
+
+ @Test
+ public void getExecutionModeShouldReturnAsynchronous() throws Exception {
+ assertThat(testee.getExecutionMode()).isEqualTo(MailboxListener.ExecutionMode.SYNCHRONOUS);
+ }
+
+ @Test
+ public void eventShouldDoNothingWhenEmptyNewRights() throws Exception {
+ storeRightManager.applyRightsCommand(
+ GRAND_CHILD_MAILBOX,
+ MailboxACL.command()
+ .key(SHARED_USER_KEY)
+ .rights()
+ .asAddition(),
+ mailboxSession);
+
+ MailboxACL actualACL = storeMailboxManager.getMailbox(parentMailboxId, mailboxSession)
+ .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT)
+ .getACL();
+
+ assertThat(actualACL.getEntries())
+ .doesNotContainKeys(SHARED_USER_KEY);
+ }
+
+ @Test
+ public void eventShouldDoNothingWhenNewACLIsTheSameAsTheOldOne() throws Exception {
+ Mailbox grandChildMailbox = mailboxMapper.getMailboxMapper(mailboxSession).findMailboxById(grandChildMailboxId);
+ mailboxMapper.getMailboxMapper(mailboxSession).setACL(grandChildMailbox, new MailboxACL(
+ new Entry(SHARED_USER_KEY, new Rfc4314Rights(Right.Lookup))));
+
+ storeRightManager.applyRightsCommand(
+ GRAND_CHILD_MAILBOX,
+ MailboxACL.command()
+ .key(SHARED_USER_KEY)
+ .rights(Right.Lookup)
+ .asAddition(),
+ mailboxSession);
+
+ MailboxACL actualACL = storeMailboxManager.getMailbox(parentMailboxId, mailboxSession)
+ .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT)
+ .getACL();
+
+ assertThat(actualACL.getEntries())
+ .doesNotContainKeys(SHARED_USER_KEY);
+ }
+
+ @Test
+ public void eventShouldUpdateParentWhenMailboxACLAddLookupRight() throws Exception {
+ storeRightManager.applyRightsCommand(
+ GRAND_CHILD_MAILBOX,
+ MailboxACL.command()
+ .key(SHARED_USER_KEY)
+ .rights(Right.Lookup)
+ .asAddition(),
+ mailboxSession);
+
+ MailboxACL actualACL = storeMailboxManager.getMailbox(parentMailboxId, mailboxSession)
+ .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT)
+ .getACL();
+
+ assertThat(actualACL.getEntries())
+ .hasSize(2)
+ .contains(lookupEntry);
+ }
+
+ @Test
+ public void eventShouldUpdateParentWhenMailboxACLUpdateLookupRight() throws Exception {
+ Mailbox grandChildMailbox = mailboxMapper.getMailboxMapper(mailboxSession).findMailboxById(grandChildMailboxId);
+ mailboxMapper.getMailboxMapper(mailboxSession).setACL(grandChildMailbox, new MailboxACL(
+ new Entry(SHARED_USER_KEY, new Rfc4314Rights(Right.Write))));
+
+ storeRightManager.setRights(
+ GRAND_CHILD_MAILBOX,
+ new MailboxACL(
+ new Entry(SHARED_USER_KEY, new Rfc4314Rights(Right.Lookup))),
+ mailboxSession);
+
+ MailboxACL actualACL = storeMailboxManager.getMailbox(parentMailboxId, mailboxSession)
+ .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT)
+ .getACL();
+
+ assertThat(actualACL.getEntries())
+ .hasSize(2)
+ .contains(lookupEntry);
+ }
+
+ @Test
+ public void eventShouldUpdateAllParentWhenMailboxACLUpdateLookupRight() throws Exception {
+ Mailbox grandChildMailbox = mailboxMapper.getMailboxMapper(mailboxSession).findMailboxById(grandChildMailboxId);
+ mailboxMapper.getMailboxMapper(mailboxSession).setACL(grandChildMailbox, new MailboxACL(
+ new Entry(SHARED_USER_KEY, new Rfc4314Rights(Right.Write))));
+
+ storeRightManager.setRights(
+ GRAND_CHILD_MAILBOX,
+ new MailboxACL(
+ new Entry(SHARED_USER_KEY, new Rfc4314Rights(Right.Lookup))),
+ mailboxSession);
+
+ MailboxACL actualParentACL = storeMailboxManager.getMailbox(parentMailboxId, mailboxSession)
+ .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT)
+ .getACL();
+
+ MailboxACL actualChildACL = storeMailboxManager.getMailbox(parentMailboxId, mailboxSession)
+ .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT)
+ .getACL();
+
+ assertThat(actualParentACL.getEntries())
+ .contains(lookupEntry);
+ assertThat(actualChildACL.getEntries())
+ .contains(lookupEntry);
+ }
+
+ @Test
+ public void eventShouldDoNothingWhenMailboxACLRemoveLookupRight() throws Exception {
+ Mailbox grandChildMailbox = mailboxMapper.getMailboxMapper(mailboxSession).findMailboxById(grandChildMailboxId);
+ mailboxMapper.getMailboxMapper(mailboxSession).setACL(grandChildMailbox, new MailboxACL(
+ new Entry(SHARED_USER_KEY, new Rfc4314Rights(Right.Write, Right.Lookup))));
+
+ storeRightManager.applyRightsCommand(
+ GRAND_CHILD_MAILBOX,
+ MailboxACL.command()
+ .key(SHARED_USER_KEY)
+ .rights(Right.Lookup)
+ .asRemoval(),
+ mailboxSession);
+
+ MailboxACL actualACL = storeMailboxManager.getMailbox(parentMailboxId, mailboxSession)
+ .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT)
+ .getACL();
+
+ assertThat(actualACL.getEntries())
+ .doesNotContainKeys(SHARED_USER_KEY);
+ }
+
+ @Test
+ public void eventShouldDoNothingWhenMailboxACLButNoLookupRight() throws Exception {
+ storeRightManager.applyRightsCommand(
+ GRAND_CHILD_MAILBOX,
+ MailboxACL.command()
+ .key(SHARED_USER_KEY)
+ .rights(Right.Administer)
+ .asAddition(),
+ mailboxSession);
+
+ MailboxACL actualACL = storeMailboxManager.getMailbox(parentMailboxId, mailboxSession)
+ .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT)
+ .getACL();
+
+ assertThat(actualACL.getEntries())
+ .doesNotContainKeys(SHARED_USER_KEY);
+ }
+
+ @Test
+ public void eventShouldDoNothingWhenMailboxACLUpdatedButNoLookupRight() throws Exception {
+ storeRightManager.applyRightsCommand(
+ GRAND_CHILD_MAILBOX,
+ MailboxACL.command()
+ .key(SHARED_USER_KEY)
+ .rights(Right.Administer)
+ .asReplacement(),
+ mailboxSession);
+
+ MailboxACL actualACL = storeMailboxManager.getMailbox(parentMailboxId, mailboxSession)
+ .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT)
+ .getACL();
+
+ assertThat(actualACL.getEntries())
+ .doesNotContainKeys(SHARED_USER_KEY);
+ }
+
+ @Test
+ public void eventShouldUpdateNewParentWhenRenameMailboxWhichContainLookupRight() throws Exception {
+ Mailbox childMailbox = mailboxMapper.getMailboxMapper(mailboxSession).findMailboxById(childMailboxId);
+ mailboxMapper.getMailboxMapper(mailboxSession).setACL(childMailbox, new MailboxACL(
+ new Entry(SHARED_USER_KEY, new Rfc4314Rights(Right.Write, Right.Lookup))));
+
+ storeMailboxManager.renameMailbox(CHILD_MAILBOX, MailboxPath.forUser(OWNER_USER, "shared1.sub1New"), mailboxSession);
+
+ MailboxACL actualACL = storeMailboxManager.getMailbox(parentMailboxId1, mailboxSession)
+ .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT)
+ .getACL();
+
+ assertThat(actualACL.getEntries())
+ .contains(lookupEntry);
+ }
+
+ @Test
+ public void eventShouldNotUpdateNewParentWhenRenameMailboxWhichDoesContainLookupRight() throws Exception {
+ Mailbox childMailbox = mailboxMapper.getMailboxMapper(mailboxSession).findMailboxById(childMailboxId);
+ mailboxMapper.getMailboxMapper(mailboxSession).setACL(childMailbox, new MailboxACL(
+ new Entry(SHARED_USER_KEY, new Rfc4314Rights(Right.Write))));
+
+ storeMailboxManager.renameMailbox(CHILD_MAILBOX, MailboxPath.forUser(OWNER_USER, "shared1.sub1New"), mailboxSession);
+
+ MailboxACL actualACL = storeMailboxManager.getMailbox(parentMailboxId1, mailboxSession)
+ .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT)
+ .getACL();
+
+ assertThat(actualACL.getEntries())
+ .doesNotContainKeys(SHARED_USER_KEY);
+ }
+
+ @Test
+ public void eventShouldUpdateAllNewParentWhenRenameMailboxWhichContainLookupRight() throws Exception {
+ Mailbox grandChildMailbox = mailboxMapper.getMailboxMapper(mailboxSession).findMailboxById(grandChildMailboxId);
+ mailboxMapper.getMailboxMapper(mailboxSession).setACL(grandChildMailbox, new MailboxACL(
+ new Entry(SHARED_USER_KEY, new Rfc4314Rights(Right.Write, Right.Lookup))));
+
+ storeMailboxManager.renameMailbox(GRAND_CHILD_MAILBOX, MailboxPath.forUser(OWNER_USER, "shared1.sub1.sub2"), mailboxSession);
+
+ MailboxACL parentActualACL = storeMailboxManager.getMailbox(parentMailboxId1, mailboxSession)
+ .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT)
+ .getACL();
+ MailboxACL childActualACL = storeMailboxManager.getMailbox(childMailboxId1, mailboxSession)
+ .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT)
+ .getACL();
+
+ assertThat(parentActualACL.getEntries())
+ .contains(lookupEntry);
+ assertThat(childActualACL.getEntries())
+ .contains(lookupEntry);
+ }
+
+ @Test
+ public void eventShouldDoNothingWhenNegativeACLEntry() throws Exception {
+ EntryKey negativeUserKey = EntryKey.createUserEntryKey(SHARED_USER, true);
+ storeRightManager.applyRightsCommand(
+ GRAND_CHILD_MAILBOX,
+ MailboxACL.command()
+ .key(negativeUserKey)
+ .rights(Right.Lookup)
+ .asAddition(),
+ mailboxSession);
+
+ MailboxACL actualACL = storeMailboxManager.getMailbox(parentMailboxId, mailboxSession)
+ .getMetaData(RESET_RECENT, mailboxSession, MessageManager.MetaData.FetchGroup.NO_COUNT)
+ .getACL();
+
+ assertThat(actualACL.getEntries())
+ .hasSize(1)
+ .doesNotContainKeys(negativeUserKey);
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[04/11] james-project git commit: MAILBOX-316 Re-define ACL update
event and allow emitting it
Posted by ad...@apache.org.
MAILBOX-316 Re-define ACL update event and allow emitting it
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/ef4b79cb
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/ef4b79cb
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/ef4b79cb
Branch: refs/heads/master
Commit: ef4b79cb2f0b08f346dc28636fc83bdf56c8cf92
Parents: 806a52b
Author: quynhn <qn...@linagora.com>
Authored: Mon Nov 6 16:02:03 2017 +0700
Committer: quynhn <qn...@linagora.com>
Committed: Wed Nov 15 09:22:19 2017 +0700
----------------------------------------------------------------------
.../org/apache/james/mailbox/MailboxListener.java | 18 ++++++++++--------
.../james/mailbox/store/event/EventFactory.java | 6 ++++++
.../store/event/MailboxEventDispatcher.java | 5 +++++
3 files changed, 21 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/ef4b79cb/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
index 2b074a1..ef8c8cc 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java
@@ -22,7 +22,8 @@ package org.apache.james.mailbox;
import java.io.Serializable;
import java.util.List;
-import org.apache.james.mailbox.model.MailboxACL;
+import org.apache.james.mailbox.acl.ACLDiff;
+import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageMetaData;
import org.apache.james.mailbox.model.UpdatedFlags;
@@ -143,18 +144,19 @@ public interface MailboxListener {
/**
* A mailbox event related to updated ACL
*/
- abstract class MailboxACLUpdated extends MessageEvent {
-
- /**
- *
- */
+ class MailboxACLUpdated extends Event {
+ private final ACLDiff aclDiff;
private static final long serialVersionUID = 1L;
- public MailboxACLUpdated(MailboxSession session, MailboxPath path) {
+ public MailboxACLUpdated(MailboxSession session, MailboxPath path, ACLDiff aclDiff) {
super(session, path);
+ this.aclDiff = aclDiff;
+ }
+
+ public ACLDiff getAclDiff() {
+ return aclDiff;
}
- public abstract MailboxACL getUpdatedACL();
}
/**
http://git-wip-us.apache.org/repos/asf/james-project/blob/ef4b79cb/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
index 1cffdc4..beb9fa8 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
@@ -21,11 +21,14 @@ package org.apache.james.mailbox.store.event;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
import java.util.SortedMap;
import org.apache.james.mailbox.MailboxListener;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.acl.ACLDiff;
+import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageMetaData;
import org.apache.james.mailbox.model.UpdatedFlags;
@@ -198,4 +201,7 @@ public class EventFactory {
return new MailboxAddedImpl(session, mailbox);
}
+ public MailboxListener.MailboxACLUpdated aclUpdated(MailboxSession session, MailboxPath mailboxPath, ACLDiff aclDiff) {
+ return new MailboxListener.MailboxACLUpdated(session, mailboxPath, aclDiff);
+ }
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/ef4b79cb/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
index 91b7955..8fcb5ab 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
@@ -28,6 +28,8 @@ import javax.inject.Inject;
import org.apache.james.mailbox.MailboxListener;
import org.apache.james.mailbox.MailboxSession;
import org.apache.james.mailbox.MessageUid;
+import org.apache.james.mailbox.acl.ACLDiff;
+import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MailboxPath;
import org.apache.james.mailbox.model.MessageMetaData;
import org.apache.james.mailbox.model.UpdatedFlags;
@@ -149,4 +151,7 @@ public class MailboxEventDispatcher {
listener.event(eventFactory.mailboxAdded(session, mailbox));
}
+ public void aclUpdated(MailboxSession session, MailboxPath mailboxPath, ACLDiff aclDiff) {
+ listener.event(eventFactory.aclUpdated(session, mailboxPath, aclDiff));
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[03/11] james-project git commit: MAILBOX-316 getMailboxById should
retrieve acl mailbox also
Posted by ad...@apache.org.
MAILBOX-316 getMailboxById should retrieve acl mailbox also
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/c0db96a8
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/c0db96a8
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/c0db96a8
Branch: refs/heads/master
Commit: c0db96a8fc96815336e0e1758282efbbc525292c
Parents: 5ceee78
Author: quynhn <qn...@linagora.com>
Authored: Thu Nov 2 17:30:55 2017 +0700
Committer: quynhn <qn...@linagora.com>
Committed: Wed Nov 15 09:22:18 2017 +0700
----------------------------------------------------------------------
.../cassandra/mail/CassandraMailboxMapper.java | 2 +-
.../store/mail/model/MailboxMapperACLTest.java | 14 ++++++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0db96a8/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
index 4765250..25723ff 100644
--- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
+++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxMapper.java
@@ -92,7 +92,7 @@ public class CassandraMailboxMapper implements MailboxMapper {
.thenCompose(cassandraIdOptional ->
cassandraIdOptional
.map(CassandraMailboxPathDAO.CassandraIdAndPath::getCassandraId)
- .map(mailboxDAO::retrieveMailbox)
+ .map(this::retrieveMailbox)
.orElse(CompletableFuture.completedFuture(Optional.empty())))
.join()
.orElseThrow(() -> new MailboxNotFoundException(path));
http://git-wip-us.apache.org/repos/asf/james-project/blob/c0db96a8/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java
index dcc3acb..aba69b9 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/mail/model/MailboxMapperACLTest.java
@@ -398,4 +398,18 @@ public abstract class MailboxMapperACLTest {
.containsOnly(benwaInboxMailbox);
}
+ @Test
+ public void findMailboxByPathShouldReturnMailboxWithACL() throws MailboxException {
+ EntryKey key = EntryKey.createUserEntryKey("user");
+ Rfc4314Rights rights = new Rfc4314Rights(Right.WriteSeenFlag, Right.CreateMailbox, Right.Administer, Right.PerformExpunge, Right.DeleteMessages);
+ mailboxMapper.setACL(benwaInboxMailbox,
+ new MailboxACL(ImmutableMap.of(key, rights)));
+
+ assertThat(
+ mailboxMapper.findMailboxByPath(benwaInboxMailbox.generateAssociatedPath())
+ .getACL()
+ .getEntries())
+ .hasSize(1)
+ .containsEntry(key, rights);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[02/11] james-project git commit: MAILBOX-316 Inject dispatch
listener on StoreRightManager
Posted by ad...@apache.org.
MAILBOX-316 Inject dispatch listener on StoreRightManager
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/8bd1d098
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/8bd1d098
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/8bd1d098
Branch: refs/heads/master
Commit: 8bd1d0989b8f42f0227642ea54cb98f1be1bdabc
Parents: c0db96a
Author: quynhn <qn...@linagora.com>
Authored: Thu Nov 2 17:44:52 2017 +0700
Committer: quynhn <qn...@linagora.com>
Committed: Wed Nov 15 09:22:18 2017 +0700
----------------------------------------------------------------------
.../cassandra/CassandraMailboxManagerProvider.java | 6 +++---
.../mailbox/cassandra/CassandraTestSystemFixture.java | 2 +-
.../mail/CassandraMailboxManagerAttachmentTest.java | 2 +-
.../mailbox/hbase/HBaseMailboxManagerStressTest.java | 6 +++---
.../james/mailbox/hbase/HBaseMailboxManagerTest.java | 6 +++---
.../james/mailbox/jcr/JCRMailboxManagerProvider.java | 4 ++--
.../james/mailbox/jpa/JpaMailboxManagerProvider.java | 2 +-
.../maildir/MaildirMailboxManagerProvider.java | 6 +++---
.../mail/InMemoryMailboxManagerAttachmentTest.java | 6 +++---
.../manager/InMemoryIntegrationResources.java | 13 +++++++------
.../main/resources/META-INF/spring/spring-mailbox.xml | 1 +
.../apache/james/mailbox/store/StoreRightManager.java | 6 +++++-
.../james/mailbox/store/StoreMailboxManagerTest.java | 5 ++++-
.../james/mailbox/store/StoreRightManagerTest.java | 14 +++++++++++---
.../cassandra/host/CassandraHostSystem.java | 2 +-
.../mpt/imapmailbox/hbase/host/HBaseHostSystem.java | 2 +-
.../james/mpt/imapmailbox/jcr/host/JCRHostSystem.java | 2 +-
.../james/mpt/imapmailbox/jpa/host/JPAHostSystem.java | 2 +-
.../lucenesearch/host/LuceneSearchHostSystem.java | 4 ++--
.../imapmailbox/maildir/host/MaildirHostSystem.java | 2 +-
20 files changed, 55 insertions(+), 38 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java
index 3fca347..056c899 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraMailboxManagerProvider.java
@@ -53,12 +53,12 @@ public class CassandraMailboxManagerProvider {
MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
MessageParser messageParser = new MessageParser();
- StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, aclResolver, groupMembershipResolver);
+ DefaultDelegatingMailboxListener delegatingMailboxListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingMailboxListener);
+ StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, aclResolver, groupMembershipResolver, mailboxEventDispatcher);
Authenticator noAuthenticator = null;
Authorizator noAuthorizator = null;
- DefaultDelegatingMailboxListener delegatingMailboxListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingMailboxListener);
StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mapperFactory, storeRightManager,
LIMIT_ANNOTATIONS, LIMIT_ANNOTATION_SIZE);
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
index 8a4d46e..a736f30 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/CassandraTestSystemFixture.java
@@ -58,7 +58,7 @@ public class CassandraTestSystemFixture {
public static CassandraMailboxManager createMailboxManager(CassandraMailboxSessionMapperFactory mapperFactory) throws Exception{
DefaultDelegatingMailboxListener delegatingMailboxListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingMailboxListener);
- StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver());
+ StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver(), mailboxEventDispatcher);
StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mapperFactory, storeRightManager);
CassandraMailboxManager cassandraMailboxManager = new CassandraMailboxManager(mapperFactory, mock(Authenticator.class), mock(Authorizator.class),
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
----------------------------------------------------------------------
diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
index e5d416a..40f7cd2 100644
--- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
+++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraMailboxManagerAttachmentTest.java
@@ -107,7 +107,7 @@ public class CassandraMailboxManagerAttachmentTest extends AbstractMailboxManage
Authorizator noAuthorizator = null;
DefaultDelegatingMailboxListener delegatingMailboxListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingMailboxListener);
- StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver());
+ StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver(), mailboxEventDispatcher);
StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mailboxSessionMapperFactory, storeRightManager);
mailboxManager = new CassandraMailboxManager(mailboxSessionMapperFactory,
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java
index 688894d..6ee0777 100644
--- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java
+++ b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerStressTest.java
@@ -66,12 +66,12 @@ public class HBaseMailboxManagerStressTest extends MailboxManagerStressTest {
MessageId.Factory messageIdFactory = new DefaultMessageId.Factory();
HBaseMailboxSessionMapperFactory mapperFactory = new HBaseMailboxSessionMapperFactory(CLUSTER.getConf(),
uidProvider, modSeqProvider, messageIdFactory);
- StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver());
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver(), mailboxEventDispatcher);
Authenticator noAuthenticator = null;
Authorizator noAuthorizator = null;
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mapperFactory, storeRightManager);
HBaseMailboxManager manager = new HBaseMailboxManager(mapperFactory,
noAuthenticator,
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java
index 5794093..748e50e 100644
--- a/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java
+++ b/mailbox/hbase/src/test/java/org/apache/james/mailbox/hbase/HBaseMailboxManagerTest.java
@@ -66,12 +66,12 @@ public class HBaseMailboxManagerTest extends MailboxManagerTest {
MessageId.Factory messageIdFactory = new DefaultMessageId.Factory();
HBaseMailboxSessionMapperFactory mapperFactory = new HBaseMailboxSessionMapperFactory(CLUSTER.getConf(),
uidProvider, modSeqProvider, messageIdFactory);
- StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver());
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver(), mailboxEventDispatcher);
Authenticator noAuthenticator = null;
Authorizator noAuthorizator = null;
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mapperFactory, storeRightManager);
HBaseMailboxManager manager = new HBaseMailboxManager(mapperFactory,
noAuthenticator,
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerProvider.java b/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerProvider.java
index 40bc489..ed49335 100644
--- a/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerProvider.java
+++ b/mailbox/jcr/src/test/java/org/apache/james/mailbox/jcr/JCRMailboxManagerProvider.java
@@ -68,10 +68,10 @@ public class JCRMailboxManagerProvider {
Authenticator noAuthenticator = null;
Authorizator noAuthorizator = null;
- StoreRightManager storeRightManager = new StoreRightManager(mf, aclResolver, groupMembershipResolver);
- StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mf, storeRightManager);
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreRightManager storeRightManager = new StoreRightManager(mf, aclResolver, groupMembershipResolver, mailboxEventDispatcher);
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mf, storeRightManager);
JCRMailboxManager manager = new JCRMailboxManager(mf, noAuthenticator, noAuthorizator, locker,
messageParser, new DefaultMessageId.Factory(), mailboxEventDispatcher, delegatingListener,
annotationManager, storeRightManager);
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JpaMailboxManagerProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JpaMailboxManagerProvider.java b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JpaMailboxManagerProvider.java
index 8d1439c..d0aba5b 100644
--- a/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JpaMailboxManagerProvider.java
+++ b/mailbox/jpa/src/test/java/org/apache/james/mailbox/jpa/JpaMailboxManagerProvider.java
@@ -58,9 +58,9 @@ public class JpaMailboxManagerProvider {
Authenticator noAuthenticator = null;
Authorizator noAuthorizator = null;
- StoreRightManager storeRightManager = new StoreRightManager(mf, aclResolver, groupMembershipResolver);
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreRightManager storeRightManager = new StoreRightManager(mf, aclResolver, groupMembershipResolver, mailboxEventDispatcher);
StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mf, storeRightManager,
LIMIT_ANNOTATIONS, LIMIT_ANNOTATION_SIZE);
OpenJPAMailboxManager openJPAMailboxManager = new OpenJPAMailboxManager(mf, noAuthenticator, noAuthorizator,
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java
----------------------------------------------------------------------
diff --git a/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java b/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java
index 4d10a6f..19e446b 100644
--- a/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java
+++ b/mailbox/maildir/src/test/java/org/apache/james/mailbox/maildir/MaildirMailboxManagerProvider.java
@@ -46,13 +46,13 @@ public class MaildirMailboxManagerProvider {
MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
MessageParser messageParser = new MessageParser();
- StoreRightManager storeRightManager = new StoreRightManager(mf, aclResolver, groupMembershipResolver);
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreRightManager storeRightManager = new StoreRightManager(mf, aclResolver, groupMembershipResolver, mailboxEventDispatcher);
Authenticator noAuthenticator = null;
Authorizator noAuthorizator = null;
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mf, storeRightManager);
StoreMailboxManager manager = new StoreMailboxManager(mf, noAuthenticator, noAuthorizator, new JVMMailboxPathLocker(),
messageParser, new DefaultMessageId.Factory(), annotationManager,
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxManagerAttachmentTest.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxManagerAttachmentTest.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxManagerAttachmentTest.java
index 0ba5857..eb981ab 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxManagerAttachmentTest.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/mail/InMemoryMailboxManagerAttachmentTest.java
@@ -57,13 +57,13 @@ public class InMemoryMailboxManagerAttachmentTest extends AbstractMailboxManager
mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
Authenticator noAuthenticator = null;
Authorizator noAuthorizator = null;
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
MessageId.Factory messageIdFactory = new InMemoryMessageId.Factory();
GroupMembershipResolver groupMembershipResolver = null;
UnionMailboxACLResolver aclResolver = new UnionMailboxACLResolver();
- StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, aclResolver, groupMembershipResolver);
+ StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, aclResolver, groupMembershipResolver, mailboxEventDispatcher);
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mailboxSessionMapperFactory, storeRightManager);
mailboxManager = new InMemoryMailboxManager(mailboxSessionMapperFactory, noAuthenticator, noAuthorizator, new NoMailboxPathLocker(),
new MessageParser(), messageIdFactory, mailboxEventDispatcher, delegatingListener, annotationManager, storeRightManager);
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
----------------------------------------------------------------------
diff --git a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
index 5c6e4a6..4827f82 100644
--- a/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
+++ b/mailbox/memory/src/test/java/org/apache/james/mailbox/inmemory/manager/InMemoryIntegrationResources.java
@@ -85,12 +85,13 @@ public class InMemoryIntegrationResources implements IntegrationResources<StoreM
fakeAuthenticator.addUser(ManagerTestResources.USER, ManagerTestResources.USER_PASS);
fakeAuthenticator.addUser(ManagerTestResources.OTHER_USER, ManagerTestResources.OTHER_USER_PASS);
InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
- StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, new UnionMailboxACLResolver(), groupMembershipResolver);
+ DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
+ MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, new UnionMailboxACLResolver(),
+ groupMembershipResolver, mailboxEventDispatcher);
StoreMailboxAnnotationManager annotationManager = annotationManagerBiFunction
.apply(storeRightManager, mailboxSessionMapperFactory);
- DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
- MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
StoreMailboxManager manager = new InMemoryMailboxManager(
mailboxSessionMapperFactory,
fakeAuthenticator,
@@ -109,11 +110,11 @@ public class InMemoryIntegrationResources implements IntegrationResources<StoreM
public StoreMailboxManager createMailboxManager(GroupMembershipResolver groupMembershipResolver,
Authenticator authenticator, Authorizator authorizator) throws MailboxException {
InMemoryMailboxSessionMapperFactory mailboxSessionMapperFactory = new InMemoryMailboxSessionMapperFactory();
- StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, new UnionMailboxACLResolver(), groupMembershipResolver);
- StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mailboxSessionMapperFactory, storeRightManager);
-
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, new UnionMailboxACLResolver(), groupMembershipResolver, mailboxEventDispatcher);
+ StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mailboxSessionMapperFactory, storeRightManager);
+
StoreMailboxManager manager = new InMemoryMailboxManager(
mailboxSessionMapperFactory,
authenticator,
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mailbox/spring/src/main/resources/META-INF/spring/spring-mailbox.xml
----------------------------------------------------------------------
diff --git a/mailbox/spring/src/main/resources/META-INF/spring/spring-mailbox.xml b/mailbox/spring/src/main/resources/META-INF/spring/spring-mailbox.xml
index 8caa3cb..0b50ccb 100644
--- a/mailbox/spring/src/main/resources/META-INF/spring/spring-mailbox.xml
+++ b/mailbox/spring/src/main/resources/META-INF/spring/spring-mailbox.xml
@@ -69,6 +69,7 @@
<constructor-arg index="0" ref="messageMapperFactory" />
<constructor-arg index="1" ref="aclResolver" />
<constructor-arg index="2" ref="groupMembershipResolver" />
+ <constructor-arg index="3" ref="dispatcher" />
</bean>
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
index 38076df..51c021f 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
@@ -41,6 +41,7 @@ import org.apache.james.mailbox.model.MailboxACL.Rfc4314Rights;
import org.apache.james.mailbox.model.MailboxACL.Right;
import org.apache.james.mailbox.model.MailboxId;
import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.MailboxMapper;
import org.apache.james.mailbox.store.mail.model.Mailbox;
import org.apache.james.mailbox.store.transaction.Mapper;
@@ -52,6 +53,7 @@ import com.google.common.collect.ImmutableMap;
public class StoreRightManager implements RightManager {
public static final boolean GROUP_FOLDER = true;
+ private final MailboxEventDispatcher dispatcher;
private final MailboxSessionMapperFactory mailboxSessionMapperFactory;
private final MailboxACLResolver aclResolver;
private final GroupMembershipResolver groupMembershipResolver;
@@ -59,10 +61,12 @@ public class StoreRightManager implements RightManager {
@Inject
public StoreRightManager(MailboxSessionMapperFactory mailboxSessionMapperFactory,
MailboxACLResolver aclResolver,
- GroupMembershipResolver groupMembershipResolver) {
+ GroupMembershipResolver groupMembershipResolver,
+ MailboxEventDispatcher dispatcher) {
this.mailboxSessionMapperFactory = mailboxSessionMapperFactory;
this.aclResolver = aclResolver;
this.groupMembershipResolver = groupMembershipResolver;
+ this.dispatcher = dispatcher;
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java
index 33f9efd..b97d993 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMailboxManagerTest.java
@@ -75,10 +75,13 @@ public class StoreMailboxManagerTest {
FakeAuthenticator authenticator = new FakeAuthenticator();
authenticator.addUser(CURRENT_USER, CURRENT_USER_PASSWORD);
authenticator.addUser(ADMIN, ADMIN_PASSWORD);
- StoreRightManager storeRightManager = new StoreRightManager(mockedMapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver());
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+
+ StoreRightManager storeRightManager = new StoreRightManager(mockedMapperFactory, new UnionMailboxACLResolver(),
+ new SimpleGroupMembershipResolver(), mailboxEventDispatcher);
+
StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mockedMapperFactory, storeRightManager);
storeMailboxManager = new StoreMailboxManager(mockedMapperFactory, authenticator, FakeAuthorizator.forUserAndAdmin(ADMIN, CURRENT_USER),
new JVMMailboxPathLocker(), new MessageParser(), messageIdFactory,
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreRightManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreRightManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreRightManagerTest.java
index 78ce9e6..91a481a 100644
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreRightManagerTest.java
+++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreRightManagerTest.java
@@ -30,6 +30,8 @@ import static org.mockito.Mockito.when;
import javax.mail.Flags;
+import org.apache.james.mailbox.acl.GroupMembershipResolver;
+import org.apache.james.mailbox.acl.MailboxACLResolver;
import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver;
import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.exception.DifferentDomainException;
@@ -43,6 +45,7 @@ import org.apache.james.mailbox.model.MailboxACL.ACLCommand;
import org.apache.james.mailbox.model.MailboxACL.Right;
import org.apache.james.mailbox.model.MailboxConstants;
import org.apache.james.mailbox.model.MailboxPath;
+import org.apache.james.mailbox.store.event.MailboxEventDispatcher;
import org.apache.james.mailbox.store.mail.MailboxMapper;
import org.apache.james.mailbox.store.mail.model.Mailbox;
import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
@@ -54,7 +57,8 @@ public class StoreRightManagerTest {
private static final long UID_VALIDITY = 3421L;
private StoreRightManager storeRightManager;
private MockMailboxSession aliceSession;
-
+ private MailboxACLResolver mailboxAclResolver;
+ private GroupMembershipResolver groupMembershipResolver;
private MailboxMapper mockedMailboxMapper;
@Before
@@ -62,12 +66,16 @@ public class StoreRightManagerTest {
aliceSession = new MockMailboxSession(MailboxFixture.ALICE);
MailboxSessionMapperFactory mockedMapperFactory = mock(MailboxSessionMapperFactory.class);
mockedMailboxMapper = mock(MailboxMapper.class);
+ mailboxAclResolver = new UnionMailboxACLResolver();
+ groupMembershipResolver = new SimpleGroupMembershipResolver();
+ MailboxEventDispatcher dispatcher = mock(MailboxEventDispatcher.class);
when(mockedMapperFactory.getMailboxMapper(aliceSession))
.thenReturn(mockedMailboxMapper);
storeRightManager = new StoreRightManager(mockedMapperFactory,
- new UnionMailboxACLResolver(),
- new SimpleGroupMembershipResolver());
+ mailboxAclResolver,
+ groupMembershipResolver,
+ dispatcher);
}
@Test
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
index 93fc95e..05ae0c8 100644
--- a/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
+++ b/mpt/impl/imap-mailbox/cassandra/src/test/java/org/apache/james/mpt/imapmailbox/cassandra/host/CassandraHostSystem.java
@@ -115,7 +115,7 @@ public class CassandraHostSystem extends JamesImapHostSystem {
DefaultDelegatingMailboxListener delegatingMailboxListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingMailboxListener);
- StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver());
+ StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, new UnionMailboxACLResolver(), new SimpleGroupMembershipResolver(), mailboxEventDispatcher);
StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mapperFactory, storeRightManager);
mailboxManager = new CassandraMailboxManager(mapperFactory, authenticator, authorizator,
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java b/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java
index aa1c82b..939a5f0 100644
--- a/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java
+++ b/mpt/impl/imap-mailbox/hbase/src/test/java/org/apache/james/mpt/imapmailbox/hbase/host/HBaseHostSystem.java
@@ -109,7 +109,7 @@ public class HBaseHostSystem extends JamesImapHostSystem {
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
- StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, aclResolver, groupMembershipResolver);
+ StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, aclResolver, groupMembershipResolver, mailboxEventDispatcher);
StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mapperFactory, storeRightManager);
mailboxManager = new HBaseMailboxManager(mapperFactory, authenticator, authorizator,
new JVMMailboxPathLocker(), messageParser,
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java b/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java
index 7702d20..f8eda22 100644
--- a/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java
+++ b/mpt/impl/imap-mailbox/jcr/src/test/java/org/apache/james/mpt/imapmailbox/jcr/host/JCRHostSystem.java
@@ -95,9 +95,9 @@ public class JCRHostSystem extends JamesImapHostSystem {
GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
MessageParser messageParser = new MessageParser();
- StoreRightManager storeRightManager = new StoreRightManager(mf, aclResolver, groupMembershipResolver);
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreRightManager storeRightManager = new StoreRightManager(mf, aclResolver, groupMembershipResolver, mailboxEventDispatcher);
StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mf, storeRightManager);
mailboxManager = new JCRMailboxManager(mf, authenticator, authorizator, new JVMMailboxPathLocker(), messageParser,
new DefaultMessageId.Factory(), mailboxEventDispatcher, delegatingListener,
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/host/JPAHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/host/JPAHostSystem.java b/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/host/JPAHostSystem.java
index f6468d2..c6d5c32 100644
--- a/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/host/JPAHostSystem.java
+++ b/mpt/impl/imap-mailbox/jpa/src/test/java/org/apache/james/mpt/imapmailbox/jpa/host/JPAHostSystem.java
@@ -96,9 +96,9 @@ public class JPAHostSystem extends JamesImapHostSystem {
GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
MessageParser messageParser = new MessageParser();
- StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, aclResolver, groupMembershipResolver);
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreRightManager storeRightManager = new StoreRightManager(mapperFactory, aclResolver, groupMembershipResolver, mailboxEventDispatcher);
StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mapperFactory, storeRightManager);
mailboxManager = new OpenJPAMailboxManager(mapperFactory, authenticator, authorizator,
messageParser, new DefaultMessageId.Factory(), delegatingListener,
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java b/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java
index d9a21e2..7455a89 100644
--- a/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java
+++ b/mpt/impl/imap-mailbox/lucenesearch/src/test/java/org/apache/james/mpt/imapmailbox/lucenesearch/host/LuceneSearchHostSystem.java
@@ -119,10 +119,10 @@ public class LuceneSearchHostSystem extends JamesImapHostSystem {
GroupMembershipResolver groupMembershipResolver = new SimpleGroupMembershipResolver();
MessageParser messageParser = new MessageParser();
- StoreRightManager storeRightManager = new StoreRightManager(factory, aclResolver, groupMembershipResolver);
-
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
+ StoreRightManager storeRightManager = new StoreRightManager(factory, aclResolver, groupMembershipResolver, mailboxEventDispatcher);
+
StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(factory, storeRightManager);
mailboxManager = new OpenJPAMailboxManager(factory, authenticator, authorizator,
messageParser, new DefaultMessageId.Factory(), delegatingListener,
http://git-wip-us.apache.org/repos/asf/james-project/blob/8bd1d098/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java
----------------------------------------------------------------------
diff --git a/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java b/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java
index 3730ee7..c00d99c 100644
--- a/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java
+++ b/mpt/impl/imap-mailbox/maildir/src/test/java/org/apache/james/mpt/imapmailbox/maildir/host/MaildirHostSystem.java
@@ -75,7 +75,7 @@ public class MaildirHostSystem extends JamesImapHostSystem {
DefaultDelegatingMailboxListener delegatingListener = new DefaultDelegatingMailboxListener();
MailboxEventDispatcher mailboxEventDispatcher = new MailboxEventDispatcher(delegatingListener);
- StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, aclResolver, groupMembershipResolver);
+ StoreRightManager storeRightManager = new StoreRightManager(mailboxSessionMapperFactory, aclResolver, groupMembershipResolver, mailboxEventDispatcher);
StoreMailboxAnnotationManager annotationManager = new StoreMailboxAnnotationManager(mailboxSessionMapperFactory, storeRightManager);
mailboxManager = new StoreMailboxManager(mailboxSessionMapperFactory, authenticator, authorizator, locker,
messageParser, new DefaultMessageId.Factory(), annotationManager,
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[11/11] james-project git commit: MAILBOX-316 fix typo on listRights
Posted by ad...@apache.org.
MAILBOX-316 fix typo on listRights
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/b539779b
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/b539779b
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/b539779b
Branch: refs/heads/master
Commit: b539779b22d757b4034b3409222aa9525d47ac2b
Parents: 21e7ff9
Author: Matthieu Baechler <ma...@apache.org>
Authored: Mon Nov 13 17:04:38 2017 +0100
Committer: quynhn <qn...@linagora.com>
Committed: Wed Nov 15 09:37:40 2017 +0700
----------------------------------------------------------------------
.../api/src/main/java/org/apache/james/mailbox/RightManager.java | 2 +-
.../java/org/apache/james/mailbox/store/StoreMailboxManager.java | 4 ++--
.../java/org/apache/james/mailbox/store/StoreRightManager.java | 2 +-
.../org/apache/james/imap/processor/ListRightsProcessor.java | 2 +-
.../org/apache/james/imap/processor/ListRightsProcessorTest.java | 2 +-
.../james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java | 4 ++--
6 files changed, 8 insertions(+), 8 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/b539779b/mailbox/api/src/main/java/org/apache/james/mailbox/RightManager.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/RightManager.java b/mailbox/api/src/main/java/org/apache/james/mailbox/RightManager.java
index c397d29..9ba7f87 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/RightManager.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/RightManager.java
@@ -76,7 +76,7 @@ public interface RightManager {
* @return result suitable for the LISTRIGHTS IMAP command
* @throws MailboxException in case of unknown mailbox or unsupported right
*/
- MailboxACL.Rfc4314Rights[] listRigths(MailboxPath mailboxPath, MailboxACL.EntryKey identifier, MailboxSession session) throws MailboxException;
+ MailboxACL.Rfc4314Rights[] listRights(MailboxPath mailboxPath, MailboxACL.EntryKey identifier, MailboxSession session) throws MailboxException;
MailboxACL listRights(MailboxPath mailboxPath, MailboxSession session) throws MailboxException;
http://git-wip-us.apache.org/repos/asf/james-project/blob/b539779b/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 2fcb9b7..e76ea91 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
@@ -787,8 +787,8 @@ public class StoreMailboxManager implements MailboxManager {
}
@Override
- public Rfc4314Rights[] listRigths(MailboxPath mailboxPath, MailboxACL.EntryKey key, MailboxSession session) throws MailboxException {
- return storeRightManager.listRigths(mailboxPath, key, session);
+ public Rfc4314Rights[] listRights(MailboxPath mailboxPath, MailboxACL.EntryKey key, MailboxSession session) throws MailboxException {
+ return storeRightManager.listRights(mailboxPath, key, session);
}
@Override
http://git-wip-us.apache.org/repos/asf/james-project/blob/b539779b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
index 92033f7..f3209d0 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
@@ -113,7 +113,7 @@ public class StoreRightManager implements RightManager {
}
@Override
- public Rfc4314Rights[] listRigths(MailboxPath mailboxPath, EntryKey key, MailboxSession session) throws MailboxException {
+ public Rfc4314Rights[] listRights(MailboxPath mailboxPath, EntryKey key, MailboxSession session) throws MailboxException {
MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(session);
Mailbox mailbox = mapper.findMailboxByPath(mailboxPath);
http://git-wip-us.apache.org/repos/asf/james-project/blob/b539779b/protocols/imap/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java
index e6e8a12..ebe6c16 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/ListRightsProcessor.java
@@ -112,7 +112,7 @@ public class ListRightsProcessor extends AbstractMailboxProcessor<ListRightsRequ
// Note that Section 6 recommends additional identifier’s verification
// steps.
- Rfc4314Rights[] rights = mailboxManager.listRigths(mailboxPath, key, mailboxSession);
+ Rfc4314Rights[] rights = mailboxManager.listRights(mailboxPath, key, mailboxSession);
ListRightsResponse aclResponse = new ListRightsResponse(mailboxName, identifier, rights);
responder.respond(aclResponse);
okComplete(command, tag, responder);
http://git-wip-us.apache.org/repos/asf/james-project/blob/b539779b/protocols/imap/src/test/java/org/apache/james/imap/processor/ListRightsProcessorTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/ListRightsProcessorTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/ListRightsProcessorTest.java
index f9844db..6ebcb96 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/ListRightsProcessorTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/ListRightsProcessorTest.java
@@ -171,7 +171,7 @@ public class ListRightsProcessorTest {
.thenReturn(true);
when(metaData.getACL()).thenReturn(acl);
- when(mailboxManager.listRigths(path, user1Key, mailboxSession))
+ when(mailboxManager.listRights(path, user1Key, mailboxSession))
.thenReturn(listRights);
http://git-wip-us.apache.org/repos/asf/james-project/blob/b539779b/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java
index 78430f4..f680e84 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java
@@ -210,13 +210,13 @@ public class DefaultMailboxesProvisioningFilterThreadTest {
}
@Override
- public MailboxACL.Rfc4314Rights[] listRigths(MailboxPath mailboxPath, MailboxACL.EntryKey identifier, MailboxSession session) throws MailboxException {
+ public MailboxACL.Rfc4314Rights[] listRights(MailboxPath mailboxPath, MailboxACL.EntryKey identifier, MailboxSession session) throws MailboxException {
throw new NotImplementedException();
}
@Override
public MailboxACL listRights(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
- return null;
+ throw new NotImplementedException();
}
@Override
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[10/11] james-project git commit: MAILBOX-316 create MailboxACL
RightsManager.listRights() method
Posted by ad...@apache.org.
MAILBOX-316 create MailboxACL RightsManager.listRights() method
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/21e7ff9e
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/21e7ff9e
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/21e7ff9e
Branch: refs/heads/master
Commit: 21e7ff9e046604ae70d0fe2f102c391b874edd8d
Parents: 93ad42b
Author: Matthieu Baechler <ma...@apache.org>
Authored: Mon Nov 13 16:43:57 2017 +0100
Committer: quynhn <qn...@linagora.com>
Committed: Wed Nov 15 09:37:39 2017 +0700
----------------------------------------------------------------------
.../src/main/java/org/apache/james/mailbox/RightManager.java | 3 +++
.../org/apache/james/mailbox/store/StoreMailboxManager.java | 5 +++++
.../org/apache/james/mailbox/store/StoreRightManager.java | 7 +++++++
server/protocols/jmap/pom.xml | 4 ----
.../apache/james/jmap/event/PropagateLookupRightListener.java | 2 +-
.../jmap/DefaultMailboxesProvisioningFilterThreadTest.java | 5 +++++
6 files changed, 21 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/21e7ff9e/mailbox/api/src/main/java/org/apache/james/mailbox/RightManager.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/RightManager.java b/mailbox/api/src/main/java/org/apache/james/mailbox/RightManager.java
index c021f92..c397d29 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/RightManager.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/RightManager.java
@@ -53,6 +53,7 @@ public interface RightManager {
* @throws MailboxException in case of unknown mailbox or unsupported right
*/
boolean hasRight(MailboxId mailboxId, Right right, MailboxSession session) throws MailboxException;
+
/**
* Computes a result suitable for the LISTRIGHTS IMAP command. The result is
* computed for this mailbox and the given {@code identifier}.
@@ -77,6 +78,8 @@ public interface RightManager {
*/
MailboxACL.Rfc4314Rights[] listRigths(MailboxPath mailboxPath, MailboxACL.EntryKey identifier, MailboxSession session) throws MailboxException;
+ MailboxACL listRights(MailboxPath mailboxPath, MailboxSession session) throws MailboxException;
+
/**
* Returns the rights applicable to the user who has sent the current
* request on the mailbox designated by this mailboxPath.
http://git-wip-us.apache.org/repos/asf/james-project/blob/21e7ff9e/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 5f499aa..2fcb9b7 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
@@ -792,6 +792,11 @@ public class StoreMailboxManager implements MailboxManager {
}
@Override
+ public MailboxACL listRights(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+ return storeRightManager.listRights(mailboxPath, session);
+ }
+
+ @Override
public void applyRightsCommand(MailboxPath mailboxPath, MailboxACL.ACLCommand mailboxACLCommand, MailboxSession session) throws MailboxException {
storeRightManager.applyRightsCommand(mailboxPath, mailboxACLCommand, session);
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/21e7ff9e/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
index ef4a31b..92033f7 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
@@ -124,6 +124,13 @@ public class StoreRightManager implements RightManager {
}
@Override
+ public MailboxACL listRights(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+ MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(session);
+ Mailbox mailbox = mapper.findMailboxByPath(mailboxPath);
+ return mailbox.getACL();
+ }
+
+ @Override
public void applyRightsCommand(MailboxPath mailboxPath, ACLCommand mailboxACLCommand, MailboxSession session) throws MailboxException {
assertSharesBelongsToUserDomain(mailboxPath.getUser(), mailboxACLCommand);
MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(session);
http://git-wip-us.apache.org/repos/asf/james-project/blob/21e7ff9e/server/protocols/jmap/pom.xml
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/pom.xml b/server/protocols/jmap/pom.xml
index f03b6e4..5cebbd0 100644
--- a/server/protocols/jmap/pom.xml
+++ b/server/protocols/jmap/pom.xml
@@ -45,10 +45,6 @@
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
- <artifactId>apache-james-mailbox-store</artifactId>
- </dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
<artifactId>apache-james-mailbox-memory</artifactId>
<scope>test</scope>
</dependency>
http://git-wip-us.apache.org/repos/asf/james-project/blob/21e7ff9e/server/protocols/jmap/src/main/java/org/apache/james/jmap/event/PropagateLookupRightListener.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/event/PropagateLookupRightListener.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/event/PropagateLookupRightListener.java
index fe12d68..c22e9a4 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/event/PropagateLookupRightListener.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/event/PropagateLookupRightListener.java
@@ -83,7 +83,7 @@ public class PropagateLookupRightListener implements MailboxListener {
.entrySet()
.stream()
.map(entry -> new Entry(entry.getKey(), entry.getValue()))
- ));
+ ));
} catch (MailboxException e) {
Throwables.propagate(e);
}
http://git-wip-us.apache.org/repos/asf/james-project/blob/21e7ff9e/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java
index 69bfa0f..78430f4 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/DefaultMailboxesProvisioningFilterThreadTest.java
@@ -215,6 +215,11 @@ public class DefaultMailboxesProvisioningFilterThreadTest {
}
@Override
+ public MailboxACL listRights(MailboxPath mailboxPath, MailboxSession session) throws MailboxException {
+ return null;
+ }
+
+ @Override
public void applyRightsCommand(MailboxPath mailboxPath, MailboxACL.ACLCommand mailboxACLCommand, MailboxSession session) throws MailboxException {
throw new NotImplementedException();
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
[07/11] james-project git commit: MAILBOX-316 JmapModule will bind
PropagateLookupRightListener then the event should only listen on JMAP
protocol
Posted by ad...@apache.org.
MAILBOX-316 JmapModule will bind PropagateLookupRightListener then the
event should only listen on JMAP protocol
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/2462904d
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/2462904d
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/2462904d
Branch: refs/heads/master
Commit: 2462904dbed12339ad0a8521cba2dcb5dfcf4746
Parents: 2aa77b5
Author: quynhn <qn...@linagora.com>
Authored: Mon Nov 6 17:25:10 2017 +0700
Committer: quynhn <qn...@linagora.com>
Committed: Wed Nov 15 09:33:58 2017 +0700
----------------------------------------------------------------------
.../java/org/apache/james/jmap/JMAPModule.java | 30 ++++++++++++++++++++
1 file changed, 30 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/2462904d/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java
index f5f6a29..42a3d07 100644
--- a/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java
+++ b/server/container/guice/protocols/jmap/src/main/java/org/apache/james/jmap/JMAPModule.java
@@ -28,6 +28,7 @@ import org.apache.commons.configuration.ConfigurationException;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.apache.commons.io.FileUtils;
import org.apache.james.filesystem.api.FileSystem;
+import org.apache.james.jmap.event.PropagateLookupRightListener;
import org.apache.james.jmap.mailet.VacationMailet;
import org.apache.james.jmap.methods.RequestHandler;
import org.apache.james.jmap.send.PostDequeueDecoratorFactory;
@@ -39,6 +40,7 @@ import org.apache.james.jwt.JwtConfiguration;
import org.apache.james.lifecycle.api.Configurable;
import org.apache.james.mailbox.MailboxManager;
import org.apache.james.mailbox.MailboxManager.SearchCapabilities;
+import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailetcontainer.impl.MatcherMailetPair;
import org.apache.james.modules.server.CamelMailetContainerModule;
import org.apache.james.queue.api.MailQueueItemDecoratorFactory;
@@ -89,6 +91,7 @@ public class JMAPModule extends AbstractModule {
bind(HtmlTextExtractor.class).to(JsoupHtmlTextExtractor.class);
Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(RequiredCapabilitiesPrecondition.class);
+ Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(JmapListenerRegistrationPerformer.class);
Multibinder<CamelMailetContainerModule.TransportProcessorCheck> transportProcessorChecks = Multibinder.newSetBinder(binder(), CamelMailetContainerModule.TransportProcessorCheck.class);
transportProcessorChecks.addBinding().to(VacationMailetCheck.class);
@@ -128,6 +131,33 @@ public class JMAPModule extends AbstractModule {
}
@Singleton
+ public static class JmapListenerRegistrationPerformer implements ConfigurationPerformer {
+ private final MailboxManager mailboxManager;
+ private final PropagateLookupRightListener propagateLookupRightListener;
+
+ @Inject
+ public JmapListenerRegistrationPerformer(MailboxManager mailboxManager, PropagateLookupRightListener propagateLookupRightListener) {
+ this.mailboxManager = mailboxManager;
+ this.propagateLookupRightListener = propagateLookupRightListener;
+ }
+
+ @Override
+ public void initModule() {
+ try {
+ mailboxManager.addGlobalListener(propagateLookupRightListener,
+ mailboxManager.createSystemSession("storeMailboxManager"));
+ } catch (MailboxException e) {
+ Throwables.propagate(e);
+ }
+ }
+
+ @Override
+ public List<Class<? extends Configurable>> forClasses() {
+ return ImmutableList.of();
+ }
+ }
+
+ @Singleton
public static class RequiredCapabilitiesPrecondition implements ConfigurationPerformer {
private final MailboxManager mailboxManager;
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org