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 2018/12/07 01:10:37 UTC

[14/19] james-project git commit: JAMES-2616 replace getSession() in MailboxEvent Serializing

JAMES-2616 replace getSession() in MailboxEvent Serializing

Adding getSessionId() api into Events, SelectedMailbox Listener requires sessionId
from events.


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/c81c2ae9
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/c81c2ae9
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/c81c2ae9

Branch: refs/heads/master
Commit: c81c2ae98b80dd1459bcf471888e5041430dc43a
Parents: 9ce7667
Author: tran tien duc <dt...@linagora.com>
Authored: Mon Dec 3 13:30:36 2018 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Fri Dec 7 07:52:51 2018 +0700

----------------------------------------------------------------------
 .../apache/james/mailbox/MailboxListener.java   | 84 ++++++++++++--------
 .../spamassassin/SpamAssassinListenerTest.java  |  6 +-
 .../james/mailbox/store/event/EventFactory.java | 59 +++++++-------
 .../store/event/MailboxEventDispatcher.java     | 16 ++--
 .../mailbox/store/event/MessageMoveEvent.java   | 42 ++++++++--
 .../event/MailboxAnnotationListenerTest.java    |  3 +-
 .../mailbox/store/json/EventSerializerTest.java |  0
 .../processor/base/SelectedMailboxImplTest.java |  3 +-
 8 files changed, 130 insertions(+), 83 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/c81c2ae9/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 02c5856..c44597f 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
