JAMES-2169 Improve MailboxACL.EntryKey create* static methods wording
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/2f97ab96 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/2f97ab96 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/2f97ab96 Branch: refs/heads/master Commit: 2f97ab96f89ad810f439ba7ef3503e2e7382cf7d Parents: f15ff20 Author: benwa <[email protected]> Authored: Tue Oct 3 09:30:09 2017 +0700 Committer: benwa <[email protected]> Committed: Wed Oct 4 16:24:11 2017 +0700 ---------------------------------------------------------------------- .../java/org/apache/james/mailbox/model/MailboxACL.java | 12 ++++++------ .../james/mailbox/acl/UnionMailboxACLResolverTest.java | 12 ++++++------ .../apache/james/mailbox/store/StoreMessageManager.java | 2 +- .../james/mailbox/store/AbstractMessageManagerTest.java | 9 ++------- .../james/mailbox/store/StoreMessageManagerTest.java | 2 +- .../org/apache/james/jmap/model/mailbox/Rights.java | 2 +- .../org/apache/james/jmap/model/mailbox/RightsTest.java | 8 ++++---- 7 files changed, 21 insertions(+), 26 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/2f97ab96/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxACL.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxACL.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxACL.java index d87d85e..e414ebc 100644 --- a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxACL.java +++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxACL.java @@ -352,19 +352,19 @@ public class MailboxACL { * */ public static class EntryKey { - public static EntryKey createGroup(String name) { + public static EntryKey createGroupEntryKey(String name) { return new EntryKey(name, NameType.group, false); } - public static EntryKey createGroup(String name, boolean negative) { + public static EntryKey createGroupEntryKey(String name, boolean negative) { return new EntryKey(name, NameType.group, negative); } - public static EntryKey createUser(String name) { + public static EntryKey createUserEntryKey(String name) { return new EntryKey(name, NameType.user, false); } - public static EntryKey createUser(String name, boolean negative) { + public static EntryKey createUserEntryKey(String name, boolean negative) { return new EntryKey(name, NameType.user, negative); } @@ -518,12 +518,12 @@ public class MailboxACL { } public Builder forUser(String user) { - key = EntryKey.createUser(user); + key = EntryKey.createUserEntryKey(user); return this; } public Builder forGroup(String group) { - key = EntryKey.createGroup(group); + key = EntryKey.createGroupEntryKey(group); return this; } http://git-wip-us.apache.org/repos/asf/james-project/blob/2f97ab96/mailbox/api/src/test/java/org/apache/james/mailbox/acl/UnionMailboxACLResolverTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/acl/UnionMailboxACLResolverTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/acl/UnionMailboxACLResolverTest.java index d8ed71b..245be05 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/acl/UnionMailboxACLResolverTest.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/acl/UnionMailboxACLResolverTest.java @@ -64,10 +64,10 @@ public class UnionMailboxACLResolverTest { @Before public void setUp() throws Exception { - user1Key = EntryKey.createUser(USER_1); - user2Key = EntryKey.createUser(USER_2); - group1Key = EntryKey.createGroup(GROUP_1); - group2Key = EntryKey.createGroup(GROUP_2); + user1Key = EntryKey.createUserEntryKey(USER_1); + user2Key = EntryKey.createUserEntryKey(USER_2); + group1Key = EntryKey.createGroupEntryKey(GROUP_1); + group2Key = EntryKey.createGroupEntryKey(GROUP_2); MailboxACL acl = new MailboxACL(new Entry(MailboxACL.AUTHENTICATED_KEY, MailboxACL.FULL_RIGHTS)); authenticatedReadListWriteGlobal = new UnionMailboxACLResolver(acl, acl); @@ -84,10 +84,10 @@ public class UnionMailboxACLResolverTest { groupMembershipResolver.addMembership(GROUP_2, USER_2); user1Read = new MailboxACL(new Entry(user1Key, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); - user1ReadNegative = new MailboxACL(new Entry(EntryKey.createUser(USER_1, true), Rfc4314Rights.fromSerializedRfc4314Rights("r"))); + user1ReadNegative = new MailboxACL(new Entry(EntryKey.createUserEntryKey(USER_1, true), Rfc4314Rights.fromSerializedRfc4314Rights("r"))); group1Read = new MailboxACL(new Entry(group1Key, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); - group1ReadNegative = new MailboxACL(new Entry(EntryKey.createGroup(GROUP_1, true), Rfc4314Rights.fromSerializedRfc4314Rights("r"))); + group1ReadNegative = new MailboxACL(new Entry(EntryKey.createGroupEntryKey(GROUP_1, true), Rfc4314Rights.fromSerializedRfc4314Rights("r"))); anybodyRead = new MailboxACL(new Entry(MailboxACL.ANYBODY_KEY, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); anybodyReadNegative = new MailboxACL(new Entry(MailboxACL.ANYBODY_NEGATIVE_KEY, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); http://git-wip-us.apache.org/repos/asf/james-project/blob/2f97ab96/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java index 7966e38..d903f3d 100644 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreMessageManager.java @@ -826,7 +826,7 @@ public class StoreMessageManager implements org.apache.james.mailbox.MessageMana if (mailboxSession.getUser().isSameUser(mailbox.getUser())) { return acl; } - MailboxACL.EntryKey userAsKey = MailboxACL.EntryKey.createUser(mailboxSession.getUser().getUserName()); + MailboxACL.EntryKey userAsKey = MailboxACL.EntryKey.createUserEntryKey(mailboxSession.getUser().getUserName()); Rfc4314Rights rights = acl.getEntries().getOrDefault(userAsKey, new Rfc4314Rights()); if (rights.contains(MailboxACL.Right.Administer)) { return acl; http://git-wip-us.apache.org/repos/asf/james-project/blob/2f97ab96/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageManagerTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageManagerTest.java index d85d342..43ac287 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageManagerTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/AbstractMessageManagerTest.java @@ -25,17 +25,12 @@ import static org.apache.james.mailbox.fixture.MailboxFixture.THIRD_USER; import static org.apache.james.mailbox.fixture.MailboxFixture.USER; import static org.assertj.core.api.Assertions.assertThat; -import javax.mail.Flags; - import org.apache.james.mailbox.MailboxManager; import org.apache.james.mailbox.MailboxSession; -import org.apache.james.mailbox.MailboxSession.SessionType; import org.apache.james.mailbox.MessageManager; -import org.apache.james.mailbox.MessageUid; import org.apache.james.mailbox.fixture.MailboxFixture; import org.apache.james.mailbox.mock.MockMailboxSession; import org.apache.james.mailbox.model.MailboxACL; -import org.apache.james.mailbox.store.mail.model.Mailbox; import org.junit.Test; public abstract class AbstractMessageManagerTest { @@ -68,7 +63,7 @@ public abstract class AbstractMessageManagerTest { MessageManager messageManager = mailboxManager.getMailbox(MAILBOX_PATH1, session); MessageManager.MetaData actual = messageManager.getMetaData(NO_RESET_RECENT, session, MessageManager.MetaData.FetchGroup.NO_COUNT); - assertThat(actual.getACL().getEntries()).containsKeys(MailboxACL.EntryKey.createUser(OTHER_USER), MailboxACL.EntryKey.createUser(THIRD_USER)); + assertThat(actual.getACL().getEntries()).containsKeys(MailboxACL.EntryKey.createUserEntryKey(OTHER_USER), MailboxACL.EntryKey.createUserEntryKey(THIRD_USER)); } @Test @@ -78,7 +73,7 @@ public abstract class AbstractMessageManagerTest { MessageManager messageManager = mailboxManager.getMailbox(MAILBOX_PATH1, session); MessageManager.MetaData actual = messageManager.getMetaData(NO_RESET_RECENT, otherSession, MessageManager.MetaData.FetchGroup.NO_COUNT); - assertThat(actual.getACL().getEntries()).containsOnlyKeys(MailboxACL.EntryKey.createUser(OTHER_USER)); + assertThat(actual.getACL().getEntries()).containsOnlyKeys(MailboxACL.EntryKey.createUserEntryKey(OTHER_USER)); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/2f97ab96/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMessageManagerTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMessageManagerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMessageManagerTest.java index 9172412..a32c27c 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMessageManagerTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/StoreMessageManagerTest.java @@ -63,6 +63,6 @@ public class StoreMessageManagerTest { .apply(MailboxACL.command().rights(Right.Read, Right.Write, Right.Administer).forUser(THIRD_USER).asAddition()); MailboxACL actual = StoreMessageManager.filteredForSession( new SimpleMailbox(MAILBOX_PATH1, UID_VALIDITY), acl, new MockMailboxSession(OTHER_USER)); - assertThat(actual.getEntries()).containsKey(MailboxACL.EntryKey.createUser(OTHER_USER)); + assertThat(actual.getEntries()).containsKey(MailboxACL.EntryKey.createUserEntryKey(OTHER_USER)); } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/james-project/blob/2f97ab96/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Rights.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Rights.java b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Rights.java index bd27bd0..99c0e79 100644 --- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Rights.java +++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/model/mailbox/Rights.java @@ -208,7 +208,7 @@ public class Rights { .stream() .map(entry -> new MailboxACL( ImmutableMap.of( - EntryKey.createUser(entry.getKey().value), + EntryKey.createUserEntryKey(entry.getKey().value), toMailboxAclRights(entry.getValue())))) .reduce(MailboxACL.EMPTY, union); } http://git-wip-us.apache.org/repos/asf/james-project/blob/2f97ab96/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/RightsTest.java ---------------------------------------------------------------------- diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/RightsTest.java b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/RightsTest.java index dae6130..a427144 100644 --- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/RightsTest.java +++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/model/mailbox/RightsTest.java @@ -101,7 +101,7 @@ public class RightsTest { @Test public void fromACLShouldFilterOutGroups() throws Exception { MailboxACL acl = new MailboxACL(ImmutableMap.of( - EntryKey.createGroup("group"), Rfc4314Rights.fromSerializedRfc4314Rights("aet"))); + EntryKey.createGroupEntryKey("group"), Rfc4314Rights.fromSerializedRfc4314Rights("aet"))); assertThat(Rights.fromACL(acl)) .isEqualTo(Rights.EMPTY); @@ -110,7 +110,7 @@ public class RightsTest { @Test public void fromACLShouldFilterNegatedUsers() throws Exception { MailboxACL acl = new MailboxACL(ImmutableMap.of( - EntryKey.createUser("user", NEGATIVE), Rfc4314Rights.fromSerializedRfc4314Rights("aet"))); + EntryKey.createUserEntryKey("user", NEGATIVE), Rfc4314Rights.fromSerializedRfc4314Rights("aet"))); assertThat(Rights.fromACL(acl)) .isEqualTo(Rights.EMPTY); @@ -119,7 +119,7 @@ public class RightsTest { @Test public void fromACLShouldAcceptUsers() throws Exception { MailboxACL acl = new MailboxACL(ImmutableMap.of( - EntryKey.createUser("user"), Rfc4314Rights.fromSerializedRfc4314Rights("aet"))); + EntryKey.createUserEntryKey("user"), Rfc4314Rights.fromSerializedRfc4314Rights("aet"))); assertThat(Rights.fromACL(acl)) .isEqualTo(Rights.builder() @@ -130,7 +130,7 @@ public class RightsTest { @Test public void fromACLShouldFilterOutUnknownRights() throws Exception { MailboxACL acl = new MailboxACL(ImmutableMap.of( - EntryKey.createUser("user"), Rfc4314Rights.fromSerializedRfc4314Rights("aetpk"))); + EntryKey.createUserEntryKey("user"), Rfc4314Rights.fromSerializedRfc4314Rights("aetpk"))); assertThat(Rights.fromACL(acl)) .isEqualTo(Rights.builder() --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
