W3C home > Mailing lists > Public > www-validator-cvs@w3.org > August 2009

2006/unicorn/src/org/w3c/unicorn/action IndexAction.java,1.1.2.3,1.1.2.4 Error404Action.java,1.1.2.3,1.1.2.4

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Fri, 07 Aug 2009 12:03:44 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1MZOAi-0001vo-UI@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/action
In directory hutz:/tmp/cvs-serv7256/src/org/w3c/unicorn/action

Modified Files:
      Tag: dev2
	IndexAction.java Error404Action.java 
Log Message:
new libs
bypassed controller
implemented some language properties

Index: IndexAction.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/Attic/IndexAction.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -d -r1.1.2.3 -r1.1.2.4
--- IndexAction.java	6 Aug 2009 12:46:56 -0000	1.1.2.3
+++ IndexAction.java	7 Aug 2009 12:03:42 -0000	1.1.2.4
@@ -4,6 +4,7 @@
 import java.io.FileReader;
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 import javax.servlet.ServletException;
@@ -11,8 +12,11 @@
 import javax.servlet.http.HttpServletResponse;
 import org.apache.log4j.Logger;
 import org.apache.velocity.VelocityContext;
+import org.w3c.unicorn.Parameters;
+import org.w3c.unicorn.language.Language;
 import org.w3c.unicorn.language.LanguageNegociator;
 import org.w3c.unicorn.message.Message;
+import org.w3c.unicorn.output.Output;
 import org.w3c.unicorn.util.Property;
 
 public class IndexAction extends Action{
@@ -20,15 +24,19 @@
 	private static final long serialVersionUID = 1L;
 	private static Logger logger = Logger.getLogger("Index");
 	private VelocityContext velocityContext;
+	private ArrayList<String> templateList;
 	
 	@Override
 	public void init() throws ServletException {
 		super.init();
 		velocityContext = new VelocityContext();
+		templateList = new ArrayList<String>();
 	}
 	
-	protected void doGet(HttpServletRequest req, HttpServletResponse resp, List<Message> messages) throws ServletException, IOException {
-		resp.setContentType("text/html");
+	
+	
+	protected void doGet(HttpServletRequest req, HttpServletResponse resp, List<Message> messages) throws Exception {
+		templateList.clear();
 		
 		// Language negotiation
 		String langParameter = req.getParameter("lang");
@@ -36,13 +44,28 @@
 		resp.setLocale(lang);
 		velocityContext.put("lang", lang.getLanguage());
 		
+		// Output mime type
+		String outputParameter = req.getParameter("output");
+		if (outputParameter == null)
+			resp.setContentType("text/html");
+		else {
+			for (String key : Parameters.outputParams.keySet())
+				if (outputParameter.equals(key))
+					resp.setContentType(Parameters.outputParams.get(key));
+		}
+		
+		velocityContext.put("param_prefix", Property.get("UNICORN_PARAMETER_PREFIX"));
 		
 		// Contains a message ?
 		if (messages == null) {
-			
+			templateList.add("index.vm");
+			Language.addToContext(velocityContext, lang);
+			Output.write(templateList, velocityContext, resp);
+			return;
 		} else {
 			for (Message mess : messages) {
 				
+				
 			}
 		}
 		
@@ -91,7 +114,12 @@
 	
 	@Override
 	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
-		doGet(req, resp, null);
+		try {
+			doGet(req, resp, null);
+		} catch (Exception e) {
+			// TODO Auto-generated catch block
+			e.printStackTrace();
+		}
 	}
 
 	@Override

Index: Error404Action.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/Attic/Error404Action.java,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -d -r1.1.2.3 -r1.1.2.4
--- Error404Action.java	6 Aug 2009 12:46:56 -0000	1.1.2.3
+++ Error404Action.java	7 Aug 2009 12:03:42 -0000	1.1.2.4
@@ -1,9 +1,14 @@
 package org.w3c.unicorn.action;
 
+import java.io.IOException;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 public class Error404Action extends Action {
+	private static final long serialVersionUID = 1L;
 
 	public Error404Action() {
 		// TODO Auto-generated constructor stub
@@ -15,4 +20,12 @@
 
 	}
 
+	@Override
+	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+			throws ServletException, IOException {
+		//(new IndexAction()).doGet(req, resp, null);
+	}
+	
+	
+
 }
Received on Friday, 7 August 2009 12:04:02 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:17:37 UTC