public void updateUser(User user) throws UpdateException { User oldUser; String sha1Password = ""; try { oldUser = rep.getUser(user.getIdUser()); oldUser.setFullName(user.getFullName()); if ((user.getPassword() != null) && (!user.getPassword().equals(""))) { sha1Password = convertPassword(user.getPassword().getBytes()); oldUser.setPassword(sha1Password); } } catch (Exception e) { throw new UpdateException(e.getMessage()); } oldUser.setLoginName(user.getLoginName()); oldUser.setType(user.getType()); oldUser.setUserMail(user.getUserMail()); rep.newTransaction(); rep.updateUser(oldUser); try { MailService ms = new MailService(); ms.notifyUserChange(user); } catch (Exception e) { throw new UpdateException(e.getMessage()); } }
public void deleteUser(int idUser) throws DeleteException { try { User user = rep.getUser(idUser); rep.newTransaction(); rep.deleteUser(user); } catch (NotFoundException e) { logger.error(e.getMessage()); throw new DeleteException(e.getMessage()); } }
public void newTransaction() { if (!rep.isOpen()) { rep.newTransaction(); } }