roller-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agillil...@apache.org
Subject svn commit: r354899 - /incubator/roller/trunk/src/org/roller/presentation/velocity/LanguageServlet.java
Date Wed, 07 Dec 2005 23:23:14 GMT
Author: agilliland
Date: Wed Dec  7 15:23:09 2005
New Revision: 354899

URL: http://svn.apache.org/viewcvs?rev=354899&view=rev
Log:
updating code formatting.


Modified:
    incubator/roller/trunk/src/org/roller/presentation/velocity/LanguageServlet.java

Modified: incubator/roller/trunk/src/org/roller/presentation/velocity/LanguageServlet.java
URL: http://svn.apache.org/viewcvs/incubator/roller/trunk/src/org/roller/presentation/velocity/LanguageServlet.java?rev=354899&r1=354898&r2=354899&view=diff
==============================================================================
--- incubator/roller/trunk/src/org/roller/presentation/velocity/LanguageServlet.java (original)
+++ incubator/roller/trunk/src/org/roller/presentation/velocity/LanguageServlet.java Wed Dec
 7 15:23:09 2005
@@ -1,6 +1,6 @@
 /*
  * Filename: LanguageServlet.java
- * 
+ *
  * Created on 02-May-04
  */
 package org.roller.presentation.velocity;
@@ -22,100 +22,96 @@
 import org.roller.presentation.LanguageUtil;
 import org.roller.presentation.RollerContext;
 
+
 /**
  * Changes the language of the current Locale to the language specified
- * by the user. The new language must be supported by Roller.  
- * 
+ * by the user. The new language must be supported by Roller.
+ *
  * And new supported languages to the web.servlet-init-param value. Make sure you add language-only
  * values at the end of a chain. So "en_US,en" instead of "en,en_US". And no spaces.
- * 
+ *
  * @web.servlet name="LanguageServlet" load-on-startup="10"
  * @web.servlet-init-param name="org.roller.presentation.supported.languages" value="en,nl,zh_cn,zh_tw,vi"
- *  
+ *
  * @web.servlet-mapping url-pattern="/language/*"
- * 
+ *
  * @author <a href="mailto:molen@mail.com">Jaap van der Molen</a>
  * @version $Revision: 1.8 $
  */
