@@ -0,0 +1,3103 @@
+package ru.job4j.todo.controller;%0A%0Aimport com.fasterxml.jackson.databind.ObjectMapper;%0Aimport org.hibernate.SessionFactory;%0Aimport ru.job4j.todo.model.Task;%0Aimport ru.job4j.todo.service.ServiceTaskHibernateImpl;%0A%0Aimport javax.servlet.ServletConfig;%0Aimport javax.servlet.ServletException;%0Aimport javax.servlet.annotation.WebServlet;%0Aimport javax.servlet.http.HttpServlet;%0Aimport javax.servlet.http.HttpServletRequest;%0Aimport javax.servlet.http.HttpServletResponse;%0Aimport java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStreamReader;%0Aimport java.text.SimpleDateFormat;%0Aimport java.util.List;%0A%0A/**%0A * Class TaskController.%0A *%0A * @author Ponkin Aleksey%0A * @version 1.0.0%0A * @since 02.04.2019.%0A */%0A@WebServlet(urlPatterns = %22/task%22)%0Apublic class TaskController extends HttpServlet %7B%0A%0A    /**%0A     * Factory session hibernate.%0A     */%0A    private SessionFactory sessionFactory;%0A%0A    public void init(ServletConfig config) throws ServletException %7B%0A        this.sessionFactory = (SessionFactory) config.getServletContext().getAttribute(%22sessionFactory%22);%0A        super.init(config);%0A    %7D%0A%0A    @Override%0A    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException %7B%0A        String done = request.getParameter(%22done%22);%0A        List%3CTask%3E tasks;%0A        ServiceTaskHibernateImpl serviceTask = new ServiceTaskHibernateImpl(sessionFactory);%0A        if (done.equals(%22false%22)) %7B%0A            tasks = serviceTask.findAllByNotDone();%0A        %7D else %7B%0A            tasks= serviceTask.findAll();%0A        %7D%0A        ObjectMapper objectMapper = new ObjectMapper();%0A        objectMapper.setDateFormat(new SimpleDateFormat(%22yyyy-MM-dd HH:mm%22));%0A        response.setContentType(%22application/json%22);%0A        response.setCharacterEncoding(%22UTF-8%22);%0A        response.getWriter().write(objectMapper.writeValueAsString(tasks));%0A    %7D%0A%0A    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException %7B%0A        String jsonTask = new BufferedReader(new InputStreamReader(request.getInputStream())).readLine();%0A        ObjectMapper mapper = new ObjectMapper();%0A        Task task = mapper.readValue(jsonTask, Task.class);%0A        new ServiceTaskHibernateImpl(sessionFactory).add(task);%0A    %7D%0A%0A    protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException %7B%0A        String jsonTask = new BufferedReader(new InputStreamReader(req.getInputStream())).readLine();%0A        ObjectMapper mapper = new ObjectMapper();%0A        Task task = mapper.readValue(jsonTask, Task.class);%0A        new ServiceTaskHibernateImpl(sessionFactory).update(task);%0A    %7D%0A%0A    protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException %7B%0A        String jsonTask = new BufferedReader(new InputStreamReader(req.getInputStream())).readLine();%0A        ObjectMapper mapper = new ObjectMapper();%0A        Task task = mapper.readValue(jsonTask, Task.class);%0A        new ServiceTaskHibernateImpl(sessionFactory).delete(task);%0A    %7D%0A%7D

Add TaskController.