if(weblogs == null) {
return;
}
// we are working on the feed cache
WeblogFeedCache feedCache = WeblogFeedCache.getInstance();
long start = System.currentTimeMillis();
Iterator allWeblogs = weblogs.iterator();
String weblogHandle = null;
while(allWeblogs.hasNext()) {
weblogHandle = (String) allWeblogs.next();
log.debug("doing weblog "+weblogHandle);
try {
// we need a feed request to represent the data
WeblogFeedRequest feedRequest = new WeblogFeedRequest();
feedRequest.setWeblogHandle(weblogHandle);
feedRequest.setType(type);
feedRequest.setFormat(format);
// populate the rendering model
HashMap model = new HashMap();
Map initData = new HashMap();
initData.put("request", null);
initData.put("feedRequest", feedRequest);
initData.put("weblogRequest", feedRequest);
// Load models for feeds
String feedModels = RollerConfig.getProperty("rendering.feedModels");
ModelLoader.loadModels(feedModels, model, initData, true);
// TODO: re-enable custom models when they are actually used
// Load weblog custom models
//ModelLoader.loadCustomModels(weblog, model, initData);
// lookup Renderer we are going to use
Renderer renderer = null;
Template template = new StaticTemplate("templates/feeds/weblog-"+type+"-"+format+".vm", null, "velocity");
renderer = RendererManager.getRenderer(template);
// render content. use default size of about 24K for a standard page
CachedContent rendererOutput = new CachedContent(24567);
renderer.render(model, rendererOutput.getCachedWriter());
// flush rendered output and close
rendererOutput.flush();
rendererOutput.close();
// now just put it in the cache
String key = feedCache.generateKey(feedRequest);
feedCache.put(key, rendererOutput);
} catch(Exception e) {
// bummer, error during rendering
log.error("Error rendering for weblog "+weblogHandle, e);
}