@RequestMapping(value = "editTask", method = RequestMethod.POST)
    public @ResponseBody
    TodoTask editTask(@RequestParam Integer id, @RequestParam String title, @RequestParam String content,
                      @RequestParam String targetTime, @RequestParam Integer priority, @RequestParam boolean completed,
                      @RequestParam Integer list, WebRequest webRequest) {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        if (authentication.isAuthenticated() && (authentication.getPrincipal() instanceof User)) {
            TodoTask task = todoTasksDAO.findTaskById(id);
            if (task == null)
                return null;

            TodoUser todoUser = (TodoUser) webRequest.getAttribute("user", WebRequest.SCOPE_SESSION);
            TodoList todoList = todoListsDAO.findListById(list);
            // Имеет ли право автор редактировать это сообщение
            if (task.getAuthor().getId().intValue() != todoUser.getId().intValue()
                && !"ROLE_ADMIN".equals(todoUser.getRole())
                && task.getList().getPubStatus() != TodoList.STATUS_PUBLIC_EDIT)
                return null;
            try {
                Date target = TodoController.DATE_FORMAT.parse(targetTime);
                task.setTargetTime(target);
            } catch (ParseException ex) {
                return null;
            }
            task.setPriority(priority);
            task.setTitle(title);
            task.setContent(content);
            task.setCompleted(completed);
            task.setList(todoList);
            todoTasksDAO.addTask(task);
            return task;
        }
        return null;
    }