JAMES-2616 Only MailboxEvent need sessionId, moved sessionId to MailboxEvent
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/4734f2da Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/4734f2da Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/4734f2da Branch: refs/heads/master Commit: 4734f2daac49f81c782fb82e7dd4d34e5c8a9358 Parents: d242d9b Author: tran tien duc <dt...@linagora.com> Authored: Tue Dec 4 18:35:06 2018 +0700 Committer: Benoit Tellier <btell...@linagora.com> Committed: Fri Dec 7 07:52:51 2018 +0700 ---------------------------------------------------------------------- .../java/org/apache/james/mailbox/Event.java | 6 -- .../apache/james/mailbox/MailboxListener.java | 26 ++++---- .../spamassassin/SpamAssassinListenerTest.java | 5 +- .../james/mailbox/store/event/EventFactory.java | 62 ++++++++++---------- .../store/event/MailboxEventDispatcher.java | 17 +++--- .../mailbox/store/event/MessageMoveEvent.java | 20 +------ .../event/AsynchronousEventDeliveryTest.java | 7 +-- .../DefaultDelegatingMailboxListenerTest.java | 28 ++++----- .../event/MailboxAnnotationListenerTest.java | 5 +- .../store/event/MixedEventDeliveryTest.java | 7 +-- .../event/SynchronousEventDeliveryTest.java | 6 +- .../processor/base/SelectedMailboxImpl.java | 8 +-- .../base/FakeMailboxListenerAdded.java | 3 +- .../base/FakeMailboxListenerFlagsUpdate.java | 3 +- .../base/MailboxEventAnalyserTest.java | 4 +- 15 files changed, 83 insertions(+), 124 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/4734f2da/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java b/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java index 51c1078..bd8073d 100644 --- a/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java +++ b/mailbox/api/src/main/java/org/apache/james/mailbox/Event.java @@ -18,15 +18,9 @@ ****************************************************************/ package org.apache.james.mailbox; -import java.util.Optional; - import org.apache.james.core.User; public interface Event { User getUser(); - - default Optional<MailboxSession.SessionId> getSessionId() { - return Optional.empty(); - } } http://git-wip-us.apache.org/repos/asf/james-project/blob/4734f2da/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java ---------------------------------------------------------------------- diff --git a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java index 91c94af..906532e 100644 --- a/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java +++ b/mailbox/api/src/main/java/org/apache/james/mailbox/MailboxListener.java @@ -23,7 +23,6 @@ import java.io.Serializable; import java.time.Instant; import java.util.List; import java.util.Objects; -import java.util.Optional; import org.apache.james.core.User; import org.apache.james.core.quota.QuotaCount; @@ -140,9 +139,9 @@ public interface MailboxListener { private final MailboxPath path; private final MailboxId mailboxId; private final User user; - private final Optional<MailboxSession.SessionId> sessionId; + private final MailboxSession.SessionId sessionId; - public MailboxEvent(Optional<MailboxSession.SessionId> sessionId, User user, MailboxPath path, MailboxId mailboxId) { + public MailboxEvent(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId) { this.user = user; this.path = path; this.mailboxId = mailboxId; @@ -166,8 +165,7 @@ public interface MailboxListener { * * @return sessionId */ - @Override - public Optional<MailboxSession.SessionId> getSessionId() { + public MailboxSession.SessionId getSessionId() { return sessionId; } @@ -204,7 +202,7 @@ public interface MailboxListener { private final QuotaCount deletedMessageCOunt; private final QuotaSize totalDeletedSize; - public MailboxDeletion(Optional<MailboxSession.SessionId> sessionId, User user, MailboxPath path, QuotaRoot quotaRoot, QuotaCount deletedMessageCOunt, QuotaSize totalDeletedSize, + public MailboxDeletion(MailboxSession.SessionId sessionId, User user, MailboxPath path, QuotaRoot quotaRoot, QuotaCount deletedMessageCOunt, QuotaSize totalDeletedSize, MailboxId mailboxId) { super(sessionId, user, path, mailboxId); this.quotaRoot = quotaRoot; @@ -234,7 +232,7 @@ public interface MailboxListener { */ private static final long serialVersionUID = 1L; - public MailboxAdded(Optional<MailboxSession.SessionId> sessionId, User user, MailboxPath path, MailboxId mailboxId) { + public MailboxAdded(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId) { super(sessionId, user, path, mailboxId); } } @@ -248,7 +246,7 @@ public interface MailboxListener { */ private static final long serialVersionUID = 1L; - public MailboxRenamed(Optional<MailboxSession.SessionId> sessionId, User user, MailboxPath path, MailboxId mailboxId) { + public MailboxRenamed(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId) { super(sessionId, user, path, mailboxId); } @@ -268,7 +266,7 @@ public interface MailboxListener { private final ACLDiff aclDiff; private static final long serialVersionUID = 1L; - public MailboxACLUpdated(Optional<MailboxSession.SessionId> sessionId, User user, MailboxPath path, ACLDiff aclDiff, MailboxId mailboxId) { + public MailboxACLUpdated(MailboxSession.SessionId sessionId, User user, MailboxPath path, ACLDiff aclDiff, MailboxId mailboxId) { super(sessionId, user, path, mailboxId); this.aclDiff = aclDiff; } @@ -289,7 +287,7 @@ public interface MailboxListener { */ private static final long serialVersionUID = 1L; - public MessageEvent(Optional<MailboxSession.SessionId> sessionId, User user, MailboxPath path, MailboxId mailboxId) { + public MessageEvent(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId) { super(sessionId, user, path, mailboxId); } @@ -303,7 +301,7 @@ public interface MailboxListener { abstract class MetaDataHoldingEvent extends MessageEvent { - public MetaDataHoldingEvent(Optional<MailboxSession.SessionId> sessionId, User user, MailboxPath path, MailboxId mailboxId) { + public MetaDataHoldingEvent(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId) { super(sessionId, user, path, mailboxId); } @@ -323,7 +321,7 @@ public interface MailboxListener { */ private static final long serialVersionUID = 1L; - public Expunged(Optional<MailboxSession.SessionId> sessionId, User user, MailboxPath path, MailboxId mailboxId) { + public Expunged(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId) { super(sessionId, user, path, mailboxId); } @@ -346,7 +344,7 @@ public interface MailboxListener { */ private static final long serialVersionUID = 1L; - public FlagsUpdated(Optional<MailboxSession.SessionId> sessionId, User user, MailboxPath path, MailboxId mailboxId) { + public FlagsUpdated(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId) { super(sessionId, user, path, mailboxId); } @@ -363,7 +361,7 @@ public interface MailboxListener { */ private static final long serialVersionUID = 1L; - public Added(Optional<MailboxSession.SessionId> sessionId, User user, MailboxPath path, MailboxId mailboxId) { + public Added(MailboxSession.SessionId sessionId, User user, MailboxPath path, MailboxId mailboxId) { super(sessionId, user, path, mailboxId); } http://git-wip-us.apache.org/repos/asf/james-project/blob/4734f2da/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java ---------------------------------------------------------------------- diff --git a/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java b/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java index 9f4c7ae..19e7755 100644 --- a/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java +++ b/mailbox/plugin/spamassassin/src/test/java/org/apache/james/mailbox/spamassassin/SpamAssassinListenerTest.java @@ -28,7 +28,6 @@ import static org.mockito.Mockito.when; import java.nio.charset.StandardCharsets; import java.util.Date; -import java.util.Optional; import javax.mail.Flags; import javax.mail.util.SharedByteArrayInputStream; @@ -252,7 +251,7 @@ public class SpamAssassinListenerTest { SimpleMailboxMessage message = createMessage(inboxId); EventFactory eventFactory = new EventFactory(); AddedImpl addedEvent = eventFactory.new AddedImpl( - Optional.of(MAILBOX_SESSION.getSessionId()), + MAILBOX_SESSION.getSessionId(), MAILBOX_SESSION.getUser().getCoreUser(), inbox, ImmutableSortedMap.of(MessageUid.of(45), new SimpleMessageMetaData(message)), @@ -268,7 +267,7 @@ public class SpamAssassinListenerTest { SimpleMailboxMessage message = createMessage(mailboxId1); EventFactory eventFactory = new EventFactory(); AddedImpl addedEvent = eventFactory.new AddedImpl( - Optional.of(MAILBOX_SESSION.getSessionId()), + MAILBOX_SESSION.getSessionId(), MAILBOX_SESSION.getUser().getCoreUser(), mailbox1, ImmutableSortedMap.of(MessageUid.of(45), new SimpleMessageMetaData(message)), http://git-wip-us.apache.org/repos/asf/james-project/blob/4734f2da/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 2b8632e..dd47954 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 @@ -21,7 +21,6 @@ package org.apache.james.mailbox.store.event; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.SortedMap; import org.apache.james.core.User; @@ -55,7 +54,7 @@ public class EventFactory { private final Map<MessageUid, MailboxMessage> availableMessages; private final Mailbox mailbox; - public AddedImpl(Optional<MailboxSession.SessionId> sessionId, User user, Mailbox mailbox, SortedMap<MessageUid, MessageMetaData> uids, Map<MessageUid, MailboxMessage> availableMessages) { + public AddedImpl(MailboxSession.SessionId sessionId, User user, Mailbox mailbox, SortedMap<MessageUid, MessageMetaData> uids, Map<MessageUid, MailboxMessage> availableMessages) { super(sessionId, user, new StoreMailboxPath(mailbox), mailbox.getMailboxId()); this.added = ImmutableMap.copyOf(uids); this.mailbox = mailbox; @@ -86,7 +85,7 @@ public class EventFactory { private final Map<MessageUid, MessageMetaData> uids; private final Mailbox mailbox; - public ExpungedImpl(Optional<MailboxSession.SessionId> sessionId, User user, Mailbox mailbox, Map<MessageUid, MessageMetaData> uids) { + public ExpungedImpl(MailboxSession.SessionId sessionId, User user, Mailbox mailbox, Map<MessageUid, MessageMetaData> uids) { super(sessionId, user, new StoreMailboxPath(mailbox), mailbox.getMailboxId()); this.uids = ImmutableMap.copyOf(uids); this.mailbox = mailbox; @@ -115,7 +114,7 @@ public class EventFactory { private final List<UpdatedFlags> uFlags; - public FlagsUpdatedImpl(Optional<MailboxSession.SessionId> sessionId, User user, Mailbox mailbox, List<MessageUid> uids, List<UpdatedFlags> uFlags) { + public FlagsUpdatedImpl(MailboxSession.SessionId sessionId, User user, Mailbox mailbox, List<MessageUid> uids, List<UpdatedFlags> uFlags) { super(sessionId, user, new StoreMailboxPath(mailbox), mailbox.getMailboxId()); this.uids = ImmutableList.copyOf(uids); this.uFlags = ImmutableList.copyOf(uFlags); @@ -142,7 +141,7 @@ public class EventFactory { public final class MailboxDeletionImpl extends MailboxListener.MailboxDeletion implements MailboxAware { private final Mailbox mailbox; - public MailboxDeletionImpl(Optional<MailboxSession.SessionId> sessionId, User user, Mailbox mailbox, QuotaRoot quotaRoot, QuotaCount deletedMessageCount, QuotaSize totalDeletedSize) { + public MailboxDeletionImpl(MailboxSession.SessionId sessionId, User user, Mailbox mailbox, QuotaRoot quotaRoot, QuotaCount deletedMessageCount, QuotaSize totalDeletedSize) { super(sessionId, user, new StoreMailboxPath(mailbox), quotaRoot, deletedMessageCount, totalDeletedSize, mailbox.getMailboxId()); this.mailbox = mailbox; } @@ -159,7 +158,7 @@ public class EventFactory { private final Mailbox mailbox; - public MailboxAddedImpl(Optional<MailboxSession.SessionId> sessionId, User user, Mailbox mailbox) { + public MailboxAddedImpl(MailboxSession.SessionId sessionId, User user, Mailbox mailbox) { super(sessionId, user, new StoreMailboxPath(mailbox), mailbox.getMailboxId()); this.mailbox = mailbox; } @@ -177,7 +176,7 @@ public class EventFactory { private final MailboxPath newPath; private final Mailbox newMailbox; - public MailboxRenamedEventImpl(Optional<MailboxSession.SessionId> sessionId, User user, MailboxPath oldPath, Mailbox newMailbox) { + public MailboxRenamedEventImpl(MailboxSession.SessionId sessionId, User user, MailboxPath oldPath, Mailbox newMailbox) { super(sessionId, user, oldPath, newMailbox.getMailboxId()); this.newPath = new StoreMailboxPath(newMailbox); this.newMailbox = newMailbox; @@ -194,64 +193,67 @@ public class EventFactory { } } - public MailboxListener.Added added(Optional<MailboxSession.SessionId> maybeSessionId, User user, SortedMap<MessageUid, MessageMetaData> uids, Mailbox mailbox, Map<MessageUid, MailboxMessage> cachedMessages) { - return new AddedImpl(maybeSessionId, user, mailbox, uids, cachedMessages); + public MailboxListener.Added added(MailboxSession session, SortedMap<MessageUid, MessageMetaData> uids, Mailbox mailbox, Map<MessageUid, MailboxMessage> cachedMessages) { + return added(session.getSessionId(), session.getUser().getCoreUser(), uids, mailbox, cachedMessages); } public MailboxListener.Added added(MailboxSession.SessionId sessionId, User user, SortedMap<MessageUid, MessageMetaData> uids, Mailbox mailbox, Map<MessageUid, MailboxMessage> cachedMessages) { - return added(Optional.ofNullable(sessionId), user, uids, mailbox, cachedMessages); + return new AddedImpl(sessionId, user, mailbox, uids, cachedMessages); } - public MailboxListener.Expunged expunged(Optional<MailboxSession.SessionId> sessionId, User user, Map<MessageUid, MessageMetaData> uids, Mailbox mailbox) { - return new ExpungedImpl(sessionId, user, mailbox, uids); + public MailboxListener.Expunged expunged(MailboxSession session, Map<MessageUid, MessageMetaData> uids, Mailbox mailbox) { + return expunged(session.getSessionId(), session.getUser().getCoreUser(), uids, mailbox); } - public MailboxListener.Expunged expunged(MailboxSession.SessionId sessionId, User user, Map<MessageUid, MessageMetaData> uids, Mailbox mailbox) { - return expunged(Optional.ofNullable(sessionId), user, uids, mailbox); + public MailboxListener.Expunged expunged(MailboxSession.SessionId sessionId, User user, Map<MessageUid, MessageMetaData> uids, Mailbox mailbox) { + return new ExpungedImpl(sessionId, user, mailbox, uids); } - public MailboxListener.FlagsUpdated flagsUpdated(Optional<MailboxSession.SessionId> sessionId, User user, List<MessageUid> uids, Mailbox mailbox, List<UpdatedFlags> uflags) { - return new FlagsUpdatedImpl(sessionId, user, mailbox, uids, uflags); + public MailboxListener.FlagsUpdated flagsUpdated(MailboxSession session, List<MessageUid> uids, Mailbox mailbox, List<UpdatedFlags> uflags) { + return flagsUpdated(session.getSessionId(), session.getUser().getCoreUser(), uids, mailbox, uflags); } public MailboxListener.FlagsUpdated flagsUpdated(MailboxSession.SessionId sessionId, User user, List<MessageUid> uids, Mailbox mailbox, List<UpdatedFlags> uflags) { - return flagsUpdated(Optional.ofNullable(sessionId), user, uids, mailbox, uflags); + return new FlagsUpdatedImpl(sessionId, user, mailbox, uids, uflags); } - public MailboxListener.MailboxRenamed mailboxRenamed(Optional<MailboxSession.SessionId> sessionId, User user, MailboxPath from, Mailbox to) { - return new MailboxRenamedEventImpl(sessionId, user, from, to); + public MailboxListener.MailboxRenamed mailboxRenamed(MailboxSession session, MailboxPath from, Mailbox to) { + return mailboxRenamed(session.getSessionId(), session.getUser().getCoreUser(), from, to); } public MailboxListener.MailboxRenamed mailboxRenamed(MailboxSession.SessionId sessionId, User user, MailboxPath from, Mailbox to) { - return mailboxRenamed(Optional.ofNullable(sessionId), user, from, to); + return new MailboxRenamedEventImpl(sessionId, user, from, to); } - public MailboxListener.MailboxDeletion mailboxDeleted(Optional<MailboxSession.SessionId> sessionId, User user, Mailbox mailbox, QuotaRoot quotaRoot, + public MailboxListener.MailboxDeletion mailboxDeleted(MailboxSession session, Mailbox mailbox, QuotaRoot quotaRoot, QuotaCount deletedMessageCount, QuotaSize totalDeletedSize) { - return new MailboxDeletionImpl(sessionId, user, mailbox, quotaRoot, deletedMessageCount, totalDeletedSize); + return mailboxDeleted(session.getSessionId(), session.getUser().getCoreUser(), mailbox, quotaRoot, deletedMessageCount, totalDeletedSize); } public MailboxListener.MailboxDeletion mailboxDeleted(MailboxSession.SessionId sessionId, User user, Mailbox mailbox, QuotaRoot quotaRoot, QuotaCount deletedMessageCount, QuotaSize totalDeletedSize) { - return new MailboxDeletionImpl(Optional.ofNullable(sessionId), user, mailbox, quotaRoot, deletedMessageCount, totalDeletedSize); + return new MailboxDeletionImpl(sessionId, user, mailbox, quotaRoot, deletedMessageCount, totalDeletedSize); } - public MailboxListener.MailboxAdded mailboxAdded(Optional<MailboxSession.SessionId> sessionId, User user, Mailbox mailbox) { - return new MailboxAddedImpl(sessionId, user, mailbox); + public MailboxListener.MailboxAdded mailboxAdded(MailboxSession session, Mailbox mailbox) { + return mailboxAdded(session.getSessionId(), session.getUser().getCoreUser(), mailbox); } public MailboxListener.MailboxAdded mailboxAdded(MailboxSession.SessionId sessionId, User user, Mailbox mailbox) { - return new MailboxAddedImpl(Optional.ofNullable(sessionId), user, mailbox); + return new MailboxAddedImpl(sessionId, user, mailbox); + } + + public MailboxListener.MailboxACLUpdated aclUpdated(MailboxSession session, MailboxPath mailboxPath, ACLDiff aclDiff, MailboxId mailboxId) { + return aclUpdated(session.getSessionId(), session.getUser().getCoreUser(), mailboxPath, aclDiff, mailboxId); } public MailboxListener.MailboxACLUpdated aclUpdated(MailboxSession.SessionId sessionId, User user, MailboxPath mailboxPath, ACLDiff aclDiff, MailboxId mailboxId) { - return new MailboxListener.MailboxACLUpdated(Optional.ofNullable(sessionId), user, mailboxPath, aclDiff, mailboxId); + return new MailboxListener.MailboxACLUpdated(sessionId, user, mailboxPath, aclDiff, mailboxId); } - public MessageMoveEvent moved(MailboxSession.SessionId sessionId, User user, MessageMoves messageMoves, Map<MessageUid, MailboxMessage> messages) { + public MessageMoveEvent moved(MailboxSession session, MessageMoves messageMoves, Map<MessageUid, MailboxMessage> messages) { return MessageMoveEvent.builder() - .sessionId(Optional.ofNullable(sessionId)) - .user(user) + .user(session.getUser().getCoreUser()) .messageMoves(messageMoves) .messages(messages) .build(); http://git-wip-us.apache.org/repos/asf/james-project/blob/4734f2da/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 1ae5ca0..206e8b7 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 @@ -22,7 +22,6 @@ package org.apache.james.mailbox.store.event; import java.time.Instant; import java.util.List; import java.util.Map; -import java.util.Optional; import java.util.SortedMap; import javax.inject.Inject; @@ -83,7 +82,7 @@ public class MailboxEventDispatcher { * @param mailbox The mailbox */ public void added(MailboxSession session, SortedMap<MessageUid, MessageMetaData> uids, Mailbox mailbox, Map<MessageUid, MailboxMessage> cachedMessages) { - listener.event(eventFactory.added(session.getSessionId(), session.getUser().getCoreUser(), uids, mailbox, cachedMessages)); + listener.event(eventFactory.added(session, uids, mailbox, cachedMessages)); } public void added(MailboxSession session, Mailbox mailbox, MailboxMessage mailboxMessage) { @@ -111,7 +110,7 @@ public class MailboxEventDispatcher { */ public void expunged(MailboxSession session, Map<MessageUid, MessageMetaData> uids, Mailbox mailbox) { if (!uids.isEmpty()) { - listener.event(eventFactory.expunged(session.getSessionId(), session.getUser().getCoreUser(), uids, mailbox)); + listener.event(eventFactory.expunged(session, uids, mailbox)); } } @@ -128,7 +127,7 @@ public class MailboxEventDispatcher { */ public void flagsUpdated(MailboxSession session, List<MessageUid> uids, Mailbox mailbox, List<UpdatedFlags> uflags) { if (!uids.isEmpty()) { - listener.event(eventFactory.flagsUpdated(session.getSessionId(), session.getUser().getCoreUser(), uids, mailbox, uflags)); + listener.event(eventFactory.flagsUpdated(session, uids, mailbox, uflags)); } } @@ -141,7 +140,7 @@ public class MailboxEventDispatcher { * MailboxListener will get triggered then */ public void mailboxRenamed(MailboxSession session, MailboxPath from, Mailbox to) { - listener.event(eventFactory.mailboxRenamed(session.getSessionId(), session.getUser().getCoreUser(), from, to)); + listener.event(eventFactory.mailboxRenamed(session, from, to)); } /** @@ -149,7 +148,7 @@ public class MailboxEventDispatcher { * MailboxListener will get triggered then */ public void mailboxDeleted(MailboxSession session, Mailbox mailbox, QuotaRoot quotaRoot, QuotaCount deletedMessageCount, QuotaSize totalDeletedSize) { - listener.event(eventFactory.mailboxDeleted(session.getSessionId(), session.getUser().getCoreUser(), mailbox, quotaRoot, deletedMessageCount, totalDeletedSize)); + listener.event(eventFactory.mailboxDeleted(session, mailbox, quotaRoot, deletedMessageCount, totalDeletedSize)); } /** @@ -157,15 +156,15 @@ public class MailboxEventDispatcher { * MailboxListener will get triggered then */ public void mailboxAdded(MailboxSession session, Mailbox mailbox) { - listener.event(eventFactory.mailboxAdded(session.getSessionId(), session.getUser().getCoreUser(), mailbox)); + listener.event(eventFactory.mailboxAdded(session, mailbox)); } public void aclUpdated(MailboxSession session, MailboxPath mailboxPath, ACLDiff aclDiff, MailboxId mailboxId) { - listener.event(eventFactory.aclUpdated(session.getSessionId(), session.getUser().getCoreUser(), mailboxPath, aclDiff, mailboxId)); + listener.event(eventFactory.aclUpdated(session, mailboxPath, aclDiff, mailboxId)); } public void moved(MailboxSession session, MessageMoves messageMoves, Map<MessageUid, MailboxMessage> messages) { - MessageMoveEvent moveEvent = eventFactory.moved(session.getSessionId(), session.getUser().getCoreUser(), messageMoves, messages); + MessageMoveEvent moveEvent = eventFactory.moved(session, messageMoves, messages); if (!moveEvent.isNoop()) { listener.event(moveEvent); } http://git-wip-us.apache.org/repos/asf/james-project/blob/4734f2da/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MessageMoveEvent.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MessageMoveEvent.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MessageMoveEvent.java index cb504c9..022303e 100644 --- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MessageMoveEvent.java +++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/event/MessageMoveEvent.java @@ -19,7 +19,6 @@ package org.apache.james.mailbox.store.event; import java.util.Map; -import java.util.Optional; import org.apache.james.core.User; import org.apache.james.mailbox.Event; @@ -41,7 +40,6 @@ public class MessageMoveEvent implements Event { public static class Builder { - private Optional<MailboxSession.SessionId> sessionId; private User user; private MessageMoves messageMoves; private ImmutableMap.Builder<MessageUid, MailboxMessage> messagesBuilder; @@ -51,16 +49,10 @@ public class MessageMoveEvent implements Event { } public Builder session(MailboxSession session) { - this.sessionId = Optional.ofNullable(session.getSessionId()); this.user = session.getUser().getCoreUser(); return this; } - public Builder sessionId(Optional<MailboxSession.SessionId> sessionId) { - this.sessionId = sessionId; - return this; - } - public Builder user(User user) { this.user = user; return this; @@ -77,24 +69,21 @@ public class MessageMoveEvent implements Event { } public MessageMoveEvent build() { - Preconditions.checkNotNull(sessionId, "'sessionId' is mandatory"); Preconditions.checkNotNull(user, "'user' is mandatory"); Preconditions.checkNotNull(messageMoves, "'messageMoves' is mandatory"); ImmutableMap<MessageUid, MailboxMessage> messages = messagesBuilder.build(); - return new MessageMoveEvent(sessionId, user, messageMoves, messages); + return new MessageMoveEvent(user, messageMoves, messages); } } - private final Optional<MailboxSession.SessionId> sessionId; private final User user; private final MessageMoves messageMoves; private final Map<MessageUid, MailboxMessage> messages; @VisibleForTesting - MessageMoveEvent(Optional<MailboxSession.SessionId> sessionId, User user, MessageMoves messageMoves, Map<MessageUid, MailboxMessage> messages) { - this.sessionId = sessionId; + MessageMoveEvent(User user, MessageMoves messageMoves, Map<MessageUid, MailboxMessage> messages) { this.user = user; this.messageMoves = messageMoves; this.messages = messages; @@ -109,11 +98,6 @@ public class MessageMoveEvent implements Event { return user; } - @Override - public Optional<MailboxSession.SessionId> getSessionId() { - return sessionId; - } - public MessageMoves getMessageMoves() { return messageMoves; } http://git-wip-us.apache.org/repos/asf/james-project/blob/4734f2da/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/AsynchronousEventDeliveryTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/AsynchronousEventDeliveryTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/AsynchronousEventDeliveryTest.java index 45ef1ea..7331968 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/AsynchronousEventDeliveryTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/AsynchronousEventDeliveryTest.java @@ -24,7 +24,6 @@ import static org.mockito.Mockito.mock; import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.verify; -import java.util.Optional; import java.util.concurrent.TimeUnit; import org.apache.james.mailbox.MailboxListener; @@ -54,7 +53,7 @@ public class AsynchronousEventDeliveryTest { @Test public void deliverShouldWork() { - MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(), null, null, null) {}; + MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, null, null) {}; asynchronousEventDelivery.deliver(mailboxListener, event); verify(mailboxListener, timeout(ONE_MINUTE)).event(event); } @@ -62,7 +61,7 @@ public class AsynchronousEventDeliveryTest { @Test public void deliverShouldNotPropagateException() { MockMailboxSession session = new MockMailboxSession("test"); - MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.ofNullable(session.getSessionId()), + MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(session.getSessionId(), session.getUser().getCoreUser(), null, null) {}; doThrow(new RuntimeException()).when(mailboxListener).event(event); asynchronousEventDelivery.deliver(mailboxListener, event); @@ -72,7 +71,7 @@ public class AsynchronousEventDeliveryTest { @Test public void deliverShouldWorkWhenThePoolIsFull() { MockMailboxSession session = new MockMailboxSession("test"); - MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.ofNullable(session.getSessionId()), + MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(session.getSessionId(), session.getUser().getCoreUser(), null, null) {}; int operationCount = 10; for (int i = 0; i < operationCount; i++) { http://git-wip-us.apache.org/repos/asf/james-project/blob/4734f2da/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListenerTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListenerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListenerTest.java index 87ce925..a5657de 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListenerTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/DefaultDelegatingMailboxListenerTest.java @@ -24,8 +24,6 @@ import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import java.util.Optional; - import org.apache.james.core.quota.QuotaCount; import org.apache.james.core.quota.QuotaSize; import org.apache.james.mailbox.MailboxListener; @@ -83,7 +81,7 @@ public class DefaultDelegatingMailboxListenerTest { @Test public void eventShouldWork() { - MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(), null, MAILBOX_PATH, MAILBOX_ID) {}; + MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, MAILBOX_PATH, MAILBOX_ID) {}; defaultDelegatingMailboxListener.event(event); assertThat(mailboxEventCollector.getEvents()).containsExactly(event); assertThat(eachNodeEventCollector.getEvents()).containsExactly(event); @@ -92,7 +90,7 @@ public class DefaultDelegatingMailboxListenerTest { @Test public void eventShouldOnlyTriggerMAILBOXListenerRelatedToTheEvent() { - MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(), null, OTHER_MAILBOX_PATH, OTHER_MAILBOX_ID) {}; + MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, OTHER_MAILBOX_PATH, OTHER_MAILBOX_ID) {}; defaultDelegatingMailboxListener.event(event); assertThat(mailboxEventCollector.getEvents()).isEmpty(); assertThat(eachNodeEventCollector.getEvents()).containsExactly(event); @@ -101,12 +99,12 @@ public class DefaultDelegatingMailboxListenerTest { @Test public void mailboxDeletionShouldUnregisterMAILBOXListeners() { - QuotaRoot quotaRoot = QuotaRoot.quotaRoot("root", Optional.empty()); + QuotaRoot quotaRoot = QuotaRoot.quotaRoot("root", null); QuotaCount deletedMessageCount = QuotaCount.count(123); QuotaSize totalDeletedSize = QuotaSize.size(456); - MailboxListener.MailboxDeletion event = new MailboxListener.MailboxDeletion(Optional.empty(), null, MAILBOX_PATH, quotaRoot, deletedMessageCount, totalDeletedSize, MAILBOX_ID) {}; + MailboxListener.MailboxDeletion event = new MailboxListener.MailboxDeletion(null, null, MAILBOX_PATH, quotaRoot, deletedMessageCount, totalDeletedSize, MAILBOX_ID) {}; defaultDelegatingMailboxListener.event(event); - MailboxListener.MailboxEvent secondEvent = new MailboxListener.MailboxEvent(Optional.empty(), null, MAILBOX_PATH, MAILBOX_ID) {}; + MailboxListener.MailboxEvent secondEvent = new MailboxListener.MailboxEvent(null, null, MAILBOX_PATH, MAILBOX_ID) {}; defaultDelegatingMailboxListener.event(secondEvent); assertThat(mailboxEventCollector.getEvents()).containsExactly(event); assertThat(eachNodeEventCollector.getEvents()).containsOnly(event, secondEvent); @@ -115,12 +113,12 @@ public class DefaultDelegatingMailboxListenerTest { @Test public void mailboxDeletionShouldNotRegisterMAILBOXListenerToOtherPaths() { - QuotaRoot quotaRoot = QuotaRoot.quotaRoot("root", Optional.empty()); + QuotaRoot quotaRoot = QuotaRoot.quotaRoot("root", null); QuotaCount quotaCount = QuotaCount.count(123); QuotaSize quotaSize = QuotaSize.size(456); - MailboxListener.MailboxDeletion event = new MailboxListener.MailboxDeletion(Optional.empty(), null, MAILBOX_PATH, quotaRoot, quotaCount, quotaSize, MAILBOX_ID) {}; + MailboxListener.MailboxDeletion event = new MailboxListener.MailboxDeletion(null, null, MAILBOX_PATH, quotaRoot, quotaCount, quotaSize, MAILBOX_ID) {}; defaultDelegatingMailboxListener.event(event); - MailboxListener.MailboxEvent secondEvent = new MailboxListener.MailboxEvent(Optional.empty(), null, OTHER_MAILBOX_PATH, MAILBOX_ID) {}; + MailboxListener.MailboxEvent secondEvent = new MailboxListener.MailboxEvent(null, null, OTHER_MAILBOX_PATH, MAILBOX_ID) {}; defaultDelegatingMailboxListener.event(secondEvent); assertThat(mailboxEventCollector.getEvents()).containsExactly(event); assertThat(eachNodeEventCollector.getEvents()).containsOnly(event, secondEvent); @@ -130,7 +128,7 @@ public class DefaultDelegatingMailboxListenerTest { @Test public void removeListenerShouldWork() { defaultDelegatingMailboxListener.removeListener(MAILBOX_ID, mailboxEventCollector, null); - MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(), null, MAILBOX_PATH, MAILBOX_ID) {}; + MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, MAILBOX_PATH, MAILBOX_ID) {}; defaultDelegatingMailboxListener.event(event); assertThat(mailboxEventCollector.getEvents()).isEmpty(); assertThat(eachNodeEventCollector.getEvents()).containsExactly(event); @@ -140,7 +138,7 @@ public class DefaultDelegatingMailboxListenerTest { @Test public void removeListenerShouldNotRemoveAListenerFromADifferentPath() { defaultDelegatingMailboxListener.removeListener(OTHER_MAILBOX_ID, mailboxEventCollector, null); - MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(), null, MAILBOX_PATH, MAILBOX_ID) {}; + MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, MAILBOX_PATH, MAILBOX_ID) {}; defaultDelegatingMailboxListener.event(event); assertThat(mailboxEventCollector.getEvents()).containsExactly(event); assertThat(eachNodeEventCollector.getEvents()).containsExactly(event); @@ -150,7 +148,7 @@ public class DefaultDelegatingMailboxListenerTest { @Test public void removeGlobalListenerShouldWorkForONCE() { defaultDelegatingMailboxListener.removeGlobalListener(eachNodeEventCollector, null); - MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(), null, MAILBOX_PATH, MAILBOX_ID) {}; + MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, MAILBOX_PATH, MAILBOX_ID) {}; defaultDelegatingMailboxListener.event(event); assertThat(mailboxEventCollector.getEvents()).containsExactly(event); assertThat(eachNodeEventCollector.getEvents()).isEmpty(); @@ -160,7 +158,7 @@ public class DefaultDelegatingMailboxListenerTest { @Test public void removeGlobalListenerShouldWorkForEACH_NODE() throws Exception { defaultDelegatingMailboxListener.removeGlobalListener(onceEventCollector, null); - MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(), null, MAILBOX_PATH, MAILBOX_ID) {}; + MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, MAILBOX_PATH, MAILBOX_ID) {}; defaultDelegatingMailboxListener.event(event); assertThat(mailboxEventCollector.getEvents()).containsExactly(event); assertThat(eachNodeEventCollector.getEvents()).containsExactly(event); @@ -170,7 +168,7 @@ public class DefaultDelegatingMailboxListenerTest { @Test public void listenersErrorsShouldNotBePropageted() throws Exception { MailboxSession session = new MockMailboxSession("benwa"); - MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.of(session.getSessionId()), + MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(session.getSessionId(), session.getUser().getCoreUser(), MAILBOX_PATH, MAILBOX_ID) {}; MailboxListener mockedListener = mock(MailboxListener.class); when(mockedListener.getType()).thenReturn(MailboxListener.ListenerType.ONCE); http://git-wip-us.apache.org/repos/asf/james-project/blob/4734f2da/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java index ea6f4bd..933ed28 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MailboxAnnotationListenerTest.java @@ -86,8 +86,7 @@ public class MailboxAnnotationListenerTest { QuotaRoot quotaRoot = QuotaRoot.quotaRoot("root", Optional.empty()); QuotaCount quotaCount = QuotaCount.count(123); QuotaSize quotaSize = QuotaSize.size(456); - deleteEvent = eventFactory.mailboxDeleted(mailboxSession.getSessionId(), mailboxSession.getUser().getCoreUser(), - mailbox, quotaRoot, quotaCount, quotaSize); + deleteEvent = eventFactory.mailboxDeleted(mailboxSession, mailbox, quotaRoot, quotaCount, quotaSize); when(mailboxManager.createSystemSession(deleteEvent.getUser().asString())) .thenReturn(mailboxSession); @@ -96,7 +95,7 @@ public class MailboxAnnotationListenerTest { @Test public void eventShouldDoNothingIfDoNotHaveMailboxDeletionEvent() { - MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(), null, MAILBOX_PATH, MAILBOX_ID) {}; + MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, MAILBOX_PATH, MAILBOX_ID) {}; listener.event(event); verifyNoMoreInteractions(mailboxSessionMapperFactory); http://git-wip-us.apache.org/repos/asf/james-project/blob/4734f2da/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MixedEventDeliveryTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MixedEventDeliveryTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MixedEventDeliveryTest.java index 8c19b3a..3c44dda 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MixedEventDeliveryTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/MixedEventDeliveryTest.java @@ -25,7 +25,6 @@ import static org.mockito.Mockito.timeout; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; -import java.util.Optional; import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; @@ -59,14 +58,14 @@ public class MixedEventDeliveryTest { @Test public void deliverShouldWorkOnSynchronousListeners() { when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.SYNCHRONOUS); - MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(), null, null, null) {}; + MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, null, null) {}; mixedEventDelivery.deliver(listener, event); verify(listener).event(event); } @Test public void deliverShouldEventuallyDeliverOnAsynchronousListeners() { - MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(), null, null, null) {}; + MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, null, null) {}; when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.ASYNCHRONOUS); mixedEventDelivery.deliver(listener, event); verify(listener, timeout(DELIVERY_DELAY * 10)).event(event); @@ -74,7 +73,7 @@ public class MixedEventDeliveryTest { @Test(timeout = ONE_MINUTE) public void deliverShouldNotBlockOnAsynchronousListeners() { - MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(), null, null, null) {}; + MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, null, null) {}; when(listener.getExecutionMode()).thenReturn(MailboxListener.ExecutionMode.ASYNCHRONOUS); final CountDownLatch latch = new CountDownLatch(1); doAnswer(invocation -> { http://git-wip-us.apache.org/repos/asf/james-project/blob/4734f2da/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/SynchronousEventDeliveryTest.java ---------------------------------------------------------------------- diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/SynchronousEventDeliveryTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/SynchronousEventDeliveryTest.java index 64ad475..cbe0c0a 100644 --- a/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/SynchronousEventDeliveryTest.java +++ b/mailbox/store/src/test/java/org/apache/james/mailbox/store/event/SynchronousEventDeliveryTest.java @@ -23,8 +23,6 @@ import static org.mockito.Mockito.doThrow; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; -import java.util.Optional; - import org.apache.james.mailbox.MailboxListener; import org.apache.james.mailbox.mock.MockMailboxSession; import org.apache.james.metrics.api.NoopMetricFactory; @@ -44,7 +42,7 @@ public class SynchronousEventDeliveryTest { @Test public void deliverShouldWork() { - MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.empty(), null, null, null) {}; + MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(null, null, null, null) {}; synchronousEventDelivery.deliver(mailboxListener, event); verify(mailboxListener).event(event); } @@ -52,7 +50,7 @@ public class SynchronousEventDeliveryTest { @Test public void deliverShouldNotPropagateException() { MockMailboxSession session = new MockMailboxSession("test"); - MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.ofNullable(session.getSessionId()), + MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(session.getSessionId(), session.getUser().getCoreUser(),null, null) {}; doThrow(new RuntimeException()).when(mailboxListener).event(event); synchronousEventDelivery.deliver(mailboxListener, event); http://git-wip-us.apache.org/repos/asf/james-project/blob/4734f2da/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java index 0ebaac5..23ab486 100644 --- a/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java +++ b/protocols/imap/src/main/java/org/apache/james/imap/processor/base/SelectedMailboxImpl.java @@ -329,7 +329,7 @@ public class SelectedMailboxImpl implements SelectedMailbox, MailboxListener { private void mailboxEvent(MailboxEvent mailboxEvent) { // Check if the event was for the mailbox we are observing if (mailboxEvent.getMailboxId().equals(getMailboxId())) { - MailboxSession.SessionId eventSessionId = extractSessionId(mailboxEvent); + MailboxSession.SessionId eventSessionId = mailboxEvent.getSessionId(); if (mailboxEvent instanceof MessageEvent) { final MessageEvent messageEvent = (MessageEvent) mailboxEvent; if (messageEvent instanceof Added) { @@ -407,12 +407,6 @@ public class SelectedMailboxImpl implements SelectedMailbox, MailboxListener { } } - private MailboxSession.SessionId extractSessionId(MailboxEvent mailboxEvent) { - return mailboxEvent.getSessionId() - .orElseThrow(() -> new RuntimeException(String.format("Event of of mailbox %s does not carry sessionId", - mailboxEvent.getMailboxId().serialize()))); - } - @Override public synchronized int msn(MessageUid uid) { return uidMsnConverter.getMsn(uid).orElse(NO_SUCH_MESSAGE); http://git-wip-us.apache.org/repos/asf/james-project/blob/4734f2da/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java index 320fd36..ac82d1f 100644 --- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java +++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerAdded.java @@ -21,7 +21,6 @@ package org.apache.james.imap.processor.base; import java.util.Date; import java.util.List; -import java.util.Optional; import javax.mail.Flags; @@ -39,7 +38,7 @@ public class FakeMailboxListenerAdded extends MailboxListener.Added { public List<MessageUid> uids; public FakeMailboxListenerAdded(MailboxSession.SessionId sessionId, User user, List<MessageUid> uids, MailboxPath path, MailboxId mailboxId) { - super(Optional.ofNullable(sessionId), user, path, mailboxId); + super(sessionId, user, path, mailboxId); this.uids = uids; } http://git-wip-us.apache.org/repos/asf/james-project/blob/4734f2da/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java index 2ca6120..61ef7fa 100644 --- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java +++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/FakeMailboxListenerFlagsUpdate.java @@ -20,7 +20,6 @@ package org.apache.james.imap.processor.base; import java.util.List; -import java.util.Optional; import org.apache.james.core.User; import org.apache.james.mailbox.MailboxListener.FlagsUpdated; @@ -41,7 +40,7 @@ public class FakeMailboxListenerFlagsUpdate extends FlagsUpdated { } FakeMailboxListenerFlagsUpdate(MailboxSession.SessionId sessionId, User user, List<MessageUid> uids, List<UpdatedFlags> flags, MailboxPath path, MailboxId mailboxId) { - super(Optional.ofNullable(sessionId), user, path, mailboxId); + super(sessionId, user, path, mailboxId); this.uids = uids; this.flags = flags; } http://git-wip-us.apache.org/repos/asf/james-project/blob/4734f2da/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java ---------------------------------------------------------------------- diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java index 5774f57..9d836c2 100644 --- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java +++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/MailboxEventAnalyserTest.java @@ -24,8 +24,6 @@ import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import java.util.Optional; - import javax.mail.Flags; import org.apache.commons.lang3.NotImplementedException; @@ -126,7 +124,7 @@ public class MailboxEventAnalyserTest { @Test public void testShouldBeNoSizeChangeOnOtherEvent() { - MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(Optional.ofNullable(MAILBOX_SESSION.getSessionId()), + MailboxListener.MailboxEvent event = new MailboxListener.MailboxEvent(MAILBOX_SESSION.getSessionId(), MAILBOX_SESSION.getUser().getCoreUser(), MAILBOX_PATH, MAILBOX_ID) {}; testee.event(event); --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org