HttpServletRequest request,
HttpServletResponse response)
throws IOException, ServletException {
ActionForward forward = mapping.findForward("editPages.page");
WeblogTemplateForm form = (WeblogTemplateForm)actionForm;
try {
request.setAttribute("model", new BasePageModel(
"pagesForm.title", request, response, mapping));
RollerRequest rreq = RollerRequest.getRollerRequest(request);
RollerSession rses = RollerSession.getRollerSession(request);
WebsiteData website = rreq.getWebsite();
if ( rses.isUserAuthorizedToAdmin(website) ) {
UserManager mgr = RollerFactory.getRoller().getUserManager();
// first off, check if template already exists
WeblogTemplate existingPage = mgr.getPageByName(website, form.getName());
if(existingPage != null) {
ActionErrors errors = new ActionErrors();
errors.add(null, new ActionError("pagesForm.error.alreadyExists", form.getName()));
saveErrors(request, errors);
addModelObjects(request, response, mapping, website, null);
return forward;
}
WeblogTemplate data = new WeblogTemplate();
form.copyTo(data, request.getLocale());
data.setWebsite(website);
data.setLastModified( new Date() );
data.setDescription(data.getName());
data.setContents(bundle.getString("pageForm.newTemplateContent"));
validateLink( data );