This is an automated email from the ASF dual-hosted git repository.
kao 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 f15acc0c18 JAMES-3889 Refactoring POP3 delete handlers to be more
extensible
f15acc0c18 is described below
commit f15acc0c181abbcb2234d9e8e3e809077a9510ad
Author: Karsten Otto <[email protected]>
AuthorDate: Tue Feb 21 14:13:38 2023 +0100
JAMES-3889 Refactoring POP3 delete handlers to be more extensible
---
.../james/protocols/pop3/core/DeleCmdHandler.java | 22 +++++++++++++---------
.../james/protocols/pop3/core/QuitCmdHandler.java | 2 +-
2 files changed, 14 insertions(+), 10 deletions(-)
diff --git
a/protocols/pop3/src/main/java/org/apache/james/protocols/pop3/core/DeleCmdHandler.java
b/protocols/pop3/src/main/java/org/apache/james/protocols/pop3/core/DeleCmdHandler.java
index 535951c1fc..8d4ced3e92 100644
---
a/protocols/pop3/src/main/java/org/apache/james/protocols/pop3/core/DeleCmdHandler.java
+++
b/protocols/pop3/src/main/java/org/apache/james/protocols/pop3/core/DeleCmdHandler.java
@@ -53,19 +53,23 @@ public class DeleCmdHandler extends
AbstractPOP3CommandHandler {
this.commandDelegate = new POP3MessageCommandDelegate(COMMANDS) {
@Override
protected Response handleMessageExists(POP3Session session,
MessageMetaData data, POP3MessageCommandArguments args) {
- List<String> deletedUidList =
session.getAttachment(POP3Session.DELETED_UID_LIST, State.Transaction)
- .orElseGet(() -> {
- ArrayList<String> uidList = new ArrayList<>();
- session.setAttachment(POP3Session.DELETED_UID_LIST,
uidList, State.Transaction);
- return uidList;
- });
-
- deletedUidList.add(data.getUid());
- return DELETED;
+ return scheduleMessageDeletion(session, data);
}
};
}
+ protected Response scheduleMessageDeletion(POP3Session session,
MessageMetaData data) {
+ List<String> deletedUidList =
session.getAttachment(POP3Session.DELETED_UID_LIST, State.Transaction)
+ .orElseGet(() -> {
+ ArrayList<String> uidList = new ArrayList<>();
+ session.setAttachment(POP3Session.DELETED_UID_LIST, uidList,
State.Transaction);
+ return uidList;
+ });
+
+ deletedUidList.add(data.getUid());
+ return DELETED;
+ }
+
/**
* Handler method called upon receipt of a DELE command. This command
* deletes a particular mail message from the mailbox.
diff --git
a/protocols/pop3/src/main/java/org/apache/james/protocols/pop3/core/QuitCmdHandler.java
b/protocols/pop3/src/main/java/org/apache/james/protocols/pop3/core/QuitCmdHandler.java
index 44da3cf8e4..7276592fd5 100644
---
a/protocols/pop3/src/main/java/org/apache/james/protocols/pop3/core/QuitCmdHandler.java
+++
b/protocols/pop3/src/main/java/org/apache/james/protocols/pop3/core/QuitCmdHandler.java
@@ -79,7 +79,7 @@ public class QuitCmdHandler extends
AbstractPOP3CommandHandler {
() -> quit(session)));
}
- private Response quit(POP3Session session) {
+ protected Response quit(POP3Session session) {
LOGGER.trace("QUIT command received");
Response response = null;
if (session.getHandlerState() == POP3Session.AUTHENTICATION_READY ||
session.getHandlerState() == POP3Session.AUTHENTICATION_USERSET) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]