Search in sources :

Example 11 with Element

use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.

the class ZMailbox method getMiniCal.

public synchronized ZGetMiniCalResult getMiniCal(long startMsec, long endMsec, String[] folderIds) throws ServiceException {
    Set<String> dates = mApptSummaryCache.getMiniCal(startMsec, endMsec, folderIds);
    List<ZMiniCalError> errors = null;
    if (dates == null) {
        Element req = newRequestElement(MailConstants.GET_MINI_CAL_REQUEST);
        req.addAttribute(MailConstants.A_CAL_START_TIME, startMsec);
        req.addAttribute(MailConstants.A_CAL_END_TIME, endMsec);
        for (String folderId : folderIds) {
            Element folderElem = req.addElement(MailConstants.E_FOLDER);
            folderElem.addAttribute(MailConstants.A_ID, folderId);
        }
        Element resp = invoke(req);
        dates = new HashSet<String>();
        for (Element date : resp.listElements(MailConstants.E_CAL_MINICAL_DATE)) {
            dates.add(date.getTextTrim());
        }
        mApptSummaryCache.putMiniCal(dates, startMsec, endMsec, folderIds);
        for (Element error : resp.listElements(MailConstants.E_ERROR)) {
            String fid = error.getAttribute(MailConstants.A_ID);
            String code = error.getAttribute(MailConstants.A_CAL_CODE);
            String msg = error.getTextTrim();
            if (errors == null) {
                errors = new ArrayList<ZMiniCalError>();
            }
            errors.add(new ZMiniCalError(fid, code, msg));
        }
    }
    return new ZGetMiniCalResult(dates, errors);
}
Also used : JSONElement(com.zimbra.common.soap.Element.JSONElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement)

Example 12 with Element

use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.

the class ZMailbox method addMessage.

/**
     * @param folderId (required) folderId of folder to add message to
     * @param flags non-comma-separated list of flags, e.g. "sf" for "sent by me and flagged",
     *        or <tt>null</tt>
     * @param tags comma-spearated list of tags, or null for no tags, or <tt>null</tt>
     * @param receivedDate time the message was originally received, in MILLISECONDS since the epoch,
     *        or <tt>0</tt> for the current time
     * @param in content stream
     * @param contentLength number of bytes in the content stream
     * @param noICal if TRUE, then don't process iCal attachments.
     * @return ID of newly created message
     * @throws ServiceException on error
     */
public String addMessage(String folderId, String flags, String tags, long receivedDate, InputStream in, long contentLength, boolean noICal) throws ServiceException {
    // first, upload the content via the FileUploadServlet
    String aid = uploadContentAsStream("message", in, "message/rfc822", contentLength, 5000);
    // now, use the returned upload ID to do the message send
    Element req = newRequestElement(MailConstants.ADD_MSG_REQUEST);
    Element m = req.addUniqueElement(MailConstants.E_MSG);
    m.addAttribute(MailConstants.A_FOLDER, folderId);
    if (flags != null && flags.length() > 0) {
        m.addAttribute(MailConstants.A_FLAGS, flags);
    }
    if (tags != null && tags.length() > 0) {
        m.addAttribute(MailConstants.A_TAGS, tags);
    }
    if (receivedDate > 0) {
        m.addAttribute(MailConstants.A_DATE, receivedDate);
    }
    m.addAttribute(MailConstants.A_ATTACHMENT_ID, aid);
    m.addAttribute(MailConstants.A_NO_ICAL, noICal);
    return invoke(req).getElement(MailConstants.E_MSG).getAttribute(MailConstants.A_ID);
}
Also used : JSONElement(com.zimbra.common.soap.Element.JSONElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement)

Example 13 with Element

use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.

the class ZImapDataSource method toElement.

public Element toElement(Element parent) {
    Element src = parent.addElement(MailConstants.E_DS_IMAP);
    src.addAttribute(MailConstants.A_ID, data.getId());
    src.addAttribute(MailConstants.A_NAME, data.getName());
    src.addAttribute(MailConstants.A_DS_IS_ENABLED, data.isEnabled());
    src.addAttribute(MailConstants.A_DS_HOST, data.getHost());
    src.addAttribute(MailConstants.A_DS_PORT, data.getPort());
    src.addAttribute(MailConstants.A_DS_USERNAME, data.getUsername());
    src.addAttribute(MailConstants.A_DS_PASSWORD, data.getPassword());
    src.addAttribute(MailConstants.A_FOLDER, data.getFolderId());
    src.addAttribute(MailConstants.A_DS_CONNECTION_TYPE, data.getConnectionType().name());
    src.addAttribute(MailConstants.A_DS_IS_IMPORTONLY, data.isImportOnly());
    return src;
}
Also used : Element(com.zimbra.common.soap.Element)

Example 14 with Element

use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.

the class ZMailbox method modifySearchFolder.

/**
     * modify a search folder.
     *
     * @param id id of search folder
     * @param query search query or null to leave unchanged.
     * @param types new types or null to leave unchanged.
     * @param sortBy new sortBy or null to leave unchanged
     * @return modified search folder
     * @throws ServiceException on error
     */
public ZSearchFolder modifySearchFolder(String id, String query, String types, SearchSortBy sortBy) throws ServiceException {
    Element req = newRequestElement(MailConstants.MODIFY_SEARCH_FOLDER_REQUEST);
    Element folderEl = req.addUniqueElement(MailConstants.E_SEARCH);
    folderEl.addAttribute(MailConstants.A_ID, id);
    if (query != null) {
        folderEl.addAttribute(MailConstants.A_QUERY, query);
    }
    if (types != null) {
        folderEl.addAttribute(MailConstants.A_SEARCH_TYPES, types);
    }
    if (sortBy != null) {
        folderEl.addAttribute(MailConstants.A_SORTBY, sortBy.name());
    }
    invoke(req);
    // this assumes notifications will modify the search folder
    return getSearchFolderById(id);
}
Also used : JSONElement(com.zimbra.common.soap.Element.JSONElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement)

Example 15 with Element

use of com.zimbra.common.soap.Element in project zm-mailbox by Zimbra.

the class ZMailbox method getDocument.

public ZDocument getDocument(String id) throws ServiceException {
    Element req = newRequestElement(MailConstants.GET_ITEM_REQUEST);
    Element item = req.addUniqueElement(MailConstants.E_ITEM);
    item.addAttribute(MailConstants.A_ID, id);
    Element e = invoke(req).getElement(MailConstants.E_DOC);
    return new ZDocument(e);
}
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