- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Thu, 20 Aug 2009 14:06:24 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/action In directory hutz:/tmp/cvs-serv17691/src/org/w3c/unicorn/action Modified Files: Tag: dev2 IndexAction.java Log Message: added the possibility to define the default task (selected task when ucn_task parameter is not specified) by adding ucn:default="true" to the task metadata in the corresponding rdf file. If ucn:default is to be found nowhere, the default task will be the first one found until next initialization (in this case an error is logged). Index: IndexAction.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/Attic/IndexAction.java,v retrieving revision 1.1.2.12 retrieving revision 1.1.2.13 diff -u -d -r1.1.2.12 -r1.1.2.13 --- IndexAction.java 19 Aug 2009 18:55:31 -0000 1.1.2.12 +++ IndexAction.java 20 Aug 2009 14:06:22 -0000 1.1.2.13 @@ -7,8 +7,6 @@ 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.util.Property; import org.w3c.unicorn.Framework; @@ -16,7 +14,7 @@ public class IndexAction extends Action { private static final long serialVersionUID = 1L; - private static Logger logger = Logger.getLogger("Index"); + private static Logger logger = Logger.getLogger(IndexAction.class); private VelocityContext velocityContext; @Override @@ -27,6 +25,8 @@ @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { + + resp.setContentType("text/html; charset=UTF-8"); // Language negotiation @@ -38,77 +38,12 @@ String taskParameter = req.getParameter(Property.get("UNICORN_PARAMETER_PREFIX") + "task"); if (taskParameter == null || !Framework.mapOfTask.containsKey(taskParameter)) - taskParameter = "conformance"; + taskParameter = Framework.mapOfTask.getDefaultTaskId(); velocityContext.put("current_task", Framework.mapOfTask.get(taskParameter)); - //velocityContext.put("current_task", req.get); - Framework.getTemplate("index").merge(velocityContext, resp.getWriter()); resp.getWriter().close(); - - - - - // 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) { - - - } - }*/ - - - - // 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
Received on Thursday, 20 August 2009 14:06:34 UTC