});
final SortedMap<Long, UpdatedFlags> uFlags = new TreeMap<Long, UpdatedFlags>();
while (it.hasNext()) {
UpdatedFlags flag = it.next();
newFlagsByUid.put(flag.getUid(), flag.getNewFlags());
uFlags.put(flag.getUid(), flag);
}
dispatcher.flagsUpdated(mailboxSession, new ArrayList<Long>(uFlags.keySet()), new StoreMailboxPath<Id>(getMailboxEntity()), new ArrayList<UpdatedFlags>(uFlags.values()));
return newFlagsByUid;