Search in sources :

Example 6 with ToZJSONObject

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

the class ZModifyMessageEvent method toZJSONObject.

public ZJSONObject toZJSONObject() throws JSONException {
    try {
        ZJSONObject zjo = new ZJSONObject();
        zjo.put("id", getId());
        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 (getFolderId(null) != null)
            zjo.put("folderId", getFolderId(null));
        return zjo;
    } catch (ServiceException se) {
        throw new JSONException(se);
    }
}
Also used : ServiceException(com.zimbra.common.service.ServiceException) ZJSONObject(com.zimbra.client.ZJSONObject) ToZJSONObject(com.zimbra.client.ToZJSONObject) JSONException(org.json.JSONException)

Example 7 with ToZJSONObject

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

the class ZModifyTagEvent method toZJSONObject.

public ZJSONObject toZJSONObject() throws JSONException {
    try {
        ZJSONObject zjo = new ZJSONObject();
        zjo.put("id", getId());
        String name = getName(null);
        if (name != null)
            zjo.put("name", name);
        if (getColor(null) != null)
            zjo.put("color", getColor(null).name());
        if (getUnreadCount(-1) != -1)
            zjo.put("unreadCount", getUnreadCount(-1));
        return zjo;
    } catch (ServiceException se) {
        throw new JSONException(se);
    }
}
Also used : ServiceException(com.zimbra.common.service.ServiceException) ZJSONObject(com.zimbra.client.ZJSONObject) ToZJSONObject(com.zimbra.client.ToZJSONObject) JSONException(org.json.JSONException)

Example 8 with ToZJSONObject

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

the class ZRefreshEvent method toZJSONObject.

public ZJSONObject toZJSONObject() throws JSONException {
    ZJSONObject zjo = new ZJSONObject();
    zjo.put("size", getSize());
    zjo.put("userRoot", mUserRoot);
    zjo.put("tags", mTags);
    return zjo;
}
Also used : ZJSONObject(com.zimbra.client.ZJSONObject) ToZJSONObject(com.zimbra.client.ToZJSONObject)

Example 9 with ToZJSONObject

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

the class ZContactEvent method toZJSONObject.

public ZJSONObject toZJSONObject() throws JSONException {
    ZJSONObject zjo = new ZJSONObject();
    try {
        zjo.put("id", getId());
        if (getFlags(null) != null)
            zjo.put("flags", getFlags(null));
        if (getTagIds(null) != null)
            zjo.put("tags", getTagIds(null));
        if (getFolderId(null) != null)
            zjo.put("folderId", getFolderId(null));
        if (getRevision(null) != null)
            zjo.put("revision", getRevision(null));
        if (getFileAsStr(null) != null)
            zjo.put("fileAsStr", getFileAsStr(null));
        if (getEmail(null) != null)
            zjo.put("email", getEmail(null));
        if (getEmail2(null) != null)
            zjo.put("email2", getEmail2(null));
        if (getEmail3(null) != null)
            zjo.put("email3", getEmail3(null));
        Map<String, String> attrs = getAttrs(null);
        if (attrs != null)
            zjo.putMap("attrs", attrs);
    } catch (ServiceException e) {
        throw new RuntimeException(e);
    }
    return zjo;
}
Also used : ServiceException(com.zimbra.common.service.ServiceException) ZJSONObject(com.zimbra.client.ZJSONObject) ToZJSONObject(com.zimbra.client.ToZJSONObject)

Example 10 with ToZJSONObject

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

the class ZConversationSummaryEvent method toZJSONObject.

public ZJSONObject toZJSONObject() throws JSONException {
    try {
        ZJSONObject zjo = new ZJSONObject();
        zjo.put("id", getId());
        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 (getMessageCount(-1) != -1)
            zjo.put("messageCount", getMessageCount(-1));
        if (getDate(-1) != -1)
            zjo.put("date", getDate(-1));
        List<ZEmailAddress> addrs = getRecipients(null);
        if (addrs != null)
            zjo.put("recipients", 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