use of com.zimbra.cs.mailbox.CalendarItem in project zm-mailbox by Zimbra.
the class GetCalendarItem method handle.
@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
ZimbraSoapContext zsc = getZimbraSoapContext(context);
Mailbox mbox = getRequestedMailbox(zsc);
OperationContext octxt = getOperationContext(zsc, context);
ItemIdFormatter ifmt = new ItemIdFormatter(zsc);
GetCalendarItemRequestBase req = zsc.elementToJaxb(request);
boolean sync = req.getSync() == null ? false : req.getSync();
boolean includeContent = req.getIncludeContent() == null ? false : req.getIncludeContent();
boolean includeInvites = req.getIncludeInvites() == null ? true : req.getIncludeInvites();
ItemId iid = null;
String uid = req.getUid();
String id = req.getId();
if (uid != null) {
if (id != null) {
throw ServiceException.INVALID_REQUEST("either id or uid should be specified, but not both", null);
}
LOG.info("<GetCalendarItem uid=" + uid + "> " + zsc);
} else {
iid = new ItemId(id, zsc);
LOG.info("<GetCalendarItem id=" + iid.getId() + "> " + zsc);
}
// want to return modified date only on sync-related requests
int fields = ToXML.NOTIFY_FIELDS;
if (sync) {
fields |= Change.CONFLICT;
}
Element response = getResponseElement(zsc);
CalendarItem calItem = null;
mbox.lock.lock(false);
try {
if (uid != null) {
calItem = mbox.getCalendarItemByUid(octxt, uid);
if (calItem == null) {
throw MailServiceException.NO_SUCH_CALITEM(uid);
}
} else {
calItem = mbox.getCalendarItemById(octxt, iid);
if (calItem == null) {
throw MailServiceException.NO_SUCH_CALITEM(iid.toString());
}
}
} finally {
mbox.lock.release();
}
ToXML.encodeCalendarItemSummary(response, ifmt, octxt, calItem, fields, includeInvites, includeContent);
return response;
}
Aggregations