Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor DefaultImapDecoderFactory to Use POJO Style and Constructo… #2410

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
b2546c2
Refactor `DefaultImapDecoderFactory` to Use POJO Style and Constructo…
superbAura Sep 16, 2024
976e1c0
Refactor DefaultImapDecoderFactory to Use Generics and Improve Flexib…
superbAura Sep 16, 2024
7da75c9
Merge branch 'apache:master' into master
superbAura Sep 19, 2024
9326927
Merge remote-tracking branch 'origin/master'
superbAura Sep 19, 2024
c162ab1
Merge remote-tracking branch 'origin/master'
superbAura Sep 19, 2024
6769424
Merge remote-tracking branch 'origin/master'
superbAura Sep 19, 2024
5bce224
Merge remote-tracking branch 'origin/master'
superbAura Sep 19, 2024
db85780
Merge remote-tracking branch 'origin/master'
superbAura Sep 19, 2024
2fffadf
Merge remote-tracking branch 'origin/master'
superbAura Sep 19, 2024
e7741a6
Merge remote-tracking branch 'origin/master'
superbAura Sep 19, 2024
0a196ae
Merge remote-tracking branch 'origin/master'
superbAura Sep 20, 2024
8c4a7c1
Merge remote-tracking branch 'origin/master'
superbAura Sep 20, 2024
9677d33
Merge remote-tracking branch 'origin/master'
superbAura Sep 20, 2024
3ba64d4
Merge remote-tracking branch 'origin/master'
superbAura Sep 20, 2024
4d0c762
Merge remote-tracking branch 'origin/master'
superbAura Sep 20, 2024
ba332db
Merge branch 'apache:master' into master
superbAura Sep 20, 2024
053b3de
Merge branch 'apache:master' into master
superbAura Sep 20, 2024
b20e5a6
Merge remote-tracking branch 'origin/master'
superbAura Sep 20, 2024
f6f2758
Merge remote-tracking branch 'origin/master'
superbAura Sep 20, 2024
be2f7a9
Merge remote-tracking branch 'origin/master'
superbAura Sep 20, 2024
d062c78
Merge remote-tracking branch 'origin/master'
superbAura Sep 20, 2024
c3a989c
Merge remote-tracking branch 'origin/master'
superbAura Sep 20, 2024
15683f5
Merge remote-tracking branch 'origin/master'
superbAura Sep 20, 2024
3814374
Merge remote-tracking branch 'origin/master'
superbAura Sep 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,16 @@
public class CassandraHostSystem extends JamesImapHostSystem {

private static final ImapFeatures IMAP_FEATURES = ImapFeatures.of(Feature.NAMESPACE_SUPPORT,
Feature.MOVE_SUPPORT,
Feature.USER_FLAGS_SUPPORT,
Feature.QUOTA_SUPPORT,
Feature.ANNOTATION_SUPPORT,
Feature.MOD_SEQ_SEARCH);
Feature.MOVE_SUPPORT,
Feature.USER_FLAGS_SUPPORT,
Feature.QUOTA_SUPPORT,
Feature.ANNOTATION_SUPPORT,
Feature.MOD_SEQ_SEARCH);

private final CassandraCluster cassandra;
private CassandraMailboxManager mailboxManager;
private CassandraPerUserMaxQuotaManagerV2 perUserMaxQuotaManager;

public CassandraHostSystem(CassandraCluster cluster) {
this.cassandra = cluster;
}
Expand All @@ -99,7 +99,7 @@ public void beforeTest() throws Exception {
ThreadIdGuessingAlgorithm threadIdGuessingAlgorithm = new NaiveThreadIdGuessingAlgorithm();
UpdatableTickingClock clock = new UpdatableTickingClock(Instant.now());
CassandraMailboxSessionMapperFactory mapperFactory = TestCassandraMailboxSessionMapperFactory.forTests(
cassandra, messageIdFactory);
cassandra, messageIdFactory);


