portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject cvs commit: jakarta-jetspeed-2/portal/src/webapp/WEB-INF/assembly pipelines.xml
Date Wed, 26 Jan 2005 00:44:41 GMT
ate         2005/01/25 16:44:41

  Modified:    portal/src/java/org/apache/jetspeed/localization/impl
                        LocalizationValveImpl.java
               portal/src/webapp/WEB-INF/assembly pipelines.xml
  Log:
  Added defaultLanguage configuration to LocalizationValveImpl which can be set through Spring.
  
  Revision  Changes    Path
  1.8       +50 -2     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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- LocalizationValveImpl.java	4 Jan 2005 16:16:26 -0000	1.7
  +++ LocalizationValveImpl.java	26 Jan 2005 00:44:41 -0000	1.8
  @@ -18,6 +18,8 @@
   import java.util.Enumeration;
   import java.util.Locale;
   
  +import org.apache.commons.logging.Log;
  +import org.apache.commons.logging.LogFactory;
   import org.apache.jetspeed.PortalReservedParameters;
   import org.apache.jetspeed.pipeline.PipelineException;
   import org.apache.jetspeed.pipeline.valve.AbstractValve;
  @@ -33,7 +35,48 @@
    */
   public class LocalizationValveImpl extends AbstractValve implements LocalizationValve
   {
  +    private static final Log log = LogFactory.getLog(LocalizationValveImpl.class);
  +    private Locale defaultLocale = null;
  +    
  +    public LocalizationValveImpl() {}
  +    
  +    public LocalizationValveImpl(String defaultLanguage)
  +    {
  +        String language = defaultLanguage != null ? defaultLanguage.trim() : "";
  +        if (language.length()>0)
  +        {
  +            // Code taken from LocaleSelectorPorltet
  +            String country = "";
  +            String variant = "";
  +            int countryIndex = language.indexOf('_');
  +            if (countryIndex > -1)
  +            {
  +                country = language.substring(countryIndex + 1).trim();
  +                language = language.substring(0, countryIndex).trim();
  +                int vDash = country.indexOf("_");
  +                if (vDash > 0)
  +                {
  +                    String cTemp = country.substring(0, vDash);
  +                    variant = country.substring(vDash + 1);
  +                    country = cTemp;
  +                }
  +            }
   
  +            defaultLocale = new Locale(language, country, variant);
  +            if ( defaultLocale.getLanguage().length() == 0 )
  +            {
  +                // not a valid language
  +                defaultLocale = null;
  +                log.warn("Invalid or unrecognized default language: "+language);
  +            }
  +            else
  +            {
  +                log.info("Default language set: "+defaultLocale);
  +            }
  +                
  +        }
  +    }
  +    
       /*
        * (non-Javadoc)
        * 
  @@ -47,11 +90,16 @@
           Locale locale =
               (Locale) request.getSessionAttribute(PortalReservedParameters.PREFERED_LOCALE_ATTRIBUTE);
   
  +        if ( locale == null && defaultLocale != null )
  +        {
  +            locale = defaultLocale;
  +        }
  +
           if (locale == null)
           {
               locale = request.getRequest().getLocale();
           }
  -
  +        
           if (locale == null)
           {
               Enumeration preferedLocales = request.getRequest().getLocales();
  
  
  
  1.9       +5 -1      jakarta-jetspeed-2/portal/src/webapp/WEB-INF/assembly/pipelines.xml
  
  Index: pipelines.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-jetspeed-2/portal/src/webapp/WEB-INF/assembly/pipelines.xml,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- pipelines.xml	5 Jan 2005 04:22:52 -0000	1.8
  +++ pipelines.xml	26 Jan 2005 00:44:41 -0000	1.9
  @@ -19,7 +19,11 @@
     <bean id="localizationValve"
           class="org.apache.jetspeed.localization.impl.LocalizationValveImpl"
           init-method="initialize"
  -  /> 
  +  >
  +    <constructor-arg>
  +      <value><!--@defaultLanguage--><!--defaultLanguage@--></value>
  +    </constructor-arg>
  +  </bean> 
     
     <bean id="capabilityValve"
           class="org.apache.jetspeed.capabilities.impl.CapabilityValveImpl"
  
  
  

---------------------------------------------------------------------
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