MAILBOX-307 Improve Rfc4314Rights constructors
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/3f013691 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/3f013691 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/3f013691 Branch: refs/heads/master Commit: 3f0136910776cbb2577fa8951134e0399f24323c Parents: 6d87110 Author: Raphael Ouazana <raphael.ouaz...@linagora.com> Authored: Thu Sep 28 16:11:18 2017 +0200 Committer: Matthieu Baechler <matth...@apache.org> Committed: Fri Sep 29 09:20:47 2017 +0200 ---------------------------------------------------------------------- .../apache/james/mailbox/model/MailboxACL.java | 34 +++++----- .../acl/UnionMailboxACLResolverTest.java | 22 +++---- .../james/mailbox/model/MailboxACLTest.java | 12 ++-- .../james/mailbox/model/Rfc4314RightsTest.java | 14 ++--- .../mpt/imapmailbox/suite/ACLCommands.java | 2 +- .../mpt/imapmailbox/suite/ACLIntegration.java | 66 ++++++++++---------- .../james/imap/processor/SetACLProcessor.java | 2 +- .../imap/processor/ListRightsProcessorTest.java | 2 +- .../imap/processor/SetACLProcessorTest.java | 2 +- 9 files changed, 79 insertions(+), 77 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/3f013691/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 4939f47..d1e1487 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 @@ -171,30 +171,32 @@ public class MailboxACL { private final EnumSet<Right> value; - private Rfc4314Rights(EnumSet<Right> rights) { + private Rfc4314Rights(Collection<Right> rights) { this.value = copyOf(rights); } - private Rfc4314Rights() { - this(EnumSet.noneOf(Right.class)); - } - public Rfc4314Rights(Right... rights) { this(copyOf(Arrays.asList(rights))); } - public Rfc4314Rights(Right right) throws UnsupportedRightException { - this.value = EnumSet.of(Right.forChar(right.asCharacter())); + // JSON Deserialization + @SuppressWarnings("unused") + private Rfc4314Rights(String serializedRfc4314Rights) throws UnsupportedRightException { + this(rightListFromSerializedRfc4314Rights(serializedRfc4314Rights)); + } + + public static Rfc4314Rights fromSerializedRfc4314Rights(String serializedRfc4314Rights) throws UnsupportedRightException { + return new Rfc4314Rights(rightListFromSerializedRfc4314Rights(serializedRfc4314Rights)); } - public Rfc4314Rights(String serializedRfc4314Rights) throws UnsupportedRightException { - this.value = copyOf(serializedRfc4314Rights.chars() + private static List<Right> rightListFromSerializedRfc4314Rights(String serializedRfc4314Rights) throws UnsupportedRightException { + return serializedRfc4314Rights.chars() .mapToObj(i -> (char) i) - .flatMap(Throwing.function(this::convert).sneakyThrow()) - .collect(Collectors.toList())); + .flatMap(Throwing.function(Rfc4314Rights::convert).sneakyThrow()) + .collect(Collectors.toList()); } - private Stream<Right> convert(char flag) throws UnsupportedRightException { + private static Stream<Right> convert(char flag) throws UnsupportedRightException { switch (flag) { case c_ObsoleteCreate: return Stream.of(Right.CreateMailbox, Right.DeleteMailbox); @@ -214,8 +216,8 @@ public class MailboxACL { return contains(Right.forChar(flag)); } - public boolean contains(Right right) throws UnsupportedRightException { - return value.contains(Right.forChar(right.asCharacter())); + public boolean contains(Right right) { + return value.contains(right); } public boolean equals(Object o) { @@ -329,7 +331,7 @@ public class MailboxACL { } public Entry(String key, String value) throws UnsupportedRightException { - this(EntryKey.deserialize(key), new Rfc4314Rights(value)); + this(EntryKey.deserialize(key), Rfc4314Rights.fromSerializedRfc4314Rights(value)); } } @@ -571,7 +573,7 @@ public class MailboxACL { ImmutableMap.Builder<EntryKey, Rfc4314Rights> builder = ImmutableMap.builder(); if (props != null) { for (Map.Entry<?, ?> prop : props.entrySet()) { - builder.put(EntryKey.deserialize((String) prop.getKey()), new Rfc4314Rights((String) prop.getValue())); + builder.put(EntryKey.deserialize((String) prop.getKey()), Rfc4314Rights.fromSerializedRfc4314Rights((String) prop.getValue())); } } return builder.build(); http://git-wip-us.apache.org/repos/asf/james-project/blob/3f013691/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 ecdd3bf..d8ed71b 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 @@ -71,7 +71,7 @@ public class UnionMailboxACLResolverTest { MailboxACL acl = new MailboxACL(new Entry(MailboxACL.AUTHENTICATED_KEY, MailboxACL.FULL_RIGHTS)); authenticatedReadListWriteGlobal = new UnionMailboxACLResolver(acl, acl); - acl = new MailboxACL(new Entry(MailboxACL.ANYBODY_KEY, new Rfc4314Rights("rl"))); + acl = new MailboxACL(new Entry(MailboxACL.ANYBODY_KEY, Rfc4314Rights.fromSerializedRfc4314Rights("rl"))); anyoneReadListGlobal = new UnionMailboxACLResolver(acl, acl); acl = new MailboxACL(new Entry(MailboxACL.OWNER_KEY, MailboxACL.FULL_RIGHTS)); ownerFullGlobal = new UnionMailboxACLResolver(acl, acl); @@ -83,20 +83,20 @@ public class UnionMailboxACLResolverTest { groupMembershipResolver.addMembership(GROUP_1, USER_1); groupMembershipResolver.addMembership(GROUP_2, USER_2); - user1Read = new MailboxACL(new Entry(user1Key, new Rfc4314Rights("r"))); - user1ReadNegative = new MailboxACL(new Entry(EntryKey.createUser(USER_1, true), new Rfc4314Rights("r"))); + user1Read = new MailboxACL(new Entry(user1Key, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); + user1ReadNegative = new MailboxACL(new Entry(EntryKey.createUser(USER_1, true), Rfc4314Rights.fromSerializedRfc4314Rights("r"))); - group1Read = new MailboxACL(new Entry(group1Key, new Rfc4314Rights("r"))); - group1ReadNegative = new MailboxACL(new Entry(EntryKey.createGroup(GROUP_1, true), new Rfc4314Rights("r"))); + group1Read = new MailboxACL(new Entry(group1Key, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); + group1ReadNegative = new MailboxACL(new Entry(EntryKey.createGroup(GROUP_1, true), Rfc4314Rights.fromSerializedRfc4314Rights("r"))); - anybodyRead = new MailboxACL(new Entry(MailboxACL.ANYBODY_KEY, new Rfc4314Rights("r"))); - anybodyReadNegative = new MailboxACL(new Entry(MailboxACL.ANYBODY_NEGATIVE_KEY, new Rfc4314Rights("r"))); + anybodyRead = new MailboxACL(new Entry(MailboxACL.ANYBODY_KEY, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); + anybodyReadNegative = new MailboxACL(new Entry(MailboxACL.ANYBODY_NEGATIVE_KEY, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); - authenticatedRead = new MailboxACL(new Entry(MailboxACL.AUTHENTICATED_KEY, new Rfc4314Rights("r"))); - authenticatedReadNegative = new MailboxACL(new Entry(MailboxACL.AUTHENTICATED_NEGATIVE_KEY, new Rfc4314Rights("r"))); + authenticatedRead = new MailboxACL(new Entry(MailboxACL.AUTHENTICATED_KEY, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); + authenticatedReadNegative = new MailboxACL(new Entry(MailboxACL.AUTHENTICATED_NEGATIVE_KEY, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); - ownerRead = new MailboxACL(new Entry(MailboxACL.OWNER_KEY, new Rfc4314Rights("r"))); - ownerReadNegative = new MailboxACL(new Entry(MailboxACL.OWNER_NEGATIVE_KEY, new Rfc4314Rights("r"))); + ownerRead = new MailboxACL(new Entry(MailboxACL.OWNER_KEY, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); + ownerReadNegative = new MailboxACL(new Entry(MailboxACL.OWNER_NEGATIVE_KEY, Rfc4314Rights.fromSerializedRfc4314Rights("r"))); } http://git-wip-us.apache.org/repos/asf/james-project/blob/3f013691/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxACLTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxACLTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxACLTest.java index 9da7152..16734d5 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxACLTest.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxACLTest.java @@ -97,7 +97,7 @@ public class MailboxACLTest { public void testUnionACLExisting() throws UnsupportedRightException { Map<EntryKey, Rfc4314Rights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - expectedEntries.put(EntryKey.deserialize(USER_1), new Rfc4314Rights(aeik + lprs)); + expectedEntries.put(EntryKey.deserialize(USER_1), Rfc4314Rights.fromSerializedRfc4314Rights(aeik + lprs)); MailboxACL toAdd = new MailboxACL(new Entry(USER_1, lprs)); MailboxACL result = u1u2g1g2ACL.union(toAdd); @@ -111,9 +111,9 @@ public class MailboxACLTest { public void testUnionEntryExisting() throws UnsupportedRightException { Map<EntryKey, Rfc4314Rights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - expectedEntries.put(EntryKey.deserialize(USER_1), new Rfc4314Rights(aeik + lprs)); + expectedEntries.put(EntryKey.deserialize(USER_1), Rfc4314Rights.fromSerializedRfc4314Rights(aeik + lprs)); - MailboxACL result = u1u2g1g2ACL.union(EntryKey.deserialize(USER_1), new Rfc4314Rights(lprs)); + MailboxACL result = u1u2g1g2ACL.union(EntryKey.deserialize(USER_1), Rfc4314Rights.fromSerializedRfc4314Rights(lprs)); Map<EntryKey, Rfc4314Rights> foundEntries = result.getEntries(); @@ -161,7 +161,7 @@ public class MailboxACLTest { public void testExceptACLExisting() throws UnsupportedRightException { Map<EntryKey, Rfc4314Rights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - expectedEntries.put(EntryKey.deserialize(USER_1), new Rfc4314Rights(ik)); + expectedEntries.put(EntryKey.deserialize(USER_1), Rfc4314Rights.fromSerializedRfc4314Rights(ik)); MailboxACL toRemove = new MailboxACL(new Entry(USER_1, ae)); MailboxACL result = u1u2g1g2ACL.except(toRemove); @@ -175,9 +175,9 @@ public class MailboxACLTest { public void testExceptEntryExisting() throws UnsupportedRightException { Map<EntryKey, Rfc4314Rights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - expectedEntries.put(EntryKey.deserialize(USER_1), new Rfc4314Rights(ik)); + expectedEntries.put(EntryKey.deserialize(USER_1), Rfc4314Rights.fromSerializedRfc4314Rights(ik)); - MailboxACL result = u1u2g1g2ACL.except(EntryKey.deserialize(USER_1), new Rfc4314Rights(ae)); + MailboxACL result = u1u2g1g2ACL.except(EntryKey.deserialize(USER_1), Rfc4314Rights.fromSerializedRfc4314Rights(ae)); Map<EntryKey, Rfc4314Rights> foundEntries = result.getEntries(); http://git-wip-us.apache.org/repos/asf/james-project/blob/3f013691/mailbox/api/src/test/java/org/apache/james/mailbox/model/Rfc4314RightsTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/Rfc4314RightsTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/Rfc4314RightsTest.java index a753e7d..33b91fb 100644 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/Rfc4314RightsTest.java +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/Rfc4314RightsTest.java @@ -52,21 +52,21 @@ public class Rfc4314RightsTest { @Before public void setUp() throws Exception { - aeik = new Rfc4314Rights("aeik"); - lprs = new Rfc4314Rights("lprs"); - twx = new Rfc4314Rights("twx"); + aeik = Rfc4314Rights.fromSerializedRfc4314Rights("aeik"); + lprs = Rfc4314Rights.fromSerializedRfc4314Rights("lprs"); + twx = Rfc4314Rights.fromSerializedRfc4314Rights("twx"); full = MailboxACL.FULL_RIGHTS; none = MailboxACL.NO_RIGHTS; } @Test(expected=NullPointerException.class) public void newInstanceShouldThrowWhenNullString() throws UnsupportedRightException { - new Rfc4314Rights((String) null); + Rfc4314Rights.fromSerializedRfc4314Rights((String) null); } @Test public void newInstanceShouldHaveNoRightsWhenEmptyString() throws UnsupportedRightException { - Rfc4314Rights rights = new Rfc4314Rights(""); + Rfc4314Rights rights = Rfc4314Rights.fromSerializedRfc4314Rights(""); assertThat(rights.list()).isEmpty(); } @@ -97,7 +97,7 @@ public class Rfc4314RightsTest { @Test public void rfc4314RightsShouldThrowWhenUnknownFlag() throws UnsupportedRightException { - assertThatThrownBy(() -> new Rfc4314Rights("z")) + assertThatThrownBy(() -> Rfc4314Rights.fromSerializedRfc4314Rights("z")) .isInstanceOf(UnsupportedRightException.class); } @@ -170,7 +170,7 @@ public class Rfc4314RightsTest { @Test public void getValueShouldReturnEmptyWhenNone() throws UnsupportedRightException { - assertThat(new Rfc4314Rights("").list()).isEmpty(); + assertThat(Rfc4314Rights.fromSerializedRfc4314Rights("").list()).isEmpty(); } @Test http://git-wip-us.apache.org/repos/asf/james-project/blob/3f013691/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ACLCommands.java ---------------------------------------------------------------------- diff --git a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ACLCommands.java b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ACLCommands.java index cb414a4..52ff7f4 100644 --- a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ACLCommands.java +++ b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ACLCommands.java @@ -53,7 +53,7 @@ public abstract class ACLCommands implements ImapTestConstants { scriptedTestProtocol = new ACLScriptedTestProtocol(grantRightsOnHost, appender, "/org/apache/james/imap/scripts/", system) .withUser(USER, PASSWORD) .withLocale(Locale.US); - readWriteSeenRight = new MailboxACL.Rfc4314Rights("rsw"); + readWriteSeenRight = MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rsw"); } @Test http://git-wip-us.apache.org/repos/asf/james-project/blob/3f013691/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ACLIntegration.java ---------------------------------------------------------------------- diff --git a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ACLIntegration.java b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ACLIntegration.java index 4b16d04..5967f87 100644 --- a/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ACLIntegration.java +++ b/mpt/impl/imap-mailbox/core/src/main/java/org/apache/james/mpt/imapmailbox/suite/ACLIntegration.java @@ -60,42 +60,42 @@ public abstract class ACLIntegration implements ImapTestConstants { @Test public void rightRShouldBeSufficientToPerformStatusSelectCloseExamineUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("r")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("r")) .run("aclIntegration/ACLIntegrationRightR"); } @Test public void rightRShouldBeNeededToPerformStatusSelectCloseExamineUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("lswipkxtecda")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("lswipkxtecda")) .run("aclIntegration/ACLIntegrationWithoutRightR"); } @Test public void rightLShouldBeSufficientToPerformListUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("l")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("l")) .run("aclIntegration/ACLIntegrationRightL"); } @Test public void rightLShouldBeNeededToPerformListLsubSubscribeUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("rswipkxtecda")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rswipkxtecda")) .run("aclIntegration/ACLIntegrationWithoutRightL"); } @Test public void rightAShouldBeSufficientToManageACLUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("a")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("a")) .run("aclIntegration/ACLIntegrationRightA"); } @Test public void rightAShouldBeNeededToManageACLUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("rswipkxtecdl")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rswipkxtecdl")) .run("aclIntegration/ACLIntegrationWithoutRightA"); } @@ -103,7 +103,7 @@ public abstract class ACLIntegration implements ImapTestConstants { public void rightXOnOriginShouldBeSufficientToRenameAMailboxUS() throws Exception { scriptedTestProtocol .withMailbox(new MailboxPath("#private","Boby","test")) - .withGrantRights(new MailboxPath("#private", OTHER_USER_NAME, "test"), USER, new MailboxACL.Rfc4314Rights("x")) + .withGrantRights(new MailboxPath("#private", OTHER_USER_NAME, "test"), USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("x")) .run("aclIntegration/ACLIntegrationRightX"); } @@ -111,7 +111,7 @@ public abstract class ACLIntegration implements ImapTestConstants { public void rightXOnOriginShouldBeNeededToRenameAMailboxUS() throws Exception { scriptedTestProtocol .withMailbox(new MailboxPath("#private","Boby","test")) - .withGrantRights(new MailboxPath("#private", OTHER_USER_NAME, "test"), USER, new MailboxACL.Rfc4314Rights("rswipktela")) + .withGrantRights(new MailboxPath("#private", OTHER_USER_NAME, "test"), USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rswipktela")) .run("aclIntegration/ACLIntegrationWithoutRightX"); } @@ -120,8 +120,8 @@ public abstract class ACLIntegration implements ImapTestConstants { MailboxPath newMailbox = new MailboxPath("#private", USER, "test"); scriptedTestProtocol .withMailbox(newMailbox) - .withGrantRights(newMailbox, USER, new MailboxACL.Rfc4314Rights("x")) - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("k")) + .withGrantRights(newMailbox, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("x")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("k")) .run("aclIntegration/ACLIntegrationRightK"); } @@ -130,64 +130,64 @@ public abstract class ACLIntegration implements ImapTestConstants { MailboxPath newMailbox = new MailboxPath("#private", USER, "test"); scriptedTestProtocol .withMailbox(newMailbox) - .withGrantRights(newMailbox, USER, new MailboxACL.Rfc4314Rights("x")) - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("rswipxtela")) + .withGrantRights(newMailbox, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("x")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rswipxtela")) .run("aclIntegration/ACLIntegrationWithoutRightK"); } @Test public void rightREShouldBeSufficientToPerformExpungeUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("re")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("re")) .run("aclIntegration/ACLIntegrationRightRE"); } @Test public void rightEShouldBeNeededToPerformExpungeUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("rswipxtclak")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rswipxtclak")) .run("aclIntegration/ACLIntegrationWithoutRightE"); } @Test public void rightIShouldBeSufficientToPerformAppendUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("ri")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("ri")) .run("aclIntegration/ACLIntegrationRightI"); } @Test public void rightIShouldBeNeededToPerformAppendUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("rswepxtcdlak")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rswepxtcdlak")) .run("aclIntegration/ACLIntegrationWithoutRightI"); } @Test public void rightISShouldBeSufficientToPerformAppendOfSeenMessageUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("ris")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("ris")) .run("aclIntegration/ACLIntegrationRightIS"); } @Test public void rightITShouldBeSufficientToPerformAppendOfDeletedMessageUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("rit")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rit")) .run("aclIntegration/ACLIntegrationRightIT"); } @Test public void rightIWShouldBeSufficientToPerformAppendOfDeletedMessageUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("riw")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("riw")) .run("aclIntegration/ACLIntegrationRightIW"); } @Test public void rightRSShouldBeSufficientToPerformStoreAndFetchOnSeenMessageUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("rs")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rs")) .withFilledMailbox(OTHER_USER_MAILBOX) .run("aclIntegration/ACLIntegrationRightRS"); } @@ -195,7 +195,7 @@ public abstract class ACLIntegration implements ImapTestConstants { @Test public void rightSShouldBeNeededToPerformStoreAndFetchOnSeenMessageUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("rwipxtcdlake")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rwipxtcdlake")) .withFilledMailbox(OTHER_USER_MAILBOX) .run("aclIntegration/ACLIntegrationWithoutRightS"); } @@ -203,7 +203,7 @@ public abstract class ACLIntegration implements ImapTestConstants { @Test public void rightRWShouldBeSufficientToPerformStoreOnFlaggedMessageUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("rw")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rw")) .withFilledMailbox(OTHER_USER_MAILBOX) .run("aclIntegration/ACLIntegrationRightRW"); } @@ -211,7 +211,7 @@ public abstract class ACLIntegration implements ImapTestConstants { @Test public void rightWShouldBeNeededToPerformStoreOnFlaggedMessageUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("rsipxtcdlake")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rsipxtcdlake")) .withFilledMailbox(OTHER_USER_MAILBOX) .run("aclIntegration/ACLIntegrationWithoutRightW"); } @@ -219,7 +219,7 @@ public abstract class ACLIntegration implements ImapTestConstants { @Test public void rightRTShouldBeSufficientToPerformStoreOnDeletedMessageUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("rt")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rt")) .withFilledMailbox(OTHER_USER_MAILBOX) .run("aclIntegration/ACLIntegrationRightRT"); } @@ -227,7 +227,7 @@ public abstract class ACLIntegration implements ImapTestConstants { @Test public void rightTShouldBeNeededToPerformStoreOnFlaggedMessageUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("rwipxslake")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rwipxslake")) .withFilledMailbox(OTHER_USER_MAILBOX) .run("aclIntegration/ACLIntegrationWithoutRightT"); } @@ -235,7 +235,7 @@ public abstract class ACLIntegration implements ImapTestConstants { @Test public void rightIShouldBeSufficientToPerformCopyUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("i")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("i")) .withFilledMailbox(MY_INBOX) .run("aclIntegration/ACLIntegrationCopyI"); } @@ -243,7 +243,7 @@ public abstract class ACLIntegration implements ImapTestConstants { @Test public void rightIShouldBeNeededToPerformCopyUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("rswpxtcdlake")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rswpxtcdlake")) .withFilledMailbox(MY_INBOX) .run("aclIntegration/ACLIntegrationCopyWithoutI"); } @@ -251,7 +251,7 @@ public abstract class ACLIntegration implements ImapTestConstants { @Test public void rightIShouldBeSufficientToPerformOfSeenMessagesCopyUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("ris")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("ris")) .withFilledMailbox(MY_INBOX) .run("aclIntegration/ACLIntegrationCopyIS"); } @@ -259,7 +259,7 @@ public abstract class ACLIntegration implements ImapTestConstants { @Test public void rightSShouldBeNeededToPerformCopyOfSeenMessageUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("riwpxtcdlake")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("riwpxtcdlake")) .withFilledMailbox(MY_INBOX) .run("aclIntegration/ACLIntegrationCopyWithoutS"); } @@ -267,7 +267,7 @@ public abstract class ACLIntegration implements ImapTestConstants { @Test public void rightIWShouldBeSufficientToPerformOfFlaggedMessagesCopyUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("riw")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("riw")) .withFilledMailbox(MY_INBOX) .run("aclIntegration/ACLIntegrationCopyIW"); } @@ -275,7 +275,7 @@ public abstract class ACLIntegration implements ImapTestConstants { @Test public void rightWShouldBeNeededToPerformCopyOfFlaggedMessageUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("rispxtcdlake")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rispxtcdlake")) .withFilledMailbox(MY_INBOX) .run("aclIntegration/ACLIntegrationCopyWithoutW"); } @@ -283,7 +283,7 @@ public abstract class ACLIntegration implements ImapTestConstants { @Test public void rightITShouldBeSufficientToPerformOfDeletedMessagesCopyUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("rit")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rit")) .withFilledMailbox(MY_INBOX) .run("aclIntegration/ACLIntegrationCopyIT"); } @@ -291,7 +291,7 @@ public abstract class ACLIntegration implements ImapTestConstants { @Test public void rightTShouldBeNeededToPerformCopyOfDeletedMessageUS() throws Exception { scriptedTestProtocol - .withGrantRights(OTHER_USER_MAILBOX, USER, new MailboxACL.Rfc4314Rights("rispxwlake")) + .withGrantRights(OTHER_USER_MAILBOX, USER, MailboxACL.Rfc4314Rights.fromSerializedRfc4314Rights("rispxwlake")) .withFilledMailbox(MY_INBOX) .run("aclIntegration/ACLIntegrationCopyWithoutT"); } http://git-wip-us.apache.org/repos/asf/james-project/blob/3f013691/protocols/imap/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java index 64ebe70..f03c6f6 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/SetACLProcessor.java @@ -86,7 +86,7 @@ public class SetACLProcessor extends AbstractMailboxProcessor<SetACLRequest> imp break; } } - Rfc4314Rights mailboxAclRights = new Rfc4314Rights(rights); + Rfc4314Rights mailboxAclRights = Rfc4314Rights.fromSerializedRfc4314Rights(rights); MailboxPath mailboxPath = PathConverter.forSession(session).buildFullPath(mailboxName); // Check that mailbox exists http://git-wip-us.apache.org/repos/asf/james-project/blob/3f013691/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 bcbb707..0f914fc 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 @@ -114,7 +114,7 @@ public class ListRightsProcessorTest { listRightsRequest = new ListRightsRequest("TAG", ImapCommand.anyStateCommand("Name"), MAILBOX_NAME, USER_1); user1Key = EntryKey.deserialize(USER_1); - listRights = new Rfc4314Rights[] {new Rfc4314Rights("ae"), new Rfc4314Rights("i"), new Rfc4314Rights("k")}; + listRights = new Rfc4314Rights[] {Rfc4314Rights.fromSerializedRfc4314Rights("ae"), Rfc4314Rights.fromSerializedRfc4314Rights("i"), Rfc4314Rights.fromSerializedRfc4314Rights("k")}; } @Test http://git-wip-us.apache.org/repos/asf/james-project/blob/3f013691/protocols/imap/src/test/java/org/apache/james/imap/processor/SetACLProcessorTest.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/SetACLProcessorTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/SetACLProcessorTest.java index 09ac72c..ab4d8e8 100644 --- a/protocols/imap/src/test/java/org/apache/james/imap/processor/SetACLProcessorTest.java +++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/SetACLProcessorTest.java @@ -116,7 +116,7 @@ public class SetACLProcessorTest { replaceACLRequest = new SetACLRequest("TAG", ImapCommand.anyStateCommand("Name"), MAILBOX_NAME, USER_1, SET_RIGHTS); user1Key = EntryKey.deserialize(USER_1); - setRights = new Rfc4314Rights(SET_RIGHTS); + setRights = Rfc4314Rights.fromSerializedRfc4314Rights(SET_RIGHTS); } @Test --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org