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

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

commit 22e9ccb9c7e31b83f54ebe60105718266a17b665
Author: Benoit TELLIER <btell...@linagora.com>
AuthorDate: Wed Oct 9 09:16:55 2024 +0200

    JAMES-2182 Inline namespace related concerns out of the mailbox session
    
    We do not need those IMAP concerns onto the storage layer.
    We will later come up with alternative implementation for
    namespace customization.
---
 .../org/apache/james/mailbox/MailboxSession.java   | 55 ----------------------
 .../james/imap/processor/NamespaceProcessor.java   | 20 ++++----
 2 files changed, 10 insertions(+), 65 deletions(-)

diff --git 
a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxSession.java 
b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxSession.java
index 1080ea0725..1901e3a55c 100644
--- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxSession.java
+++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxSession.java
@@ -19,8 +19,6 @@
 
 package org.apache.james.mailbox;
 
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
@@ -29,7 +27,6 @@ import java.util.Objects;
 import java.util.Optional;
 
 import org.apache.james.core.Username;
-import org.apache.james.mailbox.model.MailboxConstants;
 
 import com.google.common.base.MoreObjects;
 
@@ -100,9 +97,6 @@ public class MailboxSession {
         User
     }
 
-    private final Collection<String> sharedSpaces;
-    private final String otherUsersSpace;
-    private final String personalSpace;
     private final SessionId sessionId;
     private final Username userName;
     private final Optional<Username> loggedInUser;
