- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 13 Aug 2009 13:42:44 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/action
In directory hutz:/tmp/cvs-serv2554/src/org/w3c/unicorn/action
Modified Files:
Tag: dev2
IndexAction.java ObserveAction.java
Log Message:
more actions in Framework
+ IndexAction
+ language negociation structure
Index: IndexAction.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/Attic/IndexAction.java,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -d -r1.1.2.6 -r1.1.2.7
--- IndexAction.java 12 Aug 2009 13:15:21 -0000 1.1.2.6
+++ IndexAction.java 13 Aug 2009 13:42:41 -0000 1.1.2.7
@@ -1,20 +1,17 @@
package org.w3c.unicorn.action;
-import java.io.File;
-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;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.apache.velocity.VelocityContext;
+import org.apache.velocity.exception.ParseErrorException;
+import org.apache.velocity.exception.ResourceNotFoundException;
import org.w3c.unicorn.language.Language;
-import org.w3c.unicorn.language.LanguageNegociator;
-import org.w3c.unicorn.util.Property;
+import org.w3c.unicorn.Framework;
public class IndexAction extends Action{
@@ -26,7 +23,6 @@
@Override
public void init() throws ServletException {
super.init();
- velocityContext = new VelocityContext();
templateList = new ArrayList<String>();
}
@@ -38,12 +34,14 @@
// Language negotiation
String langParameter = req.getParameter("lang");
- Locale lang = LanguageNegociator.negociate(langParameter, req.getLocales());
- resp.setLocale(lang);
- velocityContext.put("lang", lang.getLanguage());
+ velocityContext = new VelocityContext(Language.getContext(langParameter));
+
+ //Locale lang = LanguageNegociator.negociate(langParameter, req.getLocales());
+ //resp.setLocale(lang);
+ //velocityContext.put("lang", lang.getLanguage());
+
- velocityContext.put("param_prefix", Property.get("UNICORN_PARAMETER_PREFIX"));
// Contains a message ?
/*if (messages == null) {
@@ -81,7 +79,7 @@
//fr.read(buffer);
//fr.close();
//writer.write(buffer.toString());
- }
+ }*/
// Else generate response
/*Writer writer = resp.getWriter();
@@ -98,18 +96,51 @@
engine.init(aProperties);
-
+
private static VelocityEngine engine = new VelocityEngine();*/
- }
+
+ Framework.getTemplate("index").merge(velocityContext, resp.getWriter());
+ try {
+ //Properties aProperties = new Properties();
+
+ /*aProperties.(
+ Property.getProps("velocity.properties")
+ );
- @Override
- protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- doGet(req, resp);
+ aProperties.put(Velocity.FILE_RESOURCE_LOADER_PATH, Property
+ .get("PATH_TO_TEMPLATES"));*/
+
+ /*Properties aProperties = Property.getProps("velocity.properties");
+
+ aProperties.put(Velocity.FILE_RESOURCE_LOADER_PATH, Property
+ .get("PATH_TO_TEMPLATES"));
+
+ velocityEngine.init(aProperties);
+
+ Template template = velocityEngine.getTemplate("index.vm", "UTF-8");
+ Writer writer = resp.getWriter();
+ template.merge(velocityContext, writer);*/
+ //Template template = Framework.getVelocityEngine().getTemplate("index.vm", "UTF-8");
+ //Writer writer = resp.getWriter();
+ //template.merge(velocityContext, writer);
+
+ //Framework.getTemplate("index").merge(velocityContext, resp.getWriter());
+ } catch (ResourceNotFoundException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (ParseErrorException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
@Override
- protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
doGet(req, resp);
}
+
}
Index: ObserveAction.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/Attic/ObserveAction.java,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -u -d -r1.1.2.5 -r1.1.2.6
--- ObserveAction.java 12 Aug 2009 13:15:21 -0000 1.1.2.5
+++ ObserveAction.java 13 Aug 2009 13:42:41 -0000 1.1.2.6
@@ -354,7 +354,7 @@
aUnicornCall.setTask(tStringParamValue[0]);
} else if (sParamName.equals("uri")) {
aUnicornCall.setEnumInputMethod(EnumInputMethod.URI);
-
+ // TODO First check that tStringParamValue[0] is at least 7 characters long
if (!tStringParamValue[0].substring(0, 7).equals("http://")) {
ObserveAction.logger.info("URI missing protocol : "
+ tStringParamValue[0]);
Received on Thursday, 13 August 2009 13:43:00 UTC