* @param request the HttpServletRequest instance
* @param response the HttpServletResponse instance
* @return the name of the next view
*/
public View process(HttpServletRequest request, HttpServletResponse response) throws ServletException {
Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
String submit = request.getParameter("submit");
if (submit != null && submit.length() > 0) {
String currentTimeZone = blog.getProperty(Blog.TIMEZONE_KEY);
Enumeration params = request.getParameterNames();
while (params.hasMoreElements()) {
String key = (String)params.nextElement();
String value = request.getParameter(key);
if (key.equals("submit")) {
// this is the parameter representing the submit button - do nothing
} else {
// this is an existing parameter - save or remove it
if (value == null || value.length() == 0) {
blog.removeProperty(key);
} else {
blog.setProperty(key, value);
}
}
}
// and now the checkboxes
String name = "richTextEditorForBlogEntriesEnabled";
String checkbox = request.getParameter(name);
if (checkbox == null) {
blog.setProperty(name, "false");
}
name = "richTextEditorForStaticPagesEnabled";
checkbox = request.getParameter(name);
if (checkbox == null) {
blog.setProperty(name, "false");
}
name = "richTextEditorForCommentsEnabled";
checkbox = request.getParameter(name);
if (checkbox == null) {
blog.setProperty(name, "false");
}
name = "gravatarSupportForCommentsEnabled";
checkbox = request.getParameter(name);
if (checkbox == null) {
blog.setProperty(name, "false");
}
try {
blog.storeProperties();
blog.info("Blog properties saved.");
} catch (BlogServiceException e) {
throw new ServletException(e);
}
// if the following properties have changed, reload the blog
// - timezone
String newTimeZone = blog.getProperty(Blog.TIMEZONE_KEY);
if (!currentTimeZone.equals(newTimeZone)) {
return new ForwardView("/reindexBlog.secureaction");
}
}
return new RedirectView(blog.getUrl() + "viewBlogProperties.secureaction");
}