Search in sources :

Example 36 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 37 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 38 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 39 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)

Example 40 with Element

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

the class ZMailbox method autoCompleteGal.

public ZSearchGalResult autoCompleteGal(String query, GalEntryType type, int limit) throws ServiceException {
    Element req = newRequestElement(AccountConstants.AUTO_COMPLETE_GAL_REQUEST);
    if (type != null) {
        req.addAttribute(AccountConstants.A_TYPE, type.name());
    }
    req.addAttribute(AccountConstants.A_LIMIT, limit);
    req.addElement(AccountConstants.E_NAME).setText(query);
    Element resp = invoke(req);
    List<ZContact> contacts = new ArrayList<ZContact>();
    for (Element contact : resp.listElements(MailConstants.E_CONTACT)) {
        contacts.add(new ZContact(contact, true, this));
    }
    return new ZSearchGalResult(contacts, resp.getAttributeBool(AccountConstants.A_MORE, false), query, type);
}
Also used : JSONElement(com.zimbra.common.soap.Element.JSONElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement) ArrayList(java.util.ArrayList)

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