Search in sources :

Example 56 with CalendarItem

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;
}
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

CalendarItem (com.zimbra.cs.mailbox.CalendarItem)56 Mailbox (com.zimbra.cs.mailbox.Mailbox)36 Element (com.zimbra.common.soap.Element)27 OperationContext (com.zimbra.cs.mailbox.OperationContext)24 Invite (com.zimbra.cs.mailbox.calendar.Invite)23 ItemId (com.zimbra.cs.service.util.ItemId)22 Account (com.zimbra.cs.account.Account)19 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)17 ServiceException (com.zimbra.common.service.ServiceException)15 MailItem (com.zimbra.cs.mailbox.MailItem)14 MailServiceException (com.zimbra.cs.mailbox.MailServiceException)13 Message (com.zimbra.cs.mailbox.Message)12 ItemIdFormatter (com.zimbra.cs.service.util.ItemIdFormatter)11 Folder (com.zimbra.cs.mailbox.Folder)9 RecurId (com.zimbra.cs.mailbox.calendar.RecurId)9 Appointment (com.zimbra.cs.mailbox.Appointment)8 ArrayList (java.util.ArrayList)8 MimeMessage (javax.mail.internet.MimeMessage)8 ParsedDateTime (com.zimbra.common.calendar.ParsedDateTime)7 TimeZoneMap (com.zimbra.common.calendar.TimeZoneMap)5