package ro.robertgabriel.controllers;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import ro.robertgabriel.dao.MongoDBListDao;
import ro.robertgabriel.frontend.Configuration;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@Controller
public class HomeController {

    @Autowired
    private Configuration configuration;

    @ResponseBody
    @RequestMapping("/")
    public void getHome(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        MongoDBListDao mongoDBListDao = new MongoDBListDao();

        List lists = mongoDBListDao.readAllList() ;

        request.setAttribute("lists", lists);
        request.setAttribute("configuration", getConfiguration());

        request.getRequestDispatcher("WEB-INF/jsp/index.jsp").forward(request, response);
    }

    public Configuration getConfiguration() {
        return configuration;
    }

    public void setConfiguration(Configuration configuration) {
        this.configuration = configuration;
    }
}

@@ -525,31 +525,8 @@
 ion;
-%0Aimport java.util.List;
 %0A%0A@C
@@ -677,20 +677,22 @@
  public 
-void
+String
  getHome
@@ -848,24 +848,26 @@
 ListDao();%0A%0A
+//
         List
@@ -906,17 +906,21 @@
 ist() ;%0A
-%0A
+//%0A//
         
@@ -957,16 +957,18 @@
 lists);%0A
+//
         
@@ -1026,17 +1026,21 @@
 ion());%0A
-%0A
+//%0A//
         
@@ -1121,16 +1121,44 @@
 ponse);%0A
+        return %22Home test%22;%0A
     %7D%0A%0A 

return string from home