Search in sources :

Example 1 with ZimbraMailItem

use of com.zimbra.common.mailbox.ZimbraMailItem in project zm-mailbox by Zimbra.

the class PendingLocalModifications method recordDeleted.

@Override
public void recordDeleted(ZimbraMailItem itemSnapshot) {
    MailItem.Type type = MailItem.Type.fromCommon(itemSnapshot.getMailItemType());
    changedTypes.add(type);
    try {
        addChangedParentFolderId(itemSnapshot.getFolderIdInMailbox());
    } catch (ServiceException e) {
        ZimbraLog.mailbox.warn("error getting folder ID for modified item");
    }
    delete(new ModificationKey(itemSnapshot), type, itemSnapshot);
}
Also used : MailItem(com.zimbra.cs.mailbox.MailItem) ZimbraMailItem(com.zimbra.common.mailbox.ZimbraMailItem) ServiceException(com.zimbra.common.service.ServiceException) Type(com.zimbra.cs.mailbox.MailItem.Type)

Example 2 with ZimbraMailItem

use of com.zimbra.common.mailbox.ZimbraMailItem in project zm-mailbox by Zimbra.

the class PendingLocalModifications method recordModified.

@Override
public void recordModified(BaseItemInfo item, int reason, ZimbraMailItem preModifyItem) {
    MailItem.Type type = MailItem.Type.fromCommon(item.getMailItemType());
    changedTypes.add(type);
    try {
        addChangedParentFolderId(item.getFolderIdInMailbox());
    } catch (ServiceException e) {
        ZimbraLog.mailbox.warn("error getting folder ID for modified item");
    }
    if (type == MailItem.Type.FOLDER) {
        try {
            addChangedFolderId(item.getIdInMailbox());
        } catch (ServiceException e) {
            ZimbraLog.mailbox.warn("error getting ID for modified item");
        }
    }
    recordModified(new ModificationKey(item), item, reason, preModifyItem, false);
}
Also used : MailItem(com.zimbra.cs.mailbox.MailItem) ZimbraMailItem(com.zimbra.common.mailbox.ZimbraMailItem) ServiceException(com.zimbra.common.service.ServiceException) Type(com.zimbra.cs.mailbox.MailItem.Type)

Example 3 with ZimbraMailItem

use of com.zimbra.common.mailbox.ZimbraMailItem in project zm-mailbox by Zimbra.

the class ZBaseItem method getModifiedSequence.

@Override
public int getModifiedSequence() {
    int modSeq = modifiedSequence;
    if (modSeq > 0) {
        return modSeq;
    }
    ZimbraMailItem zmi = null;
    try {
        zmi = getMailbox().getItemById(null, getItemIdentifier(), getMailItemType());
    } catch (ServiceException e) {
        ZimbraLog.mailbox.debug("ZBaseItem getModifiedSequence() - getItemById failed for mailbox=%s item=%s", mMailbox, getId(), e);
        return 0;
    }
    if ((null == zmi) || !(zmi instanceof ZBaseItem)) {
        return 0;
    }
    modifiedSequence = (((ZBaseItem) zmi).modifiedSequence <= 0) ? 0 : ((ZBaseItem) zmi).modifiedSequence;
    return modifiedSequence;
}
Also used : ServiceException(com.zimbra.common.service.ServiceException) ZimbraMailItem(com.zimbra.common.mailbox.ZimbraMailItem)

Example 4 with ZimbraMailItem

use of com.zimbra.common.mailbox.ZimbraMailItem in project zm-mailbox by Zimbra.

the class Mailbox method getItemsById.

/**
 * @returns MailItems with the specified ids.
 * @throws NoSuchItemException if any item does not exist
 */
@Override
public List<ZimbraMailItem> getItemsById(OpContext octxt, Collection<ItemIdentifier> ids) throws ServiceException {
    List<Integer> idInts = Lists.newArrayListWithCapacity(ids.size());
    for (ItemIdentifier iid : ids) {
        idInts.add(iid.id);
    }
    MailItem[] mitms = getItemById(OperationContext.asOperationContext(octxt), idInts, MailItem.Type.UNKNOWN);
    if (null == mitms || (mitms.length == 0)) {
        return Collections.emptyList();
    }
    return Lists.newArrayList(mitms);
}
Also used : ItemIdentifier(com.zimbra.common.mailbox.ItemIdentifier) DbMailItem(com.zimbra.cs.db.DbMailItem) ZimbraMailItem(com.zimbra.common.mailbox.ZimbraMailItem)

Example 5 with ZimbraMailItem

use of com.zimbra.common.mailbox.ZimbraMailItem in project zm-mailbox by Zimbra.

the class ZMailbox method resetImapUid.

/**
 * @return the list of new IMAP UIDs corresponding to the specified items
 */
@Override
public List<Integer> resetImapUid(OpContext octxt, List<Integer> itemIds) throws ServiceException {
    if ((null == itemIds) || itemIds.isEmpty()) {
        return Collections.emptyList();
    }
    resetImapUid(itemIds);
    // TODO:  ItemAction returns the original IDs.  However, the underlying mailbox
    // operation on the server returns the new UIDs - i.e. ItemAction throws away that information.
    // If performance is a problem probably worth creating a dedicated SOAP request.
    List<ZimbraMailItem> zmis = getItemsById(octxt, ItemIdentifier.fromAccountIdAndItemIds(getAccountId(), itemIds));
    if ((null == zmis) || zmis.isEmpty()) {
        return Collections.emptyList();
    }
    List<Integer> newImapUIDs = Lists.newArrayListWithExpectedSize(zmis.size());
    for (ZimbraMailItem zmi : zmis) {
        newImapUIDs.add(zmi.getImapUid());
    }
    return newImapUIDs;
}
Also used : ZimbraMailItem(com.zimbra.common.mailbox.ZimbraMailItem)

Aggregations

ZimbraMailItem (com.zimbra.common.mailbox.ZimbraMailItem)10 ServiceException (com.zimbra.common.service.ServiceException)6 ItemIdentifier (com.zimbra.common.mailbox.ItemIdentifier)4 MailboxStore (com.zimbra.common.mailbox.MailboxStore)3 AccountServiceException (com.zimbra.cs.account.AccountServiceException)2 ImapMessageSet (com.zimbra.cs.imap.ImapMessage.ImapMessageSet)2 MailItem (com.zimbra.cs.mailbox.MailItem)2 Type (com.zimbra.cs.mailbox.MailItem.Type)2 MailServiceException (com.zimbra.cs.mailbox.MailServiceException)2 NoSuchItemException (com.zimbra.cs.mailbox.MailServiceException.NoSuchItemException)2 Mailbox (com.zimbra.cs.mailbox.Mailbox)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 MessagingException (javax.mail.MessagingException)2 MimeMessage (javax.mail.internet.MimeMessage)2 ZContact (com.zimbra.client.ZContact)1 ZMailbox (com.zimbra.client.ZMailbox)1 ZMessage (com.zimbra.client.ZMessage)1 BaseItemInfo (com.zimbra.common.mailbox.BaseItemInfo)1 OpContext (com.zimbra.common.mailbox.OpContext)1