You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@james.apache.org by rc...@apache.org on 2024/03/18 04:02:40 UTC

(james-project) 01/08: JAMES-2586 Add PostgresAttachmentMapper to PostgresMessageIdMapper

This is an automated email from the ASF dual-hosted git repository.

rcordier pushed a commit to branch postgresql
in repository https://gitbox.apache.org/repos/asf/james-project.git

commit b0334068c6faed5f22125e0b3b1f10741be5c226
Author: hung phan <hp...@linagora.com>
AuthorDate: Thu Mar 14 16:14:25 2024 +0700

    JAMES-2586 Add PostgresAttachmentMapper to PostgresMessageIdMapper
---
 .../PostgresMailboxSessionMapperFactory.java       |  6 +--
 .../postgres/mail/PostgresAttachmentMapper.java    | 14 +++---
 .../postgres/mail/PostgresAttachmentModule.java    |  2 +-
 .../postgres/mail/PostgresMessageIdMapper.java     | 52 +++++++++++++++++++---
 .../postgres/mail/dao/PostgresAttachmentDAO.java   | 18 +++++++-
 .../postgres/DeleteMessageListenerTest.java        |  1 -
 .../postgres/DeleteMessageListenerWithRLSTest.java |  1 -
 .../PostgresMailboxManagerAttachmentTest.java      |  4 +-
 .../postgres/mail/PostgresMapperProvider.java      |  9 ++--
 .../PostgresMessageBlobReferenceSourceTest.java    |  4 +-
 .../postgres/mail/PostgresMessageMapperTest.java   |  1 +
 ...gresSubscriptionMapperRowLevelSecurityTest.java |  2 +-
 12 files changed, 83 insertions(+), 31 deletions(-)

diff --git a/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/PostgresMailboxSessionMapperFactory.java b/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/PostgresMailboxSessionMapperFactory.java
index 8b9c50118c..f2a7609120 100644
--- a/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/PostgresMailboxSessionMapperFactory.java
+++ b/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/PostgresMailboxSessionMapperFactory.java
@@ -43,7 +43,6 @@ import org.apache.james.mailbox.postgres.user.PostgresSubscriptionDAO;
 import org.apache.james.mailbox.postgres.user.PostgresSubscriptionMapper;
 import org.apache.james.mailbox.store.MailboxSessionMapperFactory;
 import org.apache.james.mailbox.store.mail.AnnotationMapper;
-import org.apache.james.mailbox.store.mail.AttachmentMapper;
 import org.apache.james.mailbox.store.mail.AttachmentMapperFactory;
 import org.apache.james.mailbox.store.mail.MailboxMapper;
 import org.apache.james.mailbox.store.mail.MessageIdMapper;
@@ -92,6 +91,7 @@ public class PostgresMailboxSessionMapperFactory extends MailboxSessionMapperFac
             new PostgresMessageDAO(executorFactory.create(session.getUser().getDomainPart()), blobIdFactory),
             new PostgresMailboxMessageDAO(executorFactory.create(session.getUser().getDomainPart())),
             getModSeqProvider(session),
+            getAttachmentMapper(session),
             blobStore,
             blobIdFactory,
             clock);
@@ -118,13 +118,13 @@ public class PostgresMailboxSessionMapperFactory extends MailboxSessionMapperFac
     }
 
     @Override
