- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 24 Aug 2009 12:51:01 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn In directory hutz:/tmp/cvs-serv19058/src/org/w3c/unicorn Modified Files: Tag: dev2 UnicornCall.java Framework.java Log Message: updated to use the new template system Index: Framework.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/Attic/Framework.java,v retrieving revision 1.1.2.16 retrieving revision 1.1.2.17 diff -u -d -r1.1.2.16 -r1.1.2.17 --- Framework.java 24 Aug 2009 09:16:10 -0000 1.1.2.16 +++ Framework.java 24 Aug 2009 12:50:59 -0000 1.1.2.17 @@ -30,6 +30,7 @@ import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; import org.apache.velocity.app.VelocityEngine; +import org.w3c.unicorn.action.ObserveAction; import org.w3c.unicorn.contract.Observer; import org.w3c.unicorn.contract.WADLUnmarshaller; import org.w3c.unicorn.contract.WADLUnmarshallerXPath; @@ -67,11 +68,6 @@ public static Tasklist mapOfTask; /** - * List of available output languages in PATH_TO_OUTPUT_TEMPLATES - */ - public static Set<String> outputLang; - - /** * Data structure for the various response parser */ public static Map<String, ResponseParser> mapOfReponseParser; @@ -533,7 +529,7 @@ logger.info("OK - Velocity successfully initialized"); - TemplateHelper.init(); + //TemplateHelper.init(); Framework.logger.info("Unicorn initialized successfully."); isUcnInitialized = true; Index: UnicornCall.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/Attic/UnicornCall.java,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -u -d -r1.1.2.4 -r1.1.2.5 --- UnicornCall.java 21 Aug 2009 14:52:02 -0000 1.1.2.4 +++ UnicornCall.java 24 Aug 2009 12:50:59 -0000 1.1.2.5 @@ -51,6 +51,8 @@ import org.w3c.unicorn.tasklisttree.TLTNode; import org.w3c.unicorn.util.Property; import org.w3c.unicorn.util.TemplateHelper; +import org.w3c.unicorn.util.Templates; + import com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl; /** @@ -564,6 +566,10 @@ this.sLang = sLang; } + public String getLang() { + return sLang.split(",")[0]; + } + /** * Returns the document name * @@ -849,35 +855,30 @@ Response aResponse = null; try { // Uncomment/comment next lines to test io_error - // throw new Exception("Message test de l'exception"); + //throw new Exception("Message test de l'exception"); aResponse = this.aRequest.doRequest(); } catch (final Exception e) { RequestThread.logger.error("Exception : " + e.getMessage(), e); e.printStackTrace(); try { StringBuilder builder = new StringBuilder(); - String lang = unicornCall.getMapOfStringParameter().get( - Property.get("UNICORN_PARAMETER_PREFIX") + "lang")[0]; - - // generateFileFromTemplate generates the error xml file if it - // doesn't exist already - // String filePath = - // TemplateHelper.generateFileFromTemplate("io_error", lang, - // Property.get("PATH_TO_INDEX_OUTPUT"), "xml"); + //String lang[] = unicornCall.getMapOfStringParameter().get( + // Property.get("UNICORN_PARAMETER_PREFIX") + "lang"); + + String lang = unicornCall.getLang(); - VelocityContext context = new VelocityContext(); - context.put("exception", e.getMessage()); - Template temp = TemplateHelper.getInternationalizedTemplate( - "io_error", lang, context); + VelocityContext context = new VelocityContext(Framework.getLanguageContexts().get(lang)); + if (e.getMessage() != null) + context.put("exception", e.getMessage()); + else + context.put("exception", ""); ByteArrayOutputStream os = new ByteArrayOutputStream(); OutputStreamWriter osw = new OutputStreamWriter(os); - temp.merge(context, osw); + Templates.write("io_error.vm", context, osw); + osw.close(); - // InputStreamReader isr = new InputStreamReader(new URL("file:" - // + filePath).openConnection().getInputStream()); - InputStreamReader isr = new InputStreamReader( new ByteArrayInputStream(os.toByteArray()));
Received on Monday, 24 August 2009 12:51:10 UTC