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

changeset 79
f64255a88d66
parent 78
bb4c52bf3439
child 80
27a25f32048e
equal deleted inserted replaced
78:bb4c52bf3439 79:f64255a88d66
48 import java.util.*; 48 import java.util.*;
49 import java.util.function.Function; 49 import java.util.function.Function;
50 50
51 /** 51 /**
52 * A special implementation of a HTTPServlet which is focused on implementing 52 * A special implementation of a HTTPServlet which is focused on implementing
53 * the necessary functionality for {@link LightPITModule}s. 53 * the necessary functionality for LightPIT pages.
54 */ 54 */
55 public abstract class AbstractLightPITServlet extends HttpServlet { 55 public abstract class AbstractLightPITServlet extends HttpServlet {
56 56
57 private static final Logger LOG = LoggerFactory.getLogger(AbstractLightPITServlet.class); 57 private static final Logger LOG = LoggerFactory.getLogger(AbstractLightPITServlet.class);
58 58
86 * <p> 86 * <p>
87 * The reason for this is the different handling of empty paths in 87 * The reason for this is the different handling of empty paths in
88 * {@link HttpServletRequest#getPathInfo()}. 88 * {@link HttpServletRequest#getPathInfo()}.
89 */ 89 */
90 private final Map<HttpMethod, Map<String, Method>> mappings = new HashMap<>(); 90 private final Map<HttpMethod, Map<String, Method>> mappings = new HashMap<>();
91
92 /**
93 * Gives implementing modules access to the {@link ModuleManager}.
94 *
95 * @return the module manager
96 */
97 protected final ModuleManager getModuleManager() {
98 return (ModuleManager) getServletContext().getAttribute(ModuleManager.SC_ATTR_NAME);
99 }
100 91
101 /** 92 /**
102 * Returns the name of the resource bundle associated with this servlet. 93 * Returns the name of the resource bundle associated with this servlet.
103 * @return the resource bundle base name 94 * @return the resource bundle base name
104 */ 95 */
330 } 321 }
331 322
332 private void forwardToFullView(HttpServletRequest req, HttpServletResponse resp) 323 private void forwardToFullView(HttpServletRequest req, HttpServletResponse resp)
333 throws IOException, ServletException { 324 throws IOException, ServletException {
334 325
335 final var mainMenu = new ArrayList<MenuEntry>(getModuleManager().getMainMenu()); 326 final String lightpitBundle = "localization.lightpit";
327 final var mainMenu = List.of(
328 new MenuEntry(new ResourceKey(lightpitBundle, "menu.projects"), "projects/"),
329 new MenuEntry(new ResourceKey(lightpitBundle, "menu.users"), "teams/"),
330 new MenuEntry(new ResourceKey(lightpitBundle, "menu.languages"), "language/")
331 );
336 for (var entry : mainMenu) { 332 for (var entry : mainMenu) {
337 if (Functions.fullPath(req).startsWith("/" + entry.getPathName())) { 333 if (Functions.fullPath(req).startsWith("/" + entry.getPathName())) {
338 entry.setActive(true); 334 entry.setActive(true);
339 } 335 }
340 } 336 }

mercurial