<repo_name>AlexNastin/EpamHostelProject<file_sep>/src/by/epam/hostel/entity/Entity.java
package by.epam.hostel.entity;

import java.io.Serializable;

public abstract class Entity  implements Cloneable, Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -1928578207162711308L;

}
<file_sep>/src/by/epam/hostel/localization/usermenu_en.properties
user.exit = Exit
user.orders = Orders
user.makeorder = Make a booking
<file_sep>/src/by/epam/hostel/logic/impl/CommandGoRegister.java
package by.epam.hostel.logic.impl;

import javax.servlet.http.HttpServletRequest;

import by.epam.hostel.controller.JspPageName;
import by.epam.hostel.logic.ICommand;
import by.epam.hostel.logic.CommandException;

/**
 * This class implements a pattern command. This class receive data for
 * displaying registration page.
 * 
 * @author <NAME>
 */
public class CommandGoRegister implements ICommand {
	/**
	 *  This method handles request to get data for displaying registration page.
	 * 
	 * @param request
	 *            a httpServletRequest
	 * @throws CommandException
	 * @return String which contains page's path for displaying
	 */
	@Override
	public String execute(HttpServletRequest request) throws CommandException {
		return JspPageName.REGISTER_PAGE;
	}
}
<file_sep>/src/by/epam/hostel/localization/errorlogin_en.properties
errorlogin.message = Invalid login or password.
errorlogin.link = Back to form<file_sep>/src/by/epam/hostel/localization/login_en.properties
login.locbutton.log = Log in
login.name = Login(e-mail)
login.pass = <PASSWORD>
login.register = Register
login.email = E-mail: 
login.log.name = Login Form<file_sep>/src/by/epam/hostel/logic/impl/admin/CommandGetUser.java
package by.epam.hostel.logic.impl.admin;

import javax.servlet.http.HttpServletRequest;

import by.epam.hostel.controller.JspPageName;
import by.epam.hostel.controller.RequestParameterName;
import by.epam.hostel.dao.DaoException;
import by.epam.hostel.dao.factory.AbstractDAOFactory;
import by.epam.hostel.dao.factory.DaoFactory;
import by.epam.hostel.dao.factory.DaoFactory.DAOType;
import by.epam.hostel.dao.impl.IMySqlAdminDao;
import by.epam.hostel.entity.User;
import by.epam.hostel.logic.ICommand;
import by.epam.hostel.logic.CommandException;

/**
 * This class implements a pattern command. This class finds the necessary user
 * in the database.
 * 
 * @author <NAME>
 */
public class CommandGetUser implements ICommand {

	private final String NOT_FIND = "admin.notfind";

	/**
	 * This method back user of the base number.
	 * 
	 * @param request a httpServletRequest
	 * @throws CommandException
	 * @return String which contains page's path for displaying
	 */
	@Override
	public String execute(HttpServletRequest request) throws CommandException {

		String idUserStr = request.getParameter(RequestParameterName.ID_USER);
		String pageName = null;
		try {
			if ("".equals(idUserStr) != true) {
				Integer idUser = Integer.valueOf(idUserStr);
				AbstractDAOFactory abstractDAOFactory = DaoFactory
						.getDAO(DAOType.MY_SQL_DAO);
				IMySqlAdminDao dao = abstractDAOFactory.getMySqlAdminDao();
				User user = dao.getUser(idUser);

				if (user != null) {
					request.setAttribute(RequestParameterName.USER, user);
					pageName = JspPageName.USERFIND_PAGE;
				} else {
					request.setAttribute(RequestParameterName.ERROR, NOT_FIND);
					pageName = JspPageName.ADMINUSERS_PAGE;
				}
			} else {
				request.setAttribute(RequestParameterName.ERROR, NOT_FIND);
				pageName = JspPageName.ADMINUSERS_PAGE;
			}
		} catch (DaoException e) {
			throw new CommandException(e);
		}

		return pageName;
	}
}
<file_sep>/src/by/epam/hostel/dao/connectionpool/ConnectionPool.java
package by.epam.hostel.dao.connectionpool;

import java.sql.Array;
import java.sql.Blob;
import java.sql.CallableStatement;
import java.sql.Clob;
import java.sql.Connection;
import java.sql.DatabaseMetaData;
import java.sql.DriverManager;
import java.sql.NClob;
import java.sql.PreparedStatement;
import java.sql.SQLClientInfoException;
import java.sql.SQLException;
import java.sql.SQLWarning;
import java.sql.SQLXML;
import java.sql.Savepoint;
import java.sql.Statement;
import java.sql.Struct;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Executor;

import org.apache.log4j.Logger;

/**
 * 
 * This class implements a pattern singleton. This class creates, handles and
 * gives connections to database.
 * 
 * @author <NAME>
 */
public final class ConnectionPool {
	/**
	 * It is a logger which print some messages to log file.
	 */
	private static final Logger LOG = Logger.getLogger(ConnectionPool.class);

	private BlockingQueue<PooledConnection> connectionQueue;
	private BlockingQueue<PooledConnection> givenAwayConQueue;

	private String driverName;
	private String url;
	private String user;
	private String password;
	private int poolSize;

	/**
	 * The constructor initializes the fields of the class Database Settings.
	 */
	private ConnectionPool() {
		/**
		 * This object provide access to config properties.
		 */
		MySqlPropertyManager propertyManager = MySqlPropertyManager
				.getInstance();
		this.driverName = propertyManager.getValue(MySqlParameter.DB_DRIVER);
		this.url = propertyManager.getValue(MySqlParameter.DB_URL);
		this.user = propertyManager.getValue(MySqlParameter.DB_USER);
		this.password = propertyManager.getValue(MySqlParameter.DB_PASSWORD);
		try {
			this.poolSize = Integer.parseInt(propertyManager
					.getValue(MySqlParameter.DB_POLL_SIZE));
		} catch (NumberFormatException e) {
			poolSize = 10;
			LOG.info("Invalid number format", e);
		}
	}

	/**
	 * The inner class for implementation singleton. It holds ConnectionPool
	 * instance.
	 */
	private static class Holder {
		private static final ConnectionPool INSTANCE = new ConnectionPool();
	}

	/**
	 * The method gives ConnectionPool singleton instance.
	 */
	public static synchronized ConnectionPool getInstance() {
		return Holder.INSTANCE;
	}

	/**
	 * Directly creates a connection pool
	 */
	public void initPoolData() throws ConnectionPoolException {
		try {
			Class.forName(driverName);
			connectionQueue = new ArrayBlockingQueue<PooledConnection>(poolSize);
			givenAwayConQueue = new ArrayBlockingQueue<PooledConnection>(
					poolSize);
			for (int i = 0; i < poolSize; i++) {
				Connection connection = DriverManager.getConnection(url, user,
						password);
				PooledConnection pooledConnection = new PooledConnection(
						connection);
				connectionQueue.add(pooledConnection);
			}
		} catch (ClassNotFoundException e) {
			throw new ConnectionPoolException(
					"Can't find database driver class", e);
		} catch (SQLException e) {
			throw new ConnectionPoolException("SQLException in ConnectionPool",
					e);
		}

	}

	/**
	 * The method closes all connections in two BlockingQueue.
	 */
	public void dispose() {
		clearConnectionQueue();
	}

	/**
	 * The method closes all connections in two BlockingQueue.
	 */
	private void clearConnectionQueue() {
		try {
			closeConnectionsQueue(givenAwayConQueue);
			closeConnectionsQueue(connectionQueue);
		} catch (SQLException e) {
			LOG.error("Error closing the connection.", e);
		}
	}

	/**
	 * The method take Connection from BlockingQueue.
	 * 
	 * @return PooledConnection
	 */
	public PooledConnection takeConnection() throws ConnectionPoolException {
		PooledConnection connection = null;
		try {
			connection = connectionQueue.take();
			givenAwayConQueue.offer(connection);
		} catch (InterruptedException e) {
			throw new ConnectionPoolException(
					"Error connecting to the data source.", e);
		}
		return connection;
	}

	/**
	 * The method closes the connection and statement.
	 * 
	 * @param Connection connection
	 * @param Statement statement
	 * @exception SQLException
	 */
	public void closeConnection(Connection connection, Statement statement) {
		try {
			statement.close();
		} catch (SQLException e) {
			LOG.error("Statement isn't closed.", e);
		}
		try {
			connection.close();
		} catch (SQLException e) {
			LOG.error("Connection isn't return to the pool.", e);
		}
	}

