1414import org .apache .james .ExtraProperties ;
1515import org .apache .james .GuiceJamesServer ;
1616import org .apache .james .JamesServerMain ;
17+ import org .apache .james .OpenSearchHighlightModule ;
1718import org .apache .james .SearchConfiguration ;
1819import org .apache .james .backends .redis .RedisHealthCheck ;
1920import org .apache .james .core .healthcheck .HealthCheck ;
2021import org .apache .james .events .RabbitMQEventBus ;
2122import org .apache .james .eventsourcing .eventstore .EventNestedTypes ;
2223import org .apache .james .jmap .InjectionKeys ;
2324import org .apache .james .jmap .JMAPListenerModule ;
25+ import org .apache .james .jmap .method .Method ;
26+ import org .apache .james .jmap .method .SearchSnippetGetMethod ;
2427import org .apache .james .json .DTO ;
2528import org .apache .james .json .DTOModule ;
2629import org .apache .james .mailbox .MailboxManager ;
30+ import org .apache .james .mailbox .MailboxSession ;
2731import org .apache .james .mailbox .cassandra .CassandraMailboxManager ;
32+ import org .apache .james .mailbox .model .MessageId ;
33+ import org .apache .james .mailbox .model .MultimailboxesSearchQuery ;
34+ import org .apache .james .mailbox .searchhighligt .SearchHighlighter ;
35+ import org .apache .james .mailbox .searchhighligt .SearchSnippet ;
2836import org .apache .james .mailbox .store .search .ListeningMessageSearchIndex ;
2937import org .apache .james .mailbox .store .search .MessageSearchIndex ;
3038import org .apache .james .mailbox .store .search .SimpleMessageSearchIndex ;
100108import org .apache .james .utils .InitializationOperation ;
101109import org .apache .james .utils .InitilizationOperationBuilder ;
102110import org .apache .james .vault .VaultConfiguration ;
111+ import org .reactivestreams .Publisher ;
103112
104113import com .google .common .collect .ImmutableList ;
105114import com .google .common .collect .ImmutableSet ;
174183import com .linagora .tmail .webadmin .archival .InboxArchivalTaskModule ;
175184import com .linagora .tmail .webadmin .cleanup .MailboxesCleanupModule ;
176185
186+ import reactor .core .publisher .Mono ;
187+
177188public class DistributedServer {
178189 private static class ScanningQuotaSearchModule extends AbstractModule {
179190 @ Override
@@ -192,6 +203,13 @@ protected void configure() {
192203 }
193204 }
194205
206+ public static final Module JMAP_DISTRIBUTED_METHOD_SUPPORTED_MODULE = new AbstractModule () {
207+ @ Override
208+ protected void configure () {
209+ Multibinder .newSetBinder (binder (), Method .class ).addBinding ().to (SearchSnippetGetMethod .class );
210+ }
211+ };
212+
195213 public static final Module WEBADMIN = Modules .combine (
196214 new CassandraRoutesModule (),
197215 new DataRoutesModules (),
@@ -242,7 +260,8 @@ protected void configure() {
242260 new WebFingerModule (),
243261 new LabelMethodModule (),
244262 new JmapSettingsMethodModule (),
245- new ContactSupportCapabilitiesModule ())
263+ new ContactSupportCapabilitiesModule (),
264+ JMAP_DISTRIBUTED_METHOD_SUPPORTED_MODULE )
246265 .with (new CassandraTicketStoreModule (), new TeamMailboxJmapModule ());
247266
248267 public static final Module PROTOCOLS = Modules .combine (
@@ -361,22 +380,40 @@ public static List<Module> chooseModules(SearchConfiguration searchConfiguration
361380 new OSContactAutoCompleteModule (),
362381 new OpenSearchClientModule (),
363382 new OpenSearchMailboxModule (),
364- new ReIndexingModule ());
383+ new ReIndexingModule (),
384+ new OpenSearchHighlightModule ());
365385 case Scanning :
366386 return ImmutableList .of (
367387 new DisabledEmailAddressContactSearchEngineModule (),
368388 new ScanningQuotaSearchModule (),
369- new ScanningSearchModule ());
389+ new ScanningSearchModule (),
390+ new FakeSearchHighlightModule ());
370391 case OpenSearchDisabled :
371392 return ImmutableList .of (
372393 new DisabledEmailAddressContactSearchEngineModule (),
373394 new OpenSearchDisabledModule (),
374- new ScanningQuotaSearchModule ());
395+ new ScanningQuotaSearchModule (),
396+ new FakeSearchHighlightModule ());
375397 default :
376398 throw new RuntimeException ("Unsupported search implementation " + searchConfiguration .getImplementation ());
377399 }
378400 }
379401
402+ private static class FakeSearchHighlighter implements SearchHighlighter {
403+
404+ @ Override
405+ public Publisher <SearchSnippet > highlightSearch (List <MessageId > messageIds , MultimailboxesSearchQuery expression , MailboxSession session ) {
406+ return Mono .error (new NotImplementedException ("not implemented" ));
407+ }
408+ }
409+
410+ private static class FakeSearchHighlightModule extends AbstractModule {
411+ @ Override
412+ protected void configure () {
413+ bind (SearchHighlighter .class ).toInstance (new FakeSearchHighlighter ());
414+ }
415+ }
416+
380417 private static Module chooseJmapModule (DistributedJamesConfiguration configuration ) {
381418 if (configuration .jmapEnabled ()) {
382419 return new JMAPListenerModule ();
0 commit comments