You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by bt...@apache.org on 2019/01/08 08:00:43 UTC
[24/47] james-project git commit: MAILBOX-364 EventFactory should
expose a builder for MailboxAdded event
MAILBOX-364 EventFactory should expose a builder for MailboxAdded event
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/8550ce9d
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/8550ce9d
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/8550ce9d
Branch: refs/heads/master
Commit: 8550ce9d2668a11f7371e3a5f21849306a007d5b
Parents: 4d6a372
Author: Benoit Tellier <bt...@linagora.com>
Authored: Wed Dec 19 11:26:09 2018 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Tue Jan 8 14:40:28 2019 +0700
----------------------------------------------------------------------
.../james/mailbox/store/event/EventFactory.java | 57 +++++++++++++++++---
.../store/event/MailboxEventDispatcher.java | 5 +-
2 files changed, 55 insertions(+), 7 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/8550ce9d/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
index 4dfd76c..13c6f9d 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/EventFactory.java
@@ -41,7 +41,56 @@ import org.apache.james.mailbox.model.QuotaRoot;
import org.apache.james.mailbox.model.UpdatedFlags;
import org.apache.james.mailbox.store.mail.model.Mailbox;
+import com.google.common.base.Preconditions;
+
public class EventFactory {
+ public static class MailboxAddedBuilder {
+ private MailboxPath path;
+ private MailboxId mailboxId;
+ private User user;
+ private MailboxSession.SessionId sessionId;
+
+ public MailboxAddedBuilder mailbox(Mailbox mailbox) {
+ path(mailbox.generateAssociatedPath());
+ mailboxId(mailbox.getMailboxId());
+ return this;
+ }
+
+ public MailboxAddedBuilder mailboxSession(MailboxSession mailboxSession) {
+ user(mailboxSession.getUser());
+ sessionId(mailboxSession.getSessionId());
+ return this;
+ }
+
+ public MailboxAddedBuilder mailboxId(MailboxId mailboxId) {
+ this.mailboxId = mailboxId;
+ return this;
+ }
+
+ public MailboxAddedBuilder path(MailboxPath path) {
+ this.path = path;
+ return this;
+ }
+
+ public MailboxAddedBuilder user(User user) {
+ this.user = user;
+ return this;
+ }
+
+ public MailboxAddedBuilder sessionId(MailboxSession.SessionId sessionId) {
+ this.sessionId = sessionId;
+ return this;
+ }
+
+ public MailboxListener.MailboxAdded build() {
+ Preconditions.checkState(user != null, "Field `user` is compulsory");
+ Preconditions.checkState(mailboxId != null, "Field `mailboxId` is compulsory");
+ Preconditions.checkState(path != null, "Field `path` is compulsory");
+ Preconditions.checkState(sessionId != null, "Field `sessionId` is compulsory");
+
+ return new MailboxListener.MailboxAdded(sessionId, user, path, mailboxId);
+ }
+ }
public MailboxListener.Added added(MailboxSession session, SortedMap<MessageUid, MessageMetaData> uids, Mailbox mailbox) {
return added(session.getSessionId(), session.getUser(), uids, mailbox);
@@ -81,12 +130,8 @@ public class EventFactory {
return new MailboxListener.MailboxDeletion(sessionId, user, mailbox.generateAssociatedPath(), quotaRoot, deletedMessageCount, totalDeletedSize, mailbox.getMailboxId());
}
- public MailboxListener.MailboxAdded mailboxAdded(MailboxSession session, Mailbox mailbox) {
- return mailboxAdded(session.getSessionId(), session.getUser(), mailbox);
- }
-
- public MailboxListener.MailboxAdded mailboxAdded(MailboxSession.SessionId sessionId, User user, Mailbox mailbox) {
- return new MailboxListener.MailboxAdded(sessionId, user, mailbox.generateAssociatedPath(), mailbox.getMailboxId());
+ public MailboxAddedBuilder mailboxAdded() {
+ return new MailboxAddedBuilder();
}
public MailboxListener.MailboxACLUpdated aclUpdated(MailboxSession session, MailboxPath mailboxPath, ACLDiff aclDiff, MailboxId mailboxId) {
http://git-wip-us.apache.org/repos/asf/james-project/blob/8550ce9d/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
index 3a4b113..fa0b0bc 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MailboxEventDispatcher.java
@@ -153,7 +153,10 @@ public class MailboxEventDispatcher {
* MailboxListener will get triggered then
*/
public void mailboxAdded(MailboxSession session, Mailbox mailbox) {
- event(eventFactory.mailboxAdded(session, mailbox));
+ listener.event(eventFactory.mailboxAdded()
+ .mailbox(mailbox)
+ .mailboxSession(session)
+ .build());
}
public void aclUpdated(MailboxSession session, MailboxPath mailboxPath, ACLDiff aclDiff, MailboxId mailboxId) {
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org