- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Wed, 05 Aug 2009 17:21:44 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3/unicorn/action In directory hutz:/tmp/cvs-serv13417/src/org/w3/unicorn/action Added Files: Tag: dev2 Error404Action.java Action.java IndexAction.java RedirectAction.java ObserveAction.java Log Message: modified xmlbean ant task +changed package name from w3c to w3 --- NEW FILE: IndexAction.java --- package org.w3.unicorn.action; import java.io.ByteArrayInputStream; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.Writer; import java.nio.CharBuffer; import javax.servlet.RequestDispatcher; 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.app.Velocity; import org.apache.velocity.app.VelocityEngine; import org.eclipse.jdt.internal.compiler.codegen.CharArrayCache; import org.w3.unicorn.language.LanguageNegociator; import org.w3.unicorn.util.Property; public class IndexAction extends Action{ private static final long serialVersionUID = 1L; private static Logger logger = Logger.getLogger("Index"); private VelocityContext velocityContext; @Override public void init() throws ServletException { super.init(); velocityContext = new VelocityContext(); } @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.setContentType("text/html"); // Language negotiation ? String lang = req.getParameter("lang"); if (lang == null) lang = LanguageNegociator.negociate(req.getLocales()); velocityContext.put("lang", lang); // Contains a message ? // Is response cached ? File cachedIndex = new File(Property.get("PATH_TO_CACHE") + "index/index." + lang + ".html"); logger.info(cachedIndex.getPath()); logger.info("exists ?"+cachedIndex.exists()); if (cachedIndex.exists()) { FileReader fr = new FileReader(cachedIndex); PrintWriter writer = resp.getWriter(); char[] chararray = new char[8192]; int readLength = 0; while((readLength = fr.read(chararray, 0, 8192)) > -1) { writer.write(chararray, 0, readLength); } fr.close(); writer.close(); //Writer writer = resp.getWriter(); //FileReader fr = new FileReader(cachedIndex); //CharBuffer buffer = new Buffer; //char[] buffer = new CharA; //fr.read(buffer); //fr.close(); //writer.write(buffer.toString()); } // Else generate response /*Writer writer = resp.getWriter(); IndexGenerator.aVelocityContext = new VelocityContext(); aProperties.load( Property.getPropertyFileURL("velocity.properties").openStream() ); aProperties.put(Velocity.FILE_RESOURCE_LOADER_PATH, Property .get("PATH_TO_TEMPLATES")); engine.init(aProperties); private static VelocityEngine engine = new VelocityEngine();*/ } @Override protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { doGet(req, resp); } @Override protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { doGet(req, resp); } } --- NEW FILE: ObserveAction.java --- package org.w3.unicorn.action; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class ObserveAction extends Action { public ObserveAction() { // TODO Auto-generated constructor stub } //@Override public void execute(HttpServletRequest request, HttpServletResponse response) { // TODO Auto-generated method stub } } --- NEW FILE: Action.java --- package org.w3.unicorn.action; import javax.servlet.http.HttpServlet; public abstract class Action extends HttpServlet { private static final long serialVersionUID = 1L; } --- NEW FILE: Error404Action.java --- package org.w3.unicorn.action; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class Error404Action extends Action { public Error404Action() { // TODO Auto-generated constructor stub } //@Override public void execute(HttpServletRequest request, HttpServletResponse response) { // TODO Auto-generated method stub } } --- NEW FILE: RedirectAction.java --- package org.w3.unicorn.action; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; public class RedirectAction extends Action { public RedirectAction(HttpServletRequest request) { } //@Override public void execute(HttpServletRequest request, HttpServletResponse response) { // TODO Auto-generated method stub } }
Received on Wednesday, 5 August 2009 17:21:59 UTC