portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wea...@apache.org
Subject cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/localization/impl LocalizationValveImpl.java
Date Tue, 13 Jul 2004 21:01:18 GMT
weaver      2004/07/13 14:01:18

  Modified:    portal/src/java/org/apache/jetspeed/localization/impl
                        LocalizationValveImpl.java
  Log:
  Removed logic to look directly at accept-header using fulcrum and replaced
  it with servlet api methods that do the exact same thing.
  
  Revision  Changes    Path
  1.3       +29 -27    jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/localization/impl/LocalizationValveImpl.java
  
  Index: LocalizationValveImpl.java
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/localization/impl/LocalizationValveImpl.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LocalizationValveImpl.java	8 Mar 2004 00:28:06 -0000	1.2
  +++ LocalizationValveImpl.java	13 Jul 2004 21:01:18 -0000	1.3
  @@ -15,10 +15,9 @@
    */
   package org.apache.jetspeed.localization.impl;
   
  +import java.util.Enumeration;
   import java.util.Locale;
   
  -import org.apache.commons.lang.StringUtils;
  -import org.apache.fulcrum.localization.LocaleTokenizer;
   import org.apache.jetspeed.pipeline.PipelineException;
   import org.apache.jetspeed.pipeline.valve.AbstractValve;
   import org.apache.jetspeed.pipeline.valve.LocalizationValve;
  @@ -27,45 +26,48 @@
   
   /**
    * LocalizationValveImpl
  - *
  - * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
  + * 
  + * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
    * @version $Id$
    */
  -public class LocalizationValveImpl
  -    extends AbstractValve
  -    implements LocalizationValve
  +public class LocalizationValveImpl extends AbstractValve implements LocalizationValve
   {
  -    public static final String ACCEPT_LANGUAGE = "Accept-Language";
  -    
  -    private static final Locale defaultLocate = new Locale("en", "US");
  -    
  -    /* (non-Javadoc)
  -     * @see org.apache.jetspeed.pipeline.valve.Valve#invoke(org.apache.jetspeed.request.RequestContext,
org.apache.jetspeed.pipeline.valve.ValveContext)
  +
  +    /*
  +     * (non-Javadoc)
  +     * 
  +     * @see org.apache.jetspeed.pipeline.valve.Valve#invoke(org.apache.jetspeed.request.RequestContext,
  +     *      org.apache.jetspeed.pipeline.valve.ValveContext)
        */
  -    public void invoke(RequestContext request, ValveContext context)
  -        throws PipelineException
  +    public void invoke( RequestContext request, ValveContext context ) throws PipelineException
       {
  -        Locale locale = defaultLocate;
  -        String header = request.getRequest().getHeader(ACCEPT_LANGUAGE);
  -        if (!StringUtils.isEmpty(header))
  +
  +        Locale locale = request.getRequest().getLocale();
  +
  +        if (locale == null)
           {
  -            LocaleTokenizer tok = new LocaleTokenizer(header);
  -            if (tok.hasNext())
  +            Enumeration preferedLocales = request.getRequest().getLocales();
  +            while (preferedLocales.hasMoreElements() && locale == null)
               {
  -                locale = (Locale) tok.next();
  +                locale = (Locale) preferedLocales.nextElement();
               }
           }
   
  +        if (locale == null)
  +        {
  +            locale = Locale.getDefault();
  +        }
  +
           request.setLocale(locale);
  -        
  +
           // Pass control to the next Valve in the Pipeline
           context.invokeNext(request);
  -        
  +
       }
  -    
  +
       public String toString()
       {
           return "LocalizationValve";
       }
  -    
  -}
  +
  +}
  \ No newline at end of file
  
  
  

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


Mime
View raw message