Package by.bsuir.hypermarket.entity

Examples of by.bsuir.hypermarket.entity.User


  @Override
  public String getParameter(String param) {
    HttpSession session = super.getSession(false);
    String command = super.getParameter("command");
    if (session != null) {
      User user = (User) session.getAttribute("user");
      if ((user == null) && (!"login".equals(command))) {
        return null;
      } else if ((Commands.SHOW_USERS_COMMAND.equals(command)) && (!user.getIsAdmin())) {
        return Commands.HOMEPAGE_COMMAND;
      } else if ((command == null) && ("command".equals(param))) {
        return Commands.HOMEPAGE_COMMAND;
      }
    } else if (!"login".equals(command)){
View Full Code Here


  public String getParameter(String param) {
    HttpSession session = super.getSession(false);
    String command = super.getParameter("command");
    System.out.println(command);
    if (session != null) {
      User user = (User) session.getAttribute("user");
      if ((user == null) && (!"login".equals(command))) {
        System.out.println("no user");
        return null;
      } else if ((command == null) && ("command".equals(param))) {
        return "homepage";
View Full Code Here

  @Override
  public String execute(CommandParams<?> request) throws ServletException, IOException {
    try
      int userUid = Integer.parseInt(request.getParameter(Commands.INVERT_BAN_USER_UID));
      UserDao userDao = new UserDao();
      User userToBan = userDao.findEntityById(userUid);
      if (userToBan.getLogin() != null) {
        userToBan.setBan(!userToBan.isBan());
        userDao.updateEntity(userToBan);
        List<User> users = userDao.findAll();
        request.setAttribute(Commands.SHOW_USERS_LIST, users);
      }
    } catch (NumberFormatException e) {
View Full Code Here

      List<User> users = userDao.findAll();
      for (User p : users) {
        System.out.println(p);
      }
     
      User user = new User();
      user.setBan(false);
      user.setIsAdmin(false);
      user.setLogin("useri");
      user.setUid(3);
     
      User prevUser = userDao.updateEntity(user);
     
      System.out.println("Find entity by id test");
      System.out.println("1 user: " + userDao.findEntityById(1));
      System.out.println("2 user: " + userDao.findEntityById(2));
     
View Full Code Here

    String page = null;
    String login = request.getParameter(Commands.LOGIN_LOGIN);
    String password = request.getParameter(Commands.LOGIN_PASSWORD);
    try
      UserDao userDao = new UserDao();
      User user = userDao.findUser(login, password);
      if (user.getLogin() != null) {
        if (!user.isBan()) {
          request.setSessionAttribute(Commands.LOGIN_USER, user);
          request.setSessionAttribute(Commands.CHANGE_LANG_LOCALE, Commands.CHANGE_LANG_ENGLISH);
          page = ConfigurationManager.INSTANCE.getProperty(ConfigurationManager.MAIN_PAGE_PATH);
        } else {
          request.setAttribute(Commands.ERROR_MESSAGE, MessageManager.INSTANCE.getProperty(
View Full Code Here

    List<User> users = new ArrayList<>();
    try (DbConnection dbConnection = DbConnectionPool.INSTANCE.getConnection();
        PreparedStatement preparedStatement = dbConnection.prepareStatement(SQL_FIND_ALL_USERS)) { 
      ResultSet resultSet = preparedStatement.executeQuery();
      while (resultSet.next()) {
        User user = new User();
        fillUpUser(resultSet, user);
        users.add(user);
      }
    } catch (ConnectionPoolException e) {
      log.error("Error during getting connection from the pool", e);
View Full Code Here

    return users;
  }
 
  @Override
  public User findEntityById(int uid) throws DaoException {
    User user = new User();
    try (DbConnection dbConnection = DbConnectionPool.INSTANCE.getConnection();
        PreparedStatement preparedStatement = dbConnection.prepareStatement(SQL_USER_BY_ID)) {
      preparedStatement.setInt(1, uid)
      ResultSet resultSet = preparedStatement.executeQuery();
      if (resultSet.next()) {
View Full Code Here

   * @param password user's password
   * @return user entity
   * @throws DaoException
   */
  public User findUser(String login, String password) throws DaoException {
    User user = new User();
    try (DbConnection dbConnection = DbConnectionPool.INSTANCE.getConnection();
        PreparedStatement preparedStatement = dbConnection.prepareStatement(SQL_FIND_USER)) {
      preparedStatement.setString(1, login);
      String passwordDigest = SHA1.getHash(password.getBytes());
      preparedStatement.setString(2, passwordDigest)
View Full Code Here

   * @param user - user's data to be updated
   * @return previous user - previous user's data  
   * @throws DaoException
   */
  public User updateEntity(User user) throws DaoException {
    User prevUser = new User();
    try (DbConnection dbConnection = DbConnectionPool.INSTANCE.getConnection();
        PreparedStatement findUserStatement = dbConnection.prepareStatement(SQL_USER_BY_ID);
        PreparedStatement preparedStatement = dbConnection.prepareStatement(SQL_UPDATE_USER)) {
      findUserStatement.setInt(1, user.getUid());
      ResultSet resultSet = findUserStatement.executeQuery();
View Full Code Here

TOP

Related Classes of by.bsuir.hypermarket.entity.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.