ValidationContext validationContext = new ValidationContext();
staticPage.validate(validationContext);
if (validationContext.hasErrors()) {
getModel().put("validationContext", validationContext);
return new StaticPageFormView();
} else {
try {
service.putStaticPage(staticPage);
staticPage.getBlog().info("Static page <a href=\"" + staticPage.getLocalPermalink() + "\">" + staticPage.getTitle() + "</a> saved.");
service.unlock(staticPage);
return new RedirectView(staticPage.getLocalPermalink());
} catch (StaticPageServiceException e) {
log.error(e.getMessage(), e);
return new StaticPageFormView();
}
}
}