247 } |
247 } |
248 |
248 |
249 private void doProcess(HttpMethod method, HttpServletRequest req, HttpServletResponse resp) |
249 private void doProcess(HttpMethod method, HttpServletRequest req, HttpServletResponse resp) |
250 throws ServletException, IOException { |
250 throws ServletException, IOException { |
251 |
251 |
|
252 // Synchronize module information with database |
|
253 getModuleManager().syncWithDatabase(getDatabaseFacade()); |
|
254 |
|
255 // choose the requested language as session language (if available) or fall back to english, otherwise |
252 HttpSession session = req.getSession(); |
256 HttpSession session = req.getSession(); |
253 |
|
254 // choose the requested language as session language (if available) or fall back to english, otherwise |
|
255 if (session.getAttribute(Constants.SESSION_ATTR_LANGUAGE) == null) { |
257 if (session.getAttribute(Constants.SESSION_ATTR_LANGUAGE) == null) { |
256 Optional<List<String>> availableLanguages = Functions.availableLanguages(getServletContext()).map(Arrays::asList); |
258 Optional<List<String>> availableLanguages = Functions.availableLanguages(getServletContext()).map(Arrays::asList); |
257 Optional<Locale> reqLocale = Optional.of(req.getLocale()); |
259 Optional<Locale> reqLocale = Optional.of(req.getLocale()); |
258 Locale sessionLocale = reqLocale.filter((rl) -> availableLanguages.map((al) -> al.contains(rl.getLanguage())).orElse(false)).orElse(Locale.ENGLISH); |
260 Locale sessionLocale = reqLocale.filter((rl) -> availableLanguages.map((al) -> al.contains(rl.getLanguage())).orElse(false)).orElse(Locale.ENGLISH); |
259 session.setAttribute(Constants.SESSION_ATTR_LANGUAGE, sessionLocale); |
261 session.setAttribute(Constants.SESSION_ATTR_LANGUAGE, sessionLocale); |