james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From matth...@apache.org
Subject [02/27] james-project git commit: MAILBOX-310 Mailbox query refactoring: Don't expose MailboxQuery constructor
Date Thu, 05 Oct 2017 18:02:14 GMT
MAILBOX-310 Mailbox query refactoring: Don't expose MailboxQuery constructor


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

Branch: refs/heads/master
Commit: 434e040bdb4fcadbdb5bf9ab7ec961aec24cf59d
Parents: 10da435
Author: Antoine Duprat <aduprat@linagora.com>
Authored: Thu Sep 28 15:09:09 2017 +0200
Committer: benwa <btellier@linagora.com>
Committed: Wed Oct 4 16:29:09 2017 +0700

----------------------------------------------------------------------
 .../apache/james/mailbox/model/MailboxQuery.java    |  2 +-
 .../apache/james/mailbox/MailboxManagerTest.java    | 16 ++++++++++++++--
 .../apache/james/imap/processor/LSubProcessor.java  |  6 +++++-
 .../apache/james/imap/processor/ListProcessor.java  |  8 +++++++-
 .../org/apache/james/modules/MailboxProbeImpl.java  |  8 +++++---
 .../adapter/mailbox/MailboxManagerManagement.java   |  8 +++++---
 .../transport/matchers/AbstractStorageQuota.java    |  8 ++++++--
 7 files changed, 43 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/434e040b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxQuery.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxQuery.java b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxQuery.java
