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

changeset 20
bd1a76c91d5b
parent 18
a94b172c3a93
child 21
b213fef2539e
equal deleted inserted replaced
19:1a0ac419f714 20:bd1a76c91d5b
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);

mercurial