throws ServletException, IOException {
log.debug("Entering");
WebsiteData weblog = null;
WeblogSearchRequest searchRequest = null;
// first off lets parse the incoming request and validate it
try {
searchRequest = new WeblogSearchRequest(request);
// now make sure the specified weblog really exists
UserManager userMgr = RollerFactory.getRoller().getUserManager();
weblog = userMgr.getWebsiteByHandle(searchRequest.getWeblogHandle(), Boolean.TRUE);
} catch(Exception e) {
// invalid search request format or weblog doesn't exist
log.debug("error creating weblog search request", e);
response.sendError(HttpServletResponse.SC_NOT_FOUND);
return;
}
// get their default page template to use for rendering
Template page = null;
try {
page = weblog.getDefaultPage();
if(page == null) {
throw new RollerException("Could not lookup default page "+
"for weblog "+weblog.getHandle());
}
} catch(Exception e) {
log.error("Error getting weblogs default page", e);
}
// set the content type
response.setContentType("text/html; charset=utf-8");
// looks like we need to render content
Map model = new HashMap();
try {
PageContext pageContext = JspFactory.getDefaultFactory().getPageContext(
this, request, response,"", false, 8192, true);
// populate the rendering model
Map initData = new HashMap();
initData.put("request", request);
initData.put("pageContext", pageContext);
// this is a little hacky, but nothing we can do about it
// we need the 'weblogRequest' to be a pageRequest so other models
// are properly loaded, which means that searchRequest needs its
// own custom initData property aside from the standard weblogRequest.
// possible better approach is make searchRequest extend pageRequest.
WeblogPageRequest pageRequest = new WeblogPageRequest();
pageRequest.setWeblogHandle(searchRequest.getWeblogHandle());
pageRequest.setWeblogCategoryName(searchRequest.getWeblogCategoryName());
initData.put("weblogRequest", pageRequest);
initData.put("searchRequest", searchRequest);
// Load models for pages
String searchModels = RollerConfig.getProperty("rendering.searchModels");