InVMEventBus eventBus = new InVMEventBus(new InVmEventDelivery(new RecordingMetricFactory()), EventBusTestFixture.RETRY_BACKOFF_CONFIGURATION, new MemoryEventDeadLetters());
Expand All @@ -121,9 +121,9 @@ public void beforeTest() throws Exception {
MessageSearchIndex index = new SimpleMessageSearchIndex(mapperFactory, mapperFactory, new DefaultTextExtractor(), attachmentManager);

mailboxManager = new CassandraMailboxManager(mapperFactory, sessionProvider,
new JVMMailboxPathLocker(), new MessageParser(), messageIdFactory,
eventBus, annotationManager, storeRightManager, quotaComponents, index, MailboxManagerConfiguration.DEFAULT,
PreDeletionHooks.NO_PRE_DELETION_HOOK, threadIdGuessingAlgorithm, clock);
new JVMMailboxPathLocker(), new MessageParser(), messageIdFactory,
eventBus, annotationManager, storeRightManager, quotaComponents, index, MailboxManagerConfiguration.DEFAULT,
PreDeletionHooks.NO_PRE_DELETION_HOOK, threadIdGuessingAlgorithm, clock);

eventBus.register(quotaUpdater);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,35 +39,35 @@
public class InMemoryHostSystem extends JamesImapHostSystem {

private static final ImapFeatures SUPPORTED_FEATURES = ImapFeatures.of(Feature.NAMESPACE_SUPPORT,
Feature.MOVE_SUPPORT,
Feature.USER_FLAGS_SUPPORT,
Feature.QUOTA_SUPPORT,
Feature.ANNOTATION_SUPPORT,
Feature.MOD_SEQ_SEARCH);
Feature.MOVE_SUPPORT,
Feature.USER_FLAGS_SUPPORT,
Feature.QUOTA_SUPPORT,
Feature.ANNOTATION_SUPPORT,
Feature.MOD_SEQ_SEARCH);

private StoreMailboxManager mailboxManager;
private InMemoryPerUserMaxQuotaManager perUserMaxQuotaManager;

