85 } |
85 } |
86 |
86 |
87 private ResponseType invokeMapping(Method method, HttpServletRequest req, HttpServletResponse resp) |
87 private ResponseType invokeMapping(Method method, HttpServletRequest req, HttpServletResponse resp) |
88 throws IOException, ServletException { |
88 throws IOException, ServletException { |
89 try { |
89 try { |
90 LOG.debug("invoke {}", method.getName()); |
90 LOG.trace("invoke {}#{}", method.getDeclaringClass().getName(), method.getName()); |
91 return (ResponseType) method.invoke(this, req, resp); |
91 return (ResponseType) method.invoke(this, req, resp); |
92 } catch (ReflectiveOperationException | ClassCastException ex) { |
92 } catch (ReflectiveOperationException | ClassCastException ex) { |
93 LOG.error(String.format("invocation of method %s failed", method.getName()), ex); |
93 LOG.error(String.format("invocation of method %s failed", method.getName()), ex); |
94 resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); |
94 resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); |
95 return ResponseType.NONE; |
95 return ResponseType.NONE; |
240 Optional<List<String>> availableLanguages = Functions.availableLanguages(getServletContext()).map(Arrays::asList); |
240 Optional<List<String>> availableLanguages = Functions.availableLanguages(getServletContext()).map(Arrays::asList); |
241 Optional<Locale> reqLocale = Optional.of(req.getLocale()); |
241 Optional<Locale> reqLocale = Optional.of(req.getLocale()); |
242 Locale sessionLocale = reqLocale.filter((rl) -> availableLanguages.map((al) -> al.contains(rl.getLanguage())).orElse(false)).orElse(Locale.ENGLISH); |
242 Locale sessionLocale = reqLocale.filter((rl) -> availableLanguages.map((al) -> al.contains(rl.getLanguage())).orElse(false)).orElse(Locale.ENGLISH); |
243 session.setAttribute(Constants.SESSION_ATTR_LANGUAGE, sessionLocale); |
243 session.setAttribute(Constants.SESSION_ATTR_LANGUAGE, sessionLocale); |
244 LOG.debug("Settng language for new session {}: {}", session.getId(), sessionLocale.getDisplayLanguage()); |
244 LOG.debug("Settng language for new session {}: {}", session.getId(), sessionLocale.getDisplayLanguage()); |
|
245 } else { |
|
246 LOG.trace("Continuing session {} with language {}", session.getId(), session.getAttribute(Constants.SESSION_ATTR_LANGUAGE)); |
245 } |
247 } |
246 |
248 |
247 req.setAttribute(Constants.REQ_ATTR_PATH, Functions.fullPath(req)); |
249 req.setAttribute(Constants.REQ_ATTR_PATH, Functions.fullPath(req)); |
248 req.setAttribute(Constants.REQ_ATTR_MODULE_CLASSNAME, this.getClass().getName()); |
250 req.setAttribute(Constants.REQ_ATTR_MODULE_CLASSNAME, this.getClass().getName()); |
249 moduleInfoELProxy.ifPresent((proxy) -> req.setAttribute(Constants.REQ_ATTR_MODULE_INFO, proxy)); |
251 moduleInfoELProxy.ifPresent((proxy) -> req.setAttribute(Constants.REQ_ATTR_MODULE_INFO, proxy)); |