use of com.zimbra.client.ZJSONObject in project zm-mailbox by Zimbra.
the class ZCreateAppointmentEvent method toZJSONObject.
public ZJSONObject toZJSONObject() throws JSONException {
try {
ZJSONObject zjo = new ZJSONObject();
zjo.put("id", getId());
return zjo;
} catch (ServiceException se) {
throw new JSONException(se);
}
}
use of com.zimbra.client.ZJSONObject in project zm-mailbox by Zimbra.
the class ZDeleteEvent method toZJSONObject.
public ZJSONObject toZJSONObject() throws JSONException {
ZJSONObject zjo = new ZJSONObject();
zjo.putList("ids", mList);
return zjo;
}
use of com.zimbra.client.ZJSONObject in project zm-mailbox by Zimbra.
the class ZModifyAppointmentEvent method toZJSONObject.
public ZJSONObject toZJSONObject() throws JSONException {
try {
ZJSONObject zjo = new ZJSONObject();
zjo.put("id", getId());
return zjo;
} catch (ServiceException e) {
throw new JSONException(e);
}
}
use of com.zimbra.client.ZJSONObject in project zm-mailbox by Zimbra.
the class Entry method toZJSONObject.
public ZJSONObject toZJSONObject(String filter, boolean applyDefaults) throws JSONException {
Map<String, Object> attrs = getAttrs(applyDefaults);
if (this instanceof NamedEntry) {
NamedEntry ne = (NamedEntry) this;
attrs.put("id", ne.getId());
attrs.put("name", ne.getName());
}
Pattern pattern = null;
if (filter != null) {
Matcher rm = regex.matcher(filter);
if (rm.matches())
pattern = Pattern.compile(rm.group(1), "i".equals(rm.group(2)) ? Pattern.CASE_INSENSITIVE : 0);
else
filter = filter.toLowerCase();
}
ZJSONObject zj = new ZJSONObject();
for (Map.Entry<String, Object> entry : attrs.entrySet()) {
if (pattern != null) {
if (!pattern.matcher(entry.getKey()).find())
continue;
} else if (filter != null) {
if (!entry.getKey().toLowerCase().contains(filter))
continue;
}
Object o = entry.getValue();
if (o instanceof String) {
zj.put(entry.getKey(), (String) o);
} else if (o instanceof String[]) {
zj.put(entry.getKey(), (String[]) o);
}
}
return zj;
}
use of com.zimbra.client.ZJSONObject in project zm-mailbox by Zimbra.
the class ZModifyFolderEvent method toZJSONObject.
public ZJSONObject toZJSONObject() throws JSONException {
try {
ZJSONObject zjo = new ZJSONObject();
zjo.put("id", getId());
if (getName(null) != null)
zjo.put("name", getName(null));
if (getParentId(null) != null)
zjo.put("parentId", getParentId(null));
if (getFlags(null) != null)
zjo.put("flags", getFlags(null));
if (getColor(null) != null)
zjo.put("color", getColor(null).getName());
if (getUnreadCount(-1) != -1)
zjo.put("unreadCount", getUnreadCount(-1));
if (getImapUnreadCount(-1) != -1)
zjo.put("imapUnreadCount", getImapUnreadCount(-1));
if (getMessageCount(-1) != -1)
zjo.put("messageCount", getMessageCount(-1));
if (getImapMessageCount(-1) != -1)
zjo.put("imapMessageCount", getImapMessageCount(-1));
if (getDefaultView(null) != null)
zjo.put("view", getDefaultView(null).name());
if (getImapUIDNEXT(-1) != -1)
zjo.put("imapUIDNEXT", getImapUIDNEXT(-1));
if (getImapMODSEQ(-1) != -1)
zjo.put("imapMODSEQ", getImapMODSEQ(-1));
if (getRemoteURL(null) != null)
zjo.put("url", getRemoteURL(null));
zjo.put("activeSyncDisabled", isActiveSyncDisabled(false));
if (getEffectivePerm(null) != null)
zjo.put("effectivePermissions", getEffectivePerm(null));
List<ZGrant> grants = getGrants(null);
if (grants != null)
zjo.put("grants", grants);
return zjo;
} catch (ServiceException se) {
throw new JSONException(se);
}
}
Aggregations