-    public AttachmentMapper createAttachmentMapper(MailboxSession session) {
+    public PostgresAttachmentMapper createAttachmentMapper(MailboxSession session) {
         PostgresAttachmentDAO postgresAttachmentDAO = new PostgresAttachmentDAO(executorFactory.create(session.getUser().getDomainPart()), blobIdFactory);
         return new PostgresAttachmentMapper(postgresAttachmentDAO, blobStore);
     }
 
     @Override
-    public AttachmentMapper getAttachmentMapper(MailboxSession session) {
+    public PostgresAttachmentMapper getAttachmentMapper(MailboxSession session) {
         return createAttachmentMapper(session);
     }
 
diff --git a/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresAttachmentMapper.java b/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresAttachmentMapper.java
index e1d187f236..f1d00421c2 100644
--- a/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresAttachmentMapper.java
+++ b/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresAttachmentMapper.java
@@ -20,7 +20,6 @@
 package org.apache.james.mailbox.postgres.mail;
 
 import static org.apache.james.blob.api.BlobStore.StoragePolicy.LOW_COST;
-import static org.apache.james.util.ReactorUtils.DEFAULT_CONCURRENCY;
 
 import java.io.InputStream;
 import java.util.Collection;
@@ -39,7 +38,6 @@ import org.apache.james.mailbox.store.mail.AttachmentMapper;
 
 import com.github.fge.lambdas.Throwing;
 import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
 
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
@@ -84,13 +82,15 @@ public class PostgresAttachmentMapper implements AttachmentMapper {
             .switchIfEmpty(Mono.error(() -> new AttachmentNotFoundException(attachmentId.getId())));
     }
 
+    public Flux<AttachmentMetadata> getAttachmentsReactive(Collection<AttachmentId> attachmentIds) {
+        Preconditions.checkArgument(attachmentIds != null);
+        return postgresAttachmentDAO.getAttachments(attachmentIds);
+    }
+
     @Override
     public List<AttachmentMetadata> getAttachments(Collection<AttachmentId> attachmentIds) {
-        Preconditions.checkArgument(attachmentIds != null);
-        return Flux.fromIterable(attachmentIds)
-            .flatMap(id -> postgresAttachmentDAO.getAttachment(id)
-                .map(Pair::getLeft), DEFAULT_CONCURRENCY)
-            .collect(ImmutableList.toImmutableList())
+        return getAttachmentsReactive(attachmentIds)
+            .collectList()
             .block();
     }
 
diff --git a/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresAttachmentModule.java b/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresAttachmentModule.java
index 2bc4e0b16b..4b3fb59510 100644
--- a/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresAttachmentModule.java
+++ b/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresAttachmentModule.java
@@ -35,7 +35,7 @@ public interface PostgresAttachmentModule {
     interface PostgresAttachmentTable {
 
         Table<Record> TABLE_NAME = DSL.table("attachment");
-        Field<UUID> ID = DSL.field("id", SQLDataType.UUID.notNull());
+        Field<String> ID = DSL.field("id", SQLDataType.VARCHAR.notNull());
         Field<String> BLOB_ID = DSL.field("blob_id", SQLDataType.VARCHAR);
         Field<String> TYPE = DSL.field("type", SQLDataType.VARCHAR);
         Field<UUID> MESSAGE_ID = DSL.field("message_id", SQLDataType.UUID);
diff --git a/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresMessageIdMapper.java b/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresMessageIdMapper.java
index b3233f8345..6e9d12fce7 100644
--- a/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresMessageIdMapper.java
+++ b/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/PostgresMessageIdMapper.java
@@ -21,6 +21,7 @@ package org.apache.james.mailbox.postgres.mail;
 
 import static org.apache.james.blob.api.BlobStore.StoragePolicy.LOW_COST;
 import static org.apache.james.blob.api.BlobStore.StoragePolicy.SIZE_BASED;
+import static org.apache.james.mailbox.postgres.mail.PostgresMessageModule.MessageTable.ATTACHMENT_METADATA;
 import static org.apache.james.mailbox.postgres.mail.PostgresMessageModule.MessageTable.BODY_BLOB_ID;
 import static org.apache.james.mailbox.postgres.mail.PostgresMessageModule.MessageTable.HEADER_CONTENT;
 
@@ -30,6 +31,7 @@ import java.time.Clock;
 import java.util.Collection;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
 import java.util.function.Function;
 
 import javax.mail.Flags;
@@ -43,11 +45,14 @@ import org.apache.james.mailbox.MessageUid;
 import org.apache.james.mailbox.ModSeq;
 import org.apache.james.mailbox.exception.MailboxException;
 import org.apache.james.mailbox.exception.MailboxNotFoundException;
+import org.apache.james.mailbox.model.AttachmentId;
+import org.apache.james.mailbox.model.AttachmentMetadata;
 import org.apache.james.mailbox.model.ComposedMessageIdWithMetaData;
 import org.apache.james.mailbox.model.Content;
 import org.apache.james.mailbox.model.HeaderAndBodyByteContent;
 import org.apache.james.mailbox.model.Mailbox;
 import org.apache.james.mailbox.model.MailboxId;
+import org.apache.james.mailbox.model.MessageAttachmentMetadata;
 import org.apache.james.mailbox.model.MessageId;
 import org.apache.james.mailbox.model.UpdatedFlags;
 import org.apache.james.mailbox.postgres.PostgresMailboxId;
@@ -69,6 +74,7 @@ import org.slf4j.LoggerFactory;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableListMultimap;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Multimap;
 import com.google.common.io.ByteSource;
 
@@ -99,18 +105,24 @@ public class PostgresMessageIdMapper implements MessageIdMapper {
     private final PostgresMessageDAO messageDAO;
     private final PostgresMailboxMessageDAO mailboxMessageDAO;
     private final PostgresModSeqProvider modSeqProvider;
+    private final PostgresAttachmentMapper attachmentMapper;
     private final BlobStore blobStore;
     private final BlobId.Factory blobIdFactory;
     private final Clock clock;
 
-    public PostgresMessageIdMapper(PostgresMailboxDAO mailboxDAO, PostgresMessageDAO messageDAO,
-                                   PostgresMailboxMessageDAO mailboxMessageDAO, PostgresModSeqProvider modSeqProvider,
-                                   BlobStore blobStore, BlobId.Factory blobIdFactory,
+    public PostgresMessageIdMapper(PostgresMailboxDAO mailboxDAO,
+                                   PostgresMessageDAO messageDAO,
+                                   PostgresMailboxMessageDAO mailboxMessageDAO,
+                                   PostgresModSeqProvider modSeqProvider,
+                                   PostgresAttachmentMapper attachmentMapper,
+                                   BlobStore blobStore,
+                                   BlobId.Factory blobIdFactory,
                                    Clock clock) {
         this.mailboxDAO = mailboxDAO;
         this.messageDAO = messageDAO;
         this.mailboxMessageDAO = mailboxMessageDAO;
         this.modSeqProvider = modSeqProvider;
+        this.attachmentMapper = attachmentMapper;
         this.blobStore = blobStore;
         this.blobIdFactory = blobIdFactory;
         this.clock = clock;
@@ -130,18 +142,44 @@ public class PostgresMessageIdMapper implements MessageIdMapper {
 
     @Override
     public Flux<MailboxMessage> findReactive(Collection<MessageId> messageIds, MessageMapper.FetchType fetchType) {
-        return mailboxMessageDAO.findMessagesByMessageIds(messageIds.stream().map(PostgresMessageId.class::cast).collect(ImmutableList.toImmutableList()),
-                fetchType)
+        return mailboxMessageDAO.findMessagesByMessageIds(messageIds.stream().map(PostgresMessageId.class::cast).collect(ImmutableList.toImmutableList()), fetchType)
             .flatMap(messageBuilderAndRecord -> {
                 SimpleMailboxMessage.Builder messageBuilder = messageBuilderAndRecord.getLeft();
+                Record record = messageBuilderAndRecord.getRight();
                 if (fetchType == MessageMapper.FetchType.FULL) {
-                    return retrieveFullContent(messageBuilderAndRecord.getRight())
-                        .map(headerAndBodyContent -> messageBuilder.content(headerAndBodyContent).build());
+                    return retrieveFullMessage(messageBuilder, record);
                 }
                 return Mono.just(messageBuilder.build());
             }, ReactorUtils.DEFAULT_CONCURRENCY);
     }
 
+    private Mono<SimpleMailboxMessage> retrieveFullMessage(SimpleMailboxMessage.Builder messageBuilder, Record record) {
+        return retrieveFullContent(record).flatMap(headerAndBodyContent -> getAttachments(toMap(record.get(ATTACHMENT_METADATA)))
+            .map(messageAttachmentMetadataList -> messageBuilder.content(headerAndBodyContent).addAttachments(messageAttachmentMetadataList).build()));
+    }
+
+    private Map<AttachmentId, MessageRepresentation.AttachmentRepresentation> toMap(List<MessageRepresentation.AttachmentRepresentation> attachmentRepresentations) {
+        return attachmentRepresentations.stream().collect(ImmutableMap.toImmutableMap(MessageRepresentation.AttachmentRepresentation::getAttachmentId, obj -> obj));
+    }
+
+    private Mono<List<MessageAttachmentMetadata>> getAttachments(Map<AttachmentId, MessageRepresentation.AttachmentRepresentation> mapAttachmentIdToAttachmentRepresentation) {
+        return attachmentMapper.getAttachmentsReactive(mapAttachmentIdToAttachmentRepresentation.values()
+                .stream()
+                .map(MessageRepresentation.AttachmentRepresentation::getAttachmentId)
+                .collect(ImmutableList.toImmutableList()))
+            .map(attachmentMetadata -> constructMessageAttachment(attachmentMetadata, mapAttachmentIdToAttachmentRepresentation.get(attachmentMetadata.getAttachmentId())))
+            .collectList();
+    }
+
+    private MessageAttachmentMetadata constructMessageAttachment(AttachmentMetadata attachment, MessageRepresentation.AttachmentRepresentation messageAttachmentRepresentation) {
+        return MessageAttachmentMetadata.builder()
+            .attachment(attachment)
+            .name(messageAttachmentRepresentation.getName().orElse(null))
+            .cid(messageAttachmentRepresentation.getCid())
+            .isInline(messageAttachmentRepresentation.isInline())
+            .build();
+    }
+
     @Override
     public List<MailboxId> findMailboxes(MessageId messageId) {
         return mailboxMessageDAO.findMailboxes(PostgresMessageId.class.cast(messageId))
diff --git a/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/dao/PostgresAttachmentDAO.java b/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/dao/PostgresAttachmentDAO.java
index 15f7f3ec62..7d60ff51c5 100644
--- a/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/dao/PostgresAttachmentDAO.java
+++ b/mailbox/postgres/src/main/java/org/apache/james/mailbox/postgres/mail/dao/PostgresAttachmentDAO.java
@@ -19,6 +19,7 @@
 
 package org.apache.james.mailbox.postgres.mail.dao;
 
+import java.util.Collection;
 import java.util.Optional;
 
 import javax.inject.Inject;
@@ -33,6 +34,8 @@ import org.apache.james.mailbox.model.AttachmentMetadata;
 import org.apache.james.mailbox.postgres.PostgresMessageId;
 import org.apache.james.mailbox.postgres.mail.PostgresAttachmentModule.PostgresAttachmentTable;
 
+import com.google.common.collect.ImmutableList;
+
 import reactor.core.publisher.Flux;
 import reactor.core.publisher.Mono;
 
@@ -69,7 +72,7 @@ public class PostgresAttachmentDAO {
                     PostgresAttachmentTable.MESSAGE_ID,
                     PostgresAttachmentTable.SIZE)
                 .from(PostgresAttachmentTable.TABLE_NAME)
-                .where(PostgresAttachmentTable.ID.eq(attachmentId.asUUID()))))
+                .where(PostgresAttachmentTable.ID.eq(attachmentId.getId()))))
             .map(row -> Pair.of(
                 AttachmentMetadata.builder()
                     .attachmentId(attachmentId)
@@ -80,9 +83,20 @@ public class PostgresAttachmentDAO {
                 blobIdFactory.from(row.get(PostgresAttachmentTable.BLOB_ID))));
     }
 
+    public Flux<AttachmentMetadata> getAttachments(Collection<AttachmentId> attachmentIds) {
+        return postgresExecutor.executeRows(dslContext -> Flux.from(dslContext.selectFrom(PostgresAttachmentTable.TABLE_NAME)
+                .where(PostgresAttachmentTable.ID.in(attachmentIds.stream().map(AttachmentId::getId).collect(ImmutableList.toImmutableList())))))
+            .map(row -> AttachmentMetadata.builder()
+                .attachmentId(AttachmentId.from(row.get(PostgresAttachmentTable.ID)))
+                .type(row.get(PostgresAttachmentTable.TYPE))
+                .messageId(PostgresMessageId.Factory.of(row.get(PostgresAttachmentTable.MESSAGE_ID)))
+                .size(row.get(PostgresAttachmentTable.SIZE))
+                .build());
+    }
+
     public Mono<Void> storeAttachment(AttachmentMetadata attachment, BlobId blobId) {
         return postgresExecutor.executeVoid(dslContext -> Mono.from(dslContext.insertInto(PostgresAttachmentTable.TABLE_NAME)
-            .set(PostgresAttachmentTable.ID, attachment.getAttachmentId().asUUID())
+            .set(PostgresAttachmentTable.ID, attachment.getAttachmentId().getId())
             .set(PostgresAttachmentTable.BLOB_ID, blobId.asString())
             .set(PostgresAttachmentTable.TYPE, attachment.getType().asString())
             .set(PostgresAttachmentTable.MESSAGE_ID, ((PostgresMessageId) attachment.getMessageId()).asUuid())
diff --git a/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/DeleteMessageListenerTest.java b/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/DeleteMessageListenerTest.java
index 7a2c846aaa..8407302b7a 100644
--- a/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/DeleteMessageListenerTest.java
+++ b/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/DeleteMessageListenerTest.java
@@ -43,7 +43,6 @@ import org.apache.james.mailbox.store.SessionProviderImpl;
 import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
 import org.apache.james.mailbox.store.StoreRightManager;
 import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
-import org.apache.james.mailbox.store.mail.NaiveThreadIdGuessingAlgorithm;
 import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
 import org.apache.james.mailbox.store.quota.QuotaComponents;
 import org.apache.james.mailbox.store.search.MessageSearchIndex;
diff --git a/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/DeleteMessageListenerWithRLSTest.java b/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/DeleteMessageListenerWithRLSTest.java
index c2ad850a80..8f92ab1990 100644
--- a/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/DeleteMessageListenerWithRLSTest.java
+++ b/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/DeleteMessageListenerWithRLSTest.java
@@ -47,7 +47,6 @@ import org.apache.james.mailbox.store.SessionProviderImpl;
 import org.apache.james.mailbox.store.StoreMailboxAnnotationManager;
 import org.apache.james.mailbox.store.StoreRightManager;
 import org.apache.james.mailbox.store.extractor.DefaultTextExtractor;
-import org.apache.james.mailbox.store.mail.NaiveThreadIdGuessingAlgorithm;
 import org.apache.james.mailbox.store.mail.model.impl.MessageParser;
 import org.apache.james.mailbox.store.quota.QuotaComponents;
 import org.apache.james.mailbox.store.search.MessageSearchIndex;
diff --git a/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/PostgresMailboxManagerAttachmentTest.java b/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/PostgresMailboxManagerAttachmentTest.java
index c4e11687be..1ce1613e01 100644
--- a/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/PostgresMailboxManagerAttachmentTest.java
+++ b/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/PostgresMailboxManagerAttachmentTest.java
@@ -92,8 +92,8 @@ public class PostgresMailboxManagerAttachmentTest extends AbstractMailboxManager
         SessionProviderImpl sessionProvider = new SessionProviderImpl(null, null);
         QuotaComponents quotaComponents = QuotaComponents.disabled(sessionProvider, mapperFactory);
 
-        MessageIdManager messageIdManager = new StoreMessageIdManager(storeRightManager, mapperFactory
-            , eventBus, new NoQuotaManager(), mock(QuotaRootResolver.class), PreDeletionHooks.NO_PRE_DELETION_HOOK);
+        MessageIdManager messageIdManager = new StoreMessageIdManager(storeRightManager, mapperFactory,
+            eventBus, new NoQuotaManager(), mock(QuotaRootResolver.class), PreDeletionHooks.NO_PRE_DELETION_HOOK);
 
         StoreAttachmentManager storeAttachmentManager = new StoreAttachmentManager(mapperFactory, messageIdManager);
 
diff --git a/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/mail/PostgresMapperProvider.java b/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/mail/PostgresMapperProvider.java
index ebd3a51cf0..06cc36cca8 100644
--- a/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/mail/PostgresMapperProvider.java
+++ b/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/mail/PostgresMapperProvider.java
@@ -37,6 +37,7 @@ import org.apache.james.mailbox.model.MailboxId;
 import org.apache.james.mailbox.model.MessageId;
 import org.apache.james.mailbox.postgres.PostgresMailboxId;
 import org.apache.james.mailbox.postgres.PostgresMessageId;
+import org.apache.james.mailbox.postgres.mail.dao.PostgresAttachmentDAO;
 import org.apache.james.mailbox.postgres.mail.dao.PostgresMailboxDAO;
 import org.apache.james.mailbox.postgres.mail.dao.PostgresMailboxMessageDAO;
 import org.apache.james.mailbox.postgres.mail.dao.PostgresMessageDAO;
@@ -46,12 +47,9 @@ import org.apache.james.mailbox.store.mail.MessageIdMapper;
 import org.apache.james.mailbox.store.mail.MessageMapper;
 import org.apache.james.mailbox.store.mail.UidProvider;
 import org.apache.james.mailbox.store.mail.model.MapperProvider;
-import org.apache.james.mailbox.store.mail.model.MessageUidProvider;
 import org.apache.james.server.blob.deduplication.DeDuplicationBlobStore;
 import org.apache.james.utils.UpdatableTickingClock;
-import org.testcontainers.utility.ThrowingFunction;
 
-import com.github.fge.lambdas.Throwing;
 import com.google.common.collect.ImmutableList;
 
 public class PostgresMapperProvider implements MapperProvider {
@@ -106,7 +104,10 @@ public class PostgresMapperProvider implements MapperProvider {
             new PostgresMessageDAO(postgresExtension.getPostgresExecutor(), blobIdFactory),
             new PostgresMailboxMessageDAO(postgresExtension.getPostgresExecutor()),
             new PostgresModSeqProvider(mailboxDAO),
-            blobStore, blobIdFactory, updatableTickingClock);
+            new PostgresAttachmentMapper(new PostgresAttachmentDAO(postgresExtension.getPostgresExecutor(), blobIdFactory), blobStore),
+            blobStore,
+            blobIdFactory,
+            updatableTickingClock);
     }
 
     @Override
diff --git a/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/mail/PostgresMessageBlobReferenceSourceTest.java b/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/mail/PostgresMessageBlobReferenceSourceTest.java
index 37b5a91117..56de642dd5 100644
--- a/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/mail/PostgresMessageBlobReferenceSourceTest.java
+++ b/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/mail/PostgresMessageBlobReferenceSourceTest.java
@@ -75,8 +75,8 @@ public class PostgresMessageBlobReferenceSourceTest {
         SimpleMailboxMessage message = createMessage(messageId1, ThreadId.fromBaseMessageId(messageId1),  CONTENT, BODY_START, new PropertyBuilder());
         MessageId messageId2 = PostgresMessageId.Factory.of(UUID.randomUUID());
         MailboxMessage message2 = createMessage(messageId2, ThreadId.fromBaseMessageId(messageId2),  CONTENT_2, BODY_START, new PropertyBuilder());
-        postgresMessageDAO.insert(message, "1") .block();
-        postgresMessageDAO.insert(message2, "2") .block();
+        postgresMessageDAO.insert(message, "1").block();
+        postgresMessageDAO.insert(message2, "2").block();
 
         assertThat(blobReferenceSource.listReferencedBlobs().collectList().block())
             .hasSize(2);
diff --git a/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/mail/PostgresMessageMapperTest.java b/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/mail/PostgresMessageMapperTest.java
index 55a6864e88..f41d556107 100644
--- a/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/mail/PostgresMessageMapperTest.java
+++ b/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/mail/PostgresMessageMapperTest.java
@@ -32,6 +32,7 @@ public class PostgresMessageMapperTest extends MessageMapperTest {
     static PostgresExtension postgresExtension = PostgresExtension.withoutRowLevelSecurity(PostgresMailboxAggregateModule.MODULE);
 
     private PostgresMapperProvider postgresMapperProvider;
+
     @Override
     protected MapperProvider createMapperProvider() {
         postgresMapperProvider = new PostgresMapperProvider(postgresExtension);
diff --git a/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/user/PostgresSubscriptionMapperRowLevelSecurityTest.java b/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/user/PostgresSubscriptionMapperRowLevelSecurityTest.java
index 553d605612..acd0bb2cef 100644
--- a/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/user/PostgresSubscriptionMapperRowLevelSecurityTest.java
+++ b/mailbox/postgres/src/test/java/org/apache/james/mailbox/postgres/user/PostgresSubscriptionMapperRowLevelSecurityTest.java
@@ -22,8 +22,8 @@ package org.apache.james.mailbox.postgres.user;
 import static org.assertj.core.api.Assertions.assertThat;
 
 import org.apache.james.backends.postgres.PostgresExtension;
-import org.apache.james.backends.postgres.utils.PostgresExecutor;
 import org.apache.james.backends.postgres.utils.DomainImplPostgresConnectionFactory;
+import org.apache.james.backends.postgres.utils.PostgresExecutor;
 import org.apache.james.core.Username;
 import org.apache.james.mailbox.MailboxSession;
 import org.apache.james.mailbox.MailboxSessionUtil;


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@james.apache.org
For additional commands, e-mail: notifications-help@james.apache.org