index e32c9be..88f923a 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxQuery.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/model/MailboxQuery.java
@@ -136,7 +136,7 @@ public final class MailboxQuery {
      * @param pathDelimiter
      *            path delimiter to use
      */
-    public MailboxQuery(MailboxPath base, String expression, char pathDelimiter) {
+    @VisibleForTesting MailboxQuery(MailboxPath base, String expression, char pathDelimiter)
{
         super();
         this.base = base;
         if (base.getName() == null)

http://git-wip-us.apache.org/repos/asf/james-project/blob/434e040b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
index 0b70549..bcc1e4e 100644
--- a/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
+++ b/mailbox/api/src/test/java/org/apache/james/mailbox/MailboxManagerTest.java
@@ -241,7 +241,13 @@ public abstract class MailboxManagerTest {
         session = mailboxManager.createSystemSession(USER_1);
         mailboxManager.createMailbox(new MailboxPath("other_namespace", USER_1, "Other"),
session);
         mailboxManager.createMailbox(MailboxPath.inbox(session), session);
-        List<MailboxMetaData> metaDatas = mailboxManager.search(new MailboxQuery(MailboxPath.forUser(USER_1,
""), "*", '.'), session);
+        List<MailboxMetaData> metaDatas = mailboxManager.search(
+                MailboxQuery.builder()
+                    .base(MailboxPath.forUser(USER_1, ""))
+                    .expression("*")
+                    .pathDelimiter('.')
+                    .build(), 
+                session);
         assertThat(metaDatas).hasSize(1);
         assertThat(metaDatas.get(0).getPath()).isEqualTo(MailboxPath.inbox(session));
     }
@@ -251,7 +257,13 @@ public abstract class MailboxManagerTest {
         session = mailboxManager.createSystemSession(USER_1);
         mailboxManager.createMailbox(MailboxPath.forUser(USER_2, "Other"), session);
         mailboxManager.createMailbox(MailboxPath.inbox(session), session);
-        List<MailboxMetaData> metaDatas = mailboxManager.search(new MailboxQuery(MailboxPath.forUser(USER_1,
""), "*", '.'), session);
+        List<MailboxMetaData> metaDatas = mailboxManager.search(
+                MailboxQuery.builder()
+                .base(MailboxPath.forUser(USER_1, ""))
+                .expression("*")
+                .pathDelimiter('.')
+                .build(), 
+            session);
         assertThat(metaDatas).hasSize(1);
         assertThat(metaDatas.get(0).getPath()).isEqualTo(MailboxPath.inbox(session));
     }

http://git-wip-us.apache.org/repos/asf/james-project/blob/434e040b/protocols/imap/src/main/java/org/apache/james/imap/processor/LSubProcessor.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/LSubProcessor.java
b/protocols/imap/src/main/java/org/apache/james/imap/processor/LSubProcessor.java
index a4bf955..a290ebd 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/LSubProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/LSubProcessor.java
@@ -73,7 +73,11 @@ public class LSubProcessor extends AbstractSubscriptionProcessor<LsubRequest>
{
             basePath = PathConverter.forSession(session).buildFullPath(CharsetUtil.decodeModifiedUTF7(finalReferencename));
         }
 
-        final MailboxQuery expression = new MailboxQuery(basePath, CharsetUtil.decodeModifiedUTF7(mailboxName),
mailboxSession.getPathDelimiter());
+        final MailboxQuery expression = MailboxQuery.builder()
+                .base(basePath)
+                .expression(CharsetUtil.decodeModifiedUTF7(mailboxName))
+                .pathDelimiter(mailboxSession.getPathDelimiter())
+                .build();
         final Collection<String> mailboxResponses = new ArrayList<>();
         for (String mailbox : mailboxes) {
             respond(responder, expression, mailbox, true, mailboxes, mailboxResponses, mailboxSession.getPathDelimiter());

http://git-wip-us.apache.org/repos/asf/james-project/blob/434e040b/protocols/imap/src/main/java/org/apache/james/imap/processor/ListProcessor.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/ListProcessor.java
b/protocols/imap/src/main/java/org/apache/james/imap/processor/ListProcessor.java
index 16a7280..fa9672d 100644
--- a/protocols/imap/src/main/java/org/apache/james/imap/processor/ListProcessor.java
+++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/ListProcessor.java
@@ -171,7 +171,13 @@ public class ListProcessor extends AbstractMailboxProcessor<ListRequest>
{
                     basePath = PathConverter.forSession(session).buildFullPath(finalReferencename);
                 }
 
-                results = getMailboxManager().search(new MailboxQuery(basePath, CharsetUtil.decodeModifiedUTF7(mailboxName),
mailboxSession.getPathDelimiter()), mailboxSession);
+                results = getMailboxManager().search(
+                        MailboxQuery.builder()
+                            .base(basePath)
+                            .expression(CharsetUtil.decodeModifiedUTF7(mailboxName))
+                            .pathDelimiter(mailboxSession.getPathDelimiter())
+                            .build()
+                        , mailboxSession);
             }
 
             for (MailboxMetaData metaData : results) {

http://git-wip-us.apache.org/repos/asf/james-project/blob/434e040b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java
----------------------------------------------------------------------
diff --git a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java
b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java
index 66e6be0..4bebc40 100644
--- a/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java
+++ b/server/container/guice/mailbox/src/main/java/org/apache/james/modules/MailboxProbeImpl.java
@@ -123,9 +123,11 @@ public class MailboxProbeImpl implements GuiceProbe, MailboxProbe {
 
     private List<MailboxMetaData> searchUserMailboxes(String username, MailboxSession
session) throws MailboxException {
         return mailboxManager.search(
-            new MailboxQuery(MailboxPath.forUser(username, ""),
-                "*",
-                session.getPathDelimiter()),
+            MailboxQuery.builder()
+                .base(MailboxPath.forUser(username, ""))
+                .expression("*")
+                .pathDelimiter(session.getPathDelimiter())
+                .build(),
             session);
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/434e040b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java
----------------------------------------------------------------------
diff --git a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java
b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java
index 320bb79..9f01266 100644
--- a/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java
+++ b/server/container/mailbox-adapter/src/main/java/org/apache/james/adapter/mailbox/MailboxManagerManagement.java
@@ -213,9 +213,11 @@ public class MailboxManagerManagement extends StandardMBean implements
MailboxMa
 
     private List<MailboxMetaData> retrieveAllUserMailboxes(String username, MailboxSession
session) throws MailboxException {
         return mailboxManager.search(
-            new MailboxQuery(MailboxPath.forUser(username, ""),
-                "*",
-                session.getPathDelimiter()),
+            MailboxQuery.builder()
+                .base(MailboxPath.forUser(username, ""))
+                .expression("*")
+                .pathDelimiter(session.getPathDelimiter())
+                .build(),
             session);
     }
 

http://git-wip-us.apache.org/repos/asf/james-project/blob/434e040b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java
----------------------------------------------------------------------
diff --git a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java
b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java
index 1fe84eb..2bc8783 100755
--- a/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java
+++ b/server/mailet/mailets/src/main/java/org/apache/james/transport/matchers/AbstractStorageQuota.java
@@ -27,6 +27,7 @@ import javax.inject.Inject;
 import javax.inject.Named;
 import javax.mail.MessagingException;
 
+import org.apache.james.core.MailAddress;
 import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageManager;
@@ -42,7 +43,6 @@ import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.api.UsersRepositoryException;
 import org.apache.mailet.Experimental;
 import org.apache.mailet.Mail;
-import org.apache.james.core.MailAddress;
 import org.apache.mailet.MailetContext;
 
 /**
@@ -125,7 +125,11 @@ abstract public class AbstractStorageQuota extends AbstractQuotaMatcher
{
             // get all mailboxes for the user to calculate the size
             // TODO: See JAMES-1198
             List<MailboxMetaData> mList = manager.search(
-                    new MailboxQuery(MailboxPath.inbox(session), "", session.getPathDelimiter()),
session);
+                    MailboxQuery.builder()
+                        .base(MailboxPath.inbox(session))
+                        .pathDelimiter(session.getPathDelimiter())
+                        .build(),
+                    session);
             for (MailboxMetaData aMList : mList) {
                 MessageManager mailbox = manager.getMailbox(aMList.getPath(), session);
                 Iterator<MessageResult> results = mailbox.getMessages(MessageRange.all(),
FetchGroupImpl.MINIMAL,


---------------------------------------------------------------------
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