@Override public void storeAttachmentsForMessage(Collection<Attachment> attachments, MessageId ownerMessageId, MailboxSession mailboxSession) throws MailboxException { attachmentMapperFactory.getAttachmentMapper(mailboxSession).storeAttachmentsForMessage(attachments, ownerMessageId); }
private Collection<MessageId> getRelatedMessageIds(AttachmentId attachmentId, MailboxSession mailboxSession) throws MailboxException { return attachmentMapperFactory.getAttachmentMapper(mailboxSession).getRelatedMessageIds(attachmentId); }
@Override public List<Attachment> getAttachments(List<AttachmentId> attachmentIds, MailboxSession mailboxSession) throws MailboxException { List<AttachmentId> accessibleAttachmentIds = attachmentIds.stream() .filter(attachmentId -> userHasAccessToAttachment(attachmentId, mailboxSession)) .collect(Guavate.toImmutableList()); return attachmentMapperFactory.getAttachmentMapper(mailboxSession).getAttachments(accessibleAttachmentIds); }
@Override public void storeAttachment(Attachment attachment, MailboxSession mailboxSession) throws MailboxException { attachmentMapperFactory.getAttachmentMapper(mailboxSession) .storeAttachmentForOwner(attachment, Username.fromMailboxSession(mailboxSession)); }
private boolean isExplicitlyAOwner(AttachmentId attachmentId, MailboxSession mailboxSession) throws MailboxException { Collection<Username> explicitOwners = attachmentMapperFactory.getAttachmentMapper(mailboxSession) .getOwners(attachmentId); return explicitOwners.stream() .anyMatch(username -> mailboxSession.getUser().isSameUser(username.getValue())); }
@Override public Attachment getAttachment(AttachmentId attachmentId, MailboxSession mailboxSession) throws MailboxException, AttachmentNotFoundException { if (!userHasAccessToAttachment(attachmentId, mailboxSession)) { throw new AttachmentNotFoundException(attachmentId.getId()); } return attachmentMapperFactory.getAttachmentMapper(mailboxSession).getAttachment(attachmentId); }