* open-postings to the newswire
*
* @author mir-coders group
- * @version $Id: ServletModuleOpenIndy.java,v 1.89.2.2 2003/06/03 20:58:30 john Exp $
+ * @version $Id: ServletModuleOpenIndy.java,v 1.89.2.3 2003/06/13 03:54:08 zapata Exp $
*
*/
private static final String SESSION_REQUEST_KEY="sessionid";
/**
+ * Selects the language for the response.
+ *
+ * @param session
+ * @param aRequest
+ */
+
+ protected Locale getResponseLocale(HttpSession aSession, HttpServletRequest aRequest) {
+ String requestLanguage = aRequest.getParameter("language");
+ String sessionLanguage = (String) aSession.getAttribute("language");
+ String acceptLanguage = aRequest.getLocale().getLanguage();
+ String defaultLanguage = configuration.getString("Mir.Login.DefaultLanguage", "en");
+
+ String language = requestLanguage;
+
+ if (language==null)
+ language = sessionLanguage;
+
+ if (language==null)
+ language = acceptLanguage;
+
+ if (language==null)
+ language = defaultLanguage;
+
+ aSession.setAttribute("language", language);
+
+ return new Locale(language, "");
+ }
+
+ /**
* Dispatch method for open sessions: a flexible extensible and customizable way
* for open access. Can be used for postings, but also for lots of other stuff.
*
Session session = new HTTPAdapters.HTTPSessionAdapter(aRequest.getSession());
SimpleResponse response = new SimpleResponse(
- ServletHelper.makeGenerationData(aResponse, new Locale[] {getLocale(aRequest), getFallbackLocale(aRequest)},
+ ServletHelper.makeGenerationData(aResponse, new Locale[] { getResponseLocale(aRequest.getSession(), aRequest), getFallbackLocale(aRequest)},
"bundles.open"));
response.setResponseValue("actionURL", aResponse.encodeURL(HttpUtils.getRequestURL(aRequest).toString())+"?"+SESSION_REQUEST_KEY+"="+aRequest.getSession().getId());