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

changeset 70
821c4950b619
parent 63
51aa5e267c7f
child 71
dca186d3911f
equal deleted inserted replaced
69:2223bd79e0c6 70:821c4950b619
89 * <p> 89 * <p>
90 * The reason for this is the different handling of empty paths in 90 * The reason for this is the different handling of empty paths in
91 * {@link HttpServletRequest#getPathInfo()}. 91 * {@link HttpServletRequest#getPathInfo()}.
92 */ 92 */
93 private final Map<HttpMethod, Map<String, Method>> mappings = new HashMap<>(); 93 private final Map<HttpMethod, Map<String, Method>> mappings = new HashMap<>();
94
95 private final List<MenuEntry> subMenu = new ArrayList<>();
96 94
97 /** 95 /**
98 * Gives implementing modules access to the {@link ModuleManager}. 96 * Gives implementing modules access to the {@link ModuleManager}.
99 * 97 *
100 * @return the module manager 98 * @return the module manager
185 || HttpServletResponse.class.isAssignableFrom(param) 183 || HttpServletResponse.class.isAssignableFrom(param)
186 || DataAccessObjects.class.isAssignableFrom(param); 184 || DataAccessObjects.class.isAssignableFrom(param);
187 } 185 }
188 if (paramsInjectible) { 186 if (paramsInjectible) {
189 String requestPath = "/" + mapping.get().requestPath(); 187 String requestPath = "/" + mapping.get().requestPath();
190 if (!mapping.get().requestPath().isBlank() && !mapping.get().menuKey().isBlank()) {
191 requestPath += "/";
192 }
193 188
194 if (mappings 189 if (mappings
195 .computeIfAbsent(mapping.get().method(), k -> new HashMap<>()) 190 .computeIfAbsent(mapping.get().method(), k -> new HashMap<>())
196 .putIfAbsent(requestPath, method) != null) { 191 .putIfAbsent(requestPath, method) != null) {
197 LOG.warn("{} {} has multiple mappings", 192 LOG.warn("{} {} has multiple mappings",
198 mapping.get().method(), 193 mapping.get().method(),
199 mapping.get().requestPath() 194 mapping.get().requestPath()
200 ); 195 );
201 }
202
203 final var menuKey = mapping.get().menuKey();
204 if (!menuKey.isBlank()) {
205 subMenu.add(new MenuEntry(
206 new ResourceKey(moduleInfo.getBundleBaseName(), menuKey),
207 moduleInfo.getModulePath() + requestPath,
208 mapping.get().menuSequence()));
209 } 196 }
210 197
211 LOG.debug("{} {} maps to {}::{}", 198 LOG.debug("{} {} maps to {}::{}",
212 mapping.get().method(), 199 mapping.get().method(),
213 requestPath, 200 requestPath,
323 310
324 private void forwardToFullView(HttpServletRequest req, HttpServletResponse resp) 311 private void forwardToFullView(HttpServletRequest req, HttpServletResponse resp)
325 throws IOException, ServletException { 312 throws IOException, ServletException {
326 313
327 req.setAttribute(Constants.REQ_ATTR_MENU, getModuleManager().getMainMenu()); 314 req.setAttribute(Constants.REQ_ATTR_MENU, getModuleManager().getMainMenu());
328 req.setAttribute(Constants.REQ_ATTR_SUB_MENU, subMenu);
329 req.getRequestDispatcher(SITE_JSP).forward(req, resp); 315 req.getRequestDispatcher(SITE_JSP).forward(req, resp);
330 } 316 }
331 317
332 private String sanitizeRequestPath(HttpServletRequest req) { 318 private String sanitizeRequestPath(HttpServletRequest req) {
333 return Optional.ofNullable(req.getPathInfo()).orElse("/"); 319 return Optional.ofNullable(req.getPathInfo()).orElse("/");

mercurial