예제 #1
0
 @Override
 public User getUser(MessageManager message, String email) throws LogicException {
   try {
     User user = userDao.findByEmail(email);
     if (user == null) {
       message.addMessage(MSG_LOGIN);
       throw new LogicException("Getting user failed");
     }
     return user;
   } catch (DatabaseException e) {
     message.addMessage(MSG_LOGIN);
     throw new LogicException("Getting user failed", e);
   }
 }
예제 #2
0
 @Override
 public String execute(HttpServletRequest request) {
   MessageManager message = new MessageManager();
   IService<User> userService = null;
   try {
     userService = UserService.getInstance();
   } catch (LogicException e) {
     LOG.error("User to edit action failed", e);
     return getForwardError();
   }
   String idString = request.getParameter(PARAM_USER_ID);
   if (idValidator.isValid(idString)) {
     try {
       long id = Long.valueOf(idString);
       User user = userService.get(id, message);
       request.setAttribute(PARAM_USER_GET, user);
     } catch (LogicException e) {
       LOG.error("User finding failed", e);
     }
   } else {
     message.addMessage(idValidator.getMessage());
   }
   setMessages(request, message);
   String forward = resources.getString(JSP_USER_EDIT);
   return forward;
 }
예제 #3
0
 @Override
 public boolean checkPasswords(MessageManager message, User user, int password) {
   if (user.getPassword() == password) {
     return true;
   }
   message.addMessage(MSG_PASSWORD);
   return false;
 }
예제 #4
0
 @Override
 public boolean checkPasswords(MessageManager message, String password, String confirmPassword) {
   if (password.equals(confirmPassword)) {
     return true;
   }
   message.addMessage(MSG_MATCH);
   return false;
 }
예제 #5
0
 @Override
 public boolean register(MessageManager message, User user) {
   if (user == null) {
     LOG.warn("User is null");
     return false;
   }
   if (isRegistered(user.getEmail())) {
     message.addMessage(MSG_EMAIL);
     return false;
   }
   try {
     userDao.save(user);
   } catch (DatabaseException e) {
     LOG.error("Register failed", e);
     message.addMessage(MSG_REGISTER);
     return false;
   }
   return true;
 }
예제 #6
0
 @Override
 public boolean login(MessageManager message, User user) {
   if (user == null) {
     LOG.warn("User is null");
     return false;
   }
   int password = user.getPassword();
   try {
     user = userDao.findByEmail(user.getEmail());
     if (user == null || user.getPassword() != password) {
       message.addMessage(MSG_ICORRECT);
       return false;
     }
   } catch (DatabaseException e) {
     LOG.error("Login failed", e);
     message.addMessage(MSG_LOGIN);
     return false;
   }
   return true;
 }
예제 #7
0
 @Override
 public boolean edit(MessageManager message, User user) {
   if (user == null) {
     LOG.warn("User is null");
     return false;
   }
   try {
     userDao.update(user);
   } catch (DatabaseException e) {
     LOG.error("Profile editing failed", e);
     message.addMessage(MSG_EDIT);
     return false;
   }
   return true;
 }