Return-Path: Delivered-To: apmail-jakarta-jetspeed-dev-archive@www.apache.org Received: (qmail 25505 invoked from network); 13 Jul 2004 21:01:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur-2.apache.org with SMTP; 13 Jul 2004 21:01:38 -0000 Received: (qmail 59683 invoked by uid 500); 13 Jul 2004 21:01:21 -0000 Delivered-To: apmail-jakarta-jetspeed-dev-archive@jakarta.apache.org Received: (qmail 59593 invoked by uid 500); 13 Jul 2004 21:01:20 -0000 Mailing-List: contact jetspeed-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jetspeed Developers List" Reply-To: "Jetspeed Developers List" Delivered-To: mailing list jetspeed-dev@jakarta.apache.org Received: (qmail 59483 invoked by uid 500); 13 Jul 2004 21:01:19 -0000 Received: (qmail 59470 invoked by uid 500); 13 Jul 2004 21:01:19 -0000 Received: (qmail 59453 invoked by uid 99); 13 Jul 2004 21:01:19 -0000 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194) by apache.org (qpsmtpd/0.27.1) with SMTP; Tue, 13 Jul 2004 14:01:19 -0700 Received: (qmail 25401 invoked by uid 1642); 13 Jul 2004 21:01:18 -0000 Date: 13 Jul 2004 21:01:18 -0000 Message-ID: <20040713210118.25400.qmail@minotaur.apache.org> From: weaver@apache.org To: jakarta-jetspeed-2-cvs@apache.org Subject: cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/localization/impl LocalizationValveImpl.java X-Virus-Checked: Checked X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N 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 David Sean Taylor + * + * @author David Sean Taylor * @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