Search in sources :

Example 61 with Element

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);
}
Also used : JSONElement(com.zimbra.common.soap.Element.JSONElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement)

Example 62 with Element

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);
}
Also used : JSONElement(com.zimbra.common.soap.Element.JSONElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement)

Example 63 with Element

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);
}
Also used : JSONElement(com.zimbra.common.soap.Element.JSONElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement)

Example 64 with Element

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);
}
Also used : JSONElement(com.zimbra.common.soap.Element.JSONElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement)

Example 65 with Element

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));
    }
}
Also used : JSONElement(com.zimbra.common.soap.Element.JSONElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement)

Aggregations

Element (com.zimbra.common.soap.Element)980 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)315 XMLElement (com.zimbra.common.soap.Element.XMLElement)269 Account (com.zimbra.cs.account.Account)220 Test (org.junit.Test)175 JSONElement (com.zimbra.common.soap.Element.JSONElement)167 Provisioning (com.zimbra.cs.account.Provisioning)147 Mailbox (com.zimbra.cs.mailbox.Mailbox)138 ServiceException (com.zimbra.common.service.ServiceException)103 ItemId (com.zimbra.cs.service.util.ItemId)81 ArrayList (java.util.ArrayList)81 OperationContext (com.zimbra.cs.mailbox.OperationContext)80 HashMap (java.util.HashMap)77 ItemIdFormatter (com.zimbra.cs.service.util.ItemIdFormatter)56 SoapHttpTransport (com.zimbra.common.soap.SoapHttpTransport)54 Server (com.zimbra.cs.account.Server)49 FilterTest (com.zimbra.soap.mail.type.FilterTest)46 IOException (java.io.IOException)45 XmlAnyElement (javax.xml.bind.annotation.XmlAnyElement)44 XmlElement (javax.xml.bind.annotation.XmlElement)44