/**
  * @param map : holds require attributes
  * @param request :for getting session
  * @return: to the specified path
  * @throws QuestionBankSystemException: handle all system related exceptions
  * @throws QuestionBankException: handle all runtime exceptions
  */
 @RequestMapping(value = "/tour")
 public String getTour(Map<String, Object> map, HttpServletRequest request)
     throws QuestionBankSystemException, QuestionBankException {
   userService.doSetupForPage(map, ""); // do setup for page
   map = setUserToMap(map, request); // do setup of user to map
   return "tour"; // redirecting to tour page
 }
 /**
  * @param map : holds require attributes
  * @param request :for getting session
  * @return: to the specified path
  * @throws QuestionBankSystemException: handle all system related exceptions
  * @throws QuestionBankException: handle all runtime exceptions
  */
 @RequestMapping(value = "/Oauth2CallBack", method = RequestMethod.GET)
 public String doGet(
     Map<String, Object> map, HttpServletRequest request, HttpServletResponse response)
     throws QuestionBankSystemException, QuestionBankException {
   userService.doSetupForPage(map, ""); // do setup for page
   map = userService.doGet(map, request, response); // for google login
   return (String) map.get("result"); // redirecting specified page
 }
 /**
  * @param map : holds require attributes
  * @param request :for getting session
  * @return: to the specified path
  * @throws QuestionBankSystemException: handle all system related exceptions
  * @throws QuestionBankException: handle all runtime exceptions
  */
 @RequestMapping(value = "/logout")
 public String logoutUser(Map<String, Object> map, HttpServletRequest request)
     throws QuestionBankSystemException, QuestionBankException {
   userService.doSetupForPage(map, ""); // do setup for page
   map = userService.logoutUser(map, request); // for logging out user
   map = userService.getDummyData(map, 1, 5, null);
   return "home"; // redirecting to home page
 }
 /**
  * @param user for login
  * @param map : holds require attributes
  * @param request :for getting session
  * @return: to the specified path
  * @throws QuestionBankSystemException: handle all system related exceptions
  * @throws QuestionBankException: handle all runtime exceptions
  */
 @RequestMapping(value = "/login", method = RequestMethod.POST)
 public String doActionsForLogin(
     @ModelAttribute("user") User user,
     BindingResult result,
     Map<String, Object> map,
     HttpServletRequest request,
     HttpServletResponse response)
     throws QuestionBankSystemException, QuestionBankException {
   userService.doSetupForPage(map, ""); // do setup for page
   map = userService.getDummyData(map, 1, 5, null);
   map = userService.doActionsForLogin(map, request, user); // do actions for loggin
   return "home"; // redirecting to home page
 }
  /**
   * @param map : holds require attributes
   * @param request :for getting session
   * @return: to the specified path
   * @throws QuestionBankSystemException: handle all system related exceptions
   * @throws QuestionBankException: handle all runtime exceptions
   */
  @RequestMapping(value = "/profile", method = RequestMethod.GET)
  public ModelAndView getUserForProfile(
      Map<String, Object> map, HttpServletRequest request, HttpServletResponse response)
      throws QuestionBankSystemException, QuestionBankException {

    userService.doSetupForPage(map, ""); // do setup for page
    int id = getUserId(request); // get id from session
    ModelAndView modelAndView = null;
    if (id == 0) {
      User userResult = new User();
      modelAndView = new ModelAndView("home");
      modelAndView.addObject(userResult);
      return modelAndView; // redirecting to home if unauthorized access
    } else {
      modelAndView = new ModelAndView("profile"); // redirecting to profile page
      modelAndView.addObject(userService.getUser(id));
    }
    User user = userService.getUser((int) request.getSession().getAttribute("id"));
    map = userService.getUserForProfile(user, map); // calling get user for profile
    return modelAndView;
  }
 /**
  * @param map : holds require attributes
  * @param request :for getting session
  * @return: to the specified path
  * @throws QuestionBankSystemException: handle all system related exceptions
  * @throws QuestionBankException: handle all runtime exceptions
  */
 @RequestMapping(value = "/", method = RequestMethod.GET)
 public String setDummyData(Map<String, Object> map, HttpServletRequest request)
     throws QuestionBankSystemException, QuestionBankException {
   List<String> data = new ArrayList<String>(); // do setup for dummy data
   data.add(role);
   data.add(user);
   data.add(questionTag);
   data.add(question);
   data.add(answer);
   userService.doSetupForPage(map, ""); // do setup for page
   int page = 1; // starting page
   int numberOfRecordsPerPage = 5; // no of records per page
   if (request.getParameter("page") != null) { // getting page for
     // pagination
     page = Integer.parseInt(request.getParameter("page"));
   }
   map =
       userService.getDummyData(map, page, numberOfRecordsPerPage, data); // calling get dummy data
   map = setUserToMap(map, request); // for setting user to map
   return "home"; // redirecting to home page
 }