Search in sources :

Example 31 with Element

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

the class ZCalDataSource method toIdElement.

public Element toIdElement(Element parent) {
    Element src = parent.addElement(MailConstants.E_DS_CAL);
    src.addAttribute(MailConstants.A_ID, getId());
    return src;
}
Also used : Element(com.zimbra.common.soap.Element)

Example 32 with Element

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

the class ZCalDataSource method toElement.

public Element toElement(Element parent) {
    Element src = parent.addElement(MailConstants.E_DS_CAL);
    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_FOLDER, data.getFolderId());
    return src;
}
Also used : Element(com.zimbra.common.soap.Element)

Example 33 with Element

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

the class ZMailbox method createDataSource.

/**
     * Creates a data source.
     *
     * @return the new data source id
     */
public String createDataSource(ZDataSource source) throws ServiceException {
    Element req = newRequestElement(MailConstants.CREATE_DATA_SOURCE_REQUEST);
    source.toElement(req);
    return invoke(req).listElements().get(0).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 34 with Element

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

the class ZMailbox method createMountpoint.

/**
     * create a new mountpoint in the specified parent folder.
     *
     * @param parentId parent folder id
     * @param name name of new folder
     * @param defaultView default view of new folder.
     * @param color
     * @param flags
     * @param ownerBy used to specify whether owner is an id or account name (email address)
     * @param owner either the id or name of the owner
     * @param itemBy used to specify whether sharedItem is an id or path to the shared item
     * @param sharedItem either the id or path of the item
     * @param reminderEnabled whether client should show reminders on appointments/tasks
     *
     * @return newly created folder
     * @throws ServiceException on error
     * @param color initial color
     * @param flags initial flags
     */
public ZMountpoint createMountpoint(String parentId, String name, ZFolder.View defaultView, ZFolder.Color color, String flags, OwnerBy ownerBy, String owner, SharedItemBy itemBy, String sharedItem, boolean reminderEnabled) throws ServiceException {
    Element req = newRequestElement(MailConstants.CREATE_MOUNTPOINT_REQUEST);
    Element linkEl = req.addUniqueElement(MailConstants.E_MOUNT);
    linkEl.addAttribute(MailConstants.A_NAME, name);
    linkEl.addAttribute(MailConstants.A_FOLDER, parentId);
    if (defaultView != null) {
        linkEl.addAttribute(MailConstants.A_DEFAULT_VIEW, defaultView.name());
    }
    if (color != null) {
        if (StringUtil.equal(color.getName(), Color.RGBCOLOR)) {
            linkEl.addAttribute(MailConstants.A_RGB, color.getRgbColorValue());
        } else {
            linkEl.addAttribute(MailConstants.A_COLOR, color.getValue());
        }
    }
    if (flags != null) {
        linkEl.addAttribute(MailConstants.A_FLAGS, flags);
    }
    linkEl.addAttribute(ownerBy == OwnerBy.BY_ID ? MailConstants.A_ZIMBRA_ID : MailConstants.A_OWNER_NAME, owner);
    linkEl.addAttribute(itemBy == SharedItemBy.BY_ID ? MailConstants.A_REMOTE_ID : MailConstants.A_PATH, sharedItem);
    linkEl.addAttribute(MailConstants.A_REMINDER, reminderEnabled);
    Element newMountEl = invoke(req).getElement(MailConstants.E_MOUNT);
    ZMountpoint newMount = getMountpointById(newMountEl.getAttribute(MailConstants.A_ID));
    return newMount != null ? newMount : new ZMountpoint(newMountEl, null, this);
}
Also used : JSONElement(com.zimbra.common.soap.Element.JSONElement) Element(com.zimbra.common.soap.Element) XMLElement(com.zimbra.common.soap.Element.XMLElement)

Example 35 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)

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