boolean hasReadRight = storeRightManager.hasRight(mailbox, MailboxACL.Right.Read, mailboxSession); if (!hasReadRight) { return MailboxMetaData.sensibleInformationFree(resolvedAcl, getMailboxEntity().getUidValidity(), isWriteable(mailboxSession), isModSeqPermanent(mailboxSession)); Flags permanentFlags = getPermanentFlags(mailboxSession); long uidValidity = getMailboxEntity().getUidValidity(); MessageUid uidNext = mapperFactory.getMessageMapper(mailboxSession).getLastUid(mailbox) .map(MessageUid::next) switch (fetchGroup) { case UNSEEN_COUNT: unseenCount = countUnseenMessagesInMailbox(mailboxSession); messageCount = getMessageCount(mailboxSession); firstUnseen = null; recent = recent(resetRecent, mailboxSession); firstUnseen = findFirstUnseenMessageUid(mailboxSession); messageCount = getMessageCount(mailboxSession); unseenCount = 0; recent = recent(resetRecent, mailboxSession); firstUnseen = null; unseenCount = 0; messageCount = getMessageCount(mailboxSession); recent = recent(resetRecent, mailboxSession); recent(resetRecent, mailboxSession); return new MailboxMetaData(recent, permanentFlags, uidValidity, uidNext, highestModSeq, messageCount, unseenCount, firstUnseen, isWriteable(mailboxSession), isModSeqPermanent(mailboxSession), resolvedAcl);
/** * Copy the {@link MessageRange} to the {@link StoreMessageManager} * * @param set * @param toMailbox * @param session * @throws MailboxException */ public List<MessageRange> copyTo(final MessageRange set, final StoreMessageManager toMailbox, final MailboxSession session) throws MailboxException { if (!toMailbox.isWriteable(session)) { throw new ReadOnlyException(new StoreMailboxPath(toMailbox.getMailboxEntity()), session.getPathDelimiter()); } return locker.executeWithLock(session, new StoreMailboxPath(toMailbox.getMailboxEntity()), () -> { SortedMap<MessageUid, MessageMetaData> copiedUids = copy(set, toMailbox, session); return MessageRange.toRanges(new ArrayList<>(copiedUids.keySet())); }, true); }
if (!isWriteable(mailboxSession)) { throw new ReadOnlyException(getMailboxPath(), mailboxSession.getPathDelimiter()); trimFlags(flags, mailboxSession); final int size = (int) file.length(); final List<MessageAttachment> attachments = extractAttachments(contentIn); propertyBuilder.setHasAttachment(hasNonInlinedAttachment(attachments)); final MailboxMessage message = createMessage(internalDate, size, bodyStartOctet, contentIn, flags, propertyBuilder, attachments); return locker.executeWithLock(mailboxSession, getMailboxPath(), () -> { MessageMetaData data = appendMessageToStore(message, attachments, mailboxSession); Mailbox mailbox = getMailboxEntity(); MailboxMessage copy = copyMessage(message); dispatcher.added(mailboxSession, mailbox, copy); return new ComposedMessageId(mailbox.getMailboxId(), data.getMessageId(), data.getUid());
/** * Returns the flags which are shared for the current mailbox, i.e. the * flags set up so that changes to those flags are visible to another user. * See RFC 4314 section 5.2. * * In this implementation, all permanent flags are shared, ergo we simply * return {@link #getPermanentFlags(MailboxSession)} * * @see UnionMailboxACLResolver#isReadWrite(MailboxACLRights, Flags) * * @param session * @return */ protected Flags getSharedPermanentFlags(MailboxSession session) { return getPermanentFlags(session); }
private SortedMap<MessageUid, MessageMetaData> copy(MessageRange set, StoreMessageManager to, MailboxSession session) throws MailboxException { IteratorWrapper<MailboxMessage> originalRows = new IteratorWrapper<>(retrieveOriginalRows(set, session)); SortedMap<MessageUid, MessageMetaData> copiedUids = collectMetadata(to.copy(originalRows, session)); ImmutableMap.Builder<MessageUid, MailboxMessage> messagesMap = ImmutableMap.builder(); for (MailboxMessage message : originalRows.getEntriesSeen()) { messagesMap.put(message.getUid(), immutableMailboxMessageFactory.from(to.getMailboxEntity().getMailboxId(), message)); } dispatcher.added(session, copiedUids, to.getMailboxEntity(), messagesMap.build()); dispatcher.moved(session, MessageMoves.builder() .previousMailboxIds(getMailboxEntity().getMailboxId()) .targetMailboxIds(to.getMailboxEntity().getMailboxId(), getMailboxEntity().getMailboxId()) .build(), messagesMap.build()); return copiedUids; }
private SortedMap<MessageUid, MessageMetaData> move(MessageRange set, StoreMessageManager to, MailboxSession session) throws MailboxException { IteratorWrapper<MailboxMessage> originalRows = new IteratorWrapper<>(retrieveOriginalRows(set, session)); MoveResult moveResult = to.move(originalRows, session); SortedMap<MessageUid, MessageMetaData> moveUids = collectMetadata(moveResult.getMovedMessages()); ImmutableMap.Builder<MessageUid, MailboxMessage> messagesMap = ImmutableMap.builder(); for (MailboxMessage message : originalRows.getEntriesSeen()) { messagesMap.put(message.getUid(), immutableMailboxMessageFactory.from(to.getMailboxEntity().getMailboxId(), message)); } dispatcher.added(session, moveUids, to.getMailboxEntity(), messagesMap.build()); dispatcher.expunged(session, collectMetadata(moveResult.getOriginalMessages()), getMailboxEntity()); dispatcher.moved(session, MessageMoves.builder() .previousMailboxIds(getMailboxEntity().getMailboxId()) .targetMailboxIds(to.getMailboxEntity().getMailboxId()) .build(), messagesMap.build()); return moveUids; }
@Override public ComposedMessageId appendMessage(AppendCommand appendCommand, MailboxSession session) throws MailboxException { return appendMessage( appendCommand.getMsgIn(), appendCommand.getInternalDate(), session, appendCommand.isRecent(), appendCommand.getFlags()); }
/** * Create a {@link MailboxManager} for the given Mailbox. By default this will return a {@link StoreMessageManager}. If * your implementation needs something different, just override this method * * @param mailbox * @param session * @return storeMailbox */ protected StoreMessageManager createMessageManager(Mailbox mailbox, MailboxSession session) throws MailboxException { return new StoreMessageManager(DEFAULT_NO_MESSAGE_CAPABILITIES, getMapperFactory(), getMessageSearchIndex(), getEventDispatcher(), getLocker(), mailbox, getQuotaManager(), getQuotaRootResolver(), getMessageParser(), getMessageIdFactory(), getBatchSizes(), getImmutableMailboxMessageFactory(), getStoreRightManager()); }
/** * Support user flags */ @Override protected Flags getPermanentFlags(MailboxSession session) { Flags flags = super.getPermanentFlags(session); flags.add(Flags.Flag.USER); return flags; }
/** * Support user flags */ @Override protected Flags getPermanentFlags(MailboxSession session) { Flags flags = super.getPermanentFlags(session); flags.add(Flags.Flag.USER); return flags; }
@Override protected Flags getPermanentFlags(MailboxSession session) { Flags permanentFlags = new Flags(super.getPermanentFlags(session)); permanentFlags.add(Flags.Flag.USER); return permanentFlags; }
Flags permFlags = getPermanentFlags(session);