http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxACLEntryKeyTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxACLEntryKeyTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxACLEntryKeyTest.java new file mode 100644 index 0000000..32e8178 --- /dev/null +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxACLEntryKeyTest.java @@ -0,0 +1,157 @@ +/* + * 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.model; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.james.mailbox.exception.UnsupportedRightException; +import org.apache.james.mailbox.model.MailboxACL.EntryKey; +import org.apache.james.mailbox.model.MailboxACL.NameType; +import org.apache.james.mailbox.model.MailboxACL.SpecialName; +import org.junit.Test; + +/** + * @author Peter Palaga + */ +public class MailboxACLEntryKeyTest { + private static final String GROUP_1 = "group1"; + private static final String USER_1 = "user1"; + + @Test + public void testUser() throws UnsupportedRightException { + assertThat(EntryKey.deserialize(USER_1)) + .isEqualTo(new EntryKey(USER_1, NameType.user, false)); + } + + @Test + public void testNegativeUser() throws UnsupportedRightException { + assertThat(EntryKey.deserialize(MailboxACL.DEFAULT_NEGATIVE_MARKER + USER_1)) + .isEqualTo(new EntryKey(USER_1, NameType.user, true)); + } + + @Test + public void testGroup() throws UnsupportedRightException { + assertThat(EntryKey.deserialize(MailboxACL.DEFAULT_GROUP_MARKER + GROUP_1)) + .isEqualTo(new EntryKey(GROUP_1, NameType.group, false)); + } + + @Test + public void testNegativeGroup() throws UnsupportedRightException { + assertThat(EntryKey.deserialize(String.valueOf(MailboxACL.DEFAULT_NEGATIVE_MARKER) + MailboxACL.DEFAULT_GROUP_MARKER + GROUP_1)) + .isEqualTo(new EntryKey(GROUP_1, NameType.group, true)); + } + + @Test + public void testOwner() throws UnsupportedRightException { + assertThat(EntryKey.deserialize(SpecialName.owner.toString())) + .isEqualTo(new EntryKey(SpecialName.owner.toString(), NameType.special, false)); + } + + @Test + public void testNegativeOwner() throws UnsupportedRightException { + assertThat(EntryKey.deserialize(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.owner.toString())) + .isEqualTo(new EntryKey(SpecialName.owner.toString(), NameType.special, true)); + } + + @Test + public void testAnybody() throws UnsupportedRightException { + assertThat(EntryKey.deserialize(SpecialName.anybody.toString())) + .isEqualTo(new EntryKey(SpecialName.anybody.toString(), NameType.special, false)); + } + + @Test + public void testNegativeAnybody() throws UnsupportedRightException { + assertThat(EntryKey.deserialize(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.anybody.toString())) + .isEqualTo(new EntryKey(SpecialName.anybody.toString(), NameType.special, true)); + } + + @Test + public void testAuthenticated() throws UnsupportedRightException { + assertThat(EntryKey.deserialize(SpecialName.authenticated.toString())) + .isEqualTo(new EntryKey(SpecialName.authenticated.toString(), NameType.special, false)); + } + + @Test + public void testNegativeAuthenticated() throws UnsupportedRightException { + assertThat(EntryKey.deserialize(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.authenticated.toString())) + .isEqualTo(new EntryKey(SpecialName.authenticated.toString(), NameType.special, true)); + } + + @Test + public void testSerializeUser() throws UnsupportedRightException { + assertThat(new EntryKey(USER_1, NameType.user, false).serialize()) + .isEqualTo(USER_1); + } + + @Test + public void testSerializeNegativeUser() throws UnsupportedRightException { + assertThat(new EntryKey(USER_1, NameType.user, true).serialize()) + .isEqualTo(MailboxACL.DEFAULT_NEGATIVE_MARKER + USER_1); + } + + @Test + public void testSerializeGroup() throws UnsupportedRightException { + assertThat(new EntryKey(GROUP_1, NameType.group, false).serialize()) + .isEqualTo(MailboxACL.DEFAULT_GROUP_MARKER + GROUP_1); + } + + @Test + public void testSerializeNegativeGroup() throws UnsupportedRightException { + assertThat(new EntryKey(GROUP_1, NameType.group, true).serialize()) + .isEqualTo(String.valueOf(MailboxACL.DEFAULT_NEGATIVE_MARKER) + MailboxACL.DEFAULT_GROUP_MARKER + GROUP_1); + } + + @Test + public void testSerializeOwner() throws UnsupportedRightException { + assertThat(new EntryKey(SpecialName.owner.toString(), NameType.special, false).serialize()) + .isEqualTo(SpecialName.owner.toString()); + } + + @Test + public void testSerializeNegativeOwner() throws UnsupportedRightException { + assertThat(new EntryKey(SpecialName.owner.toString(), NameType.special, true).serialize()) + .isEqualTo(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.owner.toString()); + } + + @Test + public void testSerializeAnybody() throws UnsupportedRightException { + assertThat(new EntryKey(SpecialName.anybody.toString(), NameType.special, false).serialize()) + .isEqualTo(SpecialName.anybody.toString()); + } + + @Test + public void testSerializeNegativeAnybody() throws UnsupportedRightException { + assertThat(new EntryKey(SpecialName.anybody.toString(), NameType.special, true).serialize()) + .isEqualTo(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.anybody.toString()); + } + + @Test + public void testSerializeAuthenticated() throws UnsupportedRightException { + assertThat(new EntryKey(SpecialName.authenticated.toString(), NameType.special, false).serialize()) + .isEqualTo(SpecialName.authenticated.toString()); + } + + @Test + public void testSerializeNegativeAuthenticated() throws UnsupportedRightException { + assertThat(new EntryKey(SpecialName.authenticated.toString(), NameType.special, true).serialize()) + .isEqualTo(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.authenticated.toString()); + } +}
http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/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 new file mode 100644 index 0000000..5c03032 --- /dev/null +++ b/mailbox/api/src/test/java/org/apache/james/mailbox/model/MailboxACLTest.java @@ -0,0 +1,224 @@ +/* + * 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.model; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.junit.Assert.assertEquals; + +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +import org.apache.james.mailbox.exception.UnsupportedRightException; +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.junit.Before; +import org.junit.Test; + +/** + * @author Peter Palaga + */ +public class MailboxACLTest { + + private static final String USER_1 = "user1"; + private static final String USER_2 = "user2"; + + private static final String ae = "ae"; + private static final String ik = "ik"; + private static final String aeik = "aeik"; + private static final String lprs = "lprs"; + private static final String twx = "twx"; + + private Properties u1u2g1g2Properties; + + private MailboxACL u1u2g1g2ACL; + + @Before + public void setUp() throws Exception { + + u1u2g1g2Properties = new Properties(); + + u1u2g1g2Properties.setProperty(USER_1, aeik); + u1u2g1g2Properties.setProperty(MailboxACL.DEFAULT_NEGATIVE_MARKER + USER_1, lprs); + u1u2g1g2Properties.setProperty(USER_2, lprs); + u1u2g1g2Properties.setProperty(MailboxACL.DEFAULT_NEGATIVE_MARKER + USER_2, twx); + + u1u2g1g2ACL = new MailboxACL(u1u2g1g2Properties); + + } + + @Test + public void testUnionACLNew() throws UnsupportedRightException { + + Map<EntryKey, Rfc4314Rights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); + expectedEntries.put(MailboxACL.OWNER_KEY, MailboxACL.FULL_RIGHTS); + + MailboxACL toAdd = MailboxACL.OWNER_FULL_ACL; + MailboxACL result = u1u2g1g2ACL.union(toAdd); + + Map<EntryKey, Rfc4314Rights> foundEntries = result.getEntries(); + + assertEquals(foundEntries, expectedEntries); + } + + @Test + public void testUnionEntryNew() throws UnsupportedRightException { + + Map<EntryKey, Rfc4314Rights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); + expectedEntries.put(MailboxACL.OWNER_KEY, MailboxACL.FULL_RIGHTS); + + MailboxACL result = u1u2g1g2ACL.union(MailboxACL.OWNER_KEY, MailboxACL.FULL_RIGHTS); + + Map<EntryKey, Rfc4314Rights> foundEntries = result.getEntries(); + + assertThat(foundEntries) + .hasSize(expectedEntries.size()) + .containsAllEntriesOf(expectedEntries); + } + + @Test + public void testUnionACLExisting() throws UnsupportedRightException { + + Map<EntryKey, Rfc4314Rights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); + expectedEntries.put(EntryKey.deserialize(USER_1), new Rfc4314Rights(aeik + lprs)); + + MailboxACL toAdd = new MailboxACL(new Entry(USER_1, lprs)); + MailboxACL result = u1u2g1g2ACL.union(toAdd); + + Map<EntryKey, Rfc4314Rights> foundEntries = result.getEntries(); + + assertEquals(foundEntries, expectedEntries); + } + + @Test + public void testUnionEntryExisting() throws UnsupportedRightException { + + Map<EntryKey, Rfc4314Rights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); + expectedEntries.put(EntryKey.deserialize(USER_1), new Rfc4314Rights(aeik + lprs)); + + MailboxACL result = u1u2g1g2ACL.union(EntryKey.deserialize(USER_1), new Rfc4314Rights(lprs)); + + Map<EntryKey, Rfc4314Rights> foundEntries = result.getEntries(); + + assertEquals(foundEntries, expectedEntries); + } + + @Test + public void testUnionACLZero() throws UnsupportedRightException { + + } + + @Test + public void testUnionEntryZero() throws UnsupportedRightException { + + } + + @Test + public void testExceptACLNew() throws UnsupportedRightException { + + /* actually no change expected */ + Map<EntryKey, Rfc4314Rights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); + + MailboxACL toRemove = MailboxACL.OWNER_FULL_ACL; + MailboxACL result = u1u2g1g2ACL.except(toRemove); + + Map<EntryKey, Rfc4314Rights> foundEntries = result.getEntries(); + + assertEquals(foundEntries, expectedEntries); + } + + @Test + public void testExceptEntryNew() throws UnsupportedRightException { + + /* actually no change expected */ + Map<EntryKey, Rfc4314Rights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); + + MailboxACL result = u1u2g1g2ACL.except(MailboxACL.OWNER_KEY, MailboxACL.FULL_RIGHTS); + + Map<EntryKey, Rfc4314Rights> foundEntries = result.getEntries(); + + assertEquals(foundEntries, expectedEntries); + } + + @Test + public void testExceptACLExisting() throws UnsupportedRightException { + + Map<EntryKey, Rfc4314Rights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); + expectedEntries.put(EntryKey.deserialize(USER_1), new Rfc4314Rights(ik)); + + MailboxACL toRemove = new MailboxACL(new Entry(USER_1, ae)); + MailboxACL result = u1u2g1g2ACL.except(toRemove); + + Map<EntryKey, Rfc4314Rights> foundEntries = result.getEntries(); + + assertThat(foundEntries) + .hasSize(expectedEntries.size()) + .containsAllEntriesOf(expectedEntries); + } + + @Test + public void testExceptEntryExisting() throws UnsupportedRightException { + + Map<EntryKey, Rfc4314Rights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); + expectedEntries.put(EntryKey.deserialize(USER_1), new Rfc4314Rights(ik)); + + MailboxACL result = u1u2g1g2ACL.except(EntryKey.deserialize(USER_1), new Rfc4314Rights(ae)); + + Map<EntryKey, Rfc4314Rights> foundEntries = result.getEntries(); + + assertThat(foundEntries) + .hasSize(expectedEntries.size()) + .containsAllEntriesOf(expectedEntries); + } + + @Test + public void testExceptACLFull() throws UnsupportedRightException { + + Map<EntryKey, Rfc4314Rights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); + expectedEntries.remove(EntryKey.deserialize(USER_1)); + + MailboxACL toRemove = new MailboxACL(new Entry(USER_1, MailboxACL.FULL_RIGHTS.serialize())); + MailboxACL result = u1u2g1g2ACL.except(toRemove); + + Map<EntryKey, Rfc4314Rights> foundEntries = result.getEntries(); + + assertThat(foundEntries) + .hasSize(expectedEntries.size()) + .containsAllEntriesOf(expectedEntries); + } + + @Test + public void testExceptEntryFull() throws UnsupportedRightException { + + Map<EntryKey, Rfc4314Rights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); + expectedEntries.remove(EntryKey.deserialize(USER_1)); + + MailboxACL result = u1u2g1g2ACL.except(EntryKey.deserialize(USER_1), MailboxACL.FULL_RIGHTS); + + Map<EntryKey, Rfc4314Rights> foundEntries = result.getEntries(); + + assertThat(foundEntries) + .hasSize(expectedEntries.size()) + .containsAllEntriesOf(expectedEntries); + } + +} http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/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 ee89e35..e5e3df3 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 @@ -20,22 +20,21 @@ package org.apache.james.mailbox.model; -import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.Administer; -import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.CreateMailbox; -import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.DeleteMailbox; -import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.Insert; -import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.Lookup; -import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.PerformExpunge; -import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.Post; -import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.Read; -import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.Write; -import static org.apache.james.mailbox.model.SimpleMailboxACL.Right.WriteSeenFlag; +import static org.apache.james.mailbox.model.MailboxACL.Right.Administer; +import static org.apache.james.mailbox.model.MailboxACL.Right.CreateMailbox; +import static org.apache.james.mailbox.model.MailboxACL.Right.DeleteMailbox; +import static org.apache.james.mailbox.model.MailboxACL.Right.Insert; +import static org.apache.james.mailbox.model.MailboxACL.Right.Lookup; +import static org.apache.james.mailbox.model.MailboxACL.Right.PerformExpunge; +import static org.apache.james.mailbox.model.MailboxACL.Right.Post; +import static org.apache.james.mailbox.model.MailboxACL.Right.Read; +import static org.apache.james.mailbox.model.MailboxACL.Right.Write; +import static org.apache.james.mailbox.model.MailboxACL.Right.WriteSeenFlag; import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; import org.apache.james.mailbox.exception.UnsupportedRightException; -import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights; -import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights; +import org.apache.james.mailbox.model.MailboxACL.Rfc4314Rights; import org.junit.Before; import org.junit.Test; @@ -47,27 +46,27 @@ public class Rfc4314RightsTest { private Rfc4314Rights aeik; private Rfc4314Rights lprs; private Rfc4314Rights twx; - private MailboxACLRights full; - private MailboxACLRights none; + private Rfc4314Rights full; + private Rfc4314Rights none; @Before public void setUp() throws Exception { - aeik = new SimpleMailboxACL.Rfc4314Rights("aeik"); - lprs = new SimpleMailboxACL.Rfc4314Rights("lprs"); - twx = new SimpleMailboxACL.Rfc4314Rights("twx"); - full = SimpleMailboxACL.FULL_RIGHTS; - none = SimpleMailboxACL.NO_RIGHTS; + aeik = new MailboxACL.Rfc4314Rights("aeik"); + lprs = new MailboxACL.Rfc4314Rights("lprs"); + twx = new MailboxACL.Rfc4314Rights("twx"); + full = MailboxACL.FULL_RIGHTS; + none = MailboxACL.NO_RIGHTS; } @Test(expected=NullPointerException.class) public void newInstanceShouldThrowWhenNullString() throws UnsupportedRightException { - new SimpleMailboxACL.Rfc4314Rights((String) null); + new MailboxACL.Rfc4314Rights((String) null); } @Test public void newInstanceShouldHaveNoRightsWhenEmptyString() throws UnsupportedRightException { - Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(""); - assertThat(rights).isEmpty(); + Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(""); + assertThat(rights.list()).isEmpty(); } @Test @@ -97,7 +96,7 @@ public class Rfc4314RightsTest { @Test public void rfc4314RightsShouldThrowWhenUnknownFlag() throws UnsupportedRightException { - assertThatThrownBy(() -> new SimpleMailboxACL.Rfc4314Rights("z")) + assertThatThrownBy(() -> new MailboxACL.Rfc4314Rights("z")) .isInstanceOf(UnsupportedRightException.class); } @@ -108,7 +107,7 @@ public class Rfc4314RightsTest { @Test public void fullRightsShouldContainsAllRights() { - assertThat(full).containsOnly( + assertThat(full.list()).containsOnly( Administer, PerformExpunge, Insert, @@ -117,19 +116,19 @@ public class Rfc4314RightsTest { Post, Read, WriteSeenFlag, - SimpleMailboxACL.Right.DeleteMessages, - SimpleMailboxACL.Right.Write, - SimpleMailboxACL.Right.DeleteMailbox); + MailboxACL.Right.DeleteMessages, + MailboxACL.Right.Write, + MailboxACL.Right.DeleteMailbox); } @Test public void noneRightsShouldContainsNoRights() { - assertThat(none).isEmpty(); + assertThat(none.list()).isEmpty(); } @Test public void rightsShouldContainsSpecificRightsWhenAEIK() { - assertThat(aeik).containsOnly( + assertThat(aeik.list()).containsOnly( Administer, PerformExpunge, Insert, @@ -138,7 +137,7 @@ public class Rfc4314RightsTest { @Test public void rightsShouldContainsSpecificRightsWhenLPRS() { - assertThat(lprs).containsOnly( + assertThat(lprs.list()).containsOnly( Lookup, Post, Read, @@ -147,30 +146,30 @@ public class Rfc4314RightsTest { @Test public void rightsShouldContainsSpecificRightsWhenTWX() { - assertThat(twx).containsOnly( - SimpleMailboxACL.Right.DeleteMessages, - SimpleMailboxACL.Right.Write, - SimpleMailboxACL.Right.DeleteMailbox); + assertThat(twx.list()).containsOnly( + MailboxACL.Right.DeleteMessages, + MailboxACL.Right.Write, + MailboxACL.Right.DeleteMailbox); } @Test public void getValueShouldReturnSigmaWhenAeik() throws UnsupportedRightException { - assertThat(aeik).containsExactly(Administer, PerformExpunge, Insert, CreateMailbox); + assertThat(aeik.list()).containsExactly(Administer, PerformExpunge, Insert, CreateMailbox); } @Test public void getValueShouldReturnSigmaWhenLprs() throws UnsupportedRightException { - assertThat(lprs).containsExactly(Lookup, Post, Read, WriteSeenFlag); + assertThat(lprs.list()).containsExactly(Lookup, Post, Read, WriteSeenFlag); } @Test public void getValueShouldReturnSigmaWhenTwx() throws UnsupportedRightException { - assertThat(twx).containsExactly(SimpleMailboxACL.Right.DeleteMessages, Write, DeleteMailbox); + assertThat(twx.list()).containsExactly(MailboxACL.Right.DeleteMessages, Write, DeleteMailbox); } @Test public void getValueShouldReturnEmptyWhenNone() throws UnsupportedRightException { - assertThat(new SimpleMailboxACL.Rfc4314Rights("")).isEmpty(); + assertThat(new MailboxACL.Rfc4314Rights("").list()).isEmpty(); } @Test http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/mailbox/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLEntryKeyTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLEntryKeyTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLEntryKeyTest.java deleted file mode 100644 index 92d4ce9..0000000 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLEntryKeyTest.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * 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.model; - -import static org.assertj.core.api.Assertions.assertThat; - -import org.apache.james.mailbox.exception.UnsupportedRightException; -import org.apache.james.mailbox.model.MailboxACL.NameType; -import org.apache.james.mailbox.model.MailboxACL.SpecialName; -import org.apache.james.mailbox.model.SimpleMailboxACL.SimpleMailboxACLEntryKey; -import org.junit.Test; - -/** - * @author Peter Palaga - */ -public class SimpleMailboxACLEntryKeyTest { - private static final String GROUP_1 = "group1"; - private static final String USER_1 = "user1"; - - @Test - public void testUser() throws UnsupportedRightException { - assertThat(SimpleMailboxACLEntryKey.deserialize(USER_1)) - .isEqualTo(new SimpleMailboxACLEntryKey(USER_1, NameType.user, false)); - } - - @Test - public void testNegativeUser() throws UnsupportedRightException { - assertThat(SimpleMailboxACLEntryKey.deserialize(MailboxACL.DEFAULT_NEGATIVE_MARKER + USER_1)) - .isEqualTo(new SimpleMailboxACLEntryKey(USER_1, NameType.user, true)); - } - - @Test - public void testGroup() throws UnsupportedRightException { - assertThat(SimpleMailboxACLEntryKey.deserialize(MailboxACL.DEFAULT_GROUP_MARKER + GROUP_1)) - .isEqualTo(new SimpleMailboxACLEntryKey(GROUP_1, NameType.group, false)); - } - - @Test - public void testNegativeGroup() throws UnsupportedRightException { - assertThat(SimpleMailboxACLEntryKey.deserialize(String.valueOf(MailboxACL.DEFAULT_NEGATIVE_MARKER) + MailboxACL.DEFAULT_GROUP_MARKER + GROUP_1)) - .isEqualTo(new SimpleMailboxACLEntryKey(GROUP_1, NameType.group, true)); - } - - @Test - public void testOwner() throws UnsupportedRightException { - assertThat(SimpleMailboxACLEntryKey.deserialize(SpecialName.owner.toString())) - .isEqualTo(new SimpleMailboxACLEntryKey(SpecialName.owner.toString(), NameType.special, false)); - } - - @Test - public void testNegativeOwner() throws UnsupportedRightException { - assertThat(SimpleMailboxACLEntryKey.deserialize(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.owner.toString())) - .isEqualTo(new SimpleMailboxACLEntryKey(SpecialName.owner.toString(), NameType.special, true)); - } - - @Test - public void testAnybody() throws UnsupportedRightException { - assertThat(SimpleMailboxACLEntryKey.deserialize(SpecialName.anybody.toString())) - .isEqualTo(new SimpleMailboxACLEntryKey(SpecialName.anybody.toString(), NameType.special, false)); - } - - @Test - public void testNegativeAnybody() throws UnsupportedRightException { - assertThat(SimpleMailboxACLEntryKey.deserialize(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.anybody.toString())) - .isEqualTo(new SimpleMailboxACLEntryKey(SpecialName.anybody.toString(), NameType.special, true)); - } - - @Test - public void testAuthenticated() throws UnsupportedRightException { - assertThat(SimpleMailboxACLEntryKey.deserialize(SpecialName.authenticated.toString())) - .isEqualTo(new SimpleMailboxACLEntryKey(SpecialName.authenticated.toString(), NameType.special, false)); - } - - @Test - public void testNegativeAuthenticated() throws UnsupportedRightException { - assertThat(SimpleMailboxACLEntryKey.deserialize(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.authenticated.toString())) - .isEqualTo(new SimpleMailboxACLEntryKey(SpecialName.authenticated.toString(), NameType.special, true)); - } - @Test - public void testSerializeUser() throws UnsupportedRightException { - assertThat(new SimpleMailboxACLEntryKey(USER_1, NameType.user, false).serialize()) - .isEqualTo(USER_1); - } - - @Test - public void testSerializeNegativeUser() throws UnsupportedRightException { - assertThat(new SimpleMailboxACLEntryKey(USER_1, NameType.user, true).serialize()) - .isEqualTo(MailboxACL.DEFAULT_NEGATIVE_MARKER + USER_1); - } - - @Test - public void testSerializeGroup() throws UnsupportedRightException { - assertThat(new SimpleMailboxACLEntryKey(GROUP_1, NameType.group, false).serialize()) - .isEqualTo(MailboxACL.DEFAULT_GROUP_MARKER + GROUP_1); - } - - @Test - public void testSerializeNegativeGroup() throws UnsupportedRightException { - assertThat(new SimpleMailboxACLEntryKey(GROUP_1, NameType.group, true).serialize()) - .isEqualTo(String.valueOf(MailboxACL.DEFAULT_NEGATIVE_MARKER) + MailboxACL.DEFAULT_GROUP_MARKER + GROUP_1); - } - - @Test - public void testSerializeOwner() throws UnsupportedRightException { - assertThat(new SimpleMailboxACLEntryKey(SpecialName.owner.toString(), NameType.special, false).serialize()) - .isEqualTo(SpecialName.owner.toString()); - } - - @Test - public void testSerializeNegativeOwner() throws UnsupportedRightException { - assertThat(new SimpleMailboxACLEntryKey(SpecialName.owner.toString(), NameType.special, true).serialize()) - .isEqualTo(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.owner.toString()); - } - - @Test - public void testSerializeAnybody() throws UnsupportedRightException { - assertThat(new SimpleMailboxACLEntryKey(SpecialName.anybody.toString(), NameType.special, false).serialize()) - .isEqualTo(SpecialName.anybody.toString()); - } - - @Test - public void testSerializeNegativeAnybody() throws UnsupportedRightException { - assertThat(new SimpleMailboxACLEntryKey(SpecialName.anybody.toString(), NameType.special, true).serialize()) - .isEqualTo(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.anybody.toString()); - } - - - @Test - public void testSerializeAuthenticated() throws UnsupportedRightException { - assertThat(new SimpleMailboxACLEntryKey(SpecialName.authenticated.toString(), NameType.special, false).serialize()) - .isEqualTo(SpecialName.authenticated.toString()); - } - - @Test - public void testSerializeNegativeAuthenticated() throws UnsupportedRightException { - assertThat(new SimpleMailboxACLEntryKey(SpecialName.authenticated.toString(), NameType.special, true).serialize()) - .isEqualTo(MailboxACL.DEFAULT_NEGATIVE_MARKER + SpecialName.authenticated.toString()); - } -} http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/mailbox/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLTest.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLTest.java deleted file mode 100644 index ed359c3..0000000 --- a/mailbox/api/src/test/java/org/apache/james/mailbox/model/SimpleMailboxACLTest.java +++ /dev/null @@ -1,226 +0,0 @@ -/* - * 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.model; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.junit.Assert.assertEquals; - -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -import org.apache.james.mailbox.exception.UnsupportedRightException; -import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey; -import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights; -import org.apache.james.mailbox.model.SimpleMailboxACL.Rfc4314Rights; -import org.apache.james.mailbox.model.SimpleMailboxACL.SimpleMailboxACLEntry; -import org.apache.james.mailbox.model.SimpleMailboxACL.SimpleMailboxACLEntryKey; -import org.junit.Before; -import org.junit.Test; - -/** - * @author Peter Palaga - */ -public class SimpleMailboxACLTest { - - private static final String USER_1 = "user1"; - private static final String USER_2 = "user2"; - - private static final String ae = "ae"; - private static final String ik = "ik"; - private static final String aeik = "aeik"; - private static final String lprs = "lprs"; - private static final String twx = "twx"; - - private Properties u1u2g1g2Properties; - - private MailboxACL u1u2g1g2ACL; - - @Before - public void setUp() throws Exception { - - u1u2g1g2Properties = new Properties(); - - u1u2g1g2Properties.setProperty(USER_1, aeik); - u1u2g1g2Properties.setProperty(MailboxACL.DEFAULT_NEGATIVE_MARKER + USER_1, lprs); - u1u2g1g2Properties.setProperty(USER_2, lprs); - u1u2g1g2Properties.setProperty(MailboxACL.DEFAULT_NEGATIVE_MARKER + USER_2, twx); - - u1u2g1g2ACL = new SimpleMailboxACL(u1u2g1g2Properties); - - } - - @Test - public void testUnionACLNew() throws UnsupportedRightException { - - Map<MailboxACLEntryKey, MailboxACLRights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - expectedEntries.put(SimpleMailboxACL.OWNER_KEY, SimpleMailboxACL.FULL_RIGHTS); - - MailboxACL toAdd = SimpleMailboxACL.OWNER_FULL_ACL; - MailboxACL result = u1u2g1g2ACL.union(toAdd); - - Map<MailboxACLEntryKey, MailboxACLRights> foundEntries = result.getEntries(); - - assertEquals(foundEntries, expectedEntries); - } - - @Test - public void testUnionEntryNew() throws UnsupportedRightException { - - Map<MailboxACLEntryKey, MailboxACLRights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - expectedEntries.put(SimpleMailboxACL.OWNER_KEY, SimpleMailboxACL.FULL_RIGHTS); - - MailboxACL result = u1u2g1g2ACL.union(SimpleMailboxACL.OWNER_KEY, SimpleMailboxACL.FULL_RIGHTS); - - Map<MailboxACLEntryKey, MailboxACLRights> foundEntries = result.getEntries(); - - assertThat(foundEntries) - .hasSize(expectedEntries.size()) - .containsAllEntriesOf(expectedEntries); - } - - @Test - public void testUnionACLExisting() throws UnsupportedRightException { - - Map<MailboxACLEntryKey, MailboxACLRights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - expectedEntries.put(SimpleMailboxACLEntryKey.deserialize(USER_1), new Rfc4314Rights(aeik + lprs)); - - MailboxACL toAdd = new SimpleMailboxACL(new SimpleMailboxACLEntry(USER_1, lprs)); - MailboxACL result = u1u2g1g2ACL.union(toAdd); - - Map<MailboxACLEntryKey, MailboxACLRights> foundEntries = result.getEntries(); - - assertEquals(foundEntries, expectedEntries); - } - - @Test - public void testUnionEntryExisting() throws UnsupportedRightException { - - Map<MailboxACLEntryKey, MailboxACLRights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - expectedEntries.put(SimpleMailboxACLEntryKey.deserialize(USER_1), new Rfc4314Rights(aeik + lprs)); - - MailboxACL result = u1u2g1g2ACL.union(SimpleMailboxACLEntryKey.deserialize(USER_1), new Rfc4314Rights(lprs)); - - Map<MailboxACLEntryKey, MailboxACLRights> foundEntries = result.getEntries(); - - assertEquals(foundEntries, expectedEntries); - } - - @Test - public void testUnionACLZero() throws UnsupportedRightException { - - } - - @Test - public void testUnionEntryZero() throws UnsupportedRightException { - - } - - @Test - public void testExceptACLNew() throws UnsupportedRightException { - - /* actually no change expected */ - Map<MailboxACLEntryKey, MailboxACLRights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - - MailboxACL toRemove = SimpleMailboxACL.OWNER_FULL_ACL; - MailboxACL result = u1u2g1g2ACL.except(toRemove); - - Map<MailboxACLEntryKey, MailboxACLRights> foundEntries = result.getEntries(); - - assertEquals(foundEntries, expectedEntries); - } - - @Test - public void testExceptEntryNew() throws UnsupportedRightException { - - /* actually no change expected */ - Map<MailboxACLEntryKey, MailboxACLRights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - - MailboxACL result = u1u2g1g2ACL.except(SimpleMailboxACL.OWNER_KEY, SimpleMailboxACL.FULL_RIGHTS); - - Map<MailboxACLEntryKey, MailboxACLRights> foundEntries = result.getEntries(); - - assertEquals(foundEntries, expectedEntries); - } - - @Test - public void testExceptACLExisting() throws UnsupportedRightException { - - Map<MailboxACLEntryKey, MailboxACLRights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - expectedEntries.put(SimpleMailboxACLEntryKey.deserialize(USER_1), new Rfc4314Rights(ik)); - - MailboxACL toRemove = new SimpleMailboxACL(new SimpleMailboxACLEntry(USER_1, ae)); - MailboxACL result = u1u2g1g2ACL.except(toRemove); - - Map<MailboxACLEntryKey, MailboxACLRights> foundEntries = result.getEntries(); - - assertThat(foundEntries) - .hasSize(expectedEntries.size()) - .containsAllEntriesOf(expectedEntries); - } - - @Test - public void testExceptEntryExisting() throws UnsupportedRightException { - - Map<MailboxACLEntryKey, MailboxACLRights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - expectedEntries.put(SimpleMailboxACLEntryKey.deserialize(USER_1), new Rfc4314Rights(ik)); - - MailboxACL result = u1u2g1g2ACL.except(SimpleMailboxACLEntryKey.deserialize(USER_1), new Rfc4314Rights(ae)); - - Map<MailboxACLEntryKey, MailboxACLRights> foundEntries = result.getEntries(); - - assertThat(foundEntries) - .hasSize(expectedEntries.size()) - .containsAllEntriesOf(expectedEntries); - } - - @Test - public void testExceptACLFull() throws UnsupportedRightException { - - Map<MailboxACLEntryKey, MailboxACLRights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - expectedEntries.remove(SimpleMailboxACLEntryKey.deserialize(USER_1)); - - MailboxACL toRemove = new SimpleMailboxACL(new SimpleMailboxACLEntry(USER_1, SimpleMailboxACL.FULL_RIGHTS.serialize())); - MailboxACL result = u1u2g1g2ACL.except(toRemove); - - Map<MailboxACLEntryKey, MailboxACLRights> foundEntries = result.getEntries(); - - assertThat(foundEntries) - .hasSize(expectedEntries.size()) - .containsAllEntriesOf(expectedEntries); - } - - @Test - public void testExceptEntryFull() throws UnsupportedRightException { - - Map<MailboxACLEntryKey, MailboxACLRights> expectedEntries = new HashMap<>(u1u2g1g2ACL.getEntries()); - expectedEntries.remove(SimpleMailboxACLEntryKey.deserialize(USER_1)); - - MailboxACL result = u1u2g1g2ACL.except(SimpleMailboxACLEntryKey.deserialize(USER_1), SimpleMailboxACL.FULL_RIGHTS); - - Map<MailboxACLEntryKey, MailboxACLRights> foundEntries = result.getEntries(); - - assertThat(foundEntries) - .hasSize(expectedEntries.size()) - .containsAllEntriesOf(expectedEntries); - } - -} http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/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 737a33f..fe96f6a 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 @@ -18,6 +18,7 @@ ****************************************************************/ package org.apache.james.mailbox.caching; + import java.util.List; import org.apache.james.mailbox.exception.MailboxException; @@ -106,7 +107,7 @@ public class CachingMailboxMapper implements MailboxMapper { } @Override - public void updateACL(Mailbox mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException { + public void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException { mailbox.setACL(mailbox.getACL().apply(mailboxACLCommand)); } http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java index 1f1527f..b17deb1 100644 --- a/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java +++ b/mailbox/cassandra/src/main/java/org/apache/james/mailbox/cassandra/CassandraMailboxManager.java @@ -31,10 +31,10 @@ 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.MailboxException; +import org.apache.james.mailbox.model.MailboxACL; import org.apache.james.mailbox.model.MailboxConstants; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.model.MessageId; -import org.apache.james.mailbox.model.SimpleMailboxACL; import org.apache.james.mailbox.store.Authenticator; import org.apache.james.mailbox.store.Authorizator; import org.apache.james.mailbox.store.StoreMailboxManager; @@ -122,7 +122,7 @@ public class CassandraMailboxManager extends StoreMailboxManager { @Override protected Mailbox doCreateMailbox(MailboxPath mailboxPath, MailboxSession session) throws MailboxException { SimpleMailbox cassandraMailbox = new SimpleMailbox(mailboxPath, randomUidValidity()); - cassandraMailbox.setACL(SimpleMailboxACL.EMPTY); + cassandraMailbox.setACL(MailboxACL.EMPTY); return cassandraMailbox; } http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/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 b2603a2..ac98402 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 @@ -41,7 +41,6 @@ import org.apache.james.mailbox.cassandra.table.CassandraMailboxTable; import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.exception.UnsupportedRightException; import org.apache.james.mailbox.model.MailboxACL; -import org.apache.james.mailbox.model.SimpleMailboxACL; import org.apache.james.mailbox.store.json.SimpleMailboxACLJsonConverter; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -116,13 +115,13 @@ public class CassandraACLMapper { private MailboxACL getAcl(CassandraId cassandraId, ResultSet resultSet) { if (resultSet.isExhausted()) { - return SimpleMailboxACL.EMPTY; + return MailboxACL.EMPTY; } String serializedACL = resultSet.one().getString(CassandraACLTable.ACL); return deserializeACL(cassandraId, serializedACL); } - public void updateACL(CassandraId cassandraId, MailboxACL.MailboxACLCommand command) throws MailboxException { + public void updateACL(CassandraId cassandraId, MailboxACL.ACLCommand command) throws MailboxException { try { new FunctionRunnerWithRetry(maxRetry) .execute( @@ -151,9 +150,9 @@ public class CassandraACLMapper { } } - private MailboxACL applyCommandOnEmptyACL(MailboxACL.MailboxACLCommand command) { + private MailboxACL applyCommandOnEmptyACL(MailboxACL.ACLCommand command) { try { - return SimpleMailboxACL.EMPTY.apply(command); + return MailboxACL.EMPTY.apply(command); } catch (UnsupportedRightException exception) { throw Throwables.propagate(exception); } @@ -208,7 +207,7 @@ public class CassandraACLMapper { "We will use empty ACL instead." + "Mailbox is {} ." + "ACL is {}", cassandraId, serializedACL, exception); - return SimpleMailboxACL.EMPTY; + return MailboxACL.EMPTY; } } @@ -221,7 +220,7 @@ public class CassandraACLMapper { this.mailboxACL = mailboxACL; } - public ACLWithVersion apply(MailboxACL.MailboxACLCommand command) { + public ACLWithVersion apply(MailboxACL.ACLCommand command) { try { return new ACLWithVersion(version, mailboxACL.apply(command)); } catch(UnsupportedRightException exception) { http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/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 a9a31d8..0fedc18 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 @@ -216,7 +216,7 @@ public class CassandraMailboxMapper implements MailboxMapper { } @Override - public void updateACL(Mailbox mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException { + public void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException { CassandraId cassandraId = (CassandraId) mailbox.getMailboxId(); cassandraACLMapper.updateACL(cassandraId, mailboxACLCommand); } http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java ---------------------------------------------------------------------- diff --git a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java index 9c4ef70..2439316 100644 --- a/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java +++ b/mailbox/cassandra/src/test/java/org/apache/james/mailbox/cassandra/mail/CassandraACLMapperTest.java @@ -38,7 +38,6 @@ import org.apache.james.mailbox.cassandra.modules.CassandraAclModule; import org.apache.james.mailbox.cassandra.table.CassandraACLTable; import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.model.MailboxACL; -import org.apache.james.mailbox.model.SimpleMailboxACL; import org.junit.After; import org.junit.Before; import org.junit.ClassRule; @@ -78,9 +77,9 @@ public class CassandraACLMapperTest { assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()) .isEqualTo( - SimpleMailboxACL.EMPTY.union( - new SimpleMailboxACL.SimpleMailboxACLEntryKey("bob", MailboxACL.NameType.user, false), - new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Right.Read)) + MailboxACL.EMPTY.union( + new MailboxACL.EntryKey("bob", MailboxACL.NameType.user, false), + new MailboxACL.Rfc4314Rights(MailboxACL.Right.Read)) ); } @@ -92,69 +91,69 @@ public class CassandraACLMapperTest { .value(CassandraACLTable.ACL, "{\"entries\":{\"bob\":invalid}}") .value(CassandraACLTable.VERSION, 1)); - assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()).isEqualTo(SimpleMailboxACL.EMPTY); + assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()).isEqualTo(MailboxACL.EMPTY); } @Test public void retrieveACLWhenNoACLStoredShouldReturnEmptyACL() { - assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()).isEqualTo(SimpleMailboxACL.EMPTY); + assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()).isEqualTo(MailboxACL.EMPTY); } @Test public void addACLWhenNoneStoredShouldReturnUpdatedACL() throws Exception { - SimpleMailboxACL.SimpleMailboxACLEntryKey key = new SimpleMailboxACL.SimpleMailboxACLEntryKey("bob", MailboxACL.NameType.user, false); - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Right.Read); + MailboxACL.EntryKey key = new MailboxACL.EntryKey("bob", MailboxACL.NameType.user, false); + MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Read); cassandraACLMapper.updateACL(MAILBOX_ID, - new SimpleMailboxACL.SimpleMailboxACLCommand(key, MailboxACL.EditMode.ADD, rights)); + new MailboxACL.ACLCommand(key, MailboxACL.EditMode.ADD, rights)); assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()) - .isEqualTo(new SimpleMailboxACL().union(key, rights)); + .isEqualTo(new MailboxACL().union(key, rights)); } @Test public void modifyACLWhenStoredShouldReturnUpdatedACL() throws MailboxException { - SimpleMailboxACL.SimpleMailboxACLEntryKey keyBob = new SimpleMailboxACL.SimpleMailboxACLEntryKey("bob", MailboxACL.NameType.user, false); - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Right.Read); + MailboxACL.EntryKey keyBob = new MailboxACL.EntryKey("bob", MailboxACL.NameType.user, false); + MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Read); - cassandraACLMapper.updateACL(MAILBOX_ID, new SimpleMailboxACL.SimpleMailboxACLCommand(keyBob, MailboxACL.EditMode.ADD, rights)); - SimpleMailboxACL.SimpleMailboxACLEntryKey keyAlice = new SimpleMailboxACL.SimpleMailboxACLEntryKey("alice", MailboxACL.NameType.user, false); - cassandraACLMapper.updateACL(MAILBOX_ID, new SimpleMailboxACL.SimpleMailboxACLCommand(keyAlice, MailboxACL.EditMode.ADD, rights)); + cassandraACLMapper.updateACL(MAILBOX_ID, new MailboxACL.ACLCommand(keyBob, MailboxACL.EditMode.ADD, rights)); + MailboxACL.EntryKey keyAlice = new MailboxACL.EntryKey("alice", MailboxACL.NameType.user, false); + cassandraACLMapper.updateACL(MAILBOX_ID, new MailboxACL.ACLCommand(keyAlice, MailboxACL.EditMode.ADD, rights)); assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()) - .isEqualTo(new SimpleMailboxACL().union(keyBob, rights).union(keyAlice, rights)); + .isEqualTo(new MailboxACL().union(keyBob, rights).union(keyAlice, rights)); } @Test public void removeWhenStoredShouldReturnUpdatedACL() throws MailboxException { - SimpleMailboxACL.SimpleMailboxACLEntryKey key = new SimpleMailboxACL.SimpleMailboxACLEntryKey("bob", MailboxACL.NameType.user, false); - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Right.Read); + MailboxACL.EntryKey key = new MailboxACL.EntryKey("bob", MailboxACL.NameType.user, false); + MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Read); - cassandraACLMapper.updateACL(MAILBOX_ID, new SimpleMailboxACL.SimpleMailboxACLCommand(key, MailboxACL.EditMode.ADD, rights)); - cassandraACLMapper.updateACL(MAILBOX_ID, new SimpleMailboxACL.SimpleMailboxACLCommand(key, MailboxACL.EditMode.REMOVE, rights)); + cassandraACLMapper.updateACL(MAILBOX_ID, new MailboxACL.ACLCommand(key, MailboxACL.EditMode.ADD, rights)); + cassandraACLMapper.updateACL(MAILBOX_ID, new MailboxACL.ACLCommand(key, MailboxACL.EditMode.REMOVE, rights)); - assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()).isEqualTo(SimpleMailboxACL.EMPTY); + assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()).isEqualTo(MailboxACL.EMPTY); } @Test public void replaceForSingleKeyWithNullRightsWhenSingleKeyStoredShouldReturnEmptyACL() throws MailboxException { - SimpleMailboxACL.SimpleMailboxACLEntryKey key = new SimpleMailboxACL.SimpleMailboxACLEntryKey("bob", MailboxACL.NameType.user, false); - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Right.Read); + MailboxACL.EntryKey key = new MailboxACL.EntryKey("bob", MailboxACL.NameType.user, false); + MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Read); - cassandraACLMapper.updateACL(MAILBOX_ID, new SimpleMailboxACL.SimpleMailboxACLCommand(key, MailboxACL.EditMode.ADD, rights)); - cassandraACLMapper.updateACL(MAILBOX_ID, new SimpleMailboxACL.SimpleMailboxACLCommand(key, MailboxACL.EditMode.REPLACE, null)); + cassandraACLMapper.updateACL(MAILBOX_ID, new MailboxACL.ACLCommand(key, MailboxACL.EditMode.ADD, rights)); + cassandraACLMapper.updateACL(MAILBOX_ID, new MailboxACL.ACLCommand(key, MailboxACL.EditMode.REPLACE, null)); - assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()).isEqualTo(SimpleMailboxACL.EMPTY); + assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()).isEqualTo(MailboxACL.EMPTY); } @Test public void replaceWhenNotStoredShouldUpdateACLEntry() throws MailboxException { - SimpleMailboxACL.SimpleMailboxACLEntryKey key = new SimpleMailboxACL.SimpleMailboxACLEntryKey("bob", MailboxACL.NameType.user, false); - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Right.Read); + MailboxACL.EntryKey key = new MailboxACL.EntryKey("bob", MailboxACL.NameType.user, false); + MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Read); - cassandraACLMapper.updateACL(MAILBOX_ID, new SimpleMailboxACL.SimpleMailboxACLCommand(key, MailboxACL.EditMode.REPLACE, rights)); + cassandraACLMapper.updateACL(MAILBOX_ID, new MailboxACL.ACLCommand(key, MailboxACL.EditMode.REPLACE, rights)); - assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()).isEqualTo(new SimpleMailboxACL().union(key, rights)); + assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()).isEqualTo(new MailboxACL().union(key, rights)); } @Test @@ -164,43 +163,43 @@ public class CassandraACLMapperTest { .value(CassandraACLTable.ID, MAILBOX_ID.asUuid()) .value(CassandraACLTable.ACL, "{\"entries\":{\"bob\":invalid}}") .value(CassandraACLTable.VERSION, 1)); - SimpleMailboxACL.SimpleMailboxACLEntryKey key = new SimpleMailboxACL.SimpleMailboxACLEntryKey("bob", MailboxACL.NameType.user, false); - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Right.Read); + MailboxACL.EntryKey key = new MailboxACL.EntryKey("bob", MailboxACL.NameType.user, false); + MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Read); - cassandraACLMapper.updateACL(MAILBOX_ID, new SimpleMailboxACL.SimpleMailboxACLCommand(key, MailboxACL.EditMode.ADD, rights)); + cassandraACLMapper.updateACL(MAILBOX_ID, new MailboxACL.ACLCommand(key, MailboxACL.EditMode.ADD, rights)); - assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()).isEqualTo(new SimpleMailboxACL().union(key, rights)); + assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()).isEqualTo(new MailboxACL().union(key, rights)); } @Test public void twoConcurrentUpdatesWhenNoACEStoredShouldReturnACEWithTwoEntries() throws Exception { CountDownLatch countDownLatch = new CountDownLatch(2); - SimpleMailboxACL.SimpleMailboxACLEntryKey keyBob = new SimpleMailboxACL.SimpleMailboxACLEntryKey("bob", MailboxACL.NameType.user, false); - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Right.Read); - SimpleMailboxACL.SimpleMailboxACLEntryKey keyAlice = new SimpleMailboxACL.SimpleMailboxACLEntryKey("alice", MailboxACL.NameType.user, false); + MailboxACL.EntryKey keyBob = new MailboxACL.EntryKey("bob", MailboxACL.NameType.user, false); + MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Read); + MailboxACL.EntryKey keyAlice = new MailboxACL.EntryKey("alice", MailboxACL.NameType.user, false); Future<Boolean> future1 = performACLUpdateInExecutor(executor, keyBob, rights, countDownLatch::countDown); Future<Boolean> future2 = performACLUpdateInExecutor(executor, keyAlice, rights, countDownLatch::countDown); awaitAll(future1, future2); assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()) - .isEqualTo(new SimpleMailboxACL().union(keyBob, rights).union(keyAlice, rights)); + .isEqualTo(new MailboxACL().union(keyBob, rights).union(keyAlice, rights)); } @Test public void twoConcurrentUpdatesWhenStoredShouldReturnACEWithTwoEntries() throws Exception { CountDownLatch countDownLatch = new CountDownLatch(2); - SimpleMailboxACL.SimpleMailboxACLEntryKey keyBenwa = new SimpleMailboxACL.SimpleMailboxACLEntryKey("benwa", MailboxACL.NameType.user, false); - SimpleMailboxACL.Rfc4314Rights rights = new SimpleMailboxACL.Rfc4314Rights(SimpleMailboxACL.Right.Read); - cassandraACLMapper.updateACL(MAILBOX_ID, new SimpleMailboxACL.SimpleMailboxACLCommand(keyBenwa, MailboxACL.EditMode.ADD, rights)); + MailboxACL.EntryKey keyBenwa = new MailboxACL.EntryKey("benwa", MailboxACL.NameType.user, false); + MailboxACL.Rfc4314Rights rights = new MailboxACL.Rfc4314Rights(MailboxACL.Right.Read); + cassandraACLMapper.updateACL(MAILBOX_ID, new MailboxACL.ACLCommand(keyBenwa, MailboxACL.EditMode.ADD, rights)); - SimpleMailboxACL.SimpleMailboxACLEntryKey keyBob = new SimpleMailboxACL.SimpleMailboxACLEntryKey("bob", MailboxACL.NameType.user, false); - SimpleMailboxACL.SimpleMailboxACLEntryKey keyAlice = new SimpleMailboxACL.SimpleMailboxACLEntryKey("alice", MailboxACL.NameType.user, false); + MailboxACL.EntryKey keyBob = new MailboxACL.EntryKey("bob", MailboxACL.NameType.user, false); + MailboxACL.EntryKey keyAlice = new MailboxACL.EntryKey("alice", MailboxACL.NameType.user, false); Future<Boolean> future1 = performACLUpdateInExecutor(executor, keyBob, rights, countDownLatch::countDown); Future<Boolean> future2 = performACLUpdateInExecutor(executor, keyAlice, rights, countDownLatch::countDown); awaitAll(future1, future2); assertThat(cassandraACLMapper.getACL(MAILBOX_ID).join()) - .isEqualTo(new SimpleMailboxACL().union(keyBob, rights).union(keyAlice, rights).union(keyBenwa, rights)); + .isEqualTo(new MailboxACL().union(keyBob, rights).union(keyAlice, rights).union(keyBenwa, rights)); } private void awaitAll(Future<?>... futures) @@ -210,14 +209,14 @@ public class CassandraACLMapperTest { } } - private Future<Boolean> performACLUpdateInExecutor(ExecutorService executor, SimpleMailboxACL.SimpleMailboxACLEntryKey key, SimpleMailboxACL.Rfc4314Rights rights, CassandraACLMapper.CodeInjector runnable) { + private Future<Boolean> performACLUpdateInExecutor(ExecutorService executor, MailboxACL.EntryKey key, MailboxACL.Rfc4314Rights rights, CassandraACLMapper.CodeInjector runnable) { return executor.submit(() -> { CassandraACLMapper aclMapper = new CassandraACLMapper( cassandra.getConf(), CassandraConfiguration.DEFAULT_CONFIGURATION, runnable); try { - aclMapper.updateACL(MAILBOX_ID, new SimpleMailboxACL.SimpleMailboxACLCommand(key, MailboxACL.EditMode.ADD, rights)); + aclMapper.updateACL(MAILBOX_ID, new MailboxACL.ACLCommand(key, MailboxACL.EditMode.ADD, rights)); } catch (MailboxException exception) { throw Throwables.propagate(exception); } http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/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 7675e4a..65833b7 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 @@ -414,7 +414,7 @@ public class HBaseMailboxMapper extends HBaseNonTransactionalMapper implements M } @Override - public void updateACL(Mailbox mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException { + public void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException { mailbox.setACL(mailbox.getACL().apply(mailboxACLCommand)); } http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailbox.java ---------------------------------------------------------------------- diff --git a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailbox.java b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailbox.java index 013371e..c5214e2 100644 --- a/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailbox.java +++ b/mailbox/hbase/src/main/java/org/apache/james/mailbox/hbase/mail/model/HBaseMailbox.java @@ -25,7 +25,6 @@ import org.apache.james.mailbox.hbase.HBaseId; import org.apache.james.mailbox.model.MailboxACL; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.SimpleMailboxACL; import org.apache.james.mailbox.store.mail.model.Mailbox; import org.apache.james.mailbox.store.mail.model.MailboxUtil; @@ -212,7 +211,7 @@ public class HBaseMailbox implements Mailbox { @Override public MailboxACL getACL() { // TODO ACL support - return SimpleMailboxACL.OWNER_FULL_ACL; + return MailboxACL.OWNER_FULL_ACL; } /* (non-Javadoc) http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/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 67f68c4..589b758 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 @@ -251,7 +251,7 @@ public class JCRMailboxMapper extends AbstractJCRScalingMapper implements Mailbo } @Override - public void updateACL(Mailbox mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException { + public void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException { mailbox.setACL(mailbox.getACL().apply(mailboxACLCommand)); } http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMailbox.java ---------------------------------------------------------------------- diff --git a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMailbox.java b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMailbox.java index 21b3ff5..b20c04d 100644 --- a/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMailbox.java +++ b/mailbox/jcr/src/main/java/org/apache/james/mailbox/jcr/mail/model/JCRMailbox.java @@ -30,7 +30,6 @@ import org.apache.james.mailbox.jcr.Persistent; import org.apache.james.mailbox.model.MailboxACL; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.SimpleMailboxACL; import org.apache.james.mailbox.store.mail.model.Mailbox; import org.apache.james.mailbox.store.mail.model.MailboxUtil; import org.slf4j.Logger; @@ -316,7 +315,7 @@ public class JCRMailbox implements Mailbox, JCRImapConstants, Persistent{ @Override public MailboxACL getACL() { // TODO ACL support - return SimpleMailboxACL.OWNER_FULL_ACL; + return MailboxACL.OWNER_FULL_ACL; } /* (non-Javadoc) http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/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 1f14941..9401ec2 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 @@ -221,7 +221,7 @@ public class JPAMailboxMapper extends JPATransactionalMapper implements MailboxM } @Override - public void updateACL(Mailbox mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException { + public void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException { mailbox.setACL(mailbox.getACL().apply(mailboxACLCommand)); } http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java ---------------------------------------------------------------------- diff --git a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java index 84ccf36..0ff88f2 100644 --- a/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java +++ b/mailbox/jpa/src/main/java/org/apache/james/mailbox/jpa/mail/model/JPAMailbox.java @@ -32,7 +32,6 @@ import org.apache.james.mailbox.jpa.JPAId; import org.apache.james.mailbox.model.MailboxACL; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.SimpleMailboxACL; import org.apache.james.mailbox.store.mail.model.Mailbox; import org.apache.james.mailbox.store.mail.model.MailboxUtil; @@ -238,7 +237,7 @@ public class JPAMailbox implements Mailbox { @Override public MailboxACL getACL() { - return SimpleMailboxACL.EMPTY; + return MailboxACL.EMPTY; } @Override http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/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 e9a0186..7f9419f 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 @@ -25,7 +25,6 @@ import org.apache.commons.lang.NotImplementedException; import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.exception.MailboxNotFoundException; import org.apache.james.mailbox.model.MailboxACL; -import org.apache.james.mailbox.model.MailboxACL.MailboxACLCommand; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxPath; import org.apache.james.mailbox.store.mail.MailboxMapper; @@ -80,7 +79,7 @@ public class TransactionalMailboxMapper implements MailboxMapper { } @Override - public void updateACL(Mailbox mailbox, MailboxACLCommand mailboxACLCommand) throws MailboxException { + public void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException { wrapped.updateACL(mailbox, mailboxACLCommand); } http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java ---------------------------------------------------------------------- diff --git a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java index 4f36473..1000686 100644 --- a/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java +++ b/mailbox/lucene/src/test/java/org/apache/james/mailbox/lucene/search/LuceneMailboxMessageSearchIndexTest.java @@ -46,7 +46,6 @@ import org.apache.james.mailbox.model.SearchQuery.DateResolution; import org.apache.james.mailbox.model.SearchQuery.Sort; import org.apache.james.mailbox.model.SearchQuery.Sort.Order; import org.apache.james.mailbox.model.SearchQuery.Sort.SortClause; -import org.apache.james.mailbox.model.SimpleMailboxACL; import org.apache.james.mailbox.model.TestId; import org.apache.james.mailbox.model.TestMessageId; import org.apache.james.mailbox.store.MessageBuilder; @@ -688,7 +687,7 @@ public class LuceneMailboxMessageSearchIndexTest { @Override public MailboxACL getACL() { - return SimpleMailboxACL.OWNER_FULL_ACL; + return MailboxACL.OWNER_FULL_ACL; } @Override http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirFolder.java ---------------------------------------------------------------------- diff --git a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirFolder.java b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirFolder.java index 03e6b8f..7a45a80 100644 --- a/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirFolder.java +++ b/mailbox/maildir/src/main/java/org/apache/james/mailbox/maildir/MaildirFolder.java @@ -40,19 +40,18 @@ import java.util.Properties; import java.util.SortedMap; import java.util.TreeMap; +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang.ArrayUtils; import org.apache.james.mailbox.MailboxPathLocker; import org.apache.james.mailbox.MailboxPathLocker.LockAwareExecution; import org.apache.james.mailbox.MailboxSession; import org.apache.james.mailbox.MessageUid; import org.apache.james.mailbox.exception.MailboxException; import org.apache.james.mailbox.model.MailboxACL; -import org.apache.james.mailbox.model.MailboxACL.MailboxACLEntryKey; -import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights; +import org.apache.james.mailbox.model.MailboxACL.EntryKey; +import org.apache.james.mailbox.model.MailboxACL.Rfc4314Rights; import org.apache.james.mailbox.model.MailboxPath; -import org.apache.james.mailbox.model.SimpleMailboxACL; -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.apache.commons.lang.ArrayUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -934,7 +933,7 @@ public class MaildirFolder { } } - return new SimpleMailboxACL(props); + return new MailboxACL(props); }, true); @@ -959,9 +958,9 @@ public class MaildirFolder { File f = aclFile; OutputStream out = null; Properties props = new Properties(); - Map<MailboxACLEntryKey, MailboxACLRights> entries = acl.getEntries(); + Map<EntryKey, Rfc4314Rights> entries = acl.getEntries(); if (entries != null) { - for (Entry<MailboxACLEntryKey, MailboxACLRights> en : entries.entrySet()) { + for (Entry<EntryKey, Rfc4314Rights> en : entries.entrySet()) { props.put(en.getKey().serialize(), en.getValue().serialize()); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/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 164369a..d459f88 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 @@ -333,7 +333,7 @@ public class MaildirMailboxMapper extends NonTransactionalMapper implements Mail } @Override - public void updateACL(Mailbox mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException { + public void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException { MaildirFolder folder = maildirStore.createMaildirFolder(mailbox); MailboxACL newACL = mailbox.getACL().apply(mailboxACLCommand); folder.setACL(session, newACL); http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/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 918be78..1db5a33 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 @@ -155,7 +155,7 @@ public class InMemoryMailboxMapper implements MailboxMapper { } @Override - public void updateACL(Mailbox mailbox, MailboxACL.MailboxACLCommand mailboxACLCommand) throws MailboxException{ + public void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException{ mailboxesByPath.get(mailbox.generateAssociatedPath()).setACL(mailbox.getACL().apply(mailboxACLCommand)); } http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/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 16391f9..c3c07e7 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 @@ -62,7 +62,6 @@ import org.apache.james.mailbox.model.MessageId; import org.apache.james.mailbox.model.MessageId.Factory; import org.apache.james.mailbox.model.MessageRange; import org.apache.james.mailbox.model.MultimailboxesSearchQuery; -import org.apache.james.mailbox.model.SimpleMailboxACL; import org.apache.james.mailbox.quota.QuotaManager; import org.apache.james.mailbox.quota.QuotaRootResolver; import org.apache.james.mailbox.store.event.DefaultDelegatingMailboxListener; @@ -790,7 +789,7 @@ public class StoreMailboxManager implements MailboxManager { } @Override - public boolean hasRight(MailboxPath mailboxPath, MailboxACL.MailboxACLRight right, MailboxSession session) throws MailboxException { + public boolean hasRight(MailboxPath mailboxPath, MailboxACL.Right right, MailboxSession session) throws MailboxException { MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(session); Mailbox mailbox = mapper.findMailboxByPath(mailboxPath); MailboxSession.User user = session.getUser(); @@ -799,35 +798,35 @@ public class StoreMailboxManager implements MailboxManager { } @Override - public MailboxACL.MailboxACLRights myRights(MailboxPath mailboxPath, MailboxSession session) throws MailboxException { + public MailboxACL.Rfc4314Rights myRights(MailboxPath mailboxPath, MailboxSession session) throws MailboxException { MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(session); Mailbox mailbox = mapper.findMailboxByPath(mailboxPath); MailboxSession.User user = session.getUser(); if (user != null) { return aclResolver.resolveRights(user.getUserName(), groupMembershipResolver, mailbox.getACL(), mailbox.getUser(), new GroupFolderResolver(session).isGroupFolder(mailbox)); } else { - return SimpleMailboxACL.NO_RIGHTS; + return MailboxACL.NO_RIGHTS; } } - public MailboxACL.MailboxACLRights[] listRigths(MailboxPath mailboxPath, MailboxACL.MailboxACLEntryKey key, MailboxSession session) throws MailboxException { - final MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(session); + public MailboxACL.Rfc4314Rights[] listRigths(MailboxPath mailboxPath, MailboxACL.EntryKey key, MailboxSession session) throws MailboxException { + MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(session); Mailbox mailbox = mapper.findMailboxByPath(mailboxPath); return aclResolver.listRights(key, groupMembershipResolver, mailbox.getUser(), new GroupFolderResolver(session).isGroupFolder(mailbox)); } @Override - public void setRights(MailboxPath mailboxPath, MailboxACL.MailboxACLCommand mailboxACLCommand, MailboxSession session) throws MailboxException { - final MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(session); - final Mailbox mailbox = mapper.findMailboxByPath(mailboxPath); + public void setRights(MailboxPath mailboxPath, MailboxACL.ACLCommand mailboxACLCommand, MailboxSession session) throws MailboxException { + MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(session); + Mailbox mailbox = mapper.findMailboxByPath(mailboxPath); mapper.execute(Mapper.toTransaction(() -> mapper.updateACL(mailbox, mailboxACLCommand))); } @Override - public void resetRights(MailboxPath mailboxPath, MailboxACL mailboxACLCommand, MailboxSession session) throws MailboxException { - final MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(session); - final Mailbox mailbox = mapper.findMailboxByPath(mailboxPath); - mapper.execute(Mapper.toTransaction(() -> mapper.resetACL(mailbox, mailboxACLCommand))); + public void resetRights(MailboxPath mailboxPath, MailboxACL mailboxACL, MailboxSession session) throws MailboxException { + MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(session); + Mailbox mailbox = mapper.findMailboxByPath(mailboxPath); + mapper.execute(Mapper.toTransaction(() -> mapper.resetACL(mailbox, mailboxACL))); } @Override http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/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 a7a0e5b..998ec96 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 @@ -52,7 +52,7 @@ import org.apache.james.mailbox.exception.ReadOnlyException; import org.apache.james.mailbox.exception.UnsupportedRightException; import org.apache.james.mailbox.model.ComposedMessageId; import org.apache.james.mailbox.model.MailboxACL; -import org.apache.james.mailbox.model.MailboxACL.MailboxACLRights; +import org.apache.james.mailbox.model.MailboxACL.Rfc4314Rights; import org.apache.james.mailbox.model.MailboxCounters; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MailboxPath; @@ -64,7 +64,6 @@ import org.apache.james.mailbox.model.MessageRange; import org.apache.james.mailbox.model.MessageResult.FetchGroup; import org.apache.james.mailbox.model.MessageResultIterator; import org.apache.james.mailbox.model.SearchQuery; -import org.apache.james.mailbox.model.SimpleMailboxACL; import org.apache.james.mailbox.model.UpdatedFlags; import org.apache.james.mailbox.quota.QuotaManager; import org.apache.james.mailbox.quota.QuotaRootResolver; @@ -799,12 +798,12 @@ public class StoreMessageManager implements org.apache.james.mailbox.MessageMana return messageMapper.findFirstUnseenMessageUid(getMailboxEntity()); } - private MailboxACLRights myRights(MailboxSession session) throws MailboxException { + private Rfc4314Rights myRights(MailboxSession session) throws MailboxException { User user = session.getUser(); if (user != null) { return aclResolver.resolveRights(user.getUserName(), groupMembershipResolver, mailbox.getACL(), mailbox.getUser(), new GroupFolderResolver(session).isGroupFolder(mailbox)); } else { - return SimpleMailboxACL.NO_RIGHTS; + return MailboxACL.NO_RIGHTS; } } http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/mailbox/store/src/main/java/org/apache/james/mailbox/store/json/SimpleMailboxACLJsonConverter.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/json/SimpleMailboxACLJsonConverter.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/json/SimpleMailboxACLJsonConverter.java index 62f9c76..a19e613 100644 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/json/SimpleMailboxACLJsonConverter.java +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/json/SimpleMailboxACLJsonConverter.java @@ -22,7 +22,6 @@ package org.apache.james.mailbox.store.json; import java.io.IOException; import org.apache.james.mailbox.model.MailboxACL; -import org.apache.james.mailbox.model.SimpleMailboxACL; import com.fasterxml.jackson.annotation.JsonValue; import com.fasterxml.jackson.core.JsonProcessingException; @@ -41,7 +40,7 @@ public class SimpleMailboxACLJsonConverter { static class ACLKeyDeserializer extends KeyDeserializer { @Override public Object deserializeKey(String key, DeserializationContext deserializationContext) throws IOException { - return SimpleMailboxACL.SimpleMailboxACLEntryKey.deserialize(key); + return MailboxACL.EntryKey.deserialize(key); } } @@ -49,11 +48,9 @@ public class SimpleMailboxACLJsonConverter { static { SimpleModule module = new SimpleModule() - .addAbstractTypeMapping(MailboxACL.MailboxACLEntryKey.class, SimpleMailboxACL.SimpleMailboxACLEntryKey.class) - .addAbstractTypeMapping(MailboxACL.MailboxACLRights.class, SimpleMailboxACL.Rfc4314Rights.class) - .addKeyDeserializer(MailboxACL.MailboxACLEntryKey.class, new ACLKeyDeserializer()); + .addKeyDeserializer(MailboxACL.EntryKey.class, new ACLKeyDeserializer()); objectMapper - .addMixIn(SimpleMailboxACL.Rfc4314Rights.class, Rfc4314RightsMixIn.class) + .addMixIn(MailboxACL.Rfc4314Rights.class, Rfc4314RightsMixIn.class) .registerModule(module); } @@ -62,6 +59,6 @@ public class SimpleMailboxACLJsonConverter { } public static MailboxACL toACL(String jsonACLString) throws IOException { - return objectMapper.readValue(jsonACLString, SimpleMailboxACL.class); + return objectMapper.readValue(jsonACLString, MailboxACL.class); } } http://git-wip-us.apache.org/repos/asf/james-project/blob/4e10f10b/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 bebf176..1922555 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 @@ -102,7 +102,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.MailboxACLCommand mailboxACLCommand) throws MailboxException; + void updateACL(Mailbox mailbox, MailboxACL.ACLCommand mailboxACLCommand) throws MailboxException; /** * Reset the ACL of the stored mailbox. --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org