	/**
	 * The method closes the connection and statement.
	 * 
	 * @param Connection connection
	 * @param Statement statement
	 * @param PreparedStatement preparedStatement
	 * @exception SQLException
	 */
	public void closeConnection(Connection connection, Statement statement,
			PreparedStatement preparedStatement) {
		try {
			statement.close();
		} catch (SQLException e) {
			LOG.error("Statement isn't closed.", e);
		}
		try {
			preparedStatement.close();
		} catch (SQLException e) {
			LOG.error("PreparedStatement isn't closed.", e);
		}
		try {
			connection.close();
		} catch (SQLException e) {
			LOG.error("Connection isn't return to the pool.", e);
		}
	}

	/**
	 * The method closes the connections in BlockingQueue.
	 * 
	 * @param BlockingQueue
	 *            <PooledConnection> queue
	 * @exception SQLException
	 */
	private void closeConnectionsQueue(BlockingQueue<PooledConnection> queue)
			throws SQLException {
		Connection connection;
		while ((connection = queue.poll()) != null) {
			if (!connection.getAutoCommit()) {
				connection.commit();
			}
			((PooledConnection) connection).reallyClose();
		}
	}

	/**
	 * Class wrapper for Connection.
	 * 
	 * @author <NAME>
	 */
	private class PooledConnection implements Connection {
		private Connection connection;

		public PooledConnection(Connection c) throws SQLException {
			this.connection = c;
			this.connection.setAutoCommit(true);
		}

		/**
		 * The method closes the connection.
		 */
		public void reallyClose() throws SQLException {
			connection.close();
		}

		@Override
		public void clearWarnings() throws SQLException {
			connection.clearWarnings();
		}

		/**
		 * Throws a connection to one BlockingQueue to another BlockingQueue.
		 */
		@Override
		public void close() throws SQLException {
			if (connection.isReadOnly()) {
				connection.setReadOnly(false);
			}
			if (!givenAwayConQueue.remove(this)) {
				throw new SQLException(
						"Error deleting connection from the given away connections pool.");
			}
			if (!connectionQueue.offer(this)) {
				throw new SQLException(
						"Error allocating connection in the pool.");
			}
		}

		@Override
		public void commit() throws SQLException {
			connection.commit();
		}

		@Override
		public Array createArrayOf(String typeName, Object[] elements)
				throws SQLException {
			return connection.createArrayOf(typeName, elements);
		}

		@Override
		public Blob createBlob() throws SQLException {
			return connection.createBlob();
		}

		@Override
		public Clob createClob() throws SQLException {
			return connection.createClob();
		}

		@Override
		public NClob createNClob() throws SQLException {
			return connection.createNClob();
		}

		@Override
		public SQLXML createSQLXML() throws SQLException {
			return connection.createSQLXML();
		}

		@Override
		public Statement createStatement() throws SQLException {
			return connection.createStatement();
		}

		@Override
		public Statement createStatement(int resultSetType,
				int resultSetConcurrency) throws SQLException {
			return connection.createStatement(resultSetType,
					resultSetConcurrency);
		}

		@Override
		public Statement createStatement(int resultSetType,
				int resultSetConcurrency, int resultSetHoldability)
				throws SQLException {
			return connection.createStatement(resultSetType,
					resultSetConcurrency, resultSetHoldability);
		}

		@Override
		public Struct createStruct(String typeName, Object[] attributes)
				throws SQLException {
			return connection.createStruct(typeName, attributes);
		}

		@Override
		public boolean getAutoCommit() throws SQLException {
			return connection.getAutoCommit();
		}

		@Override
		public String getCatalog() throws SQLException {
			return connection.getCatalog();
		}

		@Override
		public Properties getClientInfo() throws SQLException {
			return connection.getClientInfo();
		}

		@Override
		public String getClientInfo(String name) throws SQLException {
			return connection.getClientInfo(name);
		}

		@Override
		public int getHoldability() throws SQLException {
			return connection.getHoldability();
		}

		@Override
		public DatabaseMetaData getMetaData() throws SQLException {
			return connection.getMetaData();
		}

		@Override
		public int getTransactionIsolation() throws SQLException {
			return connection.getTransactionIsolation();
		}

		@Override
		public Map<String, Class<?>> getTypeMap() throws SQLException {
			return connection.getTypeMap();
		}

		@Override
		public SQLWarning getWarnings() throws SQLException {
			return connection.getWarnings();
		}

		@Override
		public boolean isClosed() throws SQLException {
			return connection.isClosed();
		}

		@Override
		public boolean isReadOnly() throws SQLException {
			return connection.isReadOnly();
		}

		@Override
		public boolean isValid(int timeout) throws SQLException {
			return connection.isValid(timeout);
		}

		@Override
		public String nativeSQL(String sql) throws SQLException {
			return connection.nativeSQL(sql);
		}

		@Override
		public CallableStatement prepareCall(String sql) throws SQLException {
			return connection.prepareCall(sql);
		}

		@Override
		public CallableStatement prepareCall(String sql, int resultSetType,
				int resultSetConcurrency) throws SQLException {
			return connection.prepareCall(sql, resultSetType,
					resultSetConcurrency);
		}

		@Override
		public CallableStatement prepareCall(String sql, int resultSetType,
				int resultSetConcurrency, int resultSetHoldability)
				throws SQLException {
			return connection.prepareCall(sql, resultSetType,
					resultSetConcurrency, resultSetHoldability);
		}

		@Override
		public PreparedStatement prepareStatement(String sql)
				throws SQLException {
			return connection.prepareStatement(sql);
		}

		@Override
		public PreparedStatement prepareStatement(String sql,
				int autoGeneratedKeys) throws SQLException {
			return connection.prepareStatement(sql, autoGeneratedKeys);
		}

		@Override
		public PreparedStatement prepareStatement(String sql,
				int[] columnIndexes) throws SQLException {
			return connection.prepareStatement(sql, columnIndexes);
		}

		@Override
		public PreparedStatement prepareStatement(String sql,
				String[] columnNames) throws SQLException {
			return connection.prepareStatement(sql, columnNames);
		}

		@Override
		public PreparedStatement prepareStatement(String sql,
				int resultSetType, int resultSetConcurrency)
				throws SQLException {
			return connection.prepareStatement(sql, resultSetType,
					resultSetConcurrency);
		}

		@Override
		public PreparedStatement prepareStatement(String sql,
				int resultSetType, int resultSetConcurrency,
				int resultSetHoldability) throws SQLException {
			return connection.prepareStatement(sql, resultSetType,
					resultSetConcurrency, resultSetHoldability);
		}

		@Override
		public void rollback() throws SQLException {
			connection.rollback();
		}

		@Override
		public void setAutoCommit(boolean autoCommit) throws SQLException {
			connection.setAutoCommit(autoCommit);
		}

		@Override
		public void setCatalog(String catalog) throws SQLException {
			connection.setCatalog(catalog);
		}

		@Override
		public void setClientInfo(String name, String value)
				throws SQLClientInfoException {
			connection.setClientInfo(name, value);
		}

		@Override
		public void setHoldability(int holdability) throws SQLException {
			connection.setHoldability(holdability);
		}

		@Override
		public void setReadOnly(boolean readOnly) throws SQLException {
			connection.setReadOnly(readOnly);
		}

		@Override
		public Savepoint setSavepoint() throws SQLException {
			return connection.setSavepoint();
		}

		@Override
		public Savepoint setSavepoint(String name) throws SQLException {
			return connection.setSavepoint(name);
		}

		@Override
		public void setTransactionIsolation(int level) throws SQLException {
			connection.setTransactionIsolation(level);
		}

		@Override
		public boolean isWrapperFor(Class<?> iface) throws SQLException {
			return connection.isWrapperFor(iface);
		}

		@Override
		public <T> T unwrap(Class<T> iface) throws SQLException {
			return connection.unwrap(iface);
		}

		@Override
		public void abort(Executor arg0) throws SQLException {
			connection.abort(arg0);
		}

		@Override
		public int getNetworkTimeout() throws SQLException {
			return connection.getNetworkTimeout();
		}

		@Override
		public String getSchema() throws SQLException {
			return connection.getSchema();
		}

		@Override
		public void releaseSavepoint(Savepoint arg0) throws SQLException {
			connection.releaseSavepoint(arg0);
		}

