- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 06 Aug 2009 12:46:58 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/action In directory hutz:/tmp/cvs-serv2800/src/org/w3c/unicorn/action Added Files: Tag: dev2 Error404Action.java ObserveAction.java RedirectAction.java Action.java IndexAction.java Log Message: w3 => w3c --- NEW FILE: IndexAction.java --- package org.w3c.unicorn.action; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; 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.w3c.unicorn.language.LanguageNegociator; import org.w3c.unicorn.message.Message; import org.w3c.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(); } protected void doGet(HttpServletRequest req, HttpServletResponse resp, List<Message> messages) throws ServletException, IOException { resp.setContentType("text/html"); // Language negotiation String langParameter = req.getParameter("lang"); Locale lang = LanguageNegociator.negociate(langParameter, req.getLocales()); resp.setLocale(lang); velocityContext.put("lang", lang.getLanguage()); // Contains a message ? if (messages == null) { } else { for (Message mess : messages) { } } // 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[10000]; int readLength = 0; while((readLength = fr.read(chararray, 0, 10000)) > -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 doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { doGet(req, resp, null); } @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.w3c.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.w3c.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.w3c.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.w3c.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 Thursday, 6 August 2009 12:47:09 UTC