*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
log.debug("Entering");
PlanetManager planet = PlanetFactory.getPlanet().getPlanetManager();
PlanetRequest planetRequest = null;
try {
planetRequest = new PlanetRequest(request);
} catch (Exception e) {
// some kind of error parsing the request
log.debug("error creating planet request", e);
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
// figure planet last modified date
Date lastModified = planetCache.getLastModified();
// Respond with 304 Not Modified if it is not modified.
if (ModDateHeaderUtil.respondIfNotModified(request, response, lastModified.getTime())) {
return;
}
// set content type
String accepts = request.getHeader("Accept");
String userAgent = request.getHeader("User-Agent");
if (accepts != null && userAgent != null && accepts.indexOf("*/*") != -1 && userAgent.startsWith("Mozilla")) {
// client is a browser and now that we offer styled feeds 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 {
response.setContentType("application/rss+xml; charset=utf-8");
}
// set last-modified date
ModDateHeaderUtil.setLastModifiedHeader(response, lastModified.getTime());
// cached content checking
String cacheKey = PlanetCache.CACHE_ID + ":" + this.generateKey(planetRequest);
CachedContent entry = (CachedContent) planetCache.get(cacheKey);
if (entry != null) {
response.setContentLength(entry.getContent().length);
response.getOutputStream().write(entry.getContent());
return;
}
// looks like we need to render content
@SuppressWarnings("unchecked")
HashMap<String, Object> model = new HashMap();
try {
// populate the rendering model
if (request.getParameter("group") != null) {
Planet planetObject = planet.getPlanet("default");
model.put("group", planet.getGroup(planetObject, request.getParameter("group")));
}
model.put("planet", planet);
model.put("date", new Date());
model.put("utils", new UtilitiesModel());
model.put("siteName", PlanetRuntimeConfig.getProperty("site.name"));