src/main/java/de/uapcore/lightpit/AbstractLightPITServlet.java

changeset 145
6d2d69fd1c12
parent 131
67df332e3146
child 151
b3f14cd4f3ab
equal deleted inserted replaced
144:7e06b75cf1b9 145:6d2d69fd1c12
374 } else { 374 } else {
375 return Optional.empty(); 375 return Optional.empty();
376 } 376 }
377 } 377 }
378 378
379 private void forwardToFullView(HttpServletRequest req, HttpServletResponse resp)
380 throws IOException, ServletException {
381
382 final String lightpitBundle = "localization.lightpit";
383 final var mainMenu = List.of(
384 new MenuEntry(new ResourceKey(lightpitBundle, "menu.projects"), "projects/"),
385 new MenuEntry(new ResourceKey(lightpitBundle, "menu.users"), "teams/"),
386 new MenuEntry(new ResourceKey(lightpitBundle, "menu.languages"), "language/")
387 );
388 for (var entry : mainMenu) {
389 if (Functions.fullPath(req).startsWith("/" + entry.getPathName())) {
390 entry.setActive(true);
391 }
392 }
393 req.setAttribute(Constants.REQ_ATTR_MENU, mainMenu);
394 req.getRequestDispatcher(SITE_JSP).forward(req, resp);
395 }
396
397 private String sanitizeRequestPath(HttpServletRequest req) { 379 private String sanitizeRequestPath(HttpServletRequest req) {
398 return Optional.ofNullable(req.getPathInfo()).orElse("/"); 380 return Optional.ofNullable(req.getPathInfo()).orElse("/");
399 } 381 }
400 382
401 private Optional<Map.Entry<PathPattern, Method>> findMapping(HttpMethod method, HttpServletRequest req) { 383 private Optional<Map.Entry<PathPattern, Method>> findMapping(HttpMethod method, HttpServletRequest req) {
410 throws ServletException, IOException { 392 throws ServletException, IOException {
411 switch (type) { 393 switch (type) {
412 case NONE: 394 case NONE:
413 return; 395 return;
414 case HTML: 396 case HTML:
415 forwardToFullView(req, resp); 397 req.getRequestDispatcher(SITE_JSP).forward(req, resp);
416 return; 398 return;
417 // TODO: implement remaining response types 399 // TODO: implement remaining response types
418 default: 400 default:
419 throw new AssertionError("ResponseType switch is not exhaustive - this is a bug!"); 401 throw new AssertionError("ResponseType switch is not exhaustive - this is a bug!");
420 } 402 }

mercurial