@Override
public void beforeTest() throws Exception {
super.beforeTest();
InMemoryIntegrationResources resources = InMemoryIntegrationResources.builder()
.authenticator(authenticator)
.authorizator(authorizator)
.inVmEventBus()
.defaultAnnotationLimits()
.defaultMessageParser()
.scanningSearchIndex()
.noPreDeletionHooks()
.storeQuotaManager()
.build();
.authenticator(authenticator)
.authorizator(authorizator)
.inVmEventBus()
.defaultAnnotationLimits()
.defaultMessageParser()
.scanningSearchIndex()
.noPreDeletionHooks()
.storeQuotaManager()
.build();
this.mailboxManager = resources.getMailboxManager();
this.perUserMaxQuotaManager = resources.getMaxQuotaManager();

ImapProcessor defaultImapProcessorFactory = DefaultImapProcessorFactory.createDefaultProcessor(mailboxManager, mailboxManager.getEventBus(), new StoreSubscriptionManager(mailboxManager.getMapperFactory(),
mailboxManager.getMapperFactory(),
mailboxManager.getEventBus()),
mailboxManager.getQuotaComponents().getQuotaManager(), mailboxManager.getQuotaComponents().getQuotaRootResolver(), new DefaultMetricFactory());
ImapProcessor defaultImapProcessorFactory = DefaultImapProcessorFactory.createDefaultProcessor(mailboxManager, mailboxManager.getEventBus(), new StoreSubscriptionManager(mailboxManager.getMapperFactory(),
mailboxManager.getMapperFactory(),
mailboxManager.getEventBus()),
mailboxManager.getQuotaComponents().getQuotaManager(), mailboxManager.getQuotaComponents().getQuotaRootResolver(), new DefaultMetricFactory());

configure(new DefaultImapDecoderFactory().buildImapDecoder(),
new DefaultImapEncoderFactory().buildImapEncoder(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,22 @@
public class JPAHostSystem extends JamesImapHostSystem {

private static final JpaTestCluster JPA_TEST_CLUSTER = JpaTestCluster.create(
ImmutableList.<Class<?>>builder()
.addAll(JPAMailboxFixture.MAILBOX_PERSISTANCE_CLASSES)
.addAll(JPAMailboxFixture.QUOTA_PERSISTANCE_CLASSES)
.build());
ImmutableList.<Class<?>>builder()
.addAll(JPAMailboxFixture.MAILBOX_PERSISTANCE_CLASSES)
.addAll(JPAMailboxFixture.QUOTA_PERSISTANCE_CLASSES)
.build());

private static final ImapFeatures SUPPORTED_FEATURES = ImapFeatures.of(Feature.NAMESPACE_SUPPORT,
Feature.USER_FLAGS_SUPPORT,
Feature.ANNOTATION_SUPPORT,
Feature.QUOTA_SUPPORT,
Feature.MOVE_SUPPORT,
Feature.MOD_SEQ_SEARCH);
Feature.USER_FLAGS_SUPPORT,
Feature.ANNOTATION_SUPPORT,
Feature.QUOTA_SUPPORT,
Feature.MOVE_SUPPORT,
Feature.MOD_SEQ_SEARCH);

static JamesImapHostSystem build() {
return new JPAHostSystem();
}

private JPAPerUserMaxQuotaManager maxQuotaManager;
private OpenJPAMailboxManager mailboxManager;

Expand All @@ -101,9 +101,9 @@ public void beforeTest() throws Exception {
JPAUidProvider uidProvider = new JPAUidProvider(entityManagerFactory);
JPAModSeqProvider modSeqProvider = new JPAModSeqProvider(entityManagerFactory);
JPAConfiguration jpaConfiguration = JPAConfiguration.builder()
.driverName("driverName")
.driverURL("driverUrl")
.build();
.driverName("driverName")
.driverURL("driverUrl")
.build();
JPAMailboxSessionMapperFactory mapperFactory = new JPAMailboxSessionMapperFactory(entityManagerFactory, uidProvider, modSeqProvider, jpaConfiguration);

MailboxACLResolver aclResolver = new UnionMailboxACLResolver();
Expand All @@ -124,18 +124,18 @@ public void beforeTest() throws Exception {
MessageSearchIndex index = new SimpleMessageSearchIndex(mapperFactory, mapperFactory, new DefaultTextExtractor(), attachmentContentLoader);

mailboxManager = new OpenJPAMailboxManager(mapperFactory, sessionProvider, messageParser, new DefaultMessageId.Factory(),
eventBus, annotationManager, storeRightManager, quotaComponents, index, new NaiveThreadIdGuessingAlgorithm(), new UpdatableTickingClock(Instant.now()));
eventBus, annotationManager, storeRightManager, quotaComponents, index, new NaiveThreadIdGuessingAlgorithm(), new UpdatableTickingClock(Instant.now()));

eventBus.register(quotaUpdater);
eventBus.register(new MailboxAnnotationListener(mapperFactory, sessionProvider));

SubscriptionManager subscriptionManager = new StoreSubscriptionManager(mapperFactory, mapperFactory, eventBus);

ImapProcessor defaultImapProcessorFactory =
DefaultImapProcessorFactory.createDefaultProcessor(
mailboxManager,
eventBus,
subscriptionManager,
subscriptionManager,
storeQuotaManager,
quotaRootResolver,
new DefaultMetricFactory());
Expand All @@ -148,9 +148,9 @@ public void beforeTest() throws Exception {
@Override
public void afterTest() {
JPA_TEST_CLUSTER.clear(ImmutableList.<String>builder()
.addAll(JPAMailboxFixture.MAILBOX_TABLE_NAMES)
.addAll(JPAMailboxFixture.QUOTA_TABLES_NAMES)
.build());
.addAll(JPAMailboxFixture.MAILBOX_TABLE_NAMES)
.addAll(JPAMailboxFixture.QUOTA_TABLES_NAMES)
.build());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@

public class LuceneSearchHostSystem extends JamesImapHostSystem {
private static final ImapFeatures SUPPORTED_FEATURES = ImapFeatures.of(Feature.NAMESPACE_SUPPORT,
Feature.MOD_SEQ_SEARCH);
Feature.MOD_SEQ_SEARCH);

private InMemoryMailboxManager mailboxManager;
private LuceneMessageSearchIndex searchIndex;
Expand All @@ -58,18 +58,18 @@ public void beforeTest() throws Exception {

private void initFields() {
InMemoryIntegrationResources resources = InMemoryIntegrationResources.builder()
.authenticator(authenticator)
.authorizator(authorizator)
.inVmEventBus()
.defaultAnnotationLimits()
.defaultMessageParser()
.listeningSearchIndex(Throwing.function(preInstanciationStage -> new LuceneMessageSearchIndex(
preInstanciationStage.getMapperFactory(), new InMemoryId.Factory(), new ByteBuffersDirectory(),
new InMemoryMessageId.Factory(),
preInstanciationStage.getSessionProvider())))
.noPreDeletionHooks()
.storeQuotaManager()
.build();
.authenticator(authenticator)
.authorizator(authorizator)
.inVmEventBus()
.defaultAnnotationLimits()
.defaultMessageParser()
.listeningSearchIndex(Throwing.function(preInstanciationStage -> new LuceneMessageSearchIndex(
preInstanciationStage.getMapperFactory(), new InMemoryId.Factory(), new ByteBuffersDirectory(),
new InMemoryMessageId.Factory(),
preInstanciationStage.getSessionProvider())))
.noPreDeletionHooks()
.storeQuotaManager()
.build();

mailboxManager = resources.getMailboxManager();

Expand All @@ -78,17 +78,17 @@ private void initFields() {
SubscriptionManager subscriptionManager = new StoreSubscriptionManager(mailboxManager.getMapperFactory(), mailboxManager.getMapperFactory(), mailboxManager.getEventBus());

ImapProcessor defaultImapProcessorFactory =
DefaultImapProcessorFactory.createDefaultProcessor(
mailboxManager,
resources.getMailboxManager().getEventBus(),
subscriptionManager,
new NoQuotaManager(),
resources.getDefaultUserQuotaRootResolver(),
new DefaultMetricFactory());
DefaultImapProcessorFactory.createDefaultProcessor(
mailboxManager,
resources.getMailboxManager().getEventBus(),
subscriptionManager,
new NoQuotaManager(),
resources.getDefaultUserQuotaRootResolver(),
new DefaultMetricFactory());

configure(new DefaultImapDecoderFactory().buildImapDecoder(),
new DefaultImapEncoderFactory().buildImapEncoder(),
defaultImapProcessorFactory);
new DefaultImapEncoderFactory().buildImapEncoder(),
defaultImapProcessorFactory);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
public class OpenSearchHostSystem extends JamesImapHostSystem {

private static final ImapFeatures SUPPORTED_FEATURES = ImapFeatures.of(Feature.NAMESPACE_SUPPORT,
Feature.MOD_SEQ_SEARCH);
Feature.MOD_SEQ_SEARCH);

private DockerOpenSearch dockerOpenSearch;
private StoreMailboxManager mailboxManager;
Expand All @@ -85,46 +85,46 @@ public void afterTest() throws IOException {

private void initFields() throws Exception {
client = MailboxIndexCreationUtil.prepareDefaultClient(
dockerOpenSearch.clientProvider().get(),
OpenSearchConfiguration.builder()
.addHost(dockerOpenSearch.getHttpHost())
.build());
dockerOpenSearch.clientProvider().get(),
OpenSearchConfiguration.builder()
.addHost(dockerOpenSearch.getHttpHost())
.build());

InMemoryMessageId.Factory messageIdFactory = new InMemoryMessageId.Factory();
MailboxIdRoutingKeyFactory routingKeyFactory = new MailboxIdRoutingKeyFactory();

InMemoryIntegrationResources resources = InMemoryIntegrationResources.builder()
.authenticator(authenticator)
.authorizator(authorizator)
.inVmEventBus()
.defaultAnnotationLimits()
.defaultMessageParser()
.listeningSearchIndex(preInstanciationStage -> new OpenSearchListeningMessageSearchIndex(
preInstanciationStage.getMapperFactory(),
ImmutableSet.of(),
new OpenSearchIndexer(client,
MailboxOpenSearchConstants.DEFAULT_MAILBOX_WRITE_ALIAS),
new OpenSearchSearcher(client, new QueryConverter(new CriterionConverter()), OpenSearchSearcher.DEFAULT_SEARCH_SIZE,
MailboxOpenSearchConstants.DEFAULT_MAILBOX_READ_ALIAS, routingKeyFactory),
new MessageToOpenSearchJson(new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.YES, IndexHeaders.YES),
preInstanciationStage.getSessionProvider(), routingKeyFactory, messageIdFactory,
OpenSearchMailboxConfiguration.builder().build(), new RecordingMetricFactory()))
.noPreDeletionHooks()
.storeQuotaManager()
.build();
.authenticator(authenticator)
.authorizator(authorizator)
.inVmEventBus()
.defaultAnnotationLimits()
.defaultMessageParser()
.listeningSearchIndex(preInstanciationStage -> new OpenSearchListeningMessageSearchIndex(
preInstanciationStage.getMapperFactory(),
ImmutableSet.of(),
new OpenSearchIndexer(client,
MailboxOpenSearchConstants.DEFAULT_MAILBOX_WRITE_ALIAS),
new OpenSearchSearcher(client, new QueryConverter(new CriterionConverter()), OpenSearchSearcher.DEFAULT_SEARCH_SIZE,
MailboxOpenSearchConstants.DEFAULT_MAILBOX_READ_ALIAS, routingKeyFactory),
new MessageToOpenSearchJson(new DefaultTextExtractor(), ZoneId.of("Europe/Paris"), IndexAttachments.YES, IndexHeaders.YES),
preInstanciationStage.getSessionProvider(), routingKeyFactory, messageIdFactory,
OpenSearchMailboxConfiguration.builder().build(), new RecordingMetricFactory()))
.noPreDeletionHooks()
.storeQuotaManager()
.build();

mailboxManager = resources.getMailboxManager();

ImapProcessor defaultImapProcessorFactory =
DefaultImapProcessorFactory.createDefaultProcessor(mailboxManager,
resources.getMailboxManager().getEventBus(),
new StoreSubscriptionManager(mailboxManager.getMapperFactory(), mailboxManager.getMapperFactory(), mailboxManager.getEventBus()),
new NoQuotaManager(),
resources.getDefaultUserQuotaRootResolver(),
new DefaultMetricFactory());
DefaultImapProcessorFactory.createDefaultProcessor(mailboxManager,
resources.getMailboxManager().getEventBus(),
new StoreSubscriptionManager(mailboxManager.getMapperFactory(), mailboxManager.getMapperFactory(), mailboxManager.getEventBus()),
new NoQuotaManager(),
resources.getDefaultUserQuotaRootResolver(),
new DefaultMetricFactory());
configure(new DefaultImapDecoderFactory().buildImapDecoder(),
new DefaultImapEncoderFactory().buildImapEncoder(),
defaultImapProcessorFactory);
new DefaultImapEncoderFactory().buildImapEncoder(),
defaultImapProcessorFactory);
}

@Override
Expand Down
Loading