Package fr.ippon.tatami.web.controller

Source Code of fr.ippon.tatami.web.controller.AccountWebController

package fr.ippon.tatami.web.controller;

import fr.ippon.tatami.domain.User;
import fr.ippon.tatami.security.AuthenticationService;
import fr.ippon.tatami.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import javax.inject.Inject;

/**
* @author Julien Dubois
*/
@Controller
public class AccountWebController {

    private final Logger log = LoggerFactory.getLogger(AccountWebController.class);

    @Inject
    private UserService userService;

    @Inject
    private AuthenticationService authenticationService;

    @RequestMapping(value = {"/account", "/account/**"},
            method = RequestMethod.GET)
    public ModelAndView getUserProfile() {
        log.debug("Request to get account");
        ModelAndView mv = basicModelAndView();
        mv.setViewName("account");
        return mv;
    }

    /**
     * Common code for all "GET" requests.
     */
    private ModelAndView basicModelAndView() {
        ModelAndView mv = new ModelAndView();
        User currentUser = authenticationService.getCurrentUser();
        User user = userService.getUserByLogin(currentUser.getLogin());
        mv.addObject("user", user);
        return mv;
    }
}
TOP

Related Classes of fr.ippon.tatami.web.controller.AccountWebController

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.