Blog blog = (Blog)getModel().get(Constants.BLOG_KEY);
String id = request.getParameter("page");
String confirm = request.getParameter("confirm");
String submit = request.getParameter("submit");
StaticPageService service = new StaticPageService();
StaticPage staticPage = null;
try {
staticPage = service.getStaticPageById(blog, id);
} catch (StaticPageServiceException e) {
throw new ServletException(e);
}
if (staticPage == null) {
return new NotFoundView();
}
if (submit.equals("Edit")) {
return new ForwardView("/editStaticPage.secureaction?page=" + id);
} else if (submit.equalsIgnoreCase("Remove") && confirm != null && confirm.equals("true")) {
try {
if (service.lock(staticPage)) {
service.removeStaticPage(staticPage);
blog.info("Static page \"" + staticPage.getTitle() + "\" removed.");
service.unlock(staticPage);
} else {
getModel().put(Constants.STATIC_PAGE_KEY, staticPage);
return new StaticPageLockedView();
}
return new RedirectView(blog.getUrl() + "viewStaticPages.secureaction");
} catch (StaticPageServiceException e) {
throw new ServletException(e);
}
} else if (submit.equalsIgnoreCase("Unlock") && confirm != null && confirm.equals("true")) {
service.unlock(staticPage);
blog.info("Static page <a href=\"" + staticPage.getLocalPermalink() + "\">" + staticPage.getTitle() + "</a> unlocked.");
return new RedirectView(blog.getUrl() + "viewStaticPages.secureaction");
}