@Override
    public void execute(View view) {
		task = new Task();
		errors.clear();
		if ("GET".equals(view.getRequest().getMethod())){
			String id = view.getRequest().getParameter("id");
			try {
				Long longId = Long.parseLong(id);
				Task task = taskRepository.getTaskById(longId);
				if (task != null) {
					view.getRequest().setAttribute("task", task);
				} else {
					errors.add("Can't find task with id = " + id);
				}
			} catch (Exception ex){
				errors.add("Can't get task with id = " + id);
				logger.log(Level.SEVERE, "Can't get task with id = " + id + " " + ex.getMessage());
			}
			return;
		}
		int taskId = -1;
		try {
			taskId = Integer.parseInt(view.getRequest().getParameter("id"));
		} catch (Exception ex) {
			logger.log(Level.SEVERE, ex.getMessage());
		}

		if (taskId > -1) {
			editTask(view);
		} else {
			addNewTask(view);
		}


    }