use of com.zimbra.cs.session.WaitSetSession in project zm-mailbox by Zimbra.
the class WaitSetRequest method processCallback.
private static void processCallback(WaitSetResp resp, WaitSetCallback cb, String waitSetId, String lastKnownSeqNo, boolean expand) throws ServiceException {
cb.ws.doneWaiting(cb);
resp.setWaitSetId(waitSetId);
if (cb.canceled) {
resp.setCanceled(true);
} else if (cb.completed) {
resp.setSeqNo(cb.seqNo);
for (String signalledAccount : cb.signalledAccounts) {
WaitSetSession signalledSession = cb.signalledSessions.get(signalledAccount);
int lastChangeId = 0;
Set<Integer> folderInterests = null;
if (signalledSession != null) {
folderInterests = signalledSession.getFolderInterest();
if (signalledSession.getMailbox() != null) {
lastChangeId = signalledSession.getMailbox().getLastChangeID();
}
} else {
Mailbox mbox = MailboxManager.getInstance().getMailboxByAccountId(signalledAccount, false);
if (mbox != null) {
lastChangeId = mbox.getLastChangeID();
}
}
AccountWithModifications info = new AccountWithModifications(signalledAccount, lastChangeId);
@SuppressWarnings("rawtypes") PendingModifications accountMods = cb.pendingModifications.get(signalledAccount);
Map<Integer, PendingFolderModifications> folderMap = PendingModifications.encodeIMAPFolderModifications(accountMods, folderInterests);
if (folderInterests != null && !folderInterests.isEmpty() && !folderMap.isEmpty()) {
// interested only in specific folders
if (expand) {
info.setPendingFolderModifications(folderMap.values());
}
resp.addSignalledAccount(info);
} else if (folderInterests == null || folderInterests.isEmpty()) {
// interested in any folder
resp.addSignalledAccount(info);
}
}
} else {
// timed out....they should try again
resp.setSeqNo(lastKnownSeqNo);
}
resp.setErrors(encodeErrors(cb.errors));
}
Aggregations