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/15 03:22:00 UTC
[25/30] james-project git commit: JAMES-2641 Avoid retrieving mailbox
information upon renames
JAMES-2641 Avoid retrieving mailbox information upon renames
This is simply not needed and causes the JPA + Lucene product to fail
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/c16d4e9b
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/c16d4e9b
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/c16d4e9b
Branch: refs/heads/master
Commit: c16d4e9b079d2c4145987b5909e6a5ae8c5f7f8b
Parents: c08473d
Author: Benoit Tellier <bt...@linagora.com>
Authored: Fri Jan 11 17:19:49 2019 +0700
Committer: Benoit Tellier <bt...@linagora.com>
Committed: Tue Jan 15 10:10:05 2019 +0700
----------------------------------------------------------------------
.../search/ListeningMessageSearchIndex.java | 25 ++++++++++++--------
1 file changed, 15 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/james-project/blob/c16d4e9b/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 de34195..25d9952 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
@@ -37,6 +37,8 @@ import org.apache.james.mailbox.store.mail.model.MailboxMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import com.google.common.collect.ImmutableList;
+
/**
* {@link MessageSearchIndex} which needs to get registered as global {@link MailboxListener} and so get
* notified about message changes. This will then allow to update the underlying index.
@@ -49,6 +51,7 @@ public abstract class ListeningMessageSearchIndex implements MessageSearchIndex,
private static final int UNLIMITED = -1;
private final MailboxSessionMapperFactory factory;
private final SessionProvider sessionProvider;
+ private static final ImmutableList<Class<? extends Event>> INTERESTING_EVENTS = ImmutableList.of(Added.class, Expunged.class, FlagsUpdated.class, MailboxDeletion.class);
public ListeningMessageSearchIndex(MailboxSessionMapperFactory factory, SessionProvider sessionProvider) {
this.factory = factory;
@@ -73,16 +76,18 @@ public abstract class ListeningMessageSearchIndex implements MessageSearchIndex,
}
private void handleMailboxEvent(Event event, MailboxSession session, MailboxEvent mailboxEvent) throws MailboxException {
- Mailbox mailbox = factory.getMailboxMapper(session).findMailboxById(mailboxEvent.getMailboxId());
-
- if (event instanceof Added) {
- handleAdded(session, mailbox, (Added) event);
- } else if (event instanceof Expunged) {
- handleExpunged(session, mailbox, (Expunged) event);
- } else if (event instanceof FlagsUpdated) {
- handleFlagsUpdated(session, mailbox, (FlagsUpdated) event);
- } else if (event instanceof MailboxDeletion) {
- deleteAll(session, mailbox);
+ if (INTERESTING_EVENTS.contains(event.getClass())) {
+ Mailbox mailbox = factory.getMailboxMapper(session).findMailboxById(mailboxEvent.getMailboxId());
+
+ if (event instanceof Added) {
+ handleAdded(session, mailbox, (Added) event);
+ } else if (event instanceof Expunged) {
+ handleExpunged(session, mailbox, (Expunged) event);
+ } else if (event instanceof FlagsUpdated) {
+ handleFlagsUpdated(session, mailbox, (FlagsUpdated) event);
+ } else if (event instanceof MailboxDeletion) {
+ deleteAll(session, mailbox);
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org