log.debug("Entering");
Planet planet = null;
PlanetGroup group = null;
PlanetGroupFeedRequest feedRequest = null;
try {
// parse the incoming request and extract the relevant data
feedRequest = new PlanetGroupFeedRequest(request);
planet = feedRequest.getPlanet();
if(planet == null) {
throw new PlanetException("unable to lookup planet: "+
feedRequest.getPlanetHandle());
}
group = feedRequest.getGroup();
if(group == null) {
throw new PlanetException("unable to lookup group: "+
feedRequest.getGroupHandle());
}
} catch(Exception e) {
// invalid feed request format or weblog doesn't exist
log.debug("error creating weblog feed request", e);
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
// set content type
String accepts = request.getHeader("Accept");
String userAgent = request.getHeader("User-Agent");
if (accepts != null && accepts.indexOf("*/*") != -1 &&
userAgent != null && userAgent.startsWith("Mozilla")) {
// client is a browser and feed style is enabled so we want
// browsers to load the page rather than popping up the download
// dialog, so we provide a content-type that browsers will display
response.setContentType("text/xml");
} else if("rss".equals(feedRequest.getFormat())) {
response.setContentType("application/rss+xml; charset=utf-8");
} else if("atom".equals(feedRequest.getFormat())) {
response.setContentType("application/atom+xml; charset=utf-8");
}
// looks like we need to render content
HashMap model = new HashMap();
try {
// populate the rendering model
Map initData = new HashMap();
initData.put("planetRequest", feedRequest);
// Load models for feeds
String feedModels = PlanetConfig.getProperty("rendering.feedModels");
ModelLoader.loadModels(feedModels, model, initData, true);
} catch (PlanetException ex) {
log.error("ERROR loading model for page", ex);
if(!response.isCommitted()) response.reset();
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
return;
}
// lookup Renderer we are going to use
Renderer renderer = null;
try {
log.debug("Looking up renderer");
String templateFile = null;
if("rss".equals(feedRequest.getFormat())) {
templateFile = "group-rss.vm";
} else if("atom".equals(feedRequest.getFormat())) {
templateFile = "group-atom.vm";
}
Template template = new StaticTemplate(templateFile, null, "velocity");
renderer = RendererManager.getRenderer(template);