		@Override
		public void rollback(Savepoint arg0) throws SQLException {
			connection.rollback(arg0);
		}

		@Override
		public void setClientInfo(Properties arg0)
				throws SQLClientInfoException {
			connection.setClientInfo(arg0);
		}

		@Override
		public void setNetworkTimeout(Executor arg0, int arg1)
				throws SQLException {
			connection.setNetworkTimeout(arg0, arg1);
		}

		@Override
		public void setSchema(String arg0) throws SQLException {
			connection.setSchema(arg0);
		}

		@Override
		public void setTypeMap(Map<String, Class<?>> arg0) throws SQLException {
			connection.setTypeMap(arg0);
		}
	}

}<file_sep>/src/by/epam/hostel/dao/connectionpool/ConnectionPoolException.java
package by.epam.hostel.dao.connectionpool;

import by.epam.hostel.exeption.ProjectException;

/**
 * This exception appears in ConnectionPool class
 * 
 * @author <NAME>
 */
public class ConnectionPoolException extends ProjectException {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8555125592745246274L;

	public ConnectionPoolException(String message) {
		super(message);

	}

	public ConnectionPoolException(String message, Throwable e) {
		super(message, e);
	}

	public ConnectionPoolException(Throwable e) {
		super(e);
	}

}
<file_sep>/src/by/epam/hostel/dao/impl/IMySqlUserDao.java
package by.epam.hostel.dao.impl;

import java.util.List;

import by.epam.hostel.dao.DaoException;
import by.epam.hostel.entity.Order;
import by.epam.hostel.entity.Room;

/**
 * This interface holds methods needed to work with database.
 * 
 * @author <NAME>
 */
public interface IMySqlUserDao {
	/**
	 * This method get all not remote room from database.
	 * 
	 * @return List<Room>
	 * @throws DAOException
	 * 
	 */
	public List<Room> getRoomsNotDeleted() throws DaoException;

	/**
	 * This method get all user orders from database.
	 * 
	 * @param int idUser
	 * @return List<Order>
	 * @throws DAOException
	 * 
	 */
	public List<Order> getUserOrders(int idUser) throws DaoException;

	/**
	 * This method insert Order to database.
	 * 
	 * @param String
	 *            arrival
	 * @param String
	 *            departure
	 * @param int idUser
	 * @param int idRoom
	 * @return int the number of rows affected.
	 * @throws DAOException
	 */
	public int insertOrder(String arrival, String departure, int idUser,
			int idRoom) throws DaoException;

	/**
	 * This method get all rooms relevant parameters from database.
	 * 
	 * @param String category
	 * @param int capacity
	 * @return List<Room>
	 * @throws DAOException
	 */
	public List<Room> getRoomsCategoryAndCapacity(String category, int capacity)
			throws DaoException;

	/**
	 * This method get all rooms relevant parameters from database.
	 * 
	 * @param double price
	 * @param int capacity
	 * @return List<Room>
	 * @throws DAOException
	 */
	public List<Room> getRoomsPriceAndCapacity(double price, int capacity)
			throws DaoException;

	/**
	 * This method get all rooms relevant parameters from database.
	 * 
	 * @param int capacity
	 * @return List<Room>
	 * @throws DAOException
	 */
	public List<Room> getRoomsCapacity(int capacity) throws DaoException;

	/**
	 * This method get all rooms relevant parameters from database.
	 * 
	 * @param String category
	 * @param double price
	 * @param int capacity
	 * @return List<Room>
	 * @throws DAOException
	 */
	public List<Room> getRoomsPriceAndCategoryAndCapacity(String category,
			double price, int capacity) throws DaoException;

	/**
	 * This method get all free rooms from database.
	 * 
	 * @param String arrival
	 * @param String departure
	 * @return List<Room>
	 * @throws DAOException
	 */
	public List<Room> getFreeRooms(String arrival, String departure)
			throws DaoException;
}
<file_sep>/src/by/epam/hostel/entity/Login.java
package by.epam.hostel.entity;

/**
 * This is the class of the business object acting as a storage database table
 * Login.
 * 
 * @author <NAME>
 */
public class Login extends Entity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 869263177225053864L;

	private int idUser;
	private String login;
	private int password;
	private boolean status;
	private boolean blacklist;

	public Login(int idUser, String login, int password, boolean status,
			boolean blacklist) {
		super();
		this.idUser = idUser;
		this.login = login;
		this.password = <PASSWORD>;
		this.status = status;
		this.blacklist = blacklist;
	}

	public Login() {
	}

	public int getIdUser() {
		return idUser;
	}

	public void setIdUser(int idUser) {
		this.idUser = idUser;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public int getPassword() {
		return password;
	}

	public void setPassword(int password) {
		this.password = <PASSWORD>;
	}

	public boolean isStatus() {
		return status;
	}

	public void setStatus(boolean status) {
		this.status = status;
	}

	public boolean isBlacklist() {
		return blacklist;
	}

	public void setBlacklist(boolean blacklist) {
		this.blacklist = blacklist;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + (blacklist ? 1231 : 1237);
		result = prime * result + idUser;
		result = prime * result + ((login == null) ? 0 : login.hashCode());
		result = prime * result + password;
		result = prime * result + (status ? 1231 : 1237);
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		Login other = (Login) obj;
		if (blacklist != other.blacklist) {
			return false;
		}
		if (idUser != other.idUser) {
			return false;
		}
		if (login == null) {
			if (other.login != null) {
				return false;
			}
		} else if (!login.equals(other.login)) {
			return false;
		}
		if (password != other.password) {
			return false;
		}
		if (status != other.status) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "Login [idUser=" + idUser + ", login=" + login + ", password="
				+ <PASSWORD> + ", status=" + status + ", blacklist=" + blacklist
				+ "]";
	}

}
<file_sep>/src/by/epam/hostel/entity/Room.java
package by.epam.hostel.entity;
/**
 * This is the class of the business object acting as a storage database table
 * Rooms.
 * 
 * @author <NAME>
 */
public class Room extends Entity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 7850899406976248706L;

	private int idRoom;
	private double price;
	private int capacity;
	private Category category;
	private boolean isDeleted;

	public Room() {
	}

	public Room(int idRoom, double price, int capacity, Category category,
			boolean isDeleted) {
		super();
		this.idRoom = idRoom;
		this.price = price;
		this.capacity = capacity;
		this.category = category;
		this.isDeleted = isDeleted;
	}

	public Room(int idRoom, double price, int capacity, Category category) {
		super();
		this.idRoom = idRoom;
		this.price = price;
		this.capacity = capacity;
		this.category = category;
	}

	public int getIdRoom() {
		return idRoom;
	}

	public void setIdRoom(int idRoom) {
		this.idRoom = idRoom;
	}

	public double getPrice() {
		return price;
	}

	public void setPrice(double price) {
		this.price = price;
	}

	public int getCapacity() {
		return capacity;
	}

	public void setCapacity(int capacity) {
		this.capacity = capacity;
	}

	public Category getCategory() {
		return category;
	}

	public void setCategory(Category category) {
		this.category = category;
	}

	public boolean isDeleted() {
		return isDeleted;
	}

	public void setDeleted(boolean isDeleted) {
		this.isDeleted = isDeleted;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + capacity;
		result = prime * result
				+ ((category == null) ? 0 : category.hashCode());
		result = prime * result + idRoom;
		result = prime * result + (isDeleted ? 1231 : 1237);
		long temp;
		temp = Double.doubleToLongBits(price);
		result = prime * result + (int) (temp ^ (temp >>> 32));
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		Room other = (Room) obj;
		if (capacity != other.capacity) {
			return false;
		}
		if (category != other.category) {
			return false;
		}
		if (idRoom != other.idRoom) {
			return false;
		}
		if (isDeleted != other.isDeleted) {
			return false;
		}
		if (Double.doubleToLongBits(price) != Double
				.doubleToLongBits(other.price)) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "Room [idRoom=" + idRoom + ", price=" + price + ", capacity="
				+ capacity + ", category=" + category + ", isDeleted="
				+ isDeleted + "]";
	}

}
<file_sep>/src/by/epam/hostel/logic/impl/user/CommandBooked.java
package by.epam.hostel.logic.impl.user;

import javax.servlet.http.HttpServletRequest;