@@ -113,21 +107,9 @@ public class MailboxSession {
 
     public MailboxSession(SessionId sessionId, Username userName, 
Optional<Username> loggedInUser,
                                 List<Locale> localePreferences, char 
pathSeparator, SessionType type) {
-        this(sessionId, userName, loggedInUser, localePreferences, new 
ArrayList<>(), null, pathSeparator, type);
-    }
-
-    public MailboxSession(SessionId sessionId, Username userName, 
Optional<Username> loggedInUser,
-                          List<Locale> localePreferences, List<String> 
sharedSpaces, String otherUsersSpace, char pathSeparator, SessionType type) {
         this.sessionId = sessionId;
         this.userName = userName;
-        this.otherUsersSpace = otherUsersSpace;
-        this.sharedSpaces = sharedSpaces;
         this.type = type;
-        if (otherUsersSpace == null && (sharedSpaces == null || 
sharedSpaces.isEmpty())) {
-            this.personalSpace = "";
-        } else {
-            this.personalSpace = MailboxConstants.USER_NAMESPACE;
-        }
 
         this.localePreferences = localePreferences;
         this.attributes = new HashMap<>();
@@ -173,43 +155,6 @@ public class MailboxSession {
         return localePreferences;
     }
 
-    /**
-     * Gets the <a href='http://www.isi.edu/in-notes/rfc2342.txt' rel='tag'>RFC
-     * 2342</a> personal namespace for the current session.<br>
-     * Note that though servers may offer multiple personal namespaces, support
-     * is not offered through this API. This decision may be revised if
-     * reasonable use cases emerge.
-     * 
-     * @return Personal Namespace, not null
-     */
-    public String getPersonalSpace() {
-        return personalSpace;
-    }
-
-    /**
-     * Gets the <a href='http://www.isi.edu/in-notes/rfc2342.txt' rel='tag'>RFC
-     * 2342</a> other users namespace for the current session.<br>
-     * Note that though servers may offer multiple other users namespaces,
-     * support is not offered through this API. This decision may be revised if
-     * reasonable use cases emerge.
-     * 
-     * @return Other Users Namespace or null when there is non available
-     */
-    public String getOtherUsersSpace() {
-        return otherUsersSpace;
-    }
-
-    /**
-     * Iterates the <a href='http://www.isi.edu/in-notes/rfc2342.txt'
-     * rel='tag'>RFC 2342</a> Shared Namespaces available for the current
-     * session.
-     * 
-     * @return not null though possibly empty
-     */
-    public Collection<String> getSharedSpaces() {
-        return sharedSpaces;
-    }
-
     /**
      * Return the stored attributes for this {@link MailboxSession}.
      */
diff --git 
a/protocols/imap/src/main/java/org/apache/james/imap/processor/NamespaceProcessor.java
 
b/protocols/imap/src/main/java/org/apache/james/imap/processor/NamespaceProcessor.java
index 2f3a4a5679..03ad9e5f52 100644
--- 
a/protocols/imap/src/main/java/org/apache/james/imap/processor/NamespaceProcessor.java
+++ 
b/protocols/imap/src/main/java/org/apache/james/imap/processor/NamespaceProcessor.java
@@ -53,11 +53,11 @@ public class NamespaceProcessor extends 
AbstractMailboxProcessor<NamespaceReques
 
     @Override
     protected Mono<Void> processRequestReactive(NamespaceRequest request, 
ImapSession session, Responder responder) {
-        final MailboxSession mailboxSession = session.getMailboxSession();
-        final List<NamespaceResponse.Namespace> personalNamespaces = 
buildPersonalNamespaces(mailboxSession, session);
-        final List<NamespaceResponse.Namespace> otherUsersNamespaces = 
buildOtherUsersSpaces(mailboxSession, session);
-        final List<NamespaceResponse.Namespace> sharedNamespaces = 
buildSharedNamespaces(mailboxSession, session);
-        final NamespaceResponse response = new 
NamespaceResponse(personalNamespaces, otherUsersNamespaces, sharedNamespaces);
+        MailboxSession mailboxSession = session.getMailboxSession();
+        List<NamespaceResponse.Namespace> personalNamespaces = 
buildPersonalNamespaces(mailboxSession);
+        List<NamespaceResponse.Namespace> otherUsersNamespaces = 
buildOtherUsersSpaces(mailboxSession);
+        List<NamespaceResponse.Namespace> sharedNamespaces = 
buildSharedNamespaces(mailboxSession);
+        NamespaceResponse response = new NamespaceResponse(personalNamespaces, 
otherUsersNamespaces, sharedNamespaces);
         responder.respond(response);
         return unsolicitedResponses(session, responder, false)
             .then(Mono.fromRunnable(() -> okComplete(request, responder)));
@@ -70,15 +70,15 @@ public class NamespaceProcessor extends 
AbstractMailboxProcessor<NamespaceReques
      *            not null
      * @return personal namespaces, not null
      */
-    private List<NamespaceResponse.Namespace> 
buildPersonalNamespaces(MailboxSession mailboxSession, ImapSession session) {
+    private List<NamespaceResponse.Namespace> 
buildPersonalNamespaces(MailboxSession mailboxSession) {
         final List<NamespaceResponse.Namespace> personalSpaces = new 
ArrayList<>();
         String personal = "";
         personalSpaces.add(new NamespaceResponse.Namespace(personal, 
mailboxSession.getPathDelimiter()));
         return personalSpaces;
     }
 
-    private List<NamespaceResponse.Namespace> 
buildOtherUsersSpaces(MailboxSession mailboxSession,  ImapSession session) {
-        final String otherUsersSpace = mailboxSession.getOtherUsersSpace();
+    private List<NamespaceResponse.Namespace> 
buildOtherUsersSpaces(MailboxSession mailboxSession) {
+        final String otherUsersSpace = null;
         final List<NamespaceResponse.Namespace> otherUsersSpaces;
         if (otherUsersSpace == null) {
             otherUsersSpaces = null;
@@ -89,9 +89,9 @@ public class NamespaceProcessor extends 
AbstractMailboxProcessor<NamespaceReques
         return otherUsersSpaces;
     }
 
-    private List<NamespaceResponse.Namespace> 
buildSharedNamespaces(MailboxSession mailboxSession,  ImapSession session) {
+    private List<NamespaceResponse.Namespace> 
buildSharedNamespaces(MailboxSession mailboxSession) {
         List<NamespaceResponse.Namespace> sharedNamespaces = null;
-        final Collection<String> sharedSpaces = 
mailboxSession.getSharedSpaces();
+        final Collection<String> sharedSpaces = new ArrayList<>();
         if (!sharedSpaces.isEmpty()) {
             sharedNamespaces = new ArrayList<>(sharedSpaces.size());
             for (String space : sharedSpaces) {


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org
For additional commands, e-mail: notifications-h...@james.apache.org

Reply via email to