// set to read only for last screen
rf2.setDisplayOnly(true);
regarea.setContent(rf2);
// create user with mandatory fields from registrationform
//FIXME
UserManager um = UserManager.getInstance();
User volatileUser = um.createUser(rf2.getTextElement(UserConstants.FIRSTNAME).getValue(),
rf2.getTextElement(UserConstants.LASTNAME).getValue(), tempKey.getEmailAddress());
// set user configured language
Preferences preferences = volatileUser.getPreferences();
preferences.setLanguage(rf2.getSingleSelectionElement("lang").getSelectedKey());
volatileUser.setPreferences(preferences);
// create an identity with the given username / pwd and the user object
String login = rf2.getTextElement("usr_login").getValue();
String pwd = rf2.getTextElement("pwd1").getValue();
Identity persistedIdentity = rm.createNewUserAndIdentityFromTemporaryKey(login, pwd, volatileUser, tempKey);
if (persistedIdentity == null) {
showError("user.notregistered");
} else {
// update other user properties from form
List<UserPropertyHandler> userPropertyHandlers = um.getUserPropertyHandlersFor(RegistrationForm2.USERPROPERTIES_FORM_IDENTIFYER, false);
User persistedUser = persistedIdentity.getUser();
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
FormElement ui = rf2.getFormElement(userPropertyHandler.getName());
userPropertyHandler.updateUserFromFormElement(persistedUser, ui);
}
// persist changes in db
um.updateUserFromIdentity(persistedIdentity);
// send notification mail to sys admin
String notiEmail = RegistrationModule.getRegistrationNotificationEmail();
if (notiEmail != null) {
rm.sendNewUserNotificationMessage(notiEmail, persistedIdentity);
}