Search in sources :

Example 56 with Element

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

the class ZMailbox method autoComplete.

public synchronized List<ZAutoCompleteMatch> autoComplete(String query, int limit) throws ServiceException {
    Element req = newRequestElement(MailConstants.AUTO_COMPLETE_REQUEST);
    req.addAttribute(MailConstants.A_LIMIT, limit);
    req.addAttribute(MailConstants.A_INCLUDE_GAL, getFeatures().getGalAutoComplete());
    req.addUniqueElement(MailConstants.E_NAME).setText(query);
    Element response = invoke(req);
    List<ZAutoCompleteMatch> matches = new ArrayList<ZAutoCompleteMatch>();
    for (Element match : response.listElements(MailConstants.E_MATCH)) {
        matches.add(new ZAutoCompleteMatch(match, this));
    }
    return matches;
}
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)

Example 57 with Element

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

the class ZMailbox method cancelAppointment.

public void cancelAppointment(String id, String component, ZTimeZone tz, ZDateTime instance, CancelRange range, ZOutgoingMessage message) throws ServiceException {
    Element req = newRequestElement(MailConstants.CANCEL_APPOINTMENT_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 58 with Element

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

the class ZMailbox method createIdentity.

public void createIdentity(ZIdentity identity) throws ServiceException {
    Element req = newRequestElement(AccountConstants.CREATE_IDENTITY_REQUEST);
    identity.toElement(req);
    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 59 with Element

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

the class ZMailbox method saveAttachmentsToBriefcase.

public synchronized List<String> saveAttachmentsToBriefcase(String mid, String[] partIds, String folderId) throws ServiceException {
    if (partIds == null || partIds.length <= 0) {
        return null;
    }
    List<String> docIds = new ArrayList<String>();
    for (String pid : partIds) {
        //!TODO We should do batch request for performance
        Element req = newRequestElement(MailConstants.SAVE_DOCUMENT_REQUEST);
        Element doc = req.addElement(MailConstants.E_DOC).addAttribute(MailConstants.A_FOLDER, folderId);
        Element m = doc.addElement(MailConstants.E_MSG).addAttribute(MailConstants.A_ID, mid);
        m.addAttribute(MailConstants.A_PART, pid);
        Element rDoc = invoke(req).getElement(MailConstants.E_DOC);
        if (rDoc == null) {
            continue;
        }
        docIds.add(rDoc.getAttribute(MailConstants.A_ID));
    }
    return docIds;
}
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)

Example 60 with Element

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

the class ZMailbox method createDocument.

public String createDocument(String folderId, String name, String attachmentId, boolean isNote) throws ServiceException {
    Element req = newRequestElement(MailConstants.SAVE_DOCUMENT_REQUEST);
    Element doc = req.addUniqueElement(MailConstants.E_DOC);
    doc.addAttribute(MailConstants.A_NAME, name);
    doc.addAttribute(MailConstants.A_FOLDER, folderId);
    if (isNote) {
        doc.addAttribute(MailConstants.A_FLAGS, ZItem.Flag.note.toString());
    }
    Element upload = doc.addElement(MailConstants.E_UPLOAD);
    upload.addAttribute(MailConstants.A_ID, attachmentId);
    return invoke(req).getElement(MailConstants.E_DOC).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)

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