package com.agilecontrol.embed.controller; import com.agilecontrol.nea.core.control.web.SessionUtils; import java.io.IOException; import java.io.PrintWriter; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; @Lazy @Controller public class PageController { @RequestMapping( value = {"/console", "/console/#"}, method = {RequestMethod.GET} ) public String toPage(HttpServletRequest request) { String sessionkey = SessionUtils.getSessionKey(request); return sessionkey != null && sessionkey.startsWith("SSO-")?"forward:/control/home":"forward:/toLogin"; } @RequestMapping( value = {"/404"}, method = {RequestMethod.GET} ) public String login() { return "page/404.html"; } @RequestMapping( value = {"/do/bad/request"}, method = {RequestMethod.GET} ) @ResponseBody public String doBadRequest() { return ""; } @RequestMapping( value = {"/do/default/page/request"}, method = {RequestMethod.GET} ) public void doConfigDefaultPage(HttpServletRequest req, HttpServletResponse res) throws IOException { res.setContentType("text/html; charset=UTF-8"); PrintWriter out = res.getWriter(); String url = req.getContextPath() + req.getAttribute("defaultPageUrl") + "/index.html"; out.println(""); out.flush(); } }