@@ -64,12 +64,12 @@ public interface MailboxListener {
 
     /**
      * Informs this listener about the given event.
-     * 
+     *
      * @param event
      *            not null
      */
     void event(Event event);
-    
+
     interface QuotaEvent extends Event {
         QuotaRoot getQuotaRoot();
     }
@@ -198,6 +198,7 @@ public interface MailboxListener {
         private final MailboxPath path;
         private final MailboxId mailboxId;
         private final User user;
+        private final long sessionId;
 
         public MailboxEvent(MailboxSession session, MailboxPath path, MailboxId mailboxId) {
             this.session = session;
@@ -208,13 +209,17 @@ public interface MailboxListener {
                 .map(MailboxSession::getUser)
                 .map(MailboxSession.User::getCoreUser)
                 .orElse(null);
+            this.sessionId = Optional.ofNullable(session)
+                .map(MailboxSession::getSessionId)
+                .orElse(0L);
         }
 
-        public MailboxEvent(User user, MailboxPath path, MailboxId mailboxId) {
+        public MailboxEvent(long sessionId, User user, MailboxPath path, MailboxId mailboxId) {
             this.user = user;
             this.path = path;
             this.mailboxId = mailboxId;
             this.session = new DummyMailboxSession();
+            this.sessionId = sessionId;
         }
 
         /**
@@ -232,7 +237,7 @@ public interface MailboxListener {
         /**
          * Gets the {@link MailboxSession} in which's context the {@link MailboxEvent}
          * happened
-         * 
+         *
          * @return session
          */
         @Override
@@ -241,8 +246,19 @@ public interface MailboxListener {
         }
 
         /**
+         * Gets the sessionId in which's context the {@link MailboxEvent}
+         * happened
+         *
+         * @return sessionId
+         */
+        @Override
+        public long getSessionId() {
+            return sessionId;
+        }
+
+        /**
          * Return the path of the Mailbox this event belongs to.
-         * 
+         *
          * @return path
          */
         public MailboxPath getMailboxPath() {
@@ -265,7 +281,7 @@ public interface MailboxListener {
     class MailboxDeletion extends MailboxEvent {
 
         /**
-         * 
+         *
          */
         private static final long serialVersionUID = 1L;
 
@@ -281,9 +297,9 @@ public interface MailboxListener {
             this.totalDeletedSize = totalDeletedSize;
         }
 
-        public MailboxDeletion(User user, MailboxPath path, QuotaRoot quotaRoot, QuotaCount deletedMessageCOunt, QuotaSize totalDeletedSize,
+        public MailboxDeletion(long sessionId, User user, MailboxPath path, QuotaRoot quotaRoot, QuotaCount deletedMessageCOunt, QuotaSize totalDeletedSize,
                                MailboxId mailboxId) {
-            super(user, path, mailboxId);
+            super(sessionId, user, path, mailboxId);
             this.quotaRoot = quotaRoot;
             this.deletedMessageCOunt = deletedMessageCOunt;
             this.totalDeletedSize = totalDeletedSize;
@@ -307,7 +323,7 @@ public interface MailboxListener {
      */
     class MailboxAdded extends MailboxEvent {
         /**
-         * 
+         *
          */
         private static final long serialVersionUID = 1L;
 
@@ -315,8 +331,8 @@ public interface MailboxListener {
             super(session, path, mailboxId);
         }
 
-        public MailboxAdded(User user, MailboxPath path, MailboxId mailboxId) {
-            super(user, path, mailboxId);
+        public MailboxAdded(long sessionId, User user, MailboxPath path, MailboxId mailboxId) {
+            super(sessionId, user, path, mailboxId);
         }
     }
 
@@ -325,7 +341,7 @@ public interface MailboxListener {
      */
     abstract class MailboxRenamed extends MailboxEvent {
         /**
-         * 
+         *
          */
         private static final long serialVersionUID = 1L;
 
@@ -333,13 +349,13 @@ public interface MailboxListener {
             super(session, path, mailboxId);
         }
 
-        public MailboxRenamed(User user, MailboxPath path, MailboxId mailboxId) {
-            super(user, path, mailboxId);
+        public MailboxRenamed(long sessionId, User user, MailboxPath path, MailboxId mailboxId) {
+            super(sessionId, user, path, mailboxId);
         }
 
         /**
          * Gets the new name for this mailbox.
-         * 
+         *
          * @return name, not null
          */
         public abstract MailboxPath getNewPath();
@@ -358,8 +374,8 @@ public interface MailboxListener {
             this.aclDiff = aclDiff;
         }
 
-        public MailboxACLUpdated(User user, MailboxPath path, ACLDiff aclDiff, MailboxId mailboxId) {
-            super(user, path, mailboxId);
+        public MailboxACLUpdated(long sessionId, User user, MailboxPath path, ACLDiff aclDiff, MailboxId mailboxId) {
+            super(sessionId, user, path, mailboxId);
             this.aclDiff = aclDiff;
         }
 
@@ -368,14 +384,14 @@ public interface MailboxListener {
         }
 
     }
-    
+
     /**
      * A mailbox event related to a message.
      */
     abstract class MessageEvent extends MailboxEvent {
 
         /**
-         * 
+         *
          */
         private static final long serialVersionUID = 1L;
 
@@ -383,13 +399,13 @@ public interface MailboxListener {
             super(session, path, mailboxId);
         }
 
-        public MessageEvent(User user, MailboxPath path, MailboxId mailboxId) {
-            super(user, path, mailboxId);
+        public MessageEvent(long sessionId, User user, MailboxPath path, MailboxId mailboxId) {
+            super(sessionId, user, path, mailboxId);
         }
 
         /**
          * Gets the message UIDs for the subject of this event.
-         * 
+         *
          * @return message uids
          */
         public abstract List<MessageUid> getUids();
@@ -401,8 +417,8 @@ public interface MailboxListener {
             super(session, path, mailboxId);
         }
 
-        public MetaDataHoldingEvent(User user, MailboxPath path, MailboxId mailboxId) {
-            super(user, path, mailboxId);
+        public MetaDataHoldingEvent(long sessionId, User user, MailboxPath path, MailboxId mailboxId) {
+            super(sessionId, user, path, mailboxId);
         }
 
         /**
@@ -417,7 +433,7 @@ public interface MailboxListener {
     abstract class Expunged extends MetaDataHoldingEvent {
 
         /**
-         * 
+         *
          */
         private static final long serialVersionUID = 1L;
 
@@ -425,13 +441,13 @@ public interface MailboxListener {
             super(session, path, mailboxId);
         }
 
-        public Expunged(User user, MailboxPath path, MailboxId mailboxId) {
-            super(user, path, mailboxId);
+        public Expunged(long sessionId, User user, MailboxPath path, MailboxId mailboxId) {
+            super(sessionId, user, path, mailboxId);
         }
 
         /**
          * Return the flags which were set for the added message
-         * 
+         *
          * @return flags
          */
         @Override
@@ -444,7 +460,7 @@ public interface MailboxListener {
     abstract class FlagsUpdated extends MessageEvent {
 
         /**
-         * 
+         *
          */
         private static final long serialVersionUID = 1L;
 
@@ -452,8 +468,8 @@ public interface MailboxListener {
             super(session, path, mailboxId);
         }
 
-        public FlagsUpdated(User user, MailboxPath path, MailboxId mailboxId) {
-            super(user, path, mailboxId);
+        public FlagsUpdated(long sessionId, User user, MailboxPath path, MailboxId mailboxId) {
+            super(sessionId, user, path, mailboxId);
         }
 
         public abstract List<UpdatedFlags> getUpdatedFlags();
@@ -465,7 +481,7 @@ public interface MailboxListener {
     abstract class Added extends MetaDataHoldingEvent {
 
         /**
-         * 
+         *
          */
         private static final long serialVersionUID = 1L;
 
@@ -473,8 +489,8 @@ public interface MailboxListener {
             super(session, path, mailboxId);
         }
 
-        public Added(User user, MailboxPath path, MailboxId mailboxId) {
-            super(user, path, mailboxId);
+        public Added(long sessionId, User user, MailboxPath path, MailboxId mailboxId) {
+            super(sessionId, user, path, mailboxId);
         }
 
         /**

http://git-wip-us.apache.org/repos/asf/james-project/blob/c81c2ae9/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 d1ba383..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
@@ -251,7 +251,8 @@ public class SpamAssassinListenerTest {
         SimpleMailboxMessage message = createMessage(inboxId);
         EventFactory eventFactory = new EventFactory();
         AddedImpl addedEvent = eventFactory.new AddedImpl(
-                MAILBOX_SESSION,
+                MAILBOX_SESSION.getSessionId(),
+                MAILBOX_SESSION.getUser().getCoreUser(),
                 inbox,
                 ImmutableSortedMap.of(MessageUid.of(45), new SimpleMessageMetaData(message)),
                 ImmutableMap.of(MessageUid.of(45), message));
@@ -266,7 +267,8 @@ public class SpamAssassinListenerTest {
         SimpleMailboxMessage message = createMessage(mailboxId1);
         EventFactory eventFactory = new EventFactory();
         AddedImpl addedEvent = eventFactory.new AddedImpl(
-                MAILBOX_SESSION,
+                MAILBOX_SESSION.getSessionId(),
+                MAILBOX_SESSION.getUser().getCoreUser(),
                 mailbox1,
                 ImmutableSortedMap.of(MessageUid.of(45), new SimpleMessageMetaData(message)),
                 ImmutableMap.of(MessageUid.of(45), message));

http://git-wip-us.apache.org/repos/asf/james-project/blob/c81c2ae9/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 2af8b42..483101c 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
@@ -23,10 +23,10 @@ import java.util.List;
 import java.util.Map;
 import java.util.SortedMap;
 
+import org.apache.james.core.User;
 import org.apache.james.core.quota.QuotaCount;
 import org.apache.james.core.quota.QuotaSize;
 import org.apache.james.mailbox.MailboxListener;
-import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.acl.ACLDiff;
 import org.apache.james.mailbox.model.MailboxId;
@@ -53,8 +53,8 @@ public class EventFactory {
         private final Map<MessageUid, MailboxMessage> availableMessages;
         private final Mailbox mailbox;
 
-        public AddedImpl(MailboxSession session, Mailbox mailbox, SortedMap<MessageUid, MessageMetaData> uids, Map<MessageUid, MailboxMessage> availableMessages) {
-            super(session, new StoreMailboxPath(mailbox), mailbox.getMailboxId());
+        public AddedImpl(long 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;
             this.availableMessages = ImmutableMap.copyOf(availableMessages);
@@ -84,8 +84,8 @@ public class EventFactory {
         private final Map<MessageUid, MessageMetaData> uids;
         private final Mailbox mailbox;
 
-        public ExpungedImpl(MailboxSession session, Mailbox mailbox,  Map<MessageUid, MessageMetaData> uids) {
-            super(session,  new StoreMailboxPath(mailbox), mailbox.getMailboxId());
+        public ExpungedImpl(long 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;
         }
@@ -113,8 +113,8 @@ public class EventFactory {
 
         private final List<UpdatedFlags> uFlags;
 
-        public FlagsUpdatedImpl(MailboxSession session, Mailbox mailbox, List<MessageUid> uids, List<UpdatedFlags> uFlags) {
-            super(session, new StoreMailboxPath(mailbox), mailbox.getMailboxId());
+        public FlagsUpdatedImpl(long 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);
             this.mailbox = mailbox;
@@ -140,8 +140,8 @@ public class EventFactory {
     public final class MailboxDeletionImpl extends MailboxListener.MailboxDeletion implements MailboxAware {
         private final Mailbox mailbox;
 
-        public MailboxDeletionImpl(MailboxSession session, Mailbox mailbox, QuotaRoot quotaRoot, QuotaCount deletedMessageCount, QuotaSize totalDeletedSize) {
-            super(session, new StoreMailboxPath(mailbox), quotaRoot, deletedMessageCount, totalDeletedSize, mailbox.getMailboxId());
+        public MailboxDeletionImpl(long 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;
         }
 
@@ -157,8 +157,8 @@ public class EventFactory {
 
         private final Mailbox mailbox;
 
-        public MailboxAddedImpl(MailboxSession session, Mailbox mailbox) {
-            super(session,  new StoreMailboxPath(mailbox), mailbox.getMailboxId());
+        public MailboxAddedImpl(long sessionId, User user, Mailbox mailbox) {
+            super(sessionId, user,  new StoreMailboxPath(mailbox), mailbox.getMailboxId());
             this.mailbox = mailbox;
         }
 
@@ -175,8 +175,8 @@ public class EventFactory {
         private final MailboxPath newPath;
         private final Mailbox newMailbox;
 
-        public MailboxRenamedEventImpl(MailboxSession session, MailboxPath oldPath, Mailbox newMailbox) {
-            super(session, oldPath, newMailbox.getMailboxId());
+        public MailboxRenamedEventImpl(long sessionId, User user, MailboxPath oldPath, Mailbox newMailbox) {
+            super(sessionId, user, oldPath, newMailbox.getMailboxId());
             this.newPath = new StoreMailboxPath(newMailbox);
             this.newMailbox = newMailbox;
         }
@@ -192,38 +192,39 @@ public class EventFactory {
         }
     }
 
-    public MailboxListener.Added added(MailboxSession session, SortedMap<MessageUid, MessageMetaData> uids, Mailbox mailbox, Map<MessageUid, MailboxMessage> cachedMessages) {
-        return new AddedImpl(session, mailbox, uids, cachedMessages);
+    public MailboxListener.Added added(long sessionId, User user, SortedMap<MessageUid, MessageMetaData> uids, Mailbox mailbox, Map<MessageUid, MailboxMessage> cachedMessages) {
+        return new AddedImpl(sessionId, user, mailbox, uids, cachedMessages);
     }
 
-    public MailboxListener.Expunged expunged(MailboxSession session,  Map<MessageUid, MessageMetaData> uids, Mailbox mailbox) {
-        return new ExpungedImpl(session, mailbox, uids);
+    public MailboxListener.Expunged expunged(long sessionId, User user,  Map<MessageUid, MessageMetaData> uids, Mailbox mailbox) {
+        return new ExpungedImpl(sessionId, user, mailbox, uids);
     }
 
-    public MailboxListener.FlagsUpdated flagsUpdated(MailboxSession session, List<MessageUid> uids, Mailbox mailbox, List<UpdatedFlags> uflags) {
-        return new FlagsUpdatedImpl(session, mailbox, uids, uflags);
+    public MailboxListener.FlagsUpdated flagsUpdated(long sessionId, User user, List<MessageUid> uids, Mailbox mailbox, List<UpdatedFlags> uflags) {
+        return new FlagsUpdatedImpl(sessionId, user, mailbox, uids, uflags);
     }
 
-    public MailboxListener.MailboxRenamed mailboxRenamed(MailboxSession session, MailboxPath from, Mailbox to) {
-        return new MailboxRenamedEventImpl(session, from, to);
+    public MailboxListener.MailboxRenamed mailboxRenamed(long sessionId, User user, MailboxPath from, Mailbox to) {
+        return new MailboxRenamedEventImpl(sessionId, user, from, to);
     }
 
-    public MailboxListener.MailboxDeletion mailboxDeleted(MailboxSession session, Mailbox mailbox, QuotaRoot quotaRoot,
+    public MailboxListener.MailboxDeletion mailboxDeleted(long sessionId, User user, Mailbox mailbox, QuotaRoot quotaRoot,
                                                           QuotaCount deletedMessageCount, QuotaSize totalDeletedSize) {
-        return new MailboxDeletionImpl(session, mailbox, quotaRoot, deletedMessageCount, totalDeletedSize);
+        return new MailboxDeletionImpl(sessionId, user, mailbox, quotaRoot, deletedMessageCount, totalDeletedSize);
     }
 
-    public MailboxListener.MailboxAdded mailboxAdded(MailboxSession session, Mailbox mailbox) {
-        return new MailboxAddedImpl(session, mailbox);
+    public MailboxListener.MailboxAdded mailboxAdded(long sessionId, User user, Mailbox mailbox) {
+        return new MailboxAddedImpl(sessionId, user, mailbox);
     }
 
-    public MailboxListener.MailboxACLUpdated aclUpdated(MailboxSession session, MailboxPath mailboxPath, ACLDiff aclDiff, MailboxId mailboxId) {
-        return new MailboxListener.MailboxACLUpdated(session, mailboxPath, aclDiff, mailboxId);
+    public MailboxListener.MailboxACLUpdated aclUpdated(long sessionId, User user, MailboxPath mailboxPath, ACLDiff aclDiff, MailboxId mailboxId) {
+        return new MailboxListener.MailboxACLUpdated(sessionId, user, mailboxPath, aclDiff, mailboxId);
     }
 
-    public MessageMoveEvent moved(MailboxSession session, MessageMoves messageMoves, Map<MessageUid, MailboxMessage> messages) {
+    public MessageMoveEvent moved(long sessionId, User user, MessageMoves messageMoves, Map<MessageUid, MailboxMessage> messages) {
         return MessageMoveEvent.builder()
-                .session(session)
+                .sessionId(sessionId)
+                .user(user)
                 .messageMoves(messageMoves)
                 .messages(messages)
                 .build();

http://git-wip-us.apache.org/repos/asf/james-project/blob/c81c2ae9/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 206e8b7..c7df6a5 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
@@ -82,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, uids, mailbox, cachedMessages));
+        listener.event(eventFactory.added(session.getSessionId(), session.getUser().getCoreUser(), uids, mailbox, cachedMessages));
     }
 
     public void added(MailboxSession session, Mailbox mailbox, MailboxMessage mailboxMessage) {
@@ -110,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, uids, mailbox));
+            listener.event(eventFactory.expunged(session.getSessionId(), session.getUser().getCoreUser(), uids, mailbox));
         }
     }
 
@@ -127,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, uids, mailbox, uflags));
+            listener.event(eventFactory.flagsUpdated(session.getSessionId(), session.getUser().getCoreUser(), uids, mailbox, uflags));
         }
     }
 
@@ -140,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, from, to));
+        listener.event(eventFactory.mailboxRenamed(session.getSessionId(), session.getUser().getCoreUser(), from, to));
     }
 
     /**
@@ -148,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, mailbox, quotaRoot, deletedMessageCount, totalDeletedSize));
+        listener.event(eventFactory.mailboxDeleted(session.getSessionId(), session.getUser().getCoreUser(), mailbox, quotaRoot, deletedMessageCount, totalDeletedSize));
     }
 
     /**
@@ -156,15 +156,15 @@ public class MailboxEventDispatcher {
      * MailboxListener will get triggered then
      */
     public void mailboxAdded(MailboxSession session, Mailbox mailbox) {
-        listener.event(eventFactory.mailboxAdded(session, mailbox));
+        listener.event(eventFactory.mailboxAdded(session.getSessionId(), session.getUser().getCoreUser(), mailbox));
     }
 
     public void aclUpdated(MailboxSession session, MailboxPath mailboxPath, ACLDiff aclDiff, MailboxId mailboxId) {
-        listener.event(eventFactory.aclUpdated(session, mailboxPath, aclDiff, mailboxId));
+        listener.event(eventFactory.aclUpdated(session.getSessionId(), session.getUser().getCoreUser(), mailboxPath, aclDiff, mailboxId));
     }
 
     public void moved(MailboxSession session, MessageMoves messageMoves, Map<MessageUid, MailboxMessage> messages) {
-        MessageMoveEvent moveEvent = eventFactory.moved(session, messageMoves, messages);
+        MessageMoveEvent moveEvent = eventFactory.moved(session.getSessionId(), session.getUser().getCoreUser(), messageMoves, messages);
         if (!moveEvent.isNoop()) {
             listener.event(moveEvent);
         }

http://git-wip-us.apache.org/repos/asf/james-project/blob/c81c2ae9/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 06221c9..3526af2 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
@@ -20,6 +20,7 @@ package org.apache.james.mailbox.store.event;
 
 import java.util.Map;
 
+import org.apache.james.core.User;
 import org.apache.james.mailbox.Event;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MessageUid;
@@ -39,7 +40,8 @@ public class MessageMoveEvent implements Event {
 
     public static class Builder {
 
-        private MailboxSession session;
+        private long sessionId;
+        private User user;
         private MessageMoves messageMoves;
         private ImmutableMap.Builder<MessageUid, MailboxMessage> messagesBuilder;
 
@@ -48,7 +50,18 @@ public class MessageMoveEvent implements Event {
         }
 
         public Builder session(MailboxSession session) {
-            this.session = session;
+            this.sessionId = session.getSessionId();
+            this.user = session.getUser().getCoreUser();
+            return this;
+        }
+
+        public Builder sessionId(long sessionId) {
+            this.sessionId = sessionId;
+            return this;
+        }
+
+        public Builder user(User user) {
+            this.user = user;
             return this;
         }
 
@@ -63,22 +76,25 @@ public class MessageMoveEvent implements Event {
         }
 
         public MessageMoveEvent build() {
-            Preconditions.checkNotNull(session, "'session' is mandatory");
+            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(session, messageMoves, messages);
+            return new MessageMoveEvent(sessionId, user, messageMoves, messages);
         }
     }
 
-    private final MailboxSession session;
+    private final long sessionId;
+    private final User user;
     private final MessageMoves messageMoves;
     private final Map<MessageUid, MailboxMessage> messages;
 
     @VisibleForTesting
-    MessageMoveEvent(MailboxSession session, MessageMoves messageMoves, Map<MessageUid, MailboxMessage> messages) {
-        this.session = session;
+    MessageMoveEvent(long sessionId, User user, MessageMoves messageMoves, Map<MessageUid, MailboxMessage> messages) {
+        this.sessionId = sessionId;
+        this.user = user;
         this.messageMoves = messageMoves;
         this.messages = messages;
     }
@@ -89,7 +105,17 @@ public class MessageMoveEvent implements Event {
 
     @Override
     public MailboxSession getSession() {
-        return session;
+        throw new UnsupportedOperationException("wiil be removed");
+    }
+
+    @Override
+    public User getUser() {
+        return user;
+    }
+
+    @Override
+    public long getSessionId() {
+        return sessionId;
     }
 
     public MessageMoves getMessageMoves() {

http://git-wip-us.apache.org/repos/asf/james-project/blob/c81c2ae9/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 9a62834..f9e1ec1 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,7 +86,8 @@ public class MailboxAnnotationListenerTest {
         QuotaRoot quotaRoot = QuotaRoot.quotaRoot("root", Optional.empty());
         QuotaCount quotaCount = QuotaCount.count(123);
         QuotaSize quotaSize = QuotaSize.size(456);
-        deleteEvent = eventFactory.mailboxDeleted(mailboxSession, mailbox, quotaRoot, quotaCount, quotaSize);
+        deleteEvent = eventFactory.mailboxDeleted(mailboxSession.getSessionId(), mailboxSession.getUser().getCoreUser(),
+            mailbox, quotaRoot, quotaCount, quotaSize);
 
         when(mailboxManager.createSystemSession(deleteEvent.getUser().asString()))
             .thenReturn(mailboxSession);

http://git-wip-us.apache.org/repos/asf/james-project/blob/c81c2ae9/mailbox/store/src/test/java/org/apache/james/mailbox/store/json/EventSerializerTest.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/test/java/org/apache/james/mailbox/store/json/EventSerializerTest.java b/mailbox/store/src/test/java/org/apache/james/mailbox/store/json/EventSerializerTest.java
new file mode 100644
index 0000000..e69de29

http://git-wip-us.apache.org/repos/asf/james-project/blob/c81c2ae9/protocols/imap/src/test/java/org/apache/james/imap/processor/base/SelectedMailboxImplTest.java
----------------------------------------------------------------------
diff --git a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/SelectedMailboxImplTest.java b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/SelectedMailboxImplTest.java
index ef8d5b9..d05ccf3 100644
--- a/protocols/imap/src/test/java/org/apache/james/imap/processor/base/SelectedMailboxImplTest.java
+++ b/protocols/imap/src/test/java/org/apache/james/imap/processor/base/SelectedMailboxImplTest.java
@@ -36,6 +36,7 @@ import java.util.concurrent.atomic.AtomicInteger;
 
 import javax.mail.Flags;
 
+import org.apache.james.core.User;
 import org.apache.james.imap.api.ImapSessionUtils;
 import org.apache.james.imap.api.process.ImapSession;
 import org.apache.james.mailbox.MailboxListener;
@@ -167,6 +168,6 @@ public class SelectedMailboxImplTest {
     private void emitEvent(MailboxListener mailboxListener) {
         TreeMap<MessageUid, MessageMetaData> result = new TreeMap<>();
         result.put(EMITTED_EVENT_UID, new SimpleMessageMetaData(EMITTED_EVENT_UID, MOD_SEQ, new Flags(), SIZE, new Date(), new DefaultMessageId()));
-        mailboxListener.event(new EventFactory().added(mock(MailboxSession.class), result, mailbox, ImmutableMap.of()));
+        mailboxListener.event(new EventFactory().added(0L, mock(User.class), result, mailbox, ImmutableMap.of()));
     }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org