public Template handleRequest( HttpServletRequest request,
HttpServletResponse response,
Context ctx )
throws Exception {
Theme previewTheme = null;
// try getting the preview theme
String themeName = request.getParameter("theme");
if (themeName != null) {
try {
Roller roller = RollerFactory.getRoller();
ThemeManager themeMgr = roller.getThemeManager();
previewTheme = themeMgr.getTheme(themeName);
} catch(ThemeNotFoundException tnfe) {
// bogus theme specified ... don't worry about it
// possibly "custom", but we'll handle that below
} catch(RollerException re) {
response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
request.setAttribute("DisplayException", re);
mLogger.error("EXCEPTION: in RollerServlet", re);
}
}
if((previewTheme == null || !previewTheme.isEnabled()) &&
!themeName.equals(Theme.CUSTOM)) {
// if we don't have a valid preview theme then
// leave it up to our parent
return super.handleRequest(request, response, ctx);
}
Template outty = null;
RollerRequest rreq = null;
// first off lets parse the incoming request and validate it
try {
PageContext pageContext =
JspFactory.getDefaultFactory().getPageContext(
this, request, response,"", true, 8192, true);
rreq = RollerRequest.getRollerRequest(pageContext);
} catch (RollerException e) {
// An error initializing the request is considered to be a 404
response.sendError(HttpServletResponse.SC_NOT_FOUND);
request.setAttribute("DisplayException", e);
return null;
}
// request appears to be valid, lets render
try {
UserManager userMgr = RollerFactory.getRoller().getUserManager();
WebsiteData website = null;
if (request.getAttribute(RollerRequest.OWNING_WEBSITE) != null)
{
UserData user = (UserData)
request.getAttribute(RollerRequest.OWNING_WEBSITE);
}
else
{
website = rreq.getWebsite();
}
// construct a temporary Website object for this request
// and set the EditorTheme to our previewTheme
WebsiteData tmpWebsite = new WebsiteData();
tmpWebsite.setData(website);
if(previewTheme != null)
tmpWebsite.setEditorTheme(previewTheme.getName());
else
tmpWebsite.setEditorTheme(Theme.CUSTOM);
org.apache.roller.pojos.Template page = null;