Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -30,8 +30,8 @@
import org.apache.james.mailbox.model.Mailbox;
import org.apache.james.mailbox.model.MessageId;
import org.apache.james.mailbox.postgres.PostgresMailboxSessionMapperFactory;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.MailboxManagerConfiguration;
import org.apache.james.mailbox.store.NoMailboxPathLocker;
import org.apache.james.mailbox.store.PreDeletionHooks;
import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
import org.apache.james.mailbox.store.StoreMailboxManager;
Expand All @@ -43,27 +43,27 @@
import org.apache.james.mailbox.store.search.MessageSearchIndex;

/**
* OpenJPA implementation of MailboxManager
* PostgreSQL implementation of MailboxManager
*/
public class OpenJPAMailboxManager extends StoreMailboxManager {
public class PostgresMailboxManager extends StoreMailboxManager {
public static final EnumSet<MailboxCapabilities> MAILBOX_CAPABILITIES = EnumSet.of(MailboxCapabilities.UserFlag,
MailboxCapabilities.Namespace,
MailboxCapabilities.Move,
MailboxCapabilities.Annotation);

@Inject
public OpenJPAMailboxManager(PostgresMailboxSessionMapperFactory mapperFactory,
SessionProvider sessionProvider,
MessageParser messageParser,
MessageId.Factory messageIdFactory,
EventBus eventBus,
StoreMailboxAnnotationManager annotationManager,
StoreRightManager storeRightManager,
QuotaComponents quotaComponents,
MessageSearchIndex index,
ThreadIdGuessingAlgorithm threadIdGuessingAlgorithm,
Clock clock) {
super(mapperFactory, sessionProvider, new JVMMailboxPathLocker(),
public PostgresMailboxManager(PostgresMailboxSessionMapperFactory mapperFactory,
SessionProvider sessionProvider,
MessageParser messageParser,
MessageId.Factory messageIdFactory,
EventBus eventBus,
StoreMailboxAnnotationManager annotationManager,
StoreRightManager storeRightManager,
QuotaComponents quotaComponents,
MessageSearchIndex index,
ThreadIdGuessingAlgorithm threadIdGuessingAlgorithm,
Clock clock) {
super(mapperFactory, sessionProvider, new NoMailboxPathLocker(),
messageParser, messageIdFactory, annotationManager,
eventBus, storeRightManager, quotaComponents,
index, MailboxManagerConfiguration.DEFAULT, PreDeletionHooks.NO_PRE_DELETION_HOOK, threadIdGuessingAlgorithm, clock);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import org.apache.james.mailbox.acl.UnionMailboxACLResolver;
import org.apache.james.mailbox.postgres.mail.JPAModSeqProvider;
import org.apache.james.mailbox.postgres.mail.JPAUidProvider;
import org.apache.james.mailbox.postgres.openjpa.OpenJPAMailboxManager;
import org.apache.james.mailbox.postgres.openjpa.PostgresMailboxManager;
import org.apache.james.mailbox.store.SessionProviderImpl;
import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
import org.apache.james.mailbox.store.StoreRightManager;
Expand All @@ -55,7 +55,7 @@ public class JpaMailboxManagerProvider {
private static final int LIMIT_ANNOTATIONS = 3;
private static final int LIMIT_ANNOTATION_SIZE = 30;

public static OpenJPAMailboxManager provideMailboxManager(JpaTestCluster jpaTestCluster, PostgresExtension postgresExtension) {
public static PostgresMailboxManager provideMailboxManager(JpaTestCluster jpaTestCluster, PostgresExtension postgresExtension) {
EntityManagerFactory entityManagerFactory = jpaTestCluster.getEntityManagerFactory();

JPAConfiguration jpaConfiguration = JPAConfiguration.builder()
Expand All @@ -81,7 +81,7 @@ public static OpenJPAMailboxManager provideMailboxManager(JpaTestCluster jpaTest
QuotaComponents quotaComponents = QuotaComponents.disabled(sessionProvider, mf);
MessageSearchIndex index = new SimpleMessageSearchIndex(mf, mf, new DefaultTextExtractor(), new JPAAttachmentContentLoader());

return new OpenJPAMailboxManager(mf, sessionProvider,
return new PostgresMailboxManager(mf, sessionProvider,
messageParser, new DefaultMessageId.Factory(),
eventBus, annotationManager,
storeRightManager, quotaComponents, index, new NaiveThreadIdGuessingAlgorithm(), new UpdatableTickingClock(Instant.now()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,21 +25,21 @@
import org.apache.james.backends.postgres.PostgresExtension;
import org.apache.james.events.EventBus;
import org.apache.james.mailbox.MailboxManagerStressContract;
import org.apache.james.mailbox.postgres.openjpa.OpenJPAMailboxManager;
import org.apache.james.mailbox.postgres.openjpa.PostgresMailboxManager;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.extension.RegisterExtension;

class JpaMailboxManagerStressTest implements MailboxManagerStressContract<OpenJPAMailboxManager> {
class PostgresMailboxManagerStressTest implements MailboxManagerStressContract<PostgresMailboxManager> {

@RegisterExtension
static PostgresExtension postgresExtension = PostgresExtension.withoutRowLevelSecurity(PostgresMailboxAggregateModule.MODULE);

static final JpaTestCluster JPA_TEST_CLUSTER = JpaTestCluster.create(JPAMailboxFixture.MAILBOX_PERSISTANCE_CLASSES);
Optional<OpenJPAMailboxManager> openJPAMailboxManager = Optional.empty();
Optional<PostgresMailboxManager> openJPAMailboxManager = Optional.empty();

@Override
public OpenJPAMailboxManager getManager() {
public PostgresMailboxManager getManager() {
return openJPAMailboxManager.get();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
import org.apache.james.events.EventBus;
import org.apache.james.mailbox.MailboxManagerTest;
import org.apache.james.mailbox.SubscriptionManager;
import org.apache.james.mailbox.postgres.openjpa.OpenJPAMailboxManager;
import org.apache.james.mailbox.postgres.openjpa.PostgresMailboxManager;
import org.apache.james.mailbox.store.StoreSubscriptionManager;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;

class JPAMailboxManagerTest extends MailboxManagerTest<OpenJPAMailboxManager> {
class PostgresMailboxManagerTest extends MailboxManagerTest<PostgresMailboxManager> {

@Disabled("JPAMailboxManager is using DefaultMessageId which doesn't support full feature of a messageId, which is an essential" +
" element of the Vault")
Expand All @@ -45,10 +45,10 @@ class HookTests {
static PostgresExtension postgresExtension = PostgresExtension.withoutRowLevelSecurity(PostgresMailboxAggregateModule.MODULE);

static final JpaTestCluster JPA_TEST_CLUSTER = JpaTestCluster.create(JPAMailboxFixture.MAILBOX_PERSISTANCE_CLASSES);
Optional<OpenJPAMailboxManager> openJPAMailboxManager = Optional.empty();
Optional<PostgresMailboxManager> openJPAMailboxManager = Optional.empty();

@Override
protected OpenJPAMailboxManager provideMailboxManager() {
protected PostgresMailboxManager provideMailboxManager() {
if (!openJPAMailboxManager.isPresent()) {
openJPAMailboxManager = Optional.of(JpaMailboxManagerProvider.provideMailboxManager(JPA_TEST_CLUSTER, postgresExtension));
}
Expand Down Expand Up @@ -79,7 +79,7 @@ class SaveDateTests {
}

@Override
protected EventBus retrieveEventBus(OpenJPAMailboxManager mailboxManager) {
protected EventBus retrieveEventBus(PostgresMailboxManager mailboxManager) {
return mailboxManager.getEventBus();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
import org.apache.james.mailbox.postgres.PostgresMailboxSessionMapperFactory;
import org.apache.james.mailbox.postgres.mail.JPAModSeqProvider;
import org.apache.james.mailbox.postgres.mail.JPAUidProvider;
import org.apache.james.mailbox.postgres.openjpa.OpenJPAMailboxManager;
import org.apache.james.mailbox.postgres.openjpa.PostgresMailboxManager;
import org.apache.james.mailbox.postgres.quota.JPAPerUserMaxQuotaDAO;
import org.apache.james.mailbox.postgres.quota.JPAPerUserMaxQuotaManager;
import org.apache.james.mailbox.postgres.quota.JpaCurrentQuotaManager;
Expand Down Expand Up @@ -95,7 +95,7 @@ static PostgresHostSystem build(PostgresExtension postgresExtension) {
}

private JPAPerUserMaxQuotaManager maxQuotaManager;
private OpenJPAMailboxManager mailboxManager;
private PostgresMailboxManager mailboxManager;
private final PostgresExtension postgresExtension;
public PostgresHostSystem(PostgresExtension postgresExtension) {
this.postgresExtension = postgresExtension;
Expand Down Expand Up @@ -134,7 +134,7 @@ public void beforeTest() throws Exception {
AttachmentContentLoader attachmentContentLoader = null;
MessageSearchIndex index = new SimpleMessageSearchIndex(mapperFactory, mapperFactory, new DefaultTextExtractor(), attachmentContentLoader);

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

eventBus.register(quotaUpdater);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
import org.apache.james.mailbox.postgres.PostgresMailboxSessionMapperFactory;
import org.apache.james.mailbox.postgres.mail.JPAModSeqProvider;
import org.apache.james.mailbox.postgres.mail.JPAUidProvider;
import org.apache.james.mailbox.postgres.openjpa.OpenJPAMailboxManager;
import org.apache.james.mailbox.postgres.openjpa.PostgresMailboxManager;
import org.apache.james.mailbox.store.JVMMailboxPathLocker;
import org.apache.james.mailbox.store.MailboxManagerConfiguration;
import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
Expand Down Expand Up @@ -84,7 +84,7 @@ protected void configure() {
install(new JPAEntityManagerModule());

bind(PostgresMailboxSessionMapperFactory.class).in(Scopes.SINGLETON);
bind(OpenJPAMailboxManager.class).in(Scopes.SINGLETON);
bind(PostgresMailboxManager.class).in(Scopes.SINGLETON);
bind(JVMMailboxPathLocker.class).in(Scopes.SINGLETON);
bind(StoreSubscriptionManager.class).in(Scopes.SINGLETON);
bind(JPAModSeqProvider.class).in(Scopes.SINGLETON);
Expand All @@ -110,8 +110,8 @@ protected void configure() {
bind(SubscriptionManager.class).to(StoreSubscriptionManager.class);
bind(MailboxPathLocker.class).to(JVMMailboxPathLocker.class);
bind(Authenticator.class).to(UserRepositoryAuthenticator.class);
bind(MailboxManager.class).to(OpenJPAMailboxManager.class);
bind(StoreMailboxManager.class).to(OpenJPAMailboxManager.class);
bind(MailboxManager.class).to(PostgresMailboxManager.class);
bind(StoreMailboxManager.class).to(PostgresMailboxManager.class);
bind(SessionProvider.class).to(SessionProviderImpl.class);
bind(Authorizator.class).to(UserRepositoryAuthorizator.class);
bind(MailboxId.Factory.class).to(JPAId.Factory.class);
Expand Down Expand Up @@ -145,7 +145,7 @@ protected void configure() {
@Singleton
private static class JPAMailboxManagerDefinition extends MailboxManagerDefinition {
@Inject
private JPAMailboxManagerDefinition(OpenJPAMailboxManager manager) {
private JPAMailboxManagerDefinition(PostgresMailboxManager manager) {
super("jpa-mailboxmanager", manager);
}
}
Expand Down