com.in28minutes.domain.User Java Examples
The following examples show how to use
com.in28minutes.domain.User.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ListTodoServlet.java From MavenIn28Minutes with MIT License | 6 votes |
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); User user = (User) session.getAttribute(TodoListUtils.SESSION_USER); TodoItemList todoList = todoService.getTodoListByUser(user.getId()); // todo list is request scoped to avoid storing and synchronizing it in // session for each CRUD operation request.setAttribute("todoList", todoList.getItems()); request.setAttribute("homeTabStyle", "active"); request.setAttribute("totalCount", todoList.getCount()); request.setAttribute("doneCount", todoList.getDoneCount()); request.setAttribute("todoCount", todoList.getTodoCount()); request.getRequestDispatcher(HOME_PAGE).forward(request, response); }
Example #2
Source File: ListTodoServlet.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 6 votes |
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); User user = (User) session.getAttribute(TodoListUtils.SESSION_USER); TodoItemList todoList = todoService.getTodoListByUser(user.getId()); // todo list is request scoped to avoid storing and synchronizing it in // session for each CRUD operation request.setAttribute("todoList", todoList.getItems()); request.setAttribute("homeTabStyle", "active"); request.setAttribute("totalCount", todoList.getCount()); request.setAttribute("doneCount", todoList.getDoneCount()); request.setAttribute("todoCount", todoList.getTodoCount()); request.getRequestDispatcher(HOME_PAGE).forward(request, response); }
Example #3
Source File: UserDataServiceImpl.java From MavenIn28Minutes with MIT License | 5 votes |
public boolean login(final String email, final String password) { TypedQuery<User> query = entityManager.createNamedQuery( "findUserByEmailAndPassword", User.class); query.setParameter("p_email", email); query.setParameter("p_password", password); List<User> users = query.getResultList(); return (users != null && !users.isEmpty()); }
Example #4
Source File: SessionCheckFilter.java From MavenIn28Minutes with MIT License | 5 votes |
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException { HttpServletRequest req = (HttpServletRequest) request; HttpSession session = req.getSession(); User user = (User) session.getAttribute(TodoListUtils.SESSION_USER); if (user != null) { chain.doFilter(request, response); } else { request.getRequestDispatcher(LOGIN_PAGE).forward(request, response); } }
Example #5
Source File: LoginServlet.java From MavenIn28Minutes with MIT License | 5 votes |
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String email = request.getParameter("email"); String password = request.getParameter("password"); LoginForm loginForm = new LoginForm(); loginForm.setEmail(email); loginForm.setPassword(password); validateCredentials(request, loginForm); if (isInvalid(request)) { request.getRequestDispatcher(LOGIN_PAGE).forward(request, response); return; } if (isValidUser(email, password)) { request.setAttribute("error", resourceBundle.getString("login.form.invalid.credentials")); request.getRequestDispatcher(LOGIN_PAGE).forward(request, response); return; } HttpSession session = request.getSession(true);// create session User user = userService.getUserByEmail(email); session.setAttribute(TodoListUtils.SESSION_USER, user); request.getRequestDispatcher(REDIRECT_HOME_PAGE).forward(request, response); }
Example #6
Source File: UserDataServiceImpl.java From MavenIn28Minutes with MIT License | 5 votes |
public User getUserByEmail(final String email) { TypedQuery<User> query = entityManager.createNamedQuery( "findUserByEmail", User.class); query.setParameter("p_email", email); List<User> users = query.getResultList(); return (users != null && !users.isEmpty()) ? users.get(0) : null; }
Example #7
Source File: UserDataServiceImpl.java From MavenIn28Minutes with MIT License | 5 votes |
public void remove(final User user) { entityManager.createNativeQuery( "DELETE FROM todo t WHERE t.userId = " + user.getId()) .executeUpdate(); User u = entityManager.find(User.class, user.getId()); entityManager.remove(u); }
Example #8
Source File: UserDataServiceImpl.java From SpringIn28Minutes with MIT License | 5 votes |
@Override public User getUserByEmail(final String email) { TypedQuery<User> query = entityManager.createNamedQuery( "findUserByEmail", User.class); query.setParameter("p_email", email); List<User> users = query.getResultList(); return users != null && !users.isEmpty() ? users.get(0) : null; }
Example #9
Source File: TodoController.java From SpringIn28Minutes with MIT License | 5 votes |
@RequestMapping(value = "/user/todos/new", method = RequestMethod.POST) public String createNewTodo(@ModelAttribute TodoItem todoItem) { final User user = sessionData.getUser(); todoItem.setDone(false); todoItem.setUserId(user.getId()); todoService.create(todoItem); return REDIRECT_TO_VIEW_TODOS_CONTROLLER; }
Example #10
Source File: UserDataServiceImpl.java From SpringIn28Minutes with MIT License | 5 votes |
@Override public void remove(final User user) { entityManager.createNativeQuery( "DELETE FROM todo t WHERE t.userId = " + user.getId()) .executeUpdate(); User u = entityManager.find(User.class, user.getId()); entityManager.remove(u); }
Example #11
Source File: UserDataServiceImpl.java From SpringIn28Minutes with MIT License | 5 votes |
@Override public boolean login(final String email, final String password) { TypedQuery<User> query = entityManager.createNamedQuery( "findUserByEmailAndPassword", User.class); query.setParameter("p_email", email); query.setParameter("p_password", password); List<User> users = query.getResultList(); return users != null && !users.isEmpty(); }
Example #12
Source File: LoginServlet.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 5 votes |
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String email = request.getParameter("email"); String password = request.getParameter("password"); LoginForm loginForm = new LoginForm(); loginForm.setEmail(email); loginForm.setPassword(password); validateCredentials(request, loginForm); if (isInvalid(request)) { request.getRequestDispatcher(LOGIN_PAGE).forward(request, response); return; } if (isValidUser(email, password)) { request.setAttribute("error", resourceBundle.getString("login.form.invalid.credentials")); request.getRequestDispatcher(LOGIN_PAGE).forward(request, response); return; } HttpSession session = request.getSession(true);// create session User user = userService.getUserByEmail(email); session.setAttribute(TodoListUtils.SESSION_USER, user); request.getRequestDispatcher(REDIRECT_HOME_PAGE).forward(request, response); }
Example #13
Source File: SessionCheckFilter.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 5 votes |
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws ServletException, IOException { HttpServletRequest req = (HttpServletRequest) request; HttpSession session = req.getSession(); User user = (User) session.getAttribute(TodoListUtils.SESSION_USER); if (user != null) { chain.doFilter(request, response); } else { request.getRequestDispatcher(LOGIN_PAGE).forward(request, response); } }
Example #14
Source File: UserDataServiceImpl.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 5 votes |
public void remove(final User user) { entityManager.createNativeQuery( "DELETE FROM todo t WHERE t.userId = " + user.getId()) .executeUpdate(); User u = entityManager.find(User.class, user.getId()); entityManager.remove(u); }
Example #15
Source File: UserDataServiceImpl.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 5 votes |
public User getUserByEmail(final String email) { TypedQuery<User> query = entityManager.createNamedQuery( "findUserByEmail", User.class); query.setParameter("p_email", email); List<User> users = query.getResultList(); return (users != null && !users.isEmpty()) ? users.get(0) : null; }
Example #16
Source File: UserDataServiceImpl.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 5 votes |
public boolean login(final String email, final String password) { TypedQuery<User> query = entityManager.createNamedQuery( "findUserByEmailAndPassword", User.class); query.setParameter("p_email", email); query.setParameter("p_password", password); List<User> users = query.getResultList(); return (users != null && !users.isEmpty()); }
Example #17
Source File: CreateTodoServlet.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 4 votes |
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); User user = (User) session.getAttribute(TodoListUtils.SESSION_USER); String title = request.getParameter("title"); String dueDate = request.getParameter("dueDate"); String priority = request.getParameter("priority"); TodoItem todoItem = new TodoItem(user.getId(), title, false, Priority.valueOf(priority), new Date(dueDate)); todoService.create(todoItem); request.getRequestDispatcher("/todos").forward(request, response); }
Example #18
Source File: UserDataServiceImpl.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 4 votes |
public User create(final User user) { entityManager.persist(user); return user; }
Example #19
Source File: UserServiceImpl.java From SpringIn28Minutes with MIT License | 4 votes |
@Transactional(readOnly = true) public User getUserByEmail(final String email) { return userDataService.getUserByEmail(email); }
Example #20
Source File: UserServiceImpl.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 4 votes |
public User create(final User user) { return userDataService.create(user); }
Example #21
Source File: UserServiceImpl.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 4 votes |
public User update(User user) { return userDataService.update(user); }
Example #22
Source File: UserServiceImpl.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 4 votes |
public void remove(final User user) { userDataService.remove(user); }
Example #23
Source File: UserDataServiceImpl.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 4 votes |
public User update(User user) { return entityManager.merge(user); }
Example #24
Source File: UserServiceImpl.java From SpringIn28Minutes with MIT License | 4 votes |
public void remove(final User user) { userDataService.remove(user); }
Example #25
Source File: UserServiceImpl.java From SpringIn28Minutes with MIT License | 4 votes |
public User update(User user) { return userDataService.update(user); }
Example #26
Source File: UserServiceImpl.java From SpringIn28Minutes with MIT License | 4 votes |
public User create(final User user) { return userDataService.create(user); }
Example #27
Source File: CreateTodoServlet.java From MavenIn28Minutes with MIT License | 4 votes |
@Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession session = request.getSession(); User user = (User) session.getAttribute(TodoListUtils.SESSION_USER); String title = request.getParameter("title"); String dueDate = request.getParameter("dueDate"); String priority = request.getParameter("priority"); TodoItem todoItem = new TodoItem(user.getId(), title, false, Priority.valueOf(priority), new Date(dueDate)); todoService.create(todoItem); request.getRequestDispatcher("/todos").forward(request, response); }
Example #28
Source File: UserDataServiceImpl.java From MavenIn28Minutes with MIT License | 4 votes |
public User create(final User user) { entityManager.persist(user); return user; }
Example #29
Source File: UserServiceImpl.java From RealWorldWebApplicationWithServletsAndJspIn28Minutes with MIT License | 4 votes |
@Transactional(readOnly = true) public User getUserByEmail(final String email) { return userDataService.getUserByEmail(email); }
Example #30
Source File: UserDataServiceImpl.java From SpringIn28Minutes with MIT License | 4 votes |
@Override public User update(User user) { return entityManager.merge(user); }