portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tay...@apache.org
Subject svn commit: r378091 - /portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/localization/impl/LocalizationValveImpl.java
Date Wed, 15 Feb 2006 21:12:30 GMT
Author: taylor
Date: Wed Feb 15 13:12:28 2006
New Revision: 378091

URL: http://svn.apache.org/viewcvs?rev=378091&view=rev
Log:
We can't be hitting the database like this per request

Modified:
    portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/localization/impl/LocalizationValveImpl.java

Modified: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/localization/impl/LocalizationValveImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/localization/impl/LocalizationValveImpl.java?rev=378091&r1=378090&r2=378091&view=diff
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/localization/impl/LocalizationValveImpl.java
(original)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/localization/impl/LocalizationValveImpl.java
Wed Feb 15 13:12:28 2006
@@ -97,39 +97,40 @@
      */
     public void invoke( RequestContext request, ValveContext context ) throws PipelineException
     {
-        Locale locale = null;
-
-        // Get the prefered locale from user's preferences(persistent storage) if not anon
user
-        Subject subject = request.getSubject();
-        if (null != subject)
-        {
-            Principal userPrincipal = SecurityHelper.getPrincipal(subject, UserPrincipal.class);
-            if (null != userPrincipal)
+        Locale locale = (Locale)request.getRequest().getSession().getAttribute(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE);
+        if (null == locale)
+        {        
+            // Get the prefered locale from user's preferences(persistent storage) if not
anon user
+            Subject subject = request.getSubject();
+            if (null != subject)
             {
-                log.debug("Got user principal: " + userPrincipal.getName());
-                UserManager userMgr = (UserManager) Jetspeed.getComponentManager().getComponent(UserManager.class);
-                try
+                Principal userPrincipal = SecurityHelper.getPrincipal(subject, UserPrincipal.class);
+                if (null != userPrincipal)
                 {
-                    if (!userMgr.getAnonymousUser().equals(userPrincipal.getName())
-                            && userMgr.userExists(userPrincipal.getName()))
+                    log.debug("Got user principal: " + userPrincipal.getName());
+                    UserManager userMgr = (UserManager) Jetspeed.getComponentManager().getComponent(UserManager.class);
+                    try
                     {
-                        User user = userMgr.getUser(userPrincipal.getName());
-                        // TODO if preferred lang or locale is defined in PLT.D, it's better
to use it
-                        Preferences prefs = user.getPreferences();
-                        String localeString = prefs.get(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE,
null);
-                        if (localeString != null)
+                        if (!userMgr.getAnonymousUser().equals(userPrincipal.getName())
+                                && userMgr.userExists(userPrincipal.getName()))
                         {
-                            locale = JetspeedLocale.convertStringToLocale(localeString);
+                            User user = userMgr.getUser(userPrincipal.getName());
+                            // TODO if preferred lang or locale is defined in PLT.D, it's
better to use it
+                            Preferences prefs = user.getPreferences();
+                            String localeString = prefs.get(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE,
null);
+                            if (localeString != null)
+                            {
+                                locale = JetspeedLocale.convertStringToLocale(localeString);
+                            }
                         }
                     }
-                }
-                catch (SecurityException e)
-                {
-                    log.warn("Unexpected SecurityException in UserInfoManager", e);
+                    catch (SecurityException e)
+                    {
+                        log.warn("Unexpected SecurityException in UserInfoManager", e);
+                    }
                 }
             }
         }
-
         if (locale == null)
         {
             locale = (Locale) request.getSessionAttribute(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE);



---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@portals.apache.org
For additional commands, e-mail: jetspeed-dev-help@portals.apache.org


Mime
View raw message