Site site = getSite(request);
if (site == null)
throw new WebApplicationException(Status.SERVICE_UNAVAILABLE);
// Get the site's cache
CacheConfiguration cache = getCache(site);
if (cache == null)
throw new WebApplicationException(Status.SERVICE_UNAVAILABLE);
// Clear the cache
try {
Dictionary<Object, Object> properties = cache.getProperties();
properties.put(CacheServiceImpl.OPT_CLEAR, "true");
// Tell the configuration admin service to update the service
cache.getConfiguration().update(properties);
properties.remove(CacheServiceImpl.OPT_CLEAR);
cache.getConfiguration().update(properties);
} catch (Throwable t) {
logger.error("Error updating cache '{}': {}", site.getIdentifier(), t.getMessage());
throw new WebApplicationException();
}