invokeGetBindingField(user);
}
public boolean save(OrganizationService service) throws Exception {
WebuiRequestContext context = WebuiRequestContext.getCurrentInstance();
UIApplication uiApp = context.getUIApplication();
String username = getUIStringInput(USERNAME).getValue();
User user = service.getUserHandler().findUserByName(username);
if (user == null) {
uiApp.addMessage(new ApplicationMessage("UIAccountInputSet.msg.user-is-deleted", null, ApplicationMessage.WARNING));
UIUserInfo userInfo = getParent();
if (userInfo != null) {
UIAccountEditInputSet accountInput = userInfo.getChild(UIAccountEditInputSet.class);
UIUserProfileInputSet userProfile = userInfo.getChild(UIUserProfileInputSet.class);
userInfo.setRenderSibling(UIListUsers.class);
accountInput.reset();
userProfile.reset();
context.setProcessRender(true);
}
return false;
}
String oldEmail = user.getEmail();
invokeSetBindingField(user);
if (isChangePassword()) {
String pass1x = getUIStringInput(PASSWORD1X).getValue();
String pass2x = getUIStringInput(PASSWORD2X).getValue();
if (!pass1x.equals(pass2x)) {
uiApp.addMessage(new ApplicationMessage("UIAccountForm.msg.password-is-not-match", null,
ApplicationMessage.WARNING));
return false;
}
user.setPassword(pass1x);
}
// Check if mail address is already used
Query query = new Query();
String email = getUIStringInput("email").getValue();
query.setEmail(email);
if (service.getUserHandler().findUsers(query).getAll().size() > 0 && !oldEmail.equals(email)) {
// Be sure it keep old value
user.setEmail(oldEmail);
query.setEmail(oldEmail);
Object[] args = { username };
uiApp.addMessage(new ApplicationMessage("UIAccountInputSet.msg.email-exist", args, ApplicationMessage.WARNING));
return false;
}
try {
service.getUserHandler().saveUser(user, true);
} catch (Exception e) {
uiApp.addMessage(new ApplicationMessage("UIAccountInputSet.msg.fail.update.user", null, ApplicationMessage.ERROR));
return false;
}
enableChangePassword(false);
ConversationState state = ConversationState.getCurrent();