You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by ad...@apache.org on 2017/11/13 15:27:40 UTC

[3/8] james-project git commit: PROTOCOLS-117 Delete GroupFolderResolver

PROTOCOLS-117 Delete GroupFolderResolver


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

Branch: refs/heads/master
Commit: 5218473de5c1e74f150c6b8ebe46ff63fac7466f
Parents: 48d7caf
Author: benwa <bt...@linagora.com>
Authored: Wed Nov 8 16:27:23 2017 +0700
Committer: Antoine Duprat <ad...@linagora.com>
Committed: Mon Nov 13 16:23:06 2017 +0100

----------------------------------------------------------------------
 .../mailbox/store/GroupFolderResolver.java      | 41 -----------
 .../james/mailbox/store/StoreRightManager.java  | 11 ++-
 .../mailbox/store/GroupFolderResolverTest.java  | 75 --------------------
 3 files changed, 8 insertions(+), 119 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/5218473d/mailbox/store/src/main/java/org/apache/james/mailbox/store/GroupFolderResolver.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/GroupFolderResolver.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/GroupFolderResolver.java
deleted file mode 100644
index 7be235d..0000000
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/GroupFolderResolver.java
+++ /dev/null
@@ -1,41 +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.store;
-
-import org.apache.james.mailbox.MailboxSession;
-import org.apache.james.mailbox.model.MailboxConstants;
-import org.apache.james.mailbox.store.mail.model.Mailbox;
-
-public class GroupFolderResolver {
-    
-    private final MailboxSession mailboxSession;
-
-    public GroupFolderResolver(MailboxSession mailboxSession) {
-        this.mailboxSession = mailboxSession;
-    }
-
-    public boolean isGroupFolder(Mailbox mailbox) {
-        String namespace = mailbox.getNamespace();
-        return namespace == null || 
-                (!namespace.equals(mailboxSession.getPersonalSpace())
-                && !namespace.equals(MailboxConstants.USER_NAMESPACE)
-                && !namespace.equals(mailboxSession.getOtherUsersSpace()));
-    }
-}

http://git-wip-us.apache.org/repos/asf/james-project/blob/5218473d/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
index e1796fb..38076df 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/StoreRightManager.java
@@ -50,6 +50,7 @@ import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableMap;
 
 public class StoreRightManager implements RightManager {
+    public static final boolean GROUP_FOLDER = true;
 
     private final MailboxSessionMapperFactory mailboxSessionMapperFactory;
     private final MailboxACLResolver aclResolver;
@@ -102,7 +103,7 @@ public class StoreRightManager implements RightManager {
                     groupMembershipResolver,
                     mailbox.getACL(),
                     mailbox.getUser(),
-                    new GroupFolderResolver(session).isGroupFolder(mailbox)))
+                    !GROUP_FOLDER))
                 .sneakyThrow())
             .orElse(MailboxACL.NO_RIGHTS);
     }
@@ -111,7 +112,11 @@ public class StoreRightManager implements RightManager {
     public Rfc4314Rights[] listRigths(MailboxPath mailboxPath, 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));
+
+        return aclResolver.listRights(key,
+            groupMembershipResolver,
+            mailbox.getUser(),
+            !GROUP_FOLDER);
     }
 
     @Override
@@ -209,7 +214,7 @@ public class StoreRightManager implements RightManager {
     public MailboxACL getResolvedMailboxACL(Mailbox mailbox, MailboxSession mailboxSession) throws UnsupportedRightException {
         MailboxACL acl = aclResolver.applyGlobalACL(
             mailbox.getACL(),
-            new GroupFolderResolver(mailboxSession).isGroupFolder(mailbox));
+            !GROUP_FOLDER);
 
         return filteredForSession(mailbox, acl, mailboxSession);
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/5218473d/mailbox/store/src/test/java/org/apache/james/mailbox/store/GroupFolderResolverTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/GroupFolderResolverTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/GroupFolderResolverTest.java
deleted file mode 100644
index 2abbaa9..0000000
--- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/GroupFolderResolverTest.java
+++ /dev/null
@@ -1,75 +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.store;
-
-import static org.assertj.core.api.Assertions.assertThat;
-
-import java.util.List;
-import java.util.Locale;
-
-import org.apache.james.mailbox.MailboxSession.SessionType;
-import org.apache.james.mailbox.model.MailboxPath;
-import org.apache.james.mailbox.store.mail.model.impl.SimpleMailbox;
-import org.junit.Test;
-
-public class GroupFolderResolverTest {
-
-    private static final long UID_VALIDITY = 9999;
-    private List<Locale> localePreferences = null;
-    private List<String> sharedSpaces = null;
-    private char pathSeparator = ' ';
-    
-    @Test
-    public void isGroupFolderShouldReturnFalseWhenMailboxNamespaceIsNull() {
-        SimpleMailboxSession mailboxSession = new SimpleMailboxSession(1, "username", "password", localePreferences, sharedSpaces, null, pathSeparator, SessionType.User);
-        GroupFolderResolver testee =  new GroupFolderResolver(mailboxSession);
-        
-        SimpleMailbox mailbox = new SimpleMailbox(new MailboxPath(null, "user", "name"), UID_VALIDITY);
-        assertThat(testee.isGroupFolder(mailbox)).isFalse();
-    }
-    
-    @Test
-    public void isGroupFolderShouldReturnFalseWhenMailboxNamespaceEqualsToUserNamespace() {
-        SimpleMailboxSession mailboxSession = new SimpleMailboxSession(1, "username", "password", localePreferences, sharedSpaces, null, pathSeparator, SessionType.User);
-        GroupFolderResolver testee =  new GroupFolderResolver(mailboxSession);
-        
-        SimpleMailbox mailbox = new SimpleMailbox(MailboxPath.forUser("user", "name"), UID_VALIDITY);
-        assertThat(testee.isGroupFolder(mailbox)).isFalse();
-    }
-    
-    @Test
-    public void isGroupFolderShouldReturnFalseWhenMailboxNamespaceEqualsToOtherUsersNamespace() {
-        String otherUsersSpace = "other";
-        SimpleMailboxSession mailboxSession = new SimpleMailboxSession(1, "username", "password", localePreferences, sharedSpaces, otherUsersSpace, pathSeparator, SessionType.User);
-        GroupFolderResolver testee =  new GroupFolderResolver(mailboxSession);
-        
-        SimpleMailbox mailbox = new SimpleMailbox(new MailboxPath("other", "user", "name"), UID_VALIDITY);
-        assertThat(testee.isGroupFolder(mailbox)).isFalse();
-    }
-    
-    @Test
-    public void isGroupFolderShouldReturnTrueWhenMailboxNamespaceDoesntEqualToOtherUsersNamespace() {
-        String otherUsersSpace = "other";
-        SimpleMailboxSession mailboxSession = new SimpleMailboxSession(1, "username", "password", localePreferences, sharedSpaces, otherUsersSpace, pathSeparator, SessionType.User);
-        GroupFolderResolver testee =  new GroupFolderResolver(mailboxSession);
-        
-        SimpleMailbox mailbox = new SimpleMailbox(new MailboxPath("namespace", "user", "name"), UID_VALIDITY);
-        assertThat(testee.isGroupFolder(mailbox)).isTrue();
-    }
-}


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