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 bt...@apache.org on 2019/11/13 03:06:57 UTC

[james-project] 08/21: [Refactoring] ListProcessor avoid representing "namespace" info as a mbx

This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit e5a8622fb953d61fe7836102bc6baf6fb6655f39
Author: Benoit Tellier <bt...@linagora.com>
AuthorDate: Tue Nov 12 15:52:24 2019 +0700

    [Refactoring] ListProcessor avoid representing "namespace" info as a mbx
---
 .../apache/james/imap/processor/ListProcessor.java | 24 ++++++++++------------
 1 file changed, 11 insertions(+), 13 deletions(-)

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 7170415..717a96b 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
@@ -20,7 +20,6 @@
 package org.apache.james.imap.processor;
 
 import java.io.Closeable;
-import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.james.imap.api.ImapCommand;
@@ -41,7 +40,6 @@ import org.apache.james.mailbox.MailboxManager;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.model.MailboxConstants;
-import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MailboxMetaData;
 import org.apache.james.mailbox.model.MailboxPath;
 import org.apache.james.mailbox.model.search.MailboxQuery;
@@ -88,7 +86,6 @@ public class ListProcessor extends AbstractMailboxProcessor<ListRequest> {
         try {
             // Should the namespace section be returned or not?
             final boolean isRelative;
-            final List<MailboxMetaData> results;
 
             if (mailboxName.length() == 0) {
                 // An empty mailboxName signifies a request for the hierarchy
@@ -111,12 +108,13 @@ public class ListProcessor extends AbstractMailboxProcessor<ListRequest> {
                     referenceRoot = "";
                     isRelative = true;
                 }
-                // Get the mailbox for the reference name.
-                MailboxPath rootPath = new MailboxPath(referenceRoot, "", "");
-                MailboxId mailboxId = null;
-                results = new ArrayList<>(1);
-                results.add(new MailboxMetaData(rootPath, mailboxId, mailboxSession.getPathDelimiter(),
-                    MailboxMetaData.Children.CHILDREN_ALLOWED_BUT_UNKNOWN, MailboxMetaData.Selectability.NOSELECT));
+
+                responder.respond(createResponse(
+                    MailboxMetaData.Children.CHILDREN_ALLOWED_BUT_UNKNOWN,
+                    MailboxMetaData.Selectability.NOSELECT,
+                    referenceRoot,
+                    mailboxSession.getPathDelimiter(),
+                    MailboxType.OTHER));
             } else {
                 // If the mailboxPattern is fully qualified, ignore the
                 // reference name.
@@ -136,7 +134,7 @@ public class ListProcessor extends AbstractMailboxProcessor<ListRequest> {
                     basePath = PathConverter.forSession(session).buildFullPath(finalReferencename);
                 }
 
-                results = getMailboxManager().search(
+                List<MailboxMetaData> results = getMailboxManager().search(
                         MailboxQuery.builder()
                             .userAndNamespaceFrom(basePath)
                             .expression(new PrefixedRegex(
@@ -144,11 +142,11 @@ public class ListProcessor extends AbstractMailboxProcessor<ListRequest> {
                                 ModifiedUtf7.decodeModifiedUTF7(mailboxName),
                                 mailboxSession.getPathDelimiter()))
                             .build(), mailboxSession);
+                for (MailboxMetaData metaData : results) {
+                    processResult(responder, isRelative, metaData, getMailboxType(session, mailboxTyper, metaData.getPath()));
+                }
             }
 
-            for (MailboxMetaData metaData : results) {
-                processResult(responder, isRelative, metaData, getMailboxType(session, mailboxTyper, metaData.getPath()));
-            }
 
             okComplete(command, tag, responder);
         } catch (MailboxException e) {


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