Search in sources :

Example 1 with CacheExtension

use of com.zimbra.cs.account.CacheExtension in project zm-mailbox by Zimbra.

the class FlushCache method doFlushCache.

public static void doFlushCache(AdminDocumentHandler handler, Map<String, Object> context, FlushCacheRequest req) throws ServiceException {
    ZimbraSoapContext zsc = getZimbraSoapContext(context);
    Server localServer = Provisioning.getInstance().getLocalServer();
    handler.checkRight(zsc, context, localServer, Admin.R_flushCache);
    CacheSelector cacheSelector = req.getCache();
    boolean allServers = cacheSelector.isAllServers();
    boolean imapServers = cacheSelector.isIncludeImapServers();
    String[] types = cacheSelector.getTypes().split(",");
    for (String type : types) {
        CacheEntryType cacheType = null;
        try {
            cacheType = CacheEntryType.fromString(type);
            doFlush(context, cacheType, cacheSelector);
        } catch (ServiceException e) {
            if (cacheType == null) {
                // see if it is a registered extension
                CacheExtension ce = CacheExtension.getHandler(type);
                if (ce != null) {
                    ce.flushCache();
                } else {
                    throw e;
                }
            } else {
                throw e;
            }
        }
    }
    if (imapServers) {
        flushCacheOnImapDaemons(req, zsc);
    }
    if (allServers) {
        flushCacheOnAllServers(zsc, req);
    }
}
Also used : CacheSelector(com.zimbra.soap.admin.type.CacheSelector) Server(com.zimbra.cs.account.Server) ServiceException(com.zimbra.common.service.ServiceException) ZimbraSoapContext(com.zimbra.soap.ZimbraSoapContext) CacheExtension(com.zimbra.cs.account.CacheExtension) CacheEntryType(com.zimbra.soap.admin.type.CacheEntryType)

Aggregations

ServiceException (com.zimbra.common.service.ServiceException)1 CacheExtension (com.zimbra.cs.account.CacheExtension)1 Server (com.zimbra.cs.account.Server)1 ZimbraSoapContext (com.zimbra.soap.ZimbraSoapContext)1 CacheEntryType (com.zimbra.soap.admin.type.CacheEntryType)1 CacheSelector (com.zimbra.soap.admin.type.CacheSelector)1