public User createUser(final String login, final String password, final String email)
     throws NameClashException, MailException {
   try {
     final UserImpl user = new UserImpl(login, password);
     if (email != null) user.setEmail(email);
     entityManager.persist(user);
     if (email != null) MailSender.sendSignupMail(login, password, email);
     return user;
   } catch (EntityExistsException e) {
     throw new NameClashException();
   }
 }
 public void updateEmail(final User user, final String email) {
   ((UserImpl) user).setEmail(email.length() > 0 ? email : null);
   entityManager.merge(user);
 }