Search in sources :

Example 1 with CopyActionResult

use of com.zimbra.cs.service.mail.CopyActionResult in project zm-mailbox by Zimbra.

the class Mailbox method copyItemAction.

/**
 * Copies the items identified in {@link idlist} to folder {@link targetFolder}
 * @param idlist - list of item ids for items to copy
 * @param targetFolder - Destination folder
 * @return The item IDs of the created items - these may be full item IDs in the case of remote folders
 */
@Override
public List<String> copyItemAction(OpContext ctxt, ItemIdentifier targetFolder, List<ItemIdentifier> idlist) throws ServiceException {
    if ((idlist == null) || idlist.isEmpty()) {
        return Collections.emptyList();
    }
    List<Integer> ids = Lists.newArrayListWithExpectedSize(idlist.size());
    for (ItemIdentifier ident : idlist) {
        if (this.referencesOtherMailbox(ident)) {
            // requests are proxied to the selected folder's owner.
            throw ServiceException.FAILURE("Unexpected attempt to copy item from mountpoint", null);
        }
        ids.add(ident.id);
    }
    ItemActionHelper op = ItemActionHelper.COPY((OperationContext) ctxt, this, null, ids, MailItem.Type.UNKNOWN, null, new ItemId(targetFolder));
    CopyActionResult caResult = (CopyActionResult) op.getResult();
    return caResult.getCreatedIds();
}
Also used : ItemIdentifier(com.zimbra.common.mailbox.ItemIdentifier) ItemActionHelper(com.zimbra.cs.service.mail.ItemActionHelper) CopyActionResult(com.zimbra.cs.service.mail.CopyActionResult) ItemId(com.zimbra.cs.service.util.ItemId)

Aggregations

ItemIdentifier (com.zimbra.common.mailbox.ItemIdentifier)1 CopyActionResult (com.zimbra.cs.service.mail.CopyActionResult)1 ItemActionHelper (com.zimbra.cs.service.mail.ItemActionHelper)1 ItemId (com.zimbra.cs.service.util.ItemId)1