private UpdatedRepresentation createUpdatedDocumentPartFromUpdatedFlags(Mailbox mailbox, UpdatedFlags updatedFlags) { try { return new UpdatedRepresentation( indexIdFor(mailbox, updatedFlags.getUid()), messageToElasticSearchJson.getUpdatedJsonMessagePart( updatedFlags.getNewFlags(), updatedFlags.getModSeq())); } catch (JsonProcessingException e) { throw new RuntimeException("Error while creating updatedDocumentParts", e); } }
@Override public Map<MessageUid, Flags> setFlags(final Flags flags, final FlagsUpdateMode flagsUpdateMode, final MessageRange set, MailboxSession mailboxSession) throws MailboxException { if (!isWriteable(mailboxSession)) { throw new ReadOnlyException(getMailboxPath(), mailboxSession.getPathDelimiter()); } final SortedMap<MessageUid, Flags> newFlagsByUid = new TreeMap<>(); trimFlags(flags, mailboxSession); final MessageMapper messageMapper = mapperFactory.getMessageMapper(mailboxSession); Iterator<UpdatedFlags> it = messageMapper.execute(() -> messageMapper.updateFlags(getMailboxEntity(), new FlagsUpdateCalculator(flags, flagsUpdateMode), set)); final SortedMap<MessageUid, UpdatedFlags> uFlags = new TreeMap<>(); while (it.hasNext()) { UpdatedFlags flag = it.next(); newFlagsByUid.put(flag.getUid(), flag.getNewFlags()); uFlags.put(flag.getUid(), flag); } dispatcher.flagsUpdated(mailboxSession, new ArrayList<>(uFlags.keySet()), getMailboxEntity(), new ArrayList<>(uFlags.values())); return newFlagsByUid; }
public UpdatedFlagsDataTransferObject(UpdatedFlags updatedFlags) { this.uid = updatedFlags.getUid().asLong(); this.modseq = updatedFlags.getModSeq(); this.oldFlags = new FlagsDataTransferObject(updatedFlags.getOldFlags()); this.newFlags = new FlagsDataTransferObject(updatedFlags.getNewFlags()); }
applicableFlags.add(flags.get(i).getNewFlags());
applicableFlags.add(flag.getNewFlags());