Search in sources :

Example 1 with CalendarCacheManager

use of com.zimbra.cs.mailbox.calendar.cache.CalendarCacheManager in project zm-mailbox by Zimbra.

the class PurgeAccountCalendarCache method handle.

@Override
public Element handle(Element request, Map<String, Object> context) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    // allow only system admin for now
    checkRight(zsc, context, null, AdminRight.PR_SYSTEM_ADMIN_ONLY);
    Provisioning prov = Provisioning.getInstance();
    String id = request.getAttribute(AdminConstants.A_ID);
    Account account = prov.get(AccountBy.id, id, zsc.getAuthToken());
    if (account == null)
        throw AccountServiceException.NO_SUCH_ACCOUNT(id);
    if (!Provisioning.onLocalServer(account))
        throw ServiceException.WRONG_HOST(account.getAttr(Provisioning.A_zimbraMailHost), null);
    CalendarCacheManager calCache = CalendarCacheManager.getInstance();
    ZimbraLog.calendar.info("Purging calendar cache for account " + account.getName());
    Mailbox mbox = MailboxManager.getInstance().getMailboxByAccount(account, false);
    if (mbox != null)
        calCache.purgeMailbox(mbox);
    Element response = zsc.createElement(AdminConstants.PURGE_ACCOUNT_CALENDAR_CACHE_RESPONSE);
    return response;
}
Also used : Account(com.zimbra.cs.account.Account) Mailbox(com.zimbra.cs.mailbox.Mailbox) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) Element(com.zimbra.common.soap.Element) CalendarCacheManager(com.zimbra.cs.mailbox.calendar.cache.CalendarCacheManager) Provisioning(com.zimbra.cs.account.Provisioning)

Aggregations

Element (com.zimbra.common.soap.Element)1 Account (com.zimbra.cs.account.Account)1 Provisioning (com.zimbra.cs.account.Provisioning)1 Mailbox (com.zimbra.cs.mailbox.Mailbox)1 CalendarCacheManager (com.zimbra.cs.mailbox.calendar.cache.CalendarCacheManager)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1