import by.epam.hostel.controller.JspPageName;
import by.epam.hostel.controller.RequestParameterName;
import by.epam.hostel.dao.DaoException;
import by.epam.hostel.dao.factory.AbstractDAOFactory;
import by.epam.hostel.dao.factory.DaoFactory;
import by.epam.hostel.dao.factory.DaoFactory.DAOType;
import by.epam.hostel.dao.impl.IMySqlAdminDao;
import by.epam.hostel.dao.impl.IMySqlUserDao;
import by.epam.hostel.entity.Room;
import by.epam.hostel.logic.ICommand;
import by.epam.hostel.logic.CommandException;

/**
 * This class implements a pattern command. This class reservation room for the
 * user.
 * 
 * @author <NAME>
 */
public class CommandBooked implements ICommand {

	private final String INFO = "user.info";

	/**
	 * This method writes the order number into the database, and considers the
	 * total amount of the order and sends the user to the main page and a
	 * message for him.
	 * 
	 * @param request
	 *            a httpServletRequest
	 * @throws CommandException
	 * @return String which contains page's path for displaying
	 */
	@Override
	public String execute(HttpServletRequest request) throws CommandException {

		Integer idRoom = Integer.valueOf(request
				.getParameter(RequestParameterName.ID_ROOM));
		int idUser = (int) request.getSession(true).getAttribute(
				RequestParameterName.ID_USER);
		String arrival = (String) request.getSession().getAttribute(
				RequestParameterName.ARRIVAL_USER);
		String departure = (String) request.getSession().getAttribute(
				RequestParameterName.DEPARTURE_USER);
		int amountDays = (int) request.getSession().getAttribute(
				RequestParameterName.AMOUNT_DAYS);
		double totalPrice = 0;

		try {

			AbstractDAOFactory abstractDAOFactory = DaoFactory
					.getDAO(DAOType.MY_SQL_DAO);
			IMySqlUserDao daoUser = abstractDAOFactory.getMySqlUserDao();
			IMySqlAdminDao daoAdmin = abstractDAOFactory.getMySqlAdminDao();
			daoUser.insertOrder(arrival, departure, idUser, idRoom);

			Room room = daoAdmin.getRoom(idRoom);
			totalPrice = room.getPrice() * (amountDays - 1);

		} catch (DaoException e) {
			throw new CommandException(e);
		}
		request.setAttribute(RequestParameterName.USER_INFO, INFO);
		request.setAttribute(RequestParameterName.TOTAL_PRICE, totalPrice);
		return JspPageName.USER_PAGE;
	}
}
<file_sep>/src/by/epam/hostel/localization/blacklist_en.properties
blacklist.message = You are blacklisted. For more information, contact the administrator.
blacklist.link = Back to form<file_sep>/src/by/epam/hostel/dao/factory/DaoFactory.java
package by.epam.hostel.dao.factory;

import by.epam.hostel.dao.DaoException;

/**
 * 
 * This class holds methods that return the necessary implementation dao.
 * 
 * @author <NAME>
 */
public class DaoFactory {

	public enum DAOType {
		MY_SQL_DAO;
	}

	private DaoFactory() {
	}

	/**
	 * 
	 * The methods returns implementation dao.
	 * 
	 * @param DAOType type
	 * @return AbstractDAOFactory
	 * @throws DaoException
	 */
	public static AbstractDAOFactory getDAO(DAOType type) throws DaoException {
		AbstractDAOFactory daoFactory = null;
		switch (type) {
		case MY_SQL_DAO:
			daoFactory = new MySqlDaoFactory();
		default:
			daoFactory = new MySqlDaoFactory();
			break;
		}
		return daoFactory;
	}

}
<file_sep>/src/by/epam/hostel/logic/impl/admin/CommandAddBlacklist.java
package by.epam.hostel.logic.impl.admin;

import javax.servlet.http.HttpServletRequest;

import by.epam.hostel.controller.JspPageName;
import by.epam.hostel.controller.RequestParameterName;
import by.epam.hostel.dao.DaoException;
import by.epam.hostel.dao.factory.AbstractDAOFactory;
import by.epam.hostel.dao.factory.DaoFactory;
import by.epam.hostel.dao.factory.DaoFactory.DAOType;
import by.epam.hostel.dao.impl.IMySqlAdminDao;
import by.epam.hostel.logic.ICommand;
import by.epam.hostel.logic.CommandException;
import by.epam.hostel.logic.helper.Helper;

/**
 * This class implements a pattern command. This class adds the user to the
 * black list.
 * 
 * @author <NAME>
 */
public class CommandAddBlacklist implements ICommand {
	/**
	 * This method adds the user to the blacklist.
	 * 
	 * @param request
	 *            a httpServletRequest
	 * @throws CommandException
	 * @return String which contains page's path for displaying
	 */
	@Override
	public String execute(HttpServletRequest request) throws CommandException {
		try {

			AbstractDAOFactory abstractDAOFactory = DaoFactory
					.getDAO(DAOType.MY_SQL_DAO);
			IMySqlAdminDao dao = abstractDAOFactory.getMySqlAdminDao();
			Integer idUser = Integer.valueOf(request
					.getParameter(RequestParameterName.ID_USER));
			Boolean blacklistBool = Boolean.valueOf(request
					.getParameter(RequestParameterName.BLACKLIST_USER));
			int blacklistInt = Helper.getInt(blacklistBool);
			dao.setBlacklistUser(idUser, Helper.changeInt(blacklistInt));
			request.setAttribute(RequestParameterName.USER, dao.getUser(idUser));
		} catch (DaoException e) {
			throw new CommandException(e);
		}
		return JspPageName.USERFIND_PAGE;
	}
}
<file_sep>/src/by/epam/hostel/logic/impl/CommandLocale.java
package by.epam.hostel.logic.impl;

import javax.servlet.http.HttpServletRequest;

import by.epam.hostel.controller.JspPageName;
import by.epam.hostel.controller.RequestParameterName;
import by.epam.hostel.logic.ICommand;
import by.epam.hostel.logic.CommandException;

/**
 * This class implements a pattern command. This class change the language in
 * the web-application.
 * 
 * @author <NAME>
 */
public class CommandLocale implements ICommand {
	
	/**
	 * This method change the language and goes to the start page.
	 * 
	 * @param request a httpServletRequest
	 * @throws CommandException
	 * @return String which contains page's path for displaying
	 */
	@Override
	public String execute(HttpServletRequest request) throws CommandException {

		String localeName = (String) request.getSession(true).getAttribute(
				RequestParameterName.LOCALE);

		if ("en".equalsIgnoreCase(localeName)) {
			localeName = "ru";
		} else {
			localeName = "en";
		}

		request.getSession(true).setAttribute(RequestParameterName.LOCALE,
				localeName);

		return JspPageName.INDEX_PAGE;
	}
}
<file_sep>/src/by/epam/hostel/logic/impl/admin/CommandMakeAdmin.java
package by.epam.hostel.logic.impl.admin;

import javax.servlet.http.HttpServletRequest;

import by.epam.hostel.controller.JspPageName;
import by.epam.hostel.controller.RequestParameterName;
import by.epam.hostel.dao.DaoException;
import by.epam.hostel.dao.factory.AbstractDAOFactory;
import by.epam.hostel.dao.factory.DaoFactory;
import by.epam.hostel.dao.factory.DaoFactory.DAOType;
import by.epam.hostel.dao.impl.IMySqlAdminDao;
import by.epam.hostel.logic.ICommand;
import by.epam.hostel.logic.CommandException;
import by.epam.hostel.logic.helper.Helper;

/**
 * This class implements a pattern command. This class changes the status of the
 * user.
 * 
 * @author <NAME>
 */
public class CommandMakeAdmin implements ICommand {
	/**
	 * This method changes the status of the user with the administrator or
	 * user.
	 * 
	 * @param request
	 *            a httpServletRequest
	 * @throws CommandException
	 * @return String which contains page's path for displaying
	 */
	@Override
	public String execute(HttpServletRequest request) throws CommandException {
		try {
			Integer idUser = Integer.valueOf(request
					.getParameter(RequestParameterName.ID_USER));
			Boolean statusBool = Boolean.valueOf(request
					.getParameter(RequestParameterName.STATUS_USER));
			int statusInt = Helper.getInt(statusBool);
			AbstractDAOFactory abstractDAOFactory = DaoFactory
					.getDAO(DAOType.MY_SQL_DAO);
			IMySqlAdminDao dao = abstractDAOFactory.getMySqlAdminDao();

			dao.setStatus(idUser, Helper.changeInt(statusInt));
			request.setAttribute(RequestParameterName.USER, dao.getUser(idUser));
		} catch (DaoException e) {
			throw new CommandException(e);
		}
		return JspPageName.USERFIND_PAGE;
	}
}
<file_sep>/src/by/epam/hostel/localization/title_en.properties
title.locbutton.name =  RU
title.name = Hotel Minsk 3*<file_sep>/src/by/epam/hostel/tag/GetDateTag.java
package by.epam.hostel.tag;