-public class LanguageServlet extends BasePageServlet
-{
+public class LanguageServlet extends BasePageServlet {
+    
     static final long serialVersionUID = -6548723098429557183L;
     
-	/**
-	 * Logger
-	 */
-	private static Log mLogger =
-		LogFactory.getFactory().getInstance(LanguageServlet.class);
-
-	/**
-	 * @see org.roller.presentation.velocity.BasePageServlet#init(javax.servlet.ServletConfig)
-	 */
-	public void init(ServletConfig config) throws ServletException
-	{
-		super.init(config);
-
-		// load supported languages
-		ServletContext ctx = config.getServletContext();
-		String supportedLanguages =
-			config.getInitParameter(LanguageUtil.SUPPORTED_LANGUAGES);
-		if (supportedLanguages != null
-			&& supportedLanguages.trim().length() > 0)
-		{
-			// extract langauges
-			ctx.setAttribute(
-				LanguageUtil.SUPPORTED_LANGUAGES,
-				LanguageUtil.extractLanguages(supportedLanguages));
-		}
-	}
-
-	/**
-	 * @see org.roller.presentation.velocity.BasePageServlet#handleRequest(javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context)
-	 */
-	public Template handleRequest(
-		HttpServletRequest request,
-		HttpServletResponse response,
-		Context ctx)
-	{
-		mLogger.debug("Processing language change...");
+    private static Log mLogger = LogFactory.getLog(LanguageServlet.class);
+    
+    
+    /**
+     * @see org.roller.presentation.velocity.BasePageServlet#init(javax.servlet.ServletConfig)
+     */
+    public void init(ServletConfig config) throws ServletException {
+        
+        super.init(config);
+        
+        // load supported languages
+        ServletContext ctx = config.getServletContext();
+        String supportedLanguages =
+                config.getInitParameter(LanguageUtil.SUPPORTED_LANGUAGES);
+        if (supportedLanguages != null
+                && supportedLanguages.trim().length() > 0) {
+            // extract langauges
+            ctx.setAttribute(
+                    LanguageUtil.SUPPORTED_LANGUAGES,
+                    LanguageUtil.extractLanguages(supportedLanguages));
+        }
+    }
+    
+    /**
+     * @see org.roller.presentation.velocity.BasePageServlet#handleRequest(javax.servlet.http.HttpServletRequest,
javax.servlet.http.HttpServletResponse, org.apache.velocity.context.Context)
+     */
+    public Template handleRequest(
+            HttpServletRequest request,
+            HttpServletResponse response,
+            Context ctx) {
+        
+        mLogger.debug("Processing language change...");
         ServletContext servletContext = RollerContext.getServletContext();
         
-		Locale[] supportedLanguages =
-			LanguageUtil.getSupportedLanguages(servletContext);
-
-		if (supportedLanguages == null || supportedLanguages.length == 0)
-		{
-			// add error message
-			ctx.put("languageError", "Unable to switch language: no supported languages defined.");
-			// proceed with request serving
-			return super.handleRequest(request, response, ctx);
-		}
-
-		String newLang = request.getParameter("language");
-		mLogger.debug("New language in Request: " + newLang);
-		if (newLang == null || newLang.length() == 0) {
-			// add error message
-			ctx.put("languageError", "Unable to switch language: no new language specified.");
-			// proceed with request serving
-			return super.handleRequest(request, response, ctx);
-		}
-		
-		Locale newLocale = LanguageUtil.createLocale(newLang);
-
-		// verify if new language is supported
-		if (!LanguageUtil.isSupported(newLocale, servletContext)) {
-			// add error message
-			ctx.put("languageError", "Unable to switch language: new language '"+newLang+"' is not
supported.");
-			// proceed with request serving
-			return super.handleRequest(request, response, ctx);
-		}
-
-		// by now, all should be fine: change Locale
-		HttpSession session = request.getSession();
-		session.setAttribute(Globals.LOCALE_KEY, newLocale);
-		mLogger.debug("Changed language to: " + newLocale);
-
-		// proceed with request serving
-		return super.handleRequest(request, response, ctx);
-	}
-
+        Locale[] supportedLanguages =
+                LanguageUtil.getSupportedLanguages(servletContext);
+        
+        if (supportedLanguages == null || supportedLanguages.length == 0) {
+            // add error message
+            ctx.put("languageError", "Unable to switch language: no supported languages defined.");
+            // proceed with request serving
+            return super.handleRequest(request, response, ctx);
+        }
+        
+        String newLang = request.getParameter("language");
+        mLogger.debug("New language in Request: " + newLang);
+        if (newLang == null || newLang.length() == 0) {
+            // add error message
+            ctx.put("languageError", "Unable to switch language: no new language specified.");
+            // proceed with request serving
+            return super.handleRequest(request, response, ctx);
+        }
+        
+        Locale newLocale = LanguageUtil.createLocale(newLang);
+        
+        // verify if new language is supported
+        if (!LanguageUtil.isSupported(newLocale, servletContext)) {
+            // add error message
+            ctx.put("languageError", "Unable to switch language: new language '"+newLang+"'
is not supported.");
+            // proceed with request serving
+            return super.handleRequest(request, response, ctx);
+        }
+        
+        // by now, all should be fine: change Locale
+        HttpSession session = request.getSession();
+        session.setAttribute(Globals.LOCALE_KEY, newLocale);
+        mLogger.debug("Changed language to: " + newLocale);
+        
+        // proceed with request serving
+        return super.handleRequest(request, response, ctx);
+    }
+    
 }



Mime
View raw message