mLogger.debug("entering");
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
WeblogFeedRequest feedRequest = null;
try {
feedRequest = new WeblogFeedRequest(request);
} catch(Exception e) {
mLogger.error("error creating feed request", e);
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
String key = this.CACHE_ID+":"+this.generateKey(feedRequest);
Date updateTime = null;
try {
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) {
updateTime = (Date) entry.getValue(lastExpiration);
if(updateTime == null)
mLogger.debug("HIT-INVALID "+key);
}
if (updateTime == null) {
mLogger.debug("MISS "+key);
if(feedRequest.getWeblogHandle() != null) {
Roller roller = RollerFactory.getRoller();
UserManager umgr = roller.getUserManager();
WeblogManager wmgr = roller.getWeblogManager();
updateTime = wmgr.getWeblogLastPublishTime(
umgr.getWebsiteByHandle(feedRequest.getWeblogHandle()),
feedRequest.getWeblogCategory());
this.mCache.put(key, new LazyExpiringCacheEntry(updateTime));
} else {
this.mCache.put(key, new LazyExpiringCacheEntry(new Date()));