You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by bt...@apache.org on 2021/10/14 02:21:19 UTC

[james-project] branch master updated: JAMES-3658 Allow to extend DefaultUserQuotaRootResolver (#693)

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


The following commit(s) were added to refs/heads/master by this push:
     new 94ce671  JAMES-3658 Allow to extend DefaultUserQuotaRootResolver (#693)
94ce671 is described below

commit 94ce671e129140d8ab8e858417514f2d303283cb
Author: Benoit TELLIER <bt...@linagora.com>
AuthorDate: Thu Oct 14 09:21:12 2021 +0700

    JAMES-3658 Allow to extend DefaultUserQuotaRootResolver (#693)
---
 .../store/quota/DefaultUserQuotaRootResolver.java  | 25 ++++++++++++----------
 1 file changed, 14 insertions(+), 11 deletions(-)

diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/DefaultUserQuotaRootResolver.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/DefaultUserQuotaRootResolver.java
index 11113a6..dc5ebf0 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/DefaultUserQuotaRootResolver.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/quota/DefaultUserQuotaRootResolver.java
@@ -56,7 +56,7 @@ public class DefaultUserQuotaRootResolver implements UserQuotaRootResolver {
             return QuotaRoot.quotaRoot(serializedQuotaRoot, username.getDomainPart());
         }
 
-        private List<String> toParts(String serializedQuotaRoot) throws MailboxException {
+        public List<String> toParts(String serializedQuotaRoot) throws MailboxException {
             List<String> parts = Splitter.on(SEPARATOR).splitToList(serializedQuotaRoot);
             if (parts.size() != 2) {
                 throw new MailboxException(serializedQuotaRoot + " used as QuotaRoot should contain exactly one \"" + SEPARATOR + "\"");
@@ -66,7 +66,7 @@ public class DefaultUserQuotaRootResolver implements UserQuotaRootResolver {
     }
 
     public static final String SEPARATOR = "&"; // Character illegal for mailbox naming in regard of RFC 3501 section 5.1
-    private static final DefaultQuotaRootDeserializer QUOTA_ROOT_DESERIALIZER = new DefaultQuotaRootDeserializer();
+    protected static final DefaultQuotaRootDeserializer QUOTA_ROOT_DESERIALIZER = new DefaultQuotaRootDeserializer();
 
     private final SessionProvider sessionProvider;
     private final MailboxSessionMapperFactory factory;
@@ -119,8 +119,7 @@ public class DefaultUserQuotaRootResolver implements UserQuotaRootResolver {
         return factory.getMailboxMapper(session)
             .findMailboxById(mailboxId)
             .map(Mailbox::generateAssociatedPath)
-            .map(MailboxPath::getUser)
-            .map(this::forUser);
+            .flatMap(path -> Mono.from(getQuotaRootReactive(path)));
     }
 
     @Override
@@ -144,15 +143,19 @@ public class DefaultUserQuotaRootResolver implements UserQuotaRootResolver {
             List<String> parts = QUOTA_ROOT_DESERIALIZER.toParts(quotaRoot.getValue());
             String namespace = parts.get(0);
             String user = parts.get(1);
-            return factory.getMailboxMapper(mailboxSession)
-                .findMailboxWithPathLike(MailboxQuery.builder()
-                    .namespace(namespace)
-                    .user(Username.of(user))
-                    .matchesAllMailboxNames()
-                    .build()
-                    .asUserBound());
+            return retrieveAssociatedMailboxes(mailboxSession, namespace, user);
         } catch (MailboxException e) {
             return Flux.error(e);
         }
     }
+
+    protected Flux<Mailbox> retrieveAssociatedMailboxes(MailboxSession mailboxSession, String namespace, String user) {
+        return factory.getMailboxMapper(mailboxSession)
+            .findMailboxWithPathLike(MailboxQuery.builder()
+                .namespace(namespace)
+                .user(Username.of(user))
+                .matchesAllMailboxNames()
+                .build()
+                .asUserBound());
+    }
 }

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