}
String key = this.CACHE_ID+":"+this.generateKey(feedRequest);
try {
ResponseContent respContent = null;
long lastExpiration = 0;
// first, we need to determine the last time the specified feed was expired.
// if this is a weblog specific feed then ask the CacheManager for
// the last expired time of the weblog. otherwise this is a main feed and we
// keep that last expired time ourselves
if(feedRequest.getWeblogHandle() != null) {
Date lastExpirationDate =
(Date) CacheManager.getLastExpiredDate(feedRequest.getWeblogHandle());
if(lastExpirationDate != null)
lastExpiration = lastExpirationDate.getTime();
} else {
lastExpiration = this.mainLastExpiredDate.getTime();
}
LazyExpiringCacheEntry entry =
(LazyExpiringCacheEntry) this.mCache.get(key);
if(entry != null) {
respContent = (ResponseContent) entry.getValue(lastExpiration);
if(respContent == null)
mLogger.debug("HIT-INVALID "+key);
}
if (respContent == null) {
mLogger.debug("MISS "+key);
this.misses++;
CacheHttpServletResponseWrapper cacheResponse =
new CacheHttpServletResponseWrapper(response);
chain.doFilter(request, cacheResponse);
cacheResponse.flushBuffer();
// only cache if there wasn't an exception
if (request.getAttribute("DisplayException") == null) {
ResponseContent rc = cacheResponse.getContent();
this.mCache.put(key, new LazyExpiringCacheEntry(rc));
} else {
// it is expected that whoever caught this display exception
// is the one who reported it to the logs