import java.io.IOException;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.util.Locale;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;

/**
 * This tag displays the current date according to the locale.
 * 
 * @author <NAME>
 * 
 */
@SuppressWarnings("serial")
public class GetDateTag extends TagSupport {

	private String locale;

	public void setLocale(String locale) {
		this.locale = locale;
	}

	private Locale loc;

	/**
	 * This method prints the current date.
	 * 
	 * @return SKIP_BODY
	 * @throws JspException
	 *             a JspException
	 */
	@Override
	public int doStartTag() throws JspException {
		if ("ru".equalsIgnoreCase(locale)) {
			loc = new Locale("ru", "RU");
		} else {
			loc = new Locale("en", "EN");
		}
		GregorianCalendar gc = (GregorianCalendar) Calendar.getInstance();
		DateFormat dateFormat = DateFormat
				.getDateInstance(DateFormat.FULL, loc);
		String time = "<hr/><b> " + dateFormat.format(gc.getTime())
				+ " </b><hr/>";
		try {
			JspWriter out = pageContext.getOut();
			out.write(time);
		} catch (IOException e) {
			throw new JspException(e.getMessage());
		}
		return SKIP_BODY;
	}

	/**
	 * @return EVAL_PAGE
	 * @throws JspException
	 *             a JspException
	 */
	@Override
	public int doEndTag() throws JspException {
		return EVAL_PAGE;
	}
}<file_sep>/src/by/epam/hostel/localization/user_en.properties
user.message = Welcome,
user.info = Booked Room
user.exit = Exit
user.orders = Orders
user.makeorder = Make a booking
user.allprice= Total price

user.order.idorder = ID Order
user.order.arrival = Arrival
user.order.departure = Departure

user.room.idroom = Number Room 
user.room.price = Price per night
user.room.category = Category
user.room.capacity= Capacity

user.filldate.message = Enter the dates of your stay: 
user.filldate.arrival = Check in:
user.filldate.departure = End of your stay:
user.filldate.day= dd
user.filldate.month= mm
user.filldate.year= yyyy
user.filldate.find= Find

user.picks.selection = Selection of parameters
user.picks.price = Price per night
user.picks.category = Category
user.picks.capacity = Capacity
user.picks.book= Booking
user.picks.find= Find
<file_sep>/src/by/epam/hostel/localization/admin_en.properties
admin.message = Welcome,
admin.exit = Exit
admin.users = Users
admin.rooms = Rooms
admin.orders = Orders
admin.find = Find
admin.notfind = There is no such ID in database.

admin.user.iduser = ID User 
admin.user.name = Name
admin.user.surname = Surname
admin.user.numpass= Number Passport
admin.user.email= E-mail
admin.user.status= Status
admin.user.blacklist= Blacklist

admin.room.idroom = Number room 
admin.room.price = Price per night
admin.room.category = Category
admin.room.capacity= Capacity
admin.room.isdeleted= Deleted
admin.room.insertroom = Add Room
admin.room.booked = Booked
admin.room.booking = Arrival
admin.room.notbooking = Departure

admin.order.idorder = ID Order
admin.order.arrival = Arrival
admin.order.departure = Departure
admin.order.paid = Paid

<file_sep>/src/by/epam/hostel/dao/connectionpool/MySqlPropertyManager.java
package by.epam.hostel.dao.connectionpool;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

import org.apache.log4j.Logger;

/**
 * 
 * This class implements a pattern singleton. This class derives from the
 * configuration file settings for the database.
 * 
 * @author <NAME>
 */
public class MySqlPropertyManager {
	/**
	 * It is a logger which print some messages to log file.
	 */
	private static final Logger LOG = Logger
			.getLogger(MySqlPropertyManager.class);

	private final String PATH = "db.properties";
	private final String PREFIX = this.getClass().getResource("/").getPath();

	private Properties properties = new Properties();
	private BufferedReader reader = null;
	private File file = new File(PREFIX + PATH);

	/**
	 * The inner class for implementation singleton. It holds
	 * MySqlPropertyManager instance.
	 */
	private static class Holder {
		private static final MySqlPropertyManager INSTANCE = new MySqlPropertyManager();
	}

	/**
	 * The method gives MySqlPropertyManager singleton instance.
	 */
	public static MySqlPropertyManager getInstance() {
		return Holder.INSTANCE;
	}

	/**
	 * The constructor creates BufferedReader and reads configuration file
	 * database.
	 */
	private MySqlPropertyManager() {
		try {
			reader = new BufferedReader(new FileReader(file));
			properties.load(reader);
		} catch (FileNotFoundException e) {
			LOG.error("File db.properties not found.", e);
		} catch (IOException e) {
			LOG.error(e);
		}
	}

	/**
	 * The method gives extract key parameters.
	 * 
	 * @param String key
	 * @return String
	 */
	public String getValue(String key) {
		return properties.getProperty(key);
	}

}
<file_sep>/src/by/epam/hostel/dao/connectionpool/MySqlParameter.java
package by.epam.hostel.dao.connectionpool;

/**
 * This class contains information about the name of the parameters for the
 * database.
 * 
 * @author <NAME>
 */

public final class MySqlParameter {

	private MySqlParameter() {
	}

	public static final String DB_DRIVER = "db.driver";
	public static final String DB_URL = "db.url";
	public static final String DB_USER = "db.user";
	public static final String DB_PASSWORD = "<PASSWORD>";
	public static final String DB_POLL_SIZE = "db.poolsize";

}
<file_sep>/src/by/epam/hostel/logic/impl/admin/CommandGetBooked.java
package by.epam.hostel.logic.impl.admin;

import javax.servlet.http.HttpServletRequest;

import by.epam.hostel.controller.JspPageName;
import by.epam.hostel.controller.RequestParameterName;
import by.epam.hostel.dao.DaoException;
import by.epam.hostel.dao.factory.AbstractDAOFactory;
import by.epam.hostel.dao.factory.DaoFactory;
import by.epam.hostel.dao.factory.DaoFactory.DAOType;
import by.epam.hostel.dao.impl.IMySqlAdminDao;
import by.epam.hostel.logic.ICommand;
import by.epam.hostel.logic.CommandException;

/**
 * This class implements a pattern command. This class returns the date of the
 * reservation of the room.
 * 
 * @author <NAME>
 */
public class CommandGetBooked implements ICommand {

	private final String NOT_FIND = "admin.notfind";

	/**
	 * This method returns the date of the reservation of the room.
	 * 
	 * @param request
	 *            a httpServletRequest
	 * @throws CommandException
	 * @return String which contains page's path for displaying
	 */
	@Override
	public String execute(HttpServletRequest request) throws CommandException {

		String idRoomStr = request.getParameter(RequestParameterName.ID_ROOM);
		String pageName = null;
		try {
			if ("".equalsIgnoreCase(idRoomStr) != true) {
				Integer idRoom = Integer.valueOf(idRoomStr);

				AbstractDAOFactory abstractDAOFactory = DaoFactory
						.getDAO(DAOType.MY_SQL_DAO);
				IMySqlAdminDao dao = abstractDAOFactory.getMySqlAdminDao();

				request.setAttribute(RequestParameterName.GET_BOOKEDDATES,
						dao.getBookedDatesRoom(idRoom));
				pageName = JspPageName.BOOKEDDATE_PAGE;

			} else {
				request.setAttribute(RequestParameterName.ERROR, NOT_FIND);
				pageName = JspPageName.BOOKEDDATE_PAGE;
			}
		} catch (DaoException e) {
			throw new CommandException(e);
		}

		return pageName;
	}

}
<file_sep>/src/by/epam/hostel/logic/impl/user/CommandSampleRooms.java
package by.epam.hostel.logic.impl.user;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import by.epam.hostel.controller.JspPageName;
import by.epam.hostel.controller.RequestParameterName;
import by.epam.hostel.dao.DaoException;
import by.epam.hostel.dao.factory.AbstractDAOFactory;
import by.epam.hostel.dao.factory.DaoFactory;
import by.epam.hostel.dao.factory.DaoFactory.DAOType;
import by.epam.hostel.dao.impl.IMySqlUserDao;
import by.epam.hostel.entity.Room;
import by.epam.hostel.logic.ICommand;
import by.epam.hostel.logic.CommandException;

