Search in sources :

Example 1 with ItemActionResponse

use of com.zimbra.soap.mail.message.ItemActionResponse in project zm-mailbox by Zimbra.

the class ZMailbox method delete.

/**
 * Delete <tt>MailItem</tt>s with given ids.  If there is no <tt>MailItem</tt> for a given id, that id is ignored.
 *
 * @param octxt operation context or {@code null}
 * @param itemIds item ids
 * @param nonExistingItems If not null, This gets populated with the item IDs of nonExisting items
 */
@Override
public void delete(OpContext octxt, List<Integer> itemIds, List<Integer> nonExistingItems) throws ServiceException {
    String ids = Joiner.on(",").join(itemIds);
    ActionSelector action = ActionSelector.createForIdsAndOperation(ids, MailConstants.OP_HARD_DELETE);
    action.setNonExistentIds(true);
    ItemActionRequest req = new ItemActionRequest(action);
    ItemActionResponse resp = invokeJaxb(req);
    ActionResult ar = resp.getAction();
    for (String id : ar.getNonExistentIds().split(",")) {
        if (id.length() > 0) {
            nonExistingItems.add(Integer.parseInt(id));
        }
    }
}
Also used : ItemActionRequest(com.zimbra.soap.mail.message.ItemActionRequest) ActionResult(com.zimbra.soap.mail.type.ActionResult) ActionSelector(com.zimbra.soap.mail.type.ActionSelector) ItemActionResponse(com.zimbra.soap.mail.message.ItemActionResponse)

Example 2 with ItemActionResponse

use of com.zimbra.soap.mail.message.ItemActionResponse in project zm-mailbox by Zimbra.

the class TestZClient method testCopyItemAction.

@Test
public void testCopyItemAction() throws Exception {
    ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
    String sender = TestUtil.getAddress(USER_NAME);
    String recipient = TestUtil.getAddress(RECIPIENT_USER_NAME);
    String subject = NAME_PREFIX + " testCopyItemAction";
    String content = new MessageBuilder().withSubject(subject).withFrom(sender).withToRecipient(recipient).create();
    // add a msg flagged as sent; filterSent=TRUE
    mbox.addMessage(Integer.toString(Mailbox.ID_FOLDER_DRAFTS), null, null, System.currentTimeMillis(), content, false, false);
    ZMessage msg = TestUtil.waitForMessage(mbox, "in:drafts " + subject);
    List<ItemIdentifier> ids = Lists.newArrayListWithCapacity(1);
    ids.add(new ItemIdentifier(msg.getId(), null));
    ItemActionResponse resp = mbox.copyItemAction(new ItemIdentifier(null, Mailbox.ID_FOLDER_SENT), ids);
    assertNotNull("item action response should not be null", resp);
    assertNotNull("action should not be null", resp.getAction());
    assertNotNull("action id should not be null", resp.getAction().getId());
    ZMessage copiedMessage = mbox.getMessageById(resp.getAction().getId());
    assertNotNull("copied msg should not be null", copiedMessage);
    assertEquals("subject of copied msg", subject, copiedMessage.getSubject());
// msg.getId()
}
Also used : ZMessage(com.zimbra.client.ZMessage) ItemIdentifier(com.zimbra.common.mailbox.ItemIdentifier) ZMailbox(com.zimbra.client.ZMailbox) ItemActionResponse(com.zimbra.soap.mail.message.ItemActionResponse) Test(org.junit.Test)

Aggregations

ItemActionResponse (com.zimbra.soap.mail.message.ItemActionResponse)2 ZMailbox (com.zimbra.client.ZMailbox)1 ZMessage (com.zimbra.client.ZMessage)1 ItemIdentifier (com.zimbra.common.mailbox.ItemIdentifier)1 ItemActionRequest (com.zimbra.soap.mail.message.ItemActionRequest)1 ActionResult (com.zimbra.soap.mail.type.ActionResult)1 ActionSelector (com.zimbra.soap.mail.type.ActionSelector)1 Test (org.junit.Test)1