예제 #1
0
  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());
    }
  }
예제 #2
0
 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());
   }
 }
예제 #3
0
  public User insertUser(User user) throws InsertException {
    try {
      String sha1Password = convertPassword(user.getPassword().getBytes());
      user.setPassword(sha1Password);
    } catch (Exception e) {
      throw new InsertException(e.getMessage());
    }

    User expRet = rep.insertUser(user);
    return expRet;
  }
예제 #4
0
  public User requestAccess(String fullName, String username, String password, String mailAddress)
      throws InsertException {
    User user = new User();
    user.setFullName(fullName);
    user.setLoginName(username);
    user.setPassword(password);
    user.setUserMail(mailAddress);

    try {
      String sha1Password = convertPassword(user.getPassword().getBytes());
      user.setPassword(sha1Password);
      user.setType(UserType.NEW);
      rep.insertUser(user);

      MailService ms = new MailService();
      ms.sendUserRequest(user);

    } catch (Exception e) {
      throw new InsertException(e.getMessage());
    }

    return user;
  }
예제 #5
0
 public void newTransaction() {
   if (!rep.isOpen()) {
     rep.newTransaction();
   }
 }
예제 #6
0
 public User getUser(int idUser) throws NotFoundException {
   return rep.getUser(idUser);
 }
예제 #7
0
 public User login(String loginName, String password) throws Exception {
   String sha1Password = convertPassword(password.getBytes());
   return rep.login(loginName, sha1Password);
 }
예제 #8
0
 public List<User> getList(UserType type) throws NotFoundException {
   return rep.getList(type);
 }
예제 #9
0
 public Set<User> getList() throws NotFoundException {
   return rep.getList();
 }