/**
 * This class implements a pattern command. This class in which the sample rooms
 * on an individual user's request.
 * 
 * @author <NAME>
 */
public class CommandSampleRooms implements ICommand {

	private final String FAMILY = "FAMILY";
	private final String LUX = "LUX";
	private final String SUPER_LUX = "SUPER_LUX";
	private final String ECONOM = "ECONOM";

	/**
	 * This method implements sample needed rooms for user parameters.
	 * 
	 * @param request
	 *            a httpServletRequest
	 * @throws CommandException
	 * @return String which contains page's path for displaying
	 */
	@Override
	public String execute(HttpServletRequest request) throws CommandException {
		List<Room> rooms = new ArrayList<Room>();
		try {

			AbstractDAOFactory abstractDAOFactory = DaoFactory
					.getDAO(DAOType.MY_SQL_DAO);
			IMySqlUserDao dao = abstractDAOFactory.getMySqlUserDao();

			String priceStr = request
					.getParameter(RequestParameterName.PRICE_ROOM);
			String categoryStr = request
					.getParameter(RequestParameterName.CATEGORY_ROOM);
			String capacityStr = request
					.getParameter(RequestParameterName.CAPACITY_ROOM);
			Integer capacity = Integer.valueOf(capacityStr);

			if (("".equalsIgnoreCase(priceStr) != true)) {
				Double price = Double.valueOf(priceStr);
				switch (categoryStr) {
				case FAMILY:
					rooms = dao.getRoomsPriceAndCategoryAndCapacity(
							categoryStr, price, capacity);
					break;
				case LUX:
					rooms = dao.getRoomsPriceAndCategoryAndCapacity(
							categoryStr, price, capacity);
					break;
				case SUPER_LUX:
					rooms = dao.getRoomsPriceAndCategoryAndCapacity(
							categoryStr, price, capacity);
					break;
				case ECONOM:
					rooms = dao.getRoomsPriceAndCategoryAndCapacity(
							categoryStr, price, capacity);
					break;
				default:
					rooms = dao.getRoomsPriceAndCapacity(price, capacity);
					break;
				}
			} else {
				switch (categoryStr) {
				case FAMILY:
					rooms = dao.getRoomsCategoryAndCapacity(categoryStr,
							capacity);
					break;
				case LUX:
					rooms = dao.getRoomsCategoryAndCapacity(categoryStr,
							capacity);
					break;
				case SUPER_LUX:
					rooms = dao.getRoomsCategoryAndCapacity(categoryStr,
							capacity);
					break;
				case ECONOM:
					rooms = dao.getRoomsCategoryAndCapacity(categoryStr,
							capacity);
					break;
				default:
					rooms = dao.getRoomsCapacity(capacity);
					break;
				}
			}
		} catch (DaoException e) {
			throw new CommandException(e);
		}

		request.getSession(true).setAttribute(RequestParameterName.FREEROOMS,
				rooms);
		return JspPageName.USERPICKORDER_PAGE;
	}
}
<file_sep>/src/by/epam/hostel/entity/BookedDate.java
package by.epam.hostel.entity;

import java.util.Date;

/**
 * This is the class of the business object acting as a storage database table
 * BookedDates.
 * 
 * @author <NAME>
 */
public class BookedDate extends Entity {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private int idBooked;
	private int idRoom;
	private Date booking;
	private Date notBooking;

	public BookedDate() {
		super();
	}

	public BookedDate(int idBooked, int idRoom, Date booking, Date notBooking) {
		super();
		this.idBooked = idBooked;
		this.idRoom = idRoom;
		this.booking = booking;
		this.notBooking = notBooking;
	}

	public int getIdBooked() {
		return idBooked;
	}

	public void setIdBooked(int idBooked) {
		this.idBooked = idBooked;
	}

	public int getIdRoom() {
		return idRoom;
	}

	public void setIdRoom(int idRoom) {
		this.idRoom = idRoom;
	}

	public Date getBooking() {
		return booking;
	}

	public void setBooking(Date booking) {
		this.booking = booking;
	}

	public Date getNotBooking() {
		return notBooking;
	}

	public void setNotBooking(Date notBooking) {
		this.notBooking = notBooking;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((booking == null) ? 0 : booking.hashCode());
		result = prime * result + idBooked;
		result = prime * result + idRoom;
		result = prime * result
				+ ((notBooking == null) ? 0 : notBooking.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		BookedDate other = (BookedDate) obj;
		if (booking == null) {
			if (other.booking != null) {
				return false;
			}
		} else if (!booking.equals(other.booking)) {
			return false;
		}
		if (idBooked != other.idBooked) {
			return false;
		}
		if (idRoom != other.idRoom) {
			return false;
		}
		if (notBooking == null) {
			if (other.notBooking != null) {
				return false;
			}
		} else if (!notBooking.equals(other.notBooking)) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "BookedDate [idBooked=" + idBooked + ", idRoom=" + idRoom
				+ ", booking=" + booking + ", notBooking=" + notBooking + "]";
	}

}
<file_sep>/src/by/epam/hostel/logic/CommandException.java
package by.epam.hostel.logic;

import by.epam.hostel.exeption.ProjectException;

/**
 * This exception appears from CommandException.
 * 
 * @author <NAME>
 */
public class CommandException extends ProjectException {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8967941434873708746L;

	public CommandException(String message, Throwable e) {
		super(message, e);
	}

	public CommandException(String message) {
		super(message);
	}

	public CommandException(Throwable e) {
		super(e);
	}

}
<file_sep>/WebContent/WEB-INF/classes/db.properties
db.driver = com.mysql.jdbc.Driver
db.url = jdbc:mysql://localhost:3306/hotel
db.user = root
db.password = <PASSWORD>
db.poolsize = 10<file_sep>/src/by/epam/hostel/localization/register_ru.properties
register.name = \u0418\u043C\u044F
register.surname = \u0424\u0430\u043C\u0438\u043B\u0438\u044F
register.numpass = <PASSWORD>430\u0441\u043F\u043E\u0440\u0442\u0430
register.login = \u041B\u043E\u0433\u0438\u043D(e-mail)
register.password = <PASSWORD>
register.passwordmatch = \<PASSWORD>3F\u0430\u0440\u043E\u043B\u044C
register.message = \u041E\u0442\u043F\u0440\u0430\u0432\u0438\u0442\u044C<file_sep>/src/by/epam/hostel/localization/error_en.properties
error.login = Enter the wrong login
error.fieldnot= Field is not filled.
error.name = ERROR
error.passwordnotmatch = Password do not match 
error.link = Back to mainpage<file_sep>/src/by/epam/hostel/logic/impl/user/CommandCheckDate.java
package by.epam.hostel.logic.impl.user;

import java.util.GregorianCalendar;

import javax.servlet.http.HttpServletRequest;

import by.epam.hostel.controller.JspPageName;
import by.epam.hostel.controller.RequestParameterName;
import by.epam.hostel.dao.DaoException;
import by.epam.hostel.dao.factory.AbstractDAOFactory;
import by.epam.hostel.dao.factory.DaoFactory;
import by.epam.hostel.dao.factory.DaoFactory.DAOType;
import by.epam.hostel.dao.impl.IMySqlUserDao;
import by.epam.hostel.logic.ICommand;
import by.epam.hostel.logic.CommandException;
import by.epam.hostel.logic.helper.Helper;

/**
 * This class implements a pattern command. This class determines the
 * availability for user.
 * 
 * @author <NAME>
 */
public class CommandCheckDate implements ICommand {

	private final String DASH = "-";

