Author: haint
Date: 2011-10-25 06:32:29 -0400 (Tue, 25 Oct 2011)
New Revision: 7866
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java
Log:
GTNPORTAL-2207 Hardcode for getting portal container in LocalizationFilter.java
Modified:
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java
===================================================================
---
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java 2011-10-25
10:30:39 UTC (rev 7865)
+++
portal/trunk/webui/portal/src/main/java/org/exoplatform/portal/application/localization/LocalizationFilter.java 2011-10-25
10:32:29 UTC (rev 7866)
@@ -26,6 +26,7 @@
import org.exoplatform.container.RootContainer;
import org.exoplatform.container.component.ComponentRequestLifecycle;
import org.exoplatform.container.component.RequestLifeCycle;
+import org.exoplatform.container.web.AbstractFilter;
import org.exoplatform.portal.Constants;
import org.exoplatform.portal.application.PortalRequestContext;
import org.exoplatform.services.log.ExoLogger;
@@ -37,7 +38,12 @@
import org.exoplatform.services.resources.LocaleContextInfo;
import org.exoplatform.services.resources.LocalePolicy;
-import javax.servlet.Filter;
+import java.io.IOException;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Locale;
+import java.util.Set;
+
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import javax.servlet.ServletException;
@@ -45,11 +51,6 @@
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Locale;
-import java.util.Set;
/**
* This filter provides {@link HttpServletRequest#getLocale()} and {@link
HttpServletRequest#getLocales()}
@@ -79,17 +80,18 @@
*
* @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
*/
-public class LocalizationFilter implements Filter
+public class LocalizationFilter extends AbstractFilter
{
private static Log log = ExoLogger.getLogger("portal:LocalizationFilter");
private static ThreadLocal<Locale> currentLocale = new
ThreadLocal<Locale>();
private Locale portalLocale = Locale.ENGLISH;
-
- public void init(FilterConfig filterConfig) throws ServletException
+
+ @Override
+ protected void afterInit(FilterConfig config) throws ServletException
{
- String locale = filterConfig.getInitParameter("PortalLocale");
+ String locale = config.getInitParameter("PortalLocale");
locale = locale != null ? locale.trim() : null;
if (locale != null && locale.length() > 0)
portalLocale = LocaleContextInfo.getLocale(locale);
@@ -129,7 +131,7 @@
// Initialize currentLocale
- ExoContainer container = ExoContainerContext.getCurrentContainerIfPresent();
+ ExoContainer container = getContainer();
if (container == null)
{
// Nothing we can do, move on
@@ -137,9 +139,6 @@
return;
}
- if (container instanceof RootContainer)
- container = (ExoContainer)
container.getComponentInstance("portal");
-
LocaleConfigService localeConfigService = (LocaleConfigService)
container.getComponentInstanceOfType(LocaleConfigService.class);
LocalePolicy localePolicy = (LocalePolicy)
container.getComponentInstanceOfType(LocalePolicy.class);