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 e00a459c5daeb5f77bde1eb4bb4af2c496101037 Author: Benoit TELLIER <btell...@linagora.com> AuthorDate: Wed Oct 9 22:23:10 2024 +0200 JAMES-2182 List myrights response should preserve namespace --- .../apache/james/imap/scripts/ListWithSharedMailbox.test | 9 ++++----- .../java/org/apache/james/imap/main/PathConverter.java | 15 ++++++++++----- .../org/apache/james/imap/processor/ListProcessor.java | 9 +++++---- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/ListWithSharedMailbox.test b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/ListWithSharedMailbox.test index 73214414b4..b2c54b2911 100644 --- a/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/ListWithSharedMailbox.test +++ b/mpt/impl/imap-mailbox/core/src/main/resources/org/apache/james/imap/scripts/ListWithSharedMailbox.test @@ -29,18 +29,17 @@ S: \* LIST \(\\HasNoChildren\) \".\" \"#user.boby.Sent\" S: a0 OK LIST completed. C: a1 LIST "" "*" RETURN (MYRIGHTS) -# TODO MYRIGHTS status response should keep FQDN SUB { S: \* LIST \(\\HasNoChildren\) \"\.\" \"INBOX\" S: \* MYRIGHTS \"INBOX\" \"aeiklprstwx\" S: \* LIST \(\\HasNoChildren\) \".\" \"#user.diana.sharedMailbox\" -S: \* MYRIGHTS \"sharedMailbox\" \"lr\" +S: \* MYRIGHTS \"#user.diana.sharedMailbox\" \"lr\" S: \* LIST \(\\HasChildren\) \".\" \"#user.boby.sharedMailbox\" -S: \* MYRIGHTS \"sharedMailbox\" \"lr\" +S: \* MYRIGHTS \"#user.boby.sharedMailbox\" \"lr\" S: \* LIST \(\\HasNoChildren\) \".\" \"#user.boby.sharedMailbox.child\" -S: \* MYRIGHTS \"sharedMailbox.child\" \"lr\" +S: \* MYRIGHTS \"#user.boby.sharedMailbox.child\" \"lr\" S: \* LIST \(\\HasNoChildren\) \".\" \"#user.boby.Sent\" -S: \* MYRIGHTS \"Sent\" \"lr\" +S: \* MYRIGHTS \"#user.boby.Sent\" \"lr\" } S: a1 OK LIST completed. diff --git a/protocols/imap/src/main/java/org/apache/james/imap/main/PathConverter.java b/protocols/imap/src/main/java/org/apache/james/imap/main/PathConverter.java index 4eabd621b0..731583221a 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/main/PathConverter.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/main/PathConverter.java @@ -46,11 +46,17 @@ public interface PathConverter { class Default implements Factory { public PathConverter forSession(ImapSession session) { + return new PathConverter.Default(session.getMailboxSession()); + } + + public PathConverter forSession(MailboxSession session) { return new PathConverter.Default(session); } } PathConverter forSession(ImapSession session); + + PathConverter forSession(MailboxSession session); } class Default implements PathConverter{ @@ -61,10 +67,10 @@ public interface PathConverter { .addEscape('_', "_-") .build(); - private final ImapSession session; + private final MailboxSession mailboxSession; - private Default(ImapSession session) { - this.session = session; + private Default(MailboxSession mailboxSession) { + this.mailboxSession = mailboxSession; } public MailboxPath buildFullPath(String mailboxName) { @@ -84,11 +90,10 @@ public interface PathConverter { } private MailboxPath buildRelativePath(String mailboxName) { - return new MailboxPath(MailboxConstants.USER_NAMESPACE, session.getUserName(), sanitizeMailboxName(mailboxName)); + return new MailboxPath(MailboxConstants.USER_NAMESPACE, mailboxSession.getUser(), sanitizeMailboxName(mailboxName)); } private MailboxPath buildAbsolutePath(String absolutePath) { - MailboxSession mailboxSession = session.getMailboxSession(); return asMailboxPath(Splitter.on(mailboxSession.getPathDelimiter()).splitToList(absolutePath), mailboxSession); } 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 fcb1a48aa6..ee3cce3edc 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 @@ -222,7 +222,7 @@ public class ListProcessor<T extends ListRequest> extends AbstractMailboxProcess isSubscribed.test(metaData.getPath()))); } }) - .doOnNext(metaData -> respondMyRights(request, responder, mailboxSession, metaData)) + .doOnNext(metaData -> respondMyRights(request, responder, mailboxSession, metaData, isRelative)) .concatMap(metaData -> request.getStatusDataItems().map(statusDataItems -> statusProcessor.sendStatus(retrieveMessageManager(metaData, mailboxSession), statusDataItems, responder, session, mailboxSession)).orElse(Mono.empty())) .then(); } @@ -242,7 +242,7 @@ public class ListProcessor<T extends ListRequest> extends AbstractMailboxProcess .map(tuple -> getListResponseForSelectSubscribed(session, tuple.getT1(), tuple.getT2(), request, mailboxSession, isRelative, mailboxQuery)) .flatMapIterable(list -> list) .doOnNext(pathAndResponse -> responder.respond(pathAndResponse.getMiddle())) - .doOnNext(pathAndResponse -> pathAndResponse.getRight().ifPresent(mailboxMetaData -> respondMyRights(request, responder, mailboxSession, mailboxMetaData))) + .doOnNext(pathAndResponse -> pathAndResponse.getRight().ifPresent(mailboxMetaData -> respondMyRights(request, responder, mailboxSession, mailboxMetaData, isRelative))) .concatMap(pathAndResponse -> sendStatusWhenSubscribed(session, request, responder, mailboxSession, pathAndResponse)) .then(); } @@ -313,9 +313,10 @@ public class ListProcessor<T extends ListRequest> extends AbstractMailboxProcess .collect(Collectors.toList()); } - private void respondMyRights(T request, Responder responder, MailboxSession mailboxSession, MailboxMetaData metaData) { + private void respondMyRights(T request, Responder responder, MailboxSession mailboxSession, MailboxMetaData metaData, boolean isRelative) { if (request.getReturnOptions().contains(ListRequest.ListReturnOption.MYRIGHTS)) { - MailboxName mailboxName = new MailboxName(metaData.getPath().getName()); + MailboxName mailboxName = new MailboxName(pathConverterFactory.forSession(mailboxSession) + .mailboxName(isRelative, metaData.getPath(), mailboxSession)); MyRightsResponse myRightsResponse = new MyRightsResponse(mailboxName, getRfc4314Rights(mailboxSession, metaData)); responder.respond(myRightsResponse); } --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@james.apache.org For additional commands, e-mail: notifications-h...@james.apache.org