	/**
	 * This method selects the availability for the user in a given period of
	 * time.
	 * 
	 * @param request
	 *            a httpServletRequest
	 * @throws CommandException
	 * @return String which contains page's path for displaying
	 */
	@Override
	public String execute(HttpServletRequest request) throws CommandException {
		IMySqlUserDao dao = null;

		String aday = request.getParameter(RequestParameterName.ADAY);
		String amonth = request.getParameter(RequestParameterName.AMONTH);
		String ayear = request.getParameter(RequestParameterName.AYEAR);

		String dday = request.getParameter(RequestParameterName.DDAY);
		String dmonth = request.getParameter(RequestParameterName.DMONTH);
		String dyear = request.getParameter(RequestParameterName.DYEAR);

		StringBuilder arrival = new StringBuilder();
		StringBuilder departure = new StringBuilder();

		arrival.append(ayear);
		arrival.append(DASH);
		arrival.append(amonth);
		arrival.append(DASH);
		arrival.append(aday);

		departure.append(dyear);
		departure.append(DASH);
		departure.append(dmonth);
		departure.append(DASH);
		departure.append(dday);

		GregorianCalendar dataArrival = new GregorianCalendar(
				Integer.valueOf(ayear), Integer.valueOf(amonth) - 1,
				Integer.valueOf(aday));
		GregorianCalendar dataDeparture = new GregorianCalendar(
				Integer.valueOf(dyear), Integer.valueOf(dmonth) - 1,
				Integer.valueOf(dday));
		int amountDays = Helper.getAmountDays(dataArrival, dataDeparture);

		request.getSession(true).setAttribute(
				RequestParameterName.ARRIVAL_USER, arrival.toString());
		request.getSession().setAttribute(RequestParameterName.DEPARTURE_USER,
				departure.toString());
		request.getSession().setAttribute(RequestParameterName.AMOUNT_DAYS,
				amountDays);
		try {
			AbstractDAOFactory abstractDAOFactory = DaoFactory
					.getDAO(DAOType.MY_SQL_DAO);
			dao = abstractDAOFactory.getMySqlUserDao();
			request.getSession().setAttribute(RequestParameterName.FREEROOMS,
					dao.getFreeRooms(arrival.toString(), departure.toString()));

		} catch (DaoException e) {
			throw new CommandException(e);
		}
		return JspPageName.USERPICKORDER_PAGE;
	}
}
<file_sep>/src/by/epam/hostel/dao/impl/MySqlUserDao.java
package by.epam.hostel.dao.impl;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

import by.epam.hostel.dao.DaoException;
import by.epam.hostel.dao.connectionpool.ConnectionPool;
import by.epam.hostel.dao.connectionpool.ConnectionPoolException;
import by.epam.hostel.dao.factory.DaoFactory;
import by.epam.hostel.dao.factory.DaoFactory.DAOType;
import by.epam.hostel.entity.Category;
import by.epam.hostel.entity.Order;
import by.epam.hostel.entity.Room;

/**
 * The inner class for implementation singleton. Direct implementation of the
 * interface MySqlUserDao.
 * 
 * @author <NAME>
 */
public final class MySqlUserDao implements IMySqlUserDao {

	private static ConnectionPool connectionPool = ConnectionPool.getInstance();

	private final String GET_ROOMS_NOT_DELETED = "SELECT * FROM rooms WHERE isDeleted=0";
	private final String GET_USER_ORDERS = "SELECT idOrder, idRoom, price, category, capacity, arrival, departure FROM orders, rooms, users WHERE idUser = users_idUser and rooms.idRoom = Rooms_idRoom and idUser=";

	private final String GET_BOOKEDROOM = "SELECT rooms_idRoom FROM bookeddate WHERE  notbooking>? and booking<?  group by rooms_idRoom";

	private final String GET_SPECIFIC_ROOMS_CATEGORY_AND_PRICE = "SELECT * FROM rooms WHERE category=? and price<=? and capacity=?";
	private final String GET_SPECIFIC_ROOMS_CATEGORY = "SELECT * FROM rooms WHERE category=? and capacity=?";
	private final String GET_SPECIFIC_ROOMS_PRICE = "SELECT * FROM rooms WHERE price<=? and capacity=?";
	private final String GET_SPECIFIC_ROOMS_CAPACITY = "SELECT * FROM rooms WHERE capacity=?";

	private final String INSERT_ORDER = "INSERT INTO orders (arrival, departure, users_idUser, rooms_idRoom, paid) VALUES (?,?,?,?,0)";
	private final String INSERT_BOOKEDDATE = "INSERT INTO bookeddate (rooms_idRoom, booking, notbooking) VALUES (?,?,?)";

	private MySqlUserDao() {
	}

	/**
	 * The inner class for implementation singleton. It holds MySqlUserDao
	 * instance.
	 */
	private static class Holder {
		private final static MySqlUserDao INSTANCE = new MySqlUserDao();
	}

	/**
	 * The method gives MySqlUserDao singleton instance.
	 */
	public static MySqlUserDao getInstance() {
		return Holder.INSTANCE;
	}

	@Override
	public List<Room> getRoomsNotDeleted() throws DaoException {
		List<Room> rooms = new ArrayList<Room>();
		Connection connection = null;
		Statement statement = null;
		try {
			connection = connectionPool.takeConnection();
			statement = connection.createStatement();
			ResultSet resultSet = statement.executeQuery(GET_ROOMS_NOT_DELETED);
			while (resultSet.next()) {
				Room room = new Room();
				room.setIdRoom(resultSet.getInt(1));
				room.setPrice(resultSet.getDouble(2));
				switch (resultSet.getString(3)) {
				case "ECONOM":
					room.setCategory(Category.ECONOM);
					break;
				case "FAMILY":
					room.setCategory(Category.FAMILY);
					break;
				case "LUX":
					room.setCategory(Category.LUX);
					break;
				case "SUPER_LUX":
					room.setCategory(Category.SUPER_LUX);
					break;
				default:
					throw new DaoException("There is no such category.");
				}
				room.setCapacity(resultSet.getInt(4));
				room.setDeleted(resultSet.getBoolean(5));
				rooms.add(room);
			}
		} catch (ConnectionPoolException | SQLException e) {
			throw new DaoException(e);
		} finally {
			connectionPool.closeConnection(connection, statement);
		}
		return rooms;
	}

	@Override
	public List<Room> getRoomsCategoryAndCapacity(String category, int capacity)
			throws DaoException {

		List<Room> rooms = new ArrayList<Room>();
		Connection connection = null;
		PreparedStatement preparedStatement = null;
		try {
			connection = connectionPool.takeConnection();
			preparedStatement = connection
					.prepareStatement(GET_SPECIFIC_ROOMS_CATEGORY);
			preparedStatement.setString(1, category);
			preparedStatement.setInt(2, capacity);
			ResultSet resultSet = preparedStatement.executeQuery();
			while (resultSet.next()) {
				Room room = new Room();
				room.setIdRoom(resultSet.getInt(1));
				room.setPrice(resultSet.getDouble(2));
				switch (resultSet.getString(3)) {
				case "ECONOM":
					room.setCategory(Category.ECONOM);
					break;
				case "FAMILY":
					room.setCategory(Category.FAMILY);
					break;
				case "LUX":
					room.setCategory(Category.LUX);
					break;
				case "SUPER_LUX":
					room.setCategory(Category.SUPER_LUX);
					break;
				default:
					throw new DaoException("There is no such category.");
				}
				room.setCapacity(resultSet.getInt(4));
				room.setDeleted(resultSet.getBoolean(5));
				rooms.add(room);
			}
		} catch (ConnectionPoolException | SQLException e) {
			throw new DaoException(e);
		} finally {
			connectionPool.closeConnection(connection, preparedStatement);
		}
		return rooms;
	}

	@Override
	public List<Room> getRoomsPriceAndCapacity(double price, int capacity)
			throws DaoException {
		List<Room> rooms = new ArrayList<Room>();
		Connection connection = null;
		PreparedStatement preparedStatement = null;
		try {
			connection = connectionPool.takeConnection();
			preparedStatement = connection
					.prepareStatement(GET_SPECIFIC_ROOMS_PRICE);
			preparedStatement.setDouble(1, price);
			preparedStatement.setInt(2, capacity);
			ResultSet resultSet = preparedStatement.executeQuery();
			while (resultSet.next()) {
				Room room = new Room();
				room.setIdRoom(resultSet.getInt(1));
				room.setPrice(resultSet.getDouble(2));
				switch (resultSet.getString(3)) {
				case "ECONOM":
					room.setCategory(Category.ECONOM);
					break;
				case "FAMILY":
					room.setCategory(Category.FAMILY);
					break;
				case "LUX":
					room.setCategory(Category.LUX);
					break;
				case "SUPER_LUX":
					room.setCategory(Category.SUPER_LUX);
					break;
				default:
					throw new DaoException("There is no such category.");
				}
				room.setCapacity(resultSet.getInt(4));
				room.setDeleted(resultSet.getBoolean(5));
				rooms.add(room);
			}
		} catch (ConnectionPoolException | SQLException e) {
			throw new DaoException(e);
		} finally {
			connectionPool.closeConnection(connection, preparedStatement);
		}
		return rooms;
	}

