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));
}
}
}
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()
}
Aggregations