Search in sources :

Example 16 with BaseItemInfo

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);
}
Also used : Mailbox(com.zimbra.cs.mailbox.Mailbox) BaseItemInfo(com.zimbra.common.mailbox.BaseItemInfo) Message(com.zimbra.cs.mailbox.Message)

Example 17 with BaseItemInfo

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;
}
Also used : BaseItemInfo(com.zimbra.common.mailbox.BaseItemInfo) Mailbox(com.zimbra.cs.mailbox.Mailbox) ZimbraMailItem(com.zimbra.common.mailbox.ZimbraMailItem) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

BaseItemInfo (com.zimbra.common.mailbox.BaseItemInfo)17 Change (com.zimbra.cs.session.PendingModifications.Change)10 MailItem (com.zimbra.cs.mailbox.MailItem)8 HashMap (java.util.HashMap)8 Map (java.util.Map)8 ServiceException (com.zimbra.common.service.ServiceException)7 ZimbraMailItem (com.zimbra.common.mailbox.ZimbraMailItem)6 ModificationKey (com.zimbra.cs.session.PendingModifications.ModificationKey)6 Mailbox (com.zimbra.cs.mailbox.Mailbox)5 Folder (com.zimbra.cs.mailbox.Folder)4 Type (com.zimbra.cs.mailbox.MailItem.Type)4 LinkedHashMap (java.util.LinkedHashMap)4 ZFolder (com.zimbra.client.ZFolder)3 ZimbraTag (com.zimbra.common.mailbox.ZimbraTag)3 DbTag (com.zimbra.cs.db.DbTag)3 Message (com.zimbra.cs.mailbox.Message)3 MemcachedMap (com.zimbra.common.util.memcached.MemcachedMap)2 DbMailItem (com.zimbra.cs.db.DbMailItem)2 CalendarItem (com.zimbra.cs.mailbox.CalendarItem)2 AlterItemTag (com.zimbra.cs.redolog.op.AlterItemTag)2