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 6764b721c753b3a3c63e3a75d63b921281b8c1c9 Author: Benoit Tellier <btell...@linagora.com> AuthorDate: Tue Nov 12 16:01:18 2019 +0700 [Refactoring] ListProcessor: Inline doProcess method --- .../apache/james/imap/processor/ListProcessor.java | 29 ++++++++++------------ .../james/imap/processor/XListProcessor.java | 10 -------- 2 files changed, 13 insertions(+), 26 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 1137c8a..695d442 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 @@ -56,17 +56,6 @@ public class ListProcessor extends AbstractMailboxProcessor<ListRequest> { super(ListRequest.class, next, mailboxManager, factory, metricFactory); } - @Override - protected void doProcess(ListRequest request, ImapSession session, String tag, ImapCommand command, Responder responder) { - String baseReferenceName = request.getBaseReferenceName(); - String mailboxPatternString = request.getMailboxPattern(); - doProcess(baseReferenceName, mailboxPatternString, session, tag, command, responder); - } - - protected ImapResponseMessage createResponse(MailboxMetaData.Children children, MailboxMetaData.Selectability selectability, String name, char hierarchyDelimiter, MailboxType type) { - return new ListResponse(children, selectability, name, hierarchyDelimiter); - } - /** * (from rfc3501)<br> * The LIST command returns a subset of names from the complete set of all @@ -79,22 +68,30 @@ public class ListProcessor extends AbstractMailboxProcessor<ListRequest> { * reference. The value returned as the root MAY be the empty string if the * reference is non-rooted or is an empty string. */ - protected final void doProcess(String referenceName, String mailboxName, ImapSession session, String tag, ImapCommand command, Responder responder) { + @Override + protected void doProcess(ListRequest request, ImapSession session, String tag, ImapCommand command, Responder responder) { + String baseReferenceName = request.getBaseReferenceName(); + String mailboxPatternString = request.getMailboxPattern(); String user = ImapSessionUtils.getUserName(session); MailboxSession mailboxSession = ImapSessionUtils.getMailboxSession(session); + try { - if (mailboxName.length() == 0) { - respondNamespace(referenceName, responder, mailboxSession); + if (mailboxPatternString.length() == 0) { + respondNamespace(baseReferenceName, responder, mailboxSession); } else { - respondMailboxList(referenceName, mailboxName, session, responder, user, mailboxSession); + respondMailboxList(baseReferenceName, mailboxPatternString, session, responder, user, mailboxSession); } okComplete(command, tag, responder); } catch (MailboxException e) { - LOGGER.error("List failed for mailboxName {} and user {}", mailboxName, user, e); + LOGGER.error("List failed for mailboxName {} and user {}", mailboxPatternString, user, e); no(command, tag, responder, HumanReadableText.SEARCH_FAILED); } } + protected ImapResponseMessage createResponse(MailboxMetaData.Children children, MailboxMetaData.Selectability selectability, String name, char hierarchyDelimiter, MailboxType type) { + return new ListResponse(children, selectability, name, hierarchyDelimiter); + } + private void respondNamespace(String referenceName, Responder responder, MailboxSession mailboxSession) { // An empty mailboxName signifies a request for the hierarchy // delimiter and root name of the referenceName argument diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/XListProcessor.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/XListProcessor.java index 45d7e29..381ae28 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/processor/XListProcessor.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/XListProcessor.java @@ -23,7 +23,6 @@ import static org.apache.james.imap.api.ImapConstants.SUPPORTS_XLIST; import java.util.Collections; import java.util.List; -import org.apache.james.imap.api.ImapCommand; import org.apache.james.imap.api.ImapMessage; import org.apache.james.imap.api.message.response.ImapResponseMessage; import org.apache.james.imap.api.message.response.StatusResponseFactory; @@ -31,7 +30,6 @@ import org.apache.james.imap.api.process.ImapProcessor; import org.apache.james.imap.api.process.ImapSession; import org.apache.james.imap.api.process.MailboxType; import org.apache.james.imap.api.process.MailboxTyper; -import org.apache.james.imap.message.request.ListRequest; import org.apache.james.imap.message.request.XListRequest; import org.apache.james.imap.message.response.XListResponse; import org.apache.james.mailbox.MailboxManager; @@ -72,14 +70,6 @@ public class XListProcessor extends ListProcessor implements CapabilityImplement } @Override - protected void doProcess(ListRequest message, ImapSession session, String tag, ImapCommand command, Responder responder) { - final XListRequest request = (XListRequest) message; - final String baseReferenceName = request.getBaseReferenceName(); - final String mailboxPatternString = request.getMailboxPattern(); - doProcess(baseReferenceName, mailboxPatternString, session, tag, command, responder); - } - - @Override protected ImapResponseMessage createResponse(MailboxMetaData.Children children, MailboxMetaData.Selectability selectability, String name, char hierarchyDelimiter, MailboxType type) { return new XListResponse(children, selectability, name, hierarchyDelimiter, type); } --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org