public String getMailboxPath() { return mailboxPath.asString(); }
@Override public String toString() { return asString(); }
public String getMailboxPath() { return mailboxPath.asString(); }
private Task.Result handleMultiMailboxesReindexingIterations(List<MailboxPath> mailboxPaths, GlobalRegistration globalRegistration, ReprocessingContext reprocessingContext) { return mailboxPaths.stream() .map(globalRegistration::getPathToIndex) .flatMap(OptionalUtils::toStream) .map(path -> { try { return reIndex(path, reprocessingContext); } catch (Throwable e) { LOGGER.error("Error while proceeding to full reindexing on {}", path.asString(), e); return Task.Result.PARTIAL; } }) .reduce(Task::combine) .orElse(Task.Result.COMPLETED); }
private void assertIsOwner(MailboxSession mailboxSession, MailboxPath mailboxPath) throws MailboxNotFoundException { if (!mailboxPath.belongsTo(mailboxSession)) { LOGGER.info("Mailbox {} does not belong to {}", mailboxPath.asString(), mailboxSession.getUser().getUserName()); throw new MailboxNotFoundException(mailboxPath.asString()); } }
private static MDCBuilder from(Optional<SelectedMailbox> selectedMailbox) { return selectedMailbox .map(value -> MDCBuilder.create() .addContext("selectedMailbox", value.getPath().asString())) .orElse(MDCBuilder.create()); } }
private Task.Result reIndex(MailboxPath path, MailboxSession mailboxSession, ReprocessingContext reprocessingContext) throws MailboxException { LOGGER.info("Intend to reindex {}", path.asString()); Mailbox mailbox = mailboxSessionMapperFactory.getMailboxMapper(mailboxSession).findMailboxByPath(path); messageSearchIndex.deleteAll(mailboxSession, mailbox); try { return Iterators.toStream( mailboxSessionMapperFactory.getMessageMapper(mailboxSession) .findInMailbox(mailbox, MessageRange.all(), MessageMapper.FetchType.Metadata, NO_LIMIT)) .map(MailboxMessage::getUid) .map(uid -> handleMessageReIndexing(mailboxSession, mailbox, uid)) .peek(reprocessingContext::updateAccordingToReprocessingResult) .reduce(Task::combine) .orElse(Task.Result.COMPLETED); } finally { LOGGER.info("Finish to reindex {}", path.asString()); } }
@Override public MailboxId save(Mailbox mailbox) throws MailboxException { Preconditions.checkArgument(mailbox instanceof SimpleMailbox); SimpleMailbox cassandraMailbox = (SimpleMailbox) mailbox; CassandraId cassandraId = retrieveId(cassandraMailbox); cassandraMailbox.setMailboxId(cassandraId); boolean applied = trySave(cassandraMailbox, cassandraId).join(); if (!applied) { throw new MailboxExistsException(mailbox.generateAssociatedPath().asString()); } return cassandraId; }
throw new MailboxExistsException(sanitizedMailboxPath.asString());