	@Override
	public List<Room> getRoomsPriceAndCategoryAndCapacity(String category,
			double price, int capacity) throws DaoException {
		List<Room> rooms = new ArrayList<Room>();
		Connection connection = null;
		PreparedStatement preparedStatement = null;
		try {
			connection = connectionPool.takeConnection();
			preparedStatement = connection
					.prepareStatement(GET_SPECIFIC_ROOMS_CATEGORY_AND_PRICE);
			preparedStatement.setString(1, category);
			preparedStatement.setDouble(2, price);
			preparedStatement.setInt(3, capacity);
			ResultSet resultSet = preparedStatement.executeQuery();
			while (resultSet.next()) {
				Room room = new Room();
				room.setIdRoom(resultSet.getInt(1));
				room.setPrice(resultSet.getDouble(2));
				switch (resultSet.getString(3)) {
				case "ECONOM":
					room.setCategory(Category.ECONOM);
					break;
				case "FAMILY":
					room.setCategory(Category.FAMILY);
					break;
				case "LUX":
					room.setCategory(Category.LUX);
					break;
				case "SUPER_LUX":
					room.setCategory(Category.SUPER_LUX);
					break;
				default:
					throw new DaoException("There is no such category.");
				}
				room.setCapacity(resultSet.getInt(4));
				room.setDeleted(resultSet.getBoolean(5));
				rooms.add(room);
			}
		} catch (ConnectionPoolException | SQLException e) {
			throw new DaoException(e);
		} finally {
			connectionPool.closeConnection(connection, preparedStatement);
		}
		return rooms;
	}

	@Override
	public List<Room> getRoomsCapacity(int capacity) throws DaoException {
		List<Room> rooms = new ArrayList<Room>();
		Connection connection = null;
		PreparedStatement preparedStatement = null;
		try {
			connection = connectionPool.takeConnection();
			preparedStatement = connection
					.prepareStatement(GET_SPECIFIC_ROOMS_CAPACITY);
			preparedStatement.setInt(1, capacity);
			ResultSet resultSet = preparedStatement.executeQuery();
			while (resultSet.next()) {
				Room room = new Room();
				room.setIdRoom(resultSet.getInt(1));
				room.setPrice(resultSet.getDouble(2));
				switch (resultSet.getString(3)) {
				case "ECONOM":
					room.setCategory(Category.ECONOM);
					break;
				case "FAMILY":
					room.setCategory(Category.FAMILY);
					break;
				case "LUX":
					room.setCategory(Category.LUX);
					break;
				case "SUPER_LUX":
					room.setCategory(Category.SUPER_LUX);
					break;
				default:
					throw new DaoException("There is no such category.");
				}
				room.setCapacity(resultSet.getInt(4));
				room.setDeleted(resultSet.getBoolean(5));
				rooms.add(room);
			}
		} catch (ConnectionPoolException | SQLException e) {
			throw new DaoException(e);
		} finally {
			connectionPool.closeConnection(connection, preparedStatement);
		}
		return rooms;
	}

	@Override
	public List<Order> getUserOrders(int idUser) throws DaoException {
		List<Order> orders = new ArrayList<Order>();
		Order order = null;
		Room room = null;
		Connection connection = null;
		Statement statement = null;
		ResultSet resultSet = null;
		try {
			connection = connectionPool.takeConnection();
			statement = connection.createStatement();
			resultSet = statement.executeQuery(GET_USER_ORDERS + idUser);
			while (resultSet.next()) {
				order = new Order();
				room = new Room();
				order.setIdOrder(resultSet.getInt(1));
				room.setIdRoom(resultSet.getInt(2));
				room.setPrice(resultSet.getDouble(3));
				switch (resultSet.getString(4)) {
				case "ECONOM":
					room.setCategory(Category.ECONOM);
					break;
				case "FAMILY":
					room.setCategory(Category.FAMILY);
					break;
				case "LUX":
					room.setCategory(Category.LUX);
					break;
				case "SUPER_LUX":
					room.setCategory(Category.SUPER_LUX);
					break;
				default:
					throw new DaoException("There is no such category.");
				}
				room.setCapacity(resultSet.getInt(5));
				order.setArrival(resultSet.getDate(6));
				order.setDeparture((resultSet.getDate(7)));
				order.setRoom(room);
				orders.add(order);
			}
		} catch (ConnectionPoolException | SQLException e) {
			throw new DaoException(e);
		} finally {
			connectionPool.closeConnection(connection, statement);
		}

		return orders;
	}

	@Override
	public int insertOrder(String arrival, String departure, int idUser,
			int idRoom) throws DaoException {

		int result = 0;
		Connection connection = null;
		PreparedStatement preparedStatement = null;
		try {
			connection = connectionPool.takeConnection();
			preparedStatement = connection.prepareStatement(INSERT_ORDER);
			preparedStatement.setString(1, arrival);
			preparedStatement.setString(2, departure);
			preparedStatement.setInt(3, idUser);
			preparedStatement.setInt(4, idRoom);
			result = preparedStatement.executeUpdate();
			preparedStatement.close();
			preparedStatement = connection.prepareStatement(INSERT_BOOKEDDATE);
			preparedStatement.setInt(1, idRoom);
			preparedStatement.setString(2, arrival);
			preparedStatement.setString(3, departure);
			result = preparedStatement.executeUpdate();
		} catch (ConnectionPoolException | SQLException e) {
			throw new DaoException(e);
		} finally {
			connectionPool.closeConnection(connection, preparedStatement);
		}
		return result;
	}

	@Override
	public List<Room> getFreeRooms(String arrival, String departure)
			throws DaoException {

		IMySqlAdminDao dao = DaoFactory.getDAO(DAOType.MY_SQL_DAO)
				.getMySqlAdminDao();

		List<Room> busyRooms = new ArrayList<Room>();
		List<Room> allRooms = new ArrayList<Room>();

		allRooms.addAll(getRoomsNotDeleted());
		Room room = null;
		Connection connection = null;
		PreparedStatement preparedStatement = null;
		ResultSet resultSet = null;
		try {
			connection = connectionPool.takeConnection();
			preparedStatement = connection.prepareStatement(GET_BOOKEDROOM);
			preparedStatement.setString(1, arrival);
			preparedStatement.setString(2, departure);
			resultSet = preparedStatement.executeQuery();
			while (resultSet.next()) {
				room = dao.getRoom(resultSet.getInt(1));
				busyRooms.add(room);
			}
		} catch (ConnectionPoolException | SQLException e) {
			throw new DaoException(e);
		} finally {
			connectionPool.closeConnection(connection, preparedStatement);
		}
		allRooms.removeAll(busyRooms);
		return allRooms;
	}
}
<file_sep>/src/by/epam/hostel/logic/impl/CommandLogout.java
package by.epam.hostel.logic.impl;

import javax.servlet.http.HttpServletRequest;

import by.epam.hostel.controller.JspPageName;
import by.epam.hostel.logic.ICommand;
import by.epam.hostel.logic.CommandException;

/**
 * This class implements a pattern command. This class executes logout of user
 * and clears session.
 * 
 * @author <NAME>
 * 
 */
public class CommandLogout implements ICommand {
	/**
	 * This method handles user's request logout from site. The session will be
	 * invalidated.
	 * 
	 * @param request
	 *            a httpServletRequest
	* @throws CommandException
	 * @return String which contains page's path for displaying
	 */
	@Override
	public String execute(HttpServletRequest request) throws CommandException {
		request.getSession(true).invalidate();
		return JspPageName.INDEX_PAGE;
	}
}
<file_sep>/src/by/epam/hostel/localization/register_en.properties
register.name = Name
register.surname = Surname
register.numpass = Number Passport
register.login = Login(e-mail)
register.password = <PASSWORD>
register.passwordmatch = <PASSWORD>
register.message = Send
