use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class ZMailbox method saveDraft.
/**
* Saves a message draft.
*
* @param message the message
* @param existingDraftId id of existing draft or <tt>null</tt>
* @param folderId folder to save to or <tt>null</tt> to save to the <tt>Drafts</tt> folder
* @param autoSendTime time in UTC millis at which the draft should be auto-sent by the server.
* zero value implies a normal draft, i.e. no auto-send intended.
*
* @return the message
*/
public synchronized ZMessage saveDraft(ZOutgoingMessage message, String existingDraftId, String folderId, long autoSendTime) throws ServiceException {
Element req = newRequestElement(MailConstants.SAVE_DRAFT_REQUEST);
ZMountpoint mountpoint = getMountpoint(message);
Element m = getMessageElement(req, message, mountpoint);
if (existingDraftId != null && existingDraftId.length() > 0) {
mMessageCache.remove(existingDraftId);
m.addAttribute(MailConstants.A_ID, existingDraftId);
}
if (folderId != null) {
m.addAttribute(MailConstants.A_FOLDER, folderId);
}
if (autoSendTime != 0) {
m.addAttribute(MailConstants.A_AUTO_SEND_TIME, autoSendTime);
}
if (message.getIdentityId() != null) {
m.addAttribute(MailConstants.A_IDENTITY_ID, message.getIdentityId());
}
String requestedAccountId = mountpoint == null ? null : mGetInfoResult.getId();
return new ZMessage(invoke(req, requestedAccountId).getElement(MailConstants.E_MSG), this);
}
use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class ZMailbox method invokeJaxb.
@SuppressWarnings("unchecked")
public <T> T invokeJaxb(Object jaxbObject) throws ServiceException {
Element req = JaxbUtil.jaxbToElement(jaxbObject);
Element res = invoke(req);
return (T) JaxbUtil.elementToJaxb(res);
}
use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class ZMailbox method renameFolder.
/** changes the folder's name and moves it be a child of the given target folder.
* @param id folder id
* @param name new name
* @param targetFolderId new parent, or <tt>null</tt> to keep the current parent
* @return action result
* @throws ServiceException on error
*/
public ZActionResult renameFolder(String id, String name, String targetFolderId) throws ServiceException {
Element folderAction = folderAction("rename", id);
folderAction.addAttribute(MailConstants.A_NAME, name);
if (targetFolderId != null) {
folderAction.addAttribute(MailConstants.A_FOLDER, targetFolderId);
}
return doAction(folderAction);
}
use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class ZMailbox method cancelTask.
public void cancelTask(String id, String component, ZTimeZone tz, ZDateTime instance, CancelRange range, ZOutgoingMessage message) throws ServiceException {
Element req = newRequestElement(MailConstants.CANCEL_TASK_REQUEST);
req.addAttribute(MailConstants.A_ID, id);
req.addAttribute(MailConstants.E_INVITE_COMPONENT, component);
if (tz != null) {
tz.toElement(req);
}
if (instance != null) {
Element instEl = instance.toElement(MailConstants.E_INSTANCE, req);
if (range != null) {
instEl.addAttribute(MailConstants.A_CAL_RANGE, range.name());
}
}
if (message != null) {
getMessageElement(req, message, null);
}
mMessageCache.remove(id);
invoke(req);
}
use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.
the class ZMailbox method handleResponseContext.
private void handleResponseContext(Element context) throws ServiceException {
if (context == null) {
return;
}
// handle refresh blocks
Element refresh = context.getOptionalElement(ZimbraNamespace.E_REFRESH);
if (refresh != null) {
handleRefresh(refresh);
}
for (Element notify : context.listElements(ZimbraNamespace.E_NOTIFY)) {
mTransport.setMaxNotifySeq(Math.max(mTransport.getMaxNotifySeq(), notify.getAttributeLong(HeaderConstants.A_SEQNO, 0)));
// MUST DO IN THIS ORDER!
handleDeleted(notify.getOptionalElement(ZimbraNamespace.E_DELETED));
handleCreated(notify.getOptionalElement(ZimbraNamespace.E_CREATED));
handleModified(notify.getOptionalElement(ZimbraNamespace.E_MODIFIED));
}
}
Aggregations