14
14
import org .apache .james .ExtraProperties ;
15
15
import org .apache .james .GuiceJamesServer ;
16
16
import org .apache .james .JamesServerMain ;
17
+ import org .apache .james .OpenSearchHighlightModule ;
17
18
import org .apache .james .SearchConfiguration ;
18
19
import org .apache .james .backends .redis .RedisHealthCheck ;
19
20
import org .apache .james .core .healthcheck .HealthCheck ;
20
21
import org .apache .james .events .RabbitMQEventBus ;
21
22
import org .apache .james .eventsourcing .eventstore .EventNestedTypes ;
22
23
import org .apache .james .jmap .InjectionKeys ;
23
24
import org .apache .james .jmap .JMAPListenerModule ;
25
+ import org .apache .james .jmap .method .Method ;
26
+ import org .apache .james .jmap .method .SearchSnippetGetMethod ;
24
27
import org .apache .james .json .DTO ;
25
28
import org .apache .james .json .DTOModule ;
26
29
import org .apache .james .mailbox .MailboxManager ;
30
+ import org .apache .james .mailbox .MailboxSession ;
27
31
import 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 ;
28
36
import org .apache .james .mailbox .store .search .ListeningMessageSearchIndex ;
29
37
import org .apache .james .mailbox .store .search .MessageSearchIndex ;
30
38
import org .apache .james .mailbox .store .search .SimpleMessageSearchIndex ;
100
108
import org .apache .james .utils .InitializationOperation ;
101
109
import org .apache .james .utils .InitilizationOperationBuilder ;
102
110
import org .apache .james .vault .VaultConfiguration ;
111
+ import org .reactivestreams .Publisher ;
103
112
104
113
import com .google .common .collect .ImmutableList ;
105
114
import com .google .common .collect .ImmutableSet ;
174
183
import com .linagora .tmail .webadmin .archival .InboxArchivalTaskModule ;
175
184
import com .linagora .tmail .webadmin .cleanup .MailboxesCleanupModule ;
176
185
186
+ import reactor .core .publisher .Mono ;
187
+
177
188
public class DistributedServer {
178
189
private static class ScanningQuotaSearchModule extends AbstractModule {
179
190
@ Override
@@ -192,6 +203,13 @@ protected void configure() {
192
203
}
193
204
}
194
205
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
+
195
213
public static final Module WEBADMIN = Modules .combine (
196
214
new CassandraRoutesModule (),
197
215
new DataRoutesModules (),
@@ -242,7 +260,8 @@ protected void configure() {
242
260
new WebFingerModule (),
243
261
new LabelMethodModule (),
244
262
new JmapSettingsMethodModule (),
245
- new ContactSupportCapabilitiesModule ())
263
+ new ContactSupportCapabilitiesModule (),
264
+ JMAP_DISTRIBUTED_METHOD_SUPPORTED_MODULE )
246
265
.with (new CassandraTicketStoreModule (), new TeamMailboxJmapModule ());
247
266
248
267
public static final Module PROTOCOLS = Modules .combine (
@@ -361,22 +380,40 @@ public static List<Module> chooseModules(SearchConfiguration searchConfiguration
361
380
new OSContactAutoCompleteModule (),
362
381
new OpenSearchClientModule (),
363
382
new OpenSearchMailboxModule (),
364
- new ReIndexingModule ());
383
+ new ReIndexingModule (),
384
+ new OpenSearchHighlightModule ());
365
385
case Scanning :
366
386
return ImmutableList .of (
367
387
new DisabledEmailAddressContactSearchEngineModule (),
368
388
new ScanningQuotaSearchModule (),
369
- new ScanningSearchModule ());
389
+ new ScanningSearchModule (),
390
+ new FakeSearchHighlightModule ());
370
391
case OpenSearchDisabled :
371
392
return ImmutableList .of (
372
393
new DisabledEmailAddressContactSearchEngineModule (),
373
394
new OpenSearchDisabledModule (),
374
- new ScanningQuotaSearchModule ());
395
+ new ScanningQuotaSearchModule (),
396
+ new FakeSearchHighlightModule ());
375
397
default :
376
398
throw new RuntimeException ("Unsupported search implementation " + searchConfiguration .getImplementation ());
377
399
}
378
400
}
379
401
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
+
380
417
private static Module chooseJmapModule (DistributedJamesConfiguration configuration ) {
381
418
if (configuration .jmapEnabled ()) {
382
419
return new JMAPListenerModule ();
0 commit comments