Author: tchemit Date: 2012-08-29 17:28:07 +0200 (Wed, 29 Aug 2012) New Revision: 3667 Url: http://chorem.org/repositories/revision/pollen/3667 Log: can not edit user email for the moemnt (see #796) + fix NPE when user update his account Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/UserService.java trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp Modified: trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/UserService.java =================================================================== --- trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/UserService.java 2012-08-28 20:43:45 UTC (rev 3666) +++ trunk/pollen-services/src/main/java/org/chorem/pollen/services/impl/UserService.java 2012-08-29 15:28:07 UTC (rev 3667) @@ -112,7 +112,7 @@ UserAccount.PROPERTY_PASSWORD, encodedPassword ); user.setTopiaId(userAccount.getTopiaId()); - copyUserAccount(user, userAccount); + copyUserAccount(user, userAccount, true); commitTransaction("Could not create user"); @@ -176,14 +176,17 @@ } // In case of email change, check if an other user has not already - // the new email - // existing user found - if (ObjectUtils.notEqual(user.getEmail(), userToUpdate.getEmail()) + // the new email existing user found + //FIXME-tchemit-2012-08_29 Voir http://chorem.org/issues/796 + String oldEmail = userToUpdate.getEmail(); + if (StringUtils.isNotBlank(user.getEmail()) && + ObjectUtils.notEqual(user.getEmail(), oldEmail) && dao.isUserExist(user)) { throw new UserEmailAlreadyUsedException(); } - copyUserAccount(user, userToUpdate); + //FIXME-tchemit-2012-08_29 Voir http://chorem.org/issues/796 + copyUserAccount(user, userToUpdate, false); commitTransaction("Could not update user"); return userToUpdate; @@ -254,7 +257,7 @@ } dao.delete(user); - commitTransaction("Could not delete user "+id); + commitTransaction("Could not delete user " + id); } catch (TopiaException e) { throw new PollenTechnicalException(e); } @@ -324,7 +327,8 @@ * @see Binder#copy(Object, Object, String...) */ protected void copyUserAccount(UserAccount source, - UserAccount destination) { + UserAccount destination, + boolean copyEmail) { TopiaEntityBinder<UserAccount> binder = PollenBinderHelper.getSimpleTopiaBinder(UserAccount.class); @@ -334,8 +338,10 @@ UserAccount.PROPERTY_FIRST_NAME, UserAccount.PROPERTY_LAST_NAME); - // Don't keep case for email - destination.setEmail(StringUtils.lowerCase(source.getEmail())); + if (copyEmail) { + // Don't keep case for email + destination.setEmail(StringUtils.lowerCase(source.getEmail())); + } } } Modified: trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp =================================================================== --- trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp 2012-08-28 20:43:45 UTC (rev 3666) +++ trunk/pollen-ui-struts2/src/main/webapp/WEB-INF/jsp/admin/usersList.jsp 2012-08-29 15:28:07 UTC (rev 3667) @@ -116,7 +116,7 @@ <s:textfield key="editUser.login" label="%{getText('pollen.common.login')}" required="true" readonly="true" size="40"/> <s:textfield key="editUser.email" label="%{getText('pollen.common.email')}" - required="true" size="40" disabled="%{exists}"/> + required="true" size="40" disabled="true"/> <s:textfield key="editUser.firstName" label="%{getText('pollen.common.firstName')}" size="40"/> <s:textfield key="editUser.lastName"