Search in sources :

Example 11 with ZJSONObject

use of com.zimbra.client.ZJSONObject in project zm-mailbox by Zimbra.

the class ZCreateMessageEvent method toZJSONObject.

public ZJSONObject toZJSONObject() throws JSONException {
    try {
        ZJSONObject zjo = new ZJSONObject();
        zjo.put("id", getId());
        if (getFolderId(null) != null)
            zjo.put("folderId", getFolderId(null));
        if (getConversationId(null) != null)
            zjo.put("conversationId", getConversationId(null));
        if (getFlags(null) != null)
            zjo.put("flags", getFlags(null));
        if (getTagIds(null) != null)
            zjo.put("tags", getTagIds(null));
        if (getSubject(null) != null)
            zjo.put("subject", getSubject(null));
        if (getFragment(null) != null)
            zjo.put("fragment", getFragment(null));
        if (getSize(-1) != -1)
            zjo.put("size", getSize(-1));
        if (getReceivedDate(-1) != -1)
            zjo.put("receivedDate", getReceivedDate(-1));
        if (getSentDate(-1) != -1)
            zjo.put("sentDate", getSentDate(-1));
        List<ZEmailAddress> addrs = getEmailAddresses(null);
        if (addrs != null)
            zjo.put("addresses", addrs);
        return zjo;
    } catch (ServiceException se) {
        throw new JSONException(se);
    }
}
Also used : ZEmailAddress(com.zimbra.client.ZEmailAddress) ServiceException(com.zimbra.common.service.ServiceException) ZJSONObject(com.zimbra.client.ZJSONObject) ToZJSONObject(com.zimbra.client.ToZJSONObject) JSONException(org.json.JSONException)

Aggregations

ToZJSONObject (com.zimbra.client.ToZJSONObject)11 ZJSONObject (com.zimbra.client.ZJSONObject)11 ServiceException (com.zimbra.common.service.ServiceException)8 JSONException (org.json.JSONException)7 ZEmailAddress (com.zimbra.client.ZEmailAddress)2 ZGrant (com.zimbra.client.ZGrant)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1