public void doPost(HttpServletRequest req, HttpServletResponse resp) throws IOException { String name = req.getParameter("name"); String labels = req.getParameter("labels"); if (name != null) { name = name.trim(); if (!name.isEmpty()) { TaskRepository repository = new TaskRepository(); try { repository.addTaskWithLabels(name, labels); } finally { repository.close(); } } } resp.sendRedirect("/list/"); }
/** Check if this user id NEW (create default task) */ private void isThisNewUser() { User user = SecurityHelper.getUser(); UserAccountRepository userRepository = new UserAccountRepository(); if (!userRepository.existsUser(user.getUserId())) { log.info("New user " + SecurityHelper.getUser().getEmail()); // Add user userRepository.addUser(user); // Add default tasks repository.addTaskWithLabels("Přečíst nápovědu", "todoizer"); // repository.addTaskWithLabels("Poslat děkovný dopis autorovi aplikace", "todoizer"); } }
public void close() { repository.close(); }
public List<Task> getTasks() { if (tasks == null) { tasks = repository.getTasks(labelFilter); } return tasks; }