51 */ |
51 */ |
52 public abstract class AbstractLightPITServlet extends HttpServlet { |
52 public abstract class AbstractLightPITServlet extends HttpServlet { |
53 |
53 |
54 private static final Logger LOG = LoggerFactory.getLogger(AbstractLightPITServlet.class); |
54 private static final Logger LOG = LoggerFactory.getLogger(AbstractLightPITServlet.class); |
55 |
55 |
56 private static final String HTML_FULL_DISPATCHER = Functions.jspPath("html_full"); |
56 private static final String SITE_JSP = Functions.jspPath("site"); |
57 |
57 |
58 /** |
58 /** |
59 * The EL proxy is necessary, because the EL resolver cannot handle annotation properties. |
59 * The EL proxy is necessary, because the EL resolver cannot handle annotation properties. |
60 */ |
60 */ |
61 private LightPITModule.ELProxy moduleInfo = null; |
61 private LightPITModule.ELProxy moduleInfo = null; |
232 |
232 |
233 private void forwardToFullView(HttpServletRequest req, HttpServletResponse resp) |
233 private void forwardToFullView(HttpServletRequest req, HttpServletResponse resp) |
234 throws IOException, ServletException { |
234 throws IOException, ServletException { |
235 |
235 |
236 req.setAttribute(Constants.REQ_ATTR_MENU, getModuleManager().getMainMenu()); |
236 req.setAttribute(Constants.REQ_ATTR_MENU, getModuleManager().getMainMenu()); |
237 req.getRequestDispatcher(HTML_FULL_DISPATCHER).forward(req, resp); |
237 req.getRequestDispatcher(SITE_JSP).forward(req, resp); |
238 } |
238 } |
239 |
239 |
240 private Optional<Method> findMapping(HttpMethod method, HttpServletRequest req) { |
240 private Optional<Method> findMapping(HttpMethod method, HttpServletRequest req) { |
241 return Optional.ofNullable(mappings.get(method)) |
241 return Optional.ofNullable(mappings.get(method)) |
242 .map(rm -> rm.get(Optional.ofNullable(req.getPathInfo()).orElse("/")) |
242 .map(rm -> rm.get(Optional.ofNullable(req.getPathInfo()).orElse("/")) |
246 private void forwardAsSpecified(ResponseType type, HttpServletRequest req, HttpServletResponse resp) |
246 private void forwardAsSpecified(ResponseType type, HttpServletRequest req, HttpServletResponse resp) |
247 throws ServletException, IOException { |
247 throws ServletException, IOException { |
248 switch (type) { |
248 switch (type) { |
249 case NONE: |
249 case NONE: |
250 return; |
250 return; |
251 case HTML_FULL: |
251 case HTML: |
252 forwardToFullView(req, resp); |
252 forwardToFullView(req, resp); |
253 return; |
253 return; |
254 // TODO: implement remaining response types |
254 // TODO: implement remaining response types |
255 default: |
255 default: |
256 throw new AssertionError("ResponseType switch is not exhaustive - this is a bug!"); |
256 throw new AssertionError("ResponseType switch is not exhaustive - this is a bug!"); |