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/12 10:52:03 UTC
[10/16] james-project git commit: MAILBOX-357
ListeningMessageSearchIndex should not rely on implementation details to
retrieve the mailbox
MAILBOX-357 ListeningMessageSearchIndex should not rely on implementation details to retrieve the mailbox
We should rather read it from the mailbox store
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/13f6aff3
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/13f6aff3
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/13f6aff3
Branch: refs/heads/master
Commit: 13f6aff3adabf942a5beacf33c46369f51573b7a
Parents: 0748989
Author: Benoit Tellier <bt...@linagora.com>
Authored: Mon Dec 10 14:17:35 2018 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Wed Dec 12 17:50:58 2018 +0700
----------------------------------------------------------------------
.../search/ListeningMessageSearchIndex.java | 28 ++++++++++----------
1 file changed, 14 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/13f6aff3/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/ListeningMessageSearchIndex.java
----------------------------------------------------------------------
diff --git a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/ListeningMessageSearchIndex.java b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/ListeningMessageSearchIndex.java
index 104291e..e02b736 100644
--- a/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/ListeningMessageSearchIndex.java
+++ b/mailbox/store/src/main/java/org/apache/james/mailbox/store/search/ListeningMessageSearchIndex.java
@@ -30,7 +30,6 @@ import org.apache.james.mailbox.exception.MailboxException;
import org.apache.james.mailbox.model.MessageRange;
import org.apache.james.mailbox.model.UpdatedFlags;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
-import org.apache.james.mailbox.store.event.EventFactory;
import org.apache.james.mailbox.store.mail.MessageMapper.FetchType;
import org.apache.james.mailbox.store.mail.model.Mailbox;
import org.apache.james.mailbox.store.mail.model.MailboxMessage;
@@ -63,34 +62,35 @@ public abstract class ListeningMessageSearchIndex implements MessageSearchIndex,
public void event(Event event) {
try {
MailboxSession session = mailboxManager.createSystemSession(event.getUser().asString());
- if (event instanceof MessageEvent) {
- if (event instanceof EventFactory.AddedImpl) {
- EventFactory.AddedImpl added = (EventFactory.AddedImpl) event;
- Mailbox mailbox = added.getMailbox();
+ if (event instanceof MailboxEvent) {
+ MailboxEvent mailboxEvent = (MailboxEvent) event;
+ Mailbox mailbox = factory.getMailboxMapper(session).findMailboxById(mailboxEvent.getMailboxId());
+
+ if (event instanceof Added) {
+ Added added = (Added) event;
for (MessageUid uid : added.getUids()) {
retrieveMailboxMessage(session, mailbox, uid)
.ifPresent(mailboxMessage -> addMessage(session, mailbox, mailboxMessage));
}
- } else if (event instanceof EventFactory.ExpungedImpl) {
- EventFactory.ExpungedImpl expunged = (EventFactory.ExpungedImpl) event;
+ } else if (event instanceof Expunged) {
+ Expunged expunged = (Expunged) event;
try {
- delete(session, expunged.getMailbox(), expunged.getUids());
+ delete(session, mailbox, expunged.getUids());
} catch (MailboxException e) {
- LOGGER.error("Unable to deleted messages {} from index for mailbox {}", expunged.getUids(), expunged.getMailbox(), e);
+ LOGGER.error("Unable to deleted messages {} from index for mailbox {}", expunged.getUids(), mailbox, e);
}
- } else if (event instanceof EventFactory.FlagsUpdatedImpl) {
- EventFactory.FlagsUpdatedImpl flagsUpdated = (EventFactory.FlagsUpdatedImpl) event;
- Mailbox mailbox = flagsUpdated.getMailbox();
+ } else if (event instanceof FlagsUpdated) {
+ FlagsUpdated flagsUpdated = (FlagsUpdated) event;
try {
update(session, mailbox, flagsUpdated.getUpdatedFlags());
} catch (MailboxException e) {
LOGGER.error("Unable to update flags in index for mailbox {}", mailbox, e);
}
+ } else if (event instanceof MailboxDeletion) {
+ deleteAll(session, mailbox);
}
- } else if (event instanceof EventFactory.MailboxDeletionImpl) {
- deleteAll(session, ((EventFactory.MailboxDeletionImpl) event).getMailbox());
}
} catch (MailboxException e) {
LOGGER.error("Unable to update index", e);
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org