/**
*
*/
private void register(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo) throws Exception {
String virtualWikiName = pageInfo.getVirtualWikiName();
WikiUser user = this.setWikiUser(request);
boolean isUpdate = (user.getUserId() != null);
next.addObject("newuser", user);
List<WikiMessage> errors = validate(request, user);
if (!errors.isEmpty()) {
next.addObject("errors", errors);
String oldPassword = request.getParameter("oldPassword");
String newPassword = request.getParameter("newPassword");
String confirmPassword = request.getParameter("confirmPassword");
if (oldPassword != null) {
next.addObject("oldPassword", oldPassword);
}
if (newPassword != null) {
next.addObject("newPassword", newPassword);
}
if (confirmPassword != null) {
next.addObject("confirmPassword", confirmPassword);
}
this.loadDefaults(request, next, pageInfo, user);
} else {
String username = request.getParameter("login");
String newPassword = request.getParameter("newPassword");
String encryptedPassword = null;
if (!StringUtils.isBlank(newPassword)) {
encryptedPassword = Encryption.encrypt(newPassword);
}
WikiBase.getDataHandler().writeWikiUser(user, username, encryptedPassword);
if (!StringUtils.isBlank(newPassword)) {
// login the user
this.login(request, user.getUsername(), newPassword);
}
// update the locale key since the user may have changed default locale
if (!StringUtils.isBlank(user.getDefaultLocale())) {
Locale locale = LocaleUtils.toLocale(user.getDefaultLocale());
request.getSession().setAttribute(SessionLocaleResolver.LOCALE_SESSION_ATTRIBUTE_NAME, locale);
}
if (isUpdate) {
next.addObject("updateMessage", new WikiMessage("register.caption.updatesuccess"));
this.view(request, next, pageInfo);