james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rouaz...@apache.org
Subject [03/10] james-project git commit: JAMES-1818 Introduce MailboxManager.hasChildren and use it in MailboxUtils
Date Mon, 05 Sep 2016 12:43:59 GMT
JAMES-1818 Introduce MailboxManager.hasChildren and use it in MailboxUtils


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

Branch: refs/heads/master
Commit: ed7268ed28ce86c78497055f61e98f2d775e6809
Parents: 8ec9ab9
Author: Raphael Ouazana <raphael.ouazana@linagora.com>
Authored: Tue Aug 30 16:00:06 2016 +0200
Committer: Raphael Ouazana <raphael.ouazana@linagora.com>
Committed: Mon Sep 5 14:42:00 2016 +0200

----------------------------------------------------------------------
 .../main/java/org/apache/james/mailbox/MailboxManager.java    | 2 ++
 .../org/apache/james/mailbox/store/StoreMailboxManager.java   | 7 +++++++
 .../james/imap/processor/base/MailboxEventAnalyserTest.java   | 5 +++++
 .../main/java/org/apache/james/jmap/utils/MailboxUtils.java   | 4 ++--
 .../james/jmap/FirstUserConnectionFilterThreadTest.java       | 5 +++++
 5 files changed, 21 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/ed7268ed/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
index e2cbdac..d993c4e 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxManager.java
@@ -428,4 +428,6 @@ public interface MailboxManager extends RequestAware, MailboxListenerSupport
{
      * @throws MailboxException in case of selected mailbox does not exist
      */
     void updateAnnotations(MailboxPath mailboxPath, MailboxSession session, List<MailboxAnnotation>
mailboxAnnotations) throws MailboxException;
+    
+    boolean hasChildren(MailboxPath mailboxPath, MailboxSession session) throws MailboxException;
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/ed7268ed/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 e974e18..18f4727 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
@@ -771,4 +771,11 @@ public class StoreMailboxManager implements MailboxManager {
         AnnotationMapper annotationMapper = getAnnotationMapper(mailboxPath, session);
         return annotationMapper.getAnnotationsByKeysWithAllDepth(keys);
     }
+
+    @Override
+    public boolean hasChildren(MailboxPath mailboxPath, MailboxSession session) throws MailboxException
{
+        MailboxMapper mapper = mailboxSessionMapperFactory.getMailboxMapper(session);
+        Mailbox mailbox = mapper.findMailboxByPath(mailboxPath);
+        return mapper.hasChildren(mailbox, session.getPathDelimiter());
+    }
 }

http://git-wip-us.apache.org/repos/asf/james-project/blob/ed7268ed/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
index 35d1a4e..c6d2e89 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java
@@ -423,6 +423,11 @@ public class MailboxEventAnalyserTest {
             return null;
         }
 
+        @Override
+        public boolean hasChildren(MailboxPath mailboxPath, MailboxSession session) throws
MailboxException {
+            return false;
+        }
+
     };
     
     private final class MyMailboxSession implements MailboxSession {

http://git-wip-us.apache.org/repos/asf/james-project/blob/ed7268ed/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/MailboxUtils.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/MailboxUtils.java
b/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/MailboxUtils.java
index 3584420..8bb4ba3 100644
--- a/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/MailboxUtils.java
+++ b/server/protocols/jmap/src/main/java/org/apache/james/jmap/utils/MailboxUtils.java
@@ -144,8 +144,8 @@ public class MailboxUtils {
 
     public boolean hasChildren(MailboxId mailboxId, MailboxSession mailboxSession) throws
MailboxException {
         return getMailboxFromId(mailboxId, mailboxSession)
-                .map(Throwing.function(mailbox -> 
-                    mailboxMapperFactory.getMailboxMapper(mailboxSession).hasChildren(mailbox,
mailboxSession.getPathDelimiter())))
+                .map(mailbox -> new MailboxPath(mailbox.getNamespace(), mailbox.getUser(),
mailbox.getName()))
+                .map(Throwing.function(path -> mailboxManager.hasChildren(path, mailboxSession)))
                 .orElse(false);
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/ed7268ed/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
----------------------------------------------------------------------
diff --git a/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
b/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
index 7cde34c..c64cace 100644
--- a/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
+++ b/server/protocols/jmap/src/test/java/org/apache/james/jmap/FirstUserConnectionFilterThreadTest.java
@@ -251,6 +251,11 @@ public class FirstUserConnectionFilterThreadTest {
                 Set<MailboxAnnotationKey> keys) throws MailboxException {
             return null;
         }
+
+        @Override
+        public boolean hasChildren(MailboxPath mailboxPath, MailboxSession session) throws
MailboxException {
+            return false;
+        }
     }
 }
 


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


Mime
View raw message