Search in sources :

Example 1 with GetCalendarItemRequestBase

use of com.zimbra.soap.mail.type.GetCalendarItemRequestBase 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;
}
Also used : OperationContext(com.zimbra.cs.mailbox.OperationContext) GetCalendarItemRequestBase(com.zimbra.soap.mail.type.GetCalendarItemRequestBase) CalendarItem(com.zimbra.cs.mailbox.CalendarItem) Mailbox(com.zimbra.cs.mailbox.Mailbox) ItemIdFormatter(com.zimbra.cs.service.util.ItemIdFormatter) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) ItemId(com.zimbra.cs.service.util.ItemId)

Aggregations

Element (com.zimbra.common.soap.Element)1 CalendarItem (com.zimbra.cs.mailbox.CalendarItem)1 Mailbox (com.zimbra.cs.mailbox.Mailbox)1 OperationContext (com.zimbra.cs.mailbox.OperationContext)1 ItemId (com.zimbra.cs.service.util.ItemId)1 ItemIdFormatter (com.zimbra.cs.service.util.ItemIdFormatter)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1 GetCalendarItemRequestBase (com.zimbra.soap.mail.type.GetCalendarItemRequestBase)1