public static final String CURRENT_LOCALE_KEY = "currentLocale";
private String paramValue;
@Override
protected Locale determineDefaultLocale(HttpServletRequest request){
SetupManager setupManager = (SetupManager) AppUtil.getApplicationContext().getBean("setupManager");
Locale locale = (Locale) request.getAttribute(DEFAULT_LOCALE_KEY);
if (locale == null) {
Long tempCacheDuration = 5000L; // 5 seconds
// lookup in session
boolean defaultLocaleExpired = true;
Long defaultLocaleExpiry = (Long)request.getSession().getAttribute(DEFAULT_LOCALE_EXPIRY_KEY);
if (defaultLocaleExpiry == null || defaultLocaleExpiry.compareTo(new Long(System.currentTimeMillis())) < 0) {
request.getSession().removeAttribute(DEFAULT_LOCALE_KEY);
} else {
defaultLocaleExpired = false;
}
locale = (Locale) request.getSession().getAttribute(DEFAULT_LOCALE_KEY);
if (locale == null) {
locale = DEFAULT;
try {
// reset profile and set hostname
HostManager.setCurrentProfile(null);
String hostname = request.getServerName();
HostManager.setCurrentHost(hostname);
// set locale
String systemLocale = "";
String enableUserLocale = setupManager.getSettingValue("enableUserLocale");
if (enableUserLocale != null && enableUserLocale.equalsIgnoreCase("true")) {
WorkflowUserManager workflowUserManager = (WorkflowUserManager) AppUtil.getApplicationContext().getBean("workflowUserManager");
UserDao userDao = (UserDao) AppUtil.getApplicationContext().getBean("userDao");
String username = workflowUserManager.getCurrentUsername();
User user = userDao.getUser(username);
if (user != null && user.getLocale() != null && !user.getLocale().isEmpty()) {
systemLocale = user.getLocale();
}
}
if (systemLocale == null || systemLocale.isEmpty()) {
systemLocale = setupManager.getSettingValue("systemLocale");
}
if (systemLocale != null && systemLocale.trim().length() > 0) {
String[] temp = systemLocale.split("_");