use of com.zimbra.common.mailbox.BaseItemInfo in project zm-mailbox by Zimbra.
the class SoapSession method notifyPendingChanges.
/**
* Handles the set of changes from a single Mailbox transaction.
* <p>
* Takes a set of new mailbox changes and caches it locally. This is
* currently initiated from inside the Mailbox transaction commit, but we
* still shouldn't assume that execution of this method is synchronized
* on the Mailbox.
* <p>
* *All* changes are currently cached, regardless of the client's state/views.
* @param pms A set of new change notifications from our Mailbox.
* @param changeId The change ID of the change.
* @param source The (optional) Session which initiated these changes.
*/
@Override
public void notifyPendingChanges(PendingModifications pmsIn, int changeId, Session source) {
PendingLocalModifications pms = (PendingLocalModifications) pmsIn;
Mailbox mbox = this.getMailboxOrNull();
if (pms == null || mbox == null || !pms.hasNotifications()) {
return;
}
if (source == this) {
updateLastWrite(mbox);
} else {
// keep track of "recent" message count: all present before the session started, plus all received during the session
if (pms.created != null) {
for (BaseItemInfo item : pms.created.values()) {
if (item instanceof Message) {
Message msg = (Message) item;
boolean isReceived = true;
if (msg.getFolderId() == Mailbox.ID_FOLDER_SPAM || msg.getFolderId() == Mailbox.ID_FOLDER_TRASH) {
isReceived = false;
} else if ((item.getFlagBitmask() & Mailbox.NON_DELIVERY_FLAGS) != 0) {
isReceived = false;
} else if (source != null) {
isReceived = false;
}
if (isReceived) {
recentMessages++;
ZimbraLog.session.debug("incrementing session recent count to %d", recentMessages);
}
}
}
}
}
handleNotifications(pms, source == this);
}
use of com.zimbra.common.mailbox.BaseItemInfo in project zm-mailbox by Zimbra.
the class PendingLocalModifications method add.
@Override
PendingModifications<MailItem> add(PendingModifications<MailItem> other) {
changedTypes.addAll(other.changedTypes);
addChangedParentFolderIds(other.getChangedParentFolders());
if (other.deleted != null) {
for (Map.Entry<PendingModifications.ModificationKey, PendingModifications.Change> entry : other.deleted.entrySet()) {
delete(entry.getKey(), entry.getValue());
}
}
if (other.created != null) {
for (BaseItemInfo item : other.created.values()) {
recordCreated(item);
}
}
if (other.modified != null) {
for (PendingModifications.Change chg : other.modified.values()) {
if (chg.what instanceof ZimbraMailItem) {
recordModified((ZimbraMailItem) chg.what, chg.why, (ZimbraMailItem) chg.preModifyObj);
} else if (chg.what instanceof Mailbox) {
recordModified((Mailbox) chg.what, chg.why);
}
}
}
return this;
}
Aggregations