JAMES-2555 Bind re-indexing routes in Guice products This only makes sens for ElasticSearch and Lucene products
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/5f1d6797 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/5f1d6797 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/5f1d6797 Branch: refs/heads/master Commit: 5f1d6797120439ec9873ec3bb83be417464d791a Parents: a68dae1 Author: Benoit Tellier <btell...@linagora.com> Authored: Fri Oct 12 14:04:39 2018 +0700 Committer: Benoit Tellier <btell...@linagora.com> Committed: Tue Oct 23 08:43:21 2018 +0700 ---------------------------------------------------------------------- .../apache/james/CassandraJamesServerMain.java | 4 ++- .../modules/mailbox/CassandraMailboxModule.java | 6 ++++ .../org/apache/james/JPAJamesServerMain.java | 4 ++- .../james/modules/mailbox/JPAMailboxModule.java | 5 +++ .../org/apache/james/JPAJamesServerTest.java | 3 +- .../JPAJamesServerWithSqlValidationTest.java | 3 +- .../james/modules/server/ReIndexingModule.java | 34 ++++++++++++++++++++ 7 files changed, 55 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/5f1d6797/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java index 77b6556..dcfd268 100644 --- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java +++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java @@ -53,6 +53,7 @@ import org.apache.james.modules.server.JMXServerModule; import org.apache.james.modules.server.MailQueueRoutesModule; import org.apache.james.modules.server.MailRepositoriesRoutesModule; import org.apache.james.modules.server.MailboxRoutesModule; +import org.apache.james.modules.server.ReIndexingModule; import org.apache.james.modules.server.SieveQuotaRoutesModule; import org.apache.james.modules.server.SwaggerRoutesModule; import org.apache.james.modules.server.WebAdminServerModule; @@ -73,7 +74,8 @@ public class CassandraJamesServerMain { new SwaggerRoutesModule(), new WebAdminServerModule(), new DLPRoutesModule(), - new SieveQuotaRoutesModule()); + new SieveQuotaRoutesModule(), + new ReIndexingModule()); public static final Module PROTOCOLS = Modules.combine( new CassandraJmapModule(), http://git-wip-us.apache.org/repos/asf/james-project/blob/5f1d6797/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java index 161647f..4f7d6e2 100644 --- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java +++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/mailbox/CassandraMailboxModule.java @@ -68,6 +68,7 @@ import org.apache.james.mailbox.cassandra.modules.CassandraModSeqModule; import org.apache.james.mailbox.cassandra.modules.CassandraSubscriptionModule; import org.apache.james.mailbox.cassandra.modules.CassandraUidModule; import org.apache.james.mailbox.exception.MailboxException; +import org.apache.james.mailbox.indexer.ReIndexer; import org.apache.james.mailbox.model.MailboxId; import org.apache.james.mailbox.model.MessageId; import org.apache.james.mailbox.quota.QuotaManager; @@ -91,6 +92,7 @@ import org.apache.james.mailbox.store.mail.UidProvider; import org.apache.james.mailbox.store.quota.ListeningCurrentQuotaUpdater; import org.apache.james.modules.Names; import org.apache.james.utils.MailboxManagerDefinition; +import org.apache.mailbox.tools.indexer.ReIndexerImpl; import com.google.inject.AbstractModule; import com.google.inject.Inject; @@ -143,6 +145,8 @@ public class CassandraMailboxModule extends AbstractModule { bind(UserRepositoryAuthenticator.class).in(Scopes.SINGLETON); bind(UserRepositoryAuthorizator.class).in(Scopes.SINGLETON); + bind(ReIndexerImpl.class).in(Scopes.SINGLETON); + bind(BlobManager.class).to(StoreBlobManager.class); bind(MessageMapperFactory.class).to(CassandraMailboxSessionMapperFactory.class); bind(MailboxMapperFactory.class).to(CassandraMailboxSessionMapperFactory.class); @@ -163,6 +167,8 @@ public class CassandraMailboxModule extends AbstractModule { bind(AttachmentManager.class).to(StoreAttachmentManager.class); bind(RightManager.class).to(StoreRightManager.class); + bind(ReIndexer.class).to(ReIndexerImpl.class); + Multibinder<CassandraModule> cassandraDataDefinitions = Multibinder.newSetBinder(binder(), CassandraModule.class); cassandraDataDefinitions.addBinding().toInstance(CassandraAclModule.MODULE); cassandraDataDefinitions.addBinding().toInstance(CassandraAttachmentModule.MODULE); http://git-wip-us.apache.org/repos/asf/james-project/blob/5f1d6797/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java ---------------------------------------------------------------------- diff --git a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java index 6a5ba46..a36a709 100644 --- a/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java +++ b/server/container/guice/jpa-guice/src/main/java/org/apache/james/JPAJamesServerMain.java @@ -41,6 +41,7 @@ import org.apache.james.modules.server.MailRepositoriesRoutesModule; import org.apache.james.modules.server.MailboxRoutesModule; import org.apache.james.modules.server.NoJwtModule; import org.apache.james.modules.server.RawPostDequeueDecoratorModule; +import org.apache.james.modules.server.ReIndexingModule; import org.apache.james.modules.server.SieveQuotaRoutesModule; import org.apache.james.modules.server.SwaggerRoutesModule; import org.apache.james.modules.server.WebAdminServerModule; @@ -59,7 +60,8 @@ public class JPAJamesServerMain { new MailQueueRoutesModule(), new MailRepositoriesRoutesModule(), new SwaggerRoutesModule(), - new SieveQuotaRoutesModule()); + new SieveQuotaRoutesModule(), + new ReIndexingModule()); public static final Module PROTOCOLS = Modules.combine( new IMAPServerModule(), http://git-wip-us.apache.org/repos/asf/james-project/blob/5f1d6797/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java ---------------------------------------------------------------------- diff --git a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java index 91da90e..cd3c0c4 100644 --- a/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java +++ b/server/container/guice/jpa-guice/src/main/java/org/apache/james/modules/mailbox/JPAMailboxModule.java @@ -30,6 +30,7 @@ import org.apache.james.mailbox.acl.MailboxACLResolver; import org.apache.james.mailbox.acl.SimpleGroupMembershipResolver; import org.apache.james.mailbox.acl.UnionMailboxACLResolver; import org.apache.james.mailbox.exception.MailboxException; +import org.apache.james.mailbox.indexer.ReIndexer; import org.apache.james.mailbox.jpa.JPAId; import org.apache.james.mailbox.jpa.JPAMailboxSessionMapperFactory; import org.apache.james.mailbox.jpa.JPASubscriptionManager; @@ -53,6 +54,7 @@ import org.apache.james.mailbox.store.quota.ListeningCurrentQuotaUpdater; import org.apache.james.modules.Names; import org.apache.james.modules.data.JPAEntityManagerModule; import org.apache.james.utils.MailboxManagerDefinition; +import org.apache.mailbox.tools.indexer.ReIndexerImpl; import com.google.inject.AbstractModule; import com.google.inject.Inject; @@ -81,6 +83,7 @@ public class JPAMailboxModule extends AbstractModule { bind(SimpleGroupMembershipResolver.class).in(Scopes.SINGLETON); bind(UnionMailboxACLResolver.class).in(Scopes.SINGLETON); bind(DefaultMessageId.Factory.class).in(Scopes.SINGLETON); + bind(ReIndexerImpl.class).in(Scopes.SINGLETON); bind(MessageMapperFactory.class).to(JPAMailboxSessionMapperFactory.class); bind(MailboxMapperFactory.class).to(JPAMailboxSessionMapperFactory.class); @@ -97,6 +100,8 @@ public class JPAMailboxModule extends AbstractModule { bind(MailboxId.Factory.class).to(JPAId.Factory.class); bind(GroupMembershipResolver.class).to(SimpleGroupMembershipResolver.class); bind(MailboxACLResolver.class).to(UnionMailboxACLResolver.class); + + bind(ReIndexer.class).to(ReIndexerImpl.class); Multibinder.newSetBinder(binder(), MailboxManagerDefinition.class).addBinding().to(JPAMailboxManagerDefinition.class); } http://git-wip-us.apache.org/repos/asf/james-project/blob/5f1d6797/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java ---------------------------------------------------------------------- diff --git a/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java b/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java index 7c5156f..b6647c6 100644 --- a/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java +++ b/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerTest.java @@ -24,6 +24,7 @@ import static org.assertj.core.api.Assertions.assertThat; import org.apache.james.core.quota.QuotaSize; import org.apache.james.mailbox.model.SerializableQuotaValue; import org.apache.james.modules.QuotaProbesImpl; +import org.apache.james.modules.mailbox.LuceneSearchMailboxModule; import org.apache.james.modules.protocols.ImapGuiceProbe; import org.apache.james.modules.protocols.SmtpGuiceProbe; import org.apache.james.utils.DataProbeImpl; @@ -43,7 +44,7 @@ class JPAJamesServerTest implements JamesServerContract { @RegisterExtension static JamesServerExtension jamesServerExtension = new JamesServerExtensionBuilder() .server(configuration -> GuiceJamesServer.forConfiguration(configuration) - .combineWith(JPAJamesServerMain.JPA_SERVER_MODULE, JPAJamesServerMain.PROTOCOLS) + .combineWith(JPAJamesServerMain.JPA_SERVER_MODULE, JPAJamesServerMain.PROTOCOLS, new LuceneSearchMailboxModule()) .overrideWith(new TestJPAConfigurationModule(), DOMAIN_LIST_CONFIGURATION_MODULE)) .build(); http://git-wip-us.apache.org/repos/asf/james-project/blob/5f1d6797/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerWithSqlValidationTest.java ---------------------------------------------------------------------- diff --git a/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerWithSqlValidationTest.java b/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerWithSqlValidationTest.java index 355bf95..56ee6fa 100644 --- a/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerWithSqlValidationTest.java +++ b/server/container/guice/jpa-guice/src/test/java/org/apache/james/JPAJamesServerWithSqlValidationTest.java @@ -19,6 +19,7 @@ package org.apache.james; +import org.apache.james.modules.mailbox.LuceneSearchMailboxModule; import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.extension.RegisterExtension; @@ -27,7 +28,7 @@ class JPAJamesServerWithSqlValidationTest extends JPAJamesServerTest { @RegisterExtension static JamesServerExtension jamesServerExtension = new JamesServerExtensionBuilder() .server(configuration -> GuiceJamesServer.forConfiguration(configuration) - .combineWith(JPAJamesServerMain.JPA_SERVER_MODULE, JPAJamesServerMain.PROTOCOLS) + .combineWith(JPAJamesServerMain.JPA_SERVER_MODULE, JPAJamesServerMain.PROTOCOLS, new LuceneSearchMailboxModule()) .overrideWith(new TestJPAConfigurationModuleWithSqlValidation(), DOMAIN_LIST_CONFIGURATION_MODULE)) .build(); http://git-wip-us.apache.org/repos/asf/james-project/blob/5f1d6797/server/container/guice/protocols/webadmin-mailbox/src/main/java/org/apache/james/modules/server/ReIndexingModule.java ---------------------------------------------------------------------- diff --git a/server/container/guice/protocols/webadmin-mailbox/src/main/java/org/apache/james/modules/server/ReIndexingModule.java b/server/container/guice/protocols/webadmin-mailbox/src/main/java/org/apache/james/modules/server/ReIndexingModule.java new file mode 100644 index 0000000..d1902ad --- /dev/null +++ b/server/container/guice/protocols/webadmin-mailbox/src/main/java/org/apache/james/modules/server/ReIndexingModule.java @@ -0,0 +1,34 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.modules.server; + +import org.apache.james.webadmin.Routes; +import org.apache.james.webadmin.routes.ReindexingRoutes; + +import com.google.inject.AbstractModule; +import com.google.inject.multibindings.Multibinder; + +public class ReIndexingModule extends AbstractModule { + @Override + protected void configure() { + Multibinder<Routes> routesMultibinder = Multibinder.newSetBinder(binder(), Routes.class); + routesMultibinder.addBinding().to(ReindexingRoutes.class); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org For additional commands, e-mail: server-dev-h...@james.apache.org