- From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 31 Aug 2009 15:00:17 +0000
- To: www-validator-cvs@w3.org
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/action In directory hutz:/tmp/cvs-serv26505/src/org/w3c/unicorn/action Modified Files: IndexAction.java ObserveAction.java Log Message: unicorn now displays error messages on the index page instead of a dedicated page Index: IndexAction.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/IndexAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- IndexAction.java 31 Aug 2009 11:59:09 -0000 1.4 +++ IndexAction.java 31 Aug 2009 15:00:15 -0000 1.5 @@ -9,6 +9,7 @@ import org.apache.velocity.VelocityContext; import org.w3c.unicorn.Framework; import org.w3c.unicorn.language.Language; +import org.w3c.unicorn.util.Message; import org.w3c.unicorn.util.Property; import org.w3c.unicorn.util.Templates; @@ -46,6 +47,10 @@ velocityContext.put("current_task", Framework.mapOfTask.get(taskParameter)); + if (req.getAttribute("unicorn_message") != null) + //System.out.println("TOM: " + ((Message) req.getAttribute("unicorn_message")).getMessage()); + velocityContext.put("message", req.getAttribute("unicorn_message")); + if (req.getHeader("X-Requested-With") != null && req.getHeader("X-Requested-With").equals("XMLHttpRequest")) { //for JavaScript testing purposes /*long s = System.currentTimeMillis(); Index: ObserveAction.java =================================================================== RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/ObserveAction.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ObserveAction.java 31 Aug 2009 11:59:09 -0000 1.3 +++ ObserveAction.java 31 Aug 2009 15:00:15 -0000 1.4 @@ -36,6 +36,7 @@ import org.w3c.unicorn.output.OutputFactory; import org.w3c.unicorn.output.OutputFormater; import org.w3c.unicorn.output.OutputModule; +import org.w3c.unicorn.util.Message; import org.w3c.unicorn.util.Property; /** @@ -97,7 +98,7 @@ logger.debug("Lang Parameter: " + langParameter); - //velocityContext = new VelocityContext(Language.getContext(langParameter)); + // Variables related to the output final Map<String, String[]> mapOfSpecificParameter = new Hashtable<String, String[]>(); @@ -124,15 +125,19 @@ this.addParameter(sParamName, tStringParamValue, aUnicornCall, mapOfSpecificParameter, mapOfOutputParameter); - } // For + } + + if (aUnicornCall.getTask() == null) + aUnicornCall.setTask(Framework.mapOfTask.getDefaultTaskId()); - if (aUnicornCall.getTask() == null) { + /*if (aUnicornCall.getTask() == null) { ObserveAction.logger.error("No task selected."); this.createError(resp, new NoTaskException(), mapOfSpecificParameter, mapOfOutputParameter); return; - } - + }*/ + + try { aUnicornCall.doTask(); @@ -141,8 +146,22 @@ } catch (final Exception aException) { ObserveAction.logger.error("Exception : " + aException.getMessage(), aException); - this.createError(resp, aException, - mapOfSpecificParameter, mapOfOutputParameter); + + if (mapOfOutputParameter.get("format").equals("xhtml10")) { + String errorMessage = (String) Framework.getLanguageProperties().get(langParameter).get("stack_trace_text"); + String errorContent = ""; + errorContent += aException.getMessage() + "\n"; + for (StackTraceElement stackTraceElement : aException.getStackTrace()) { + errorContent += stackTraceElement.toString() + "\n"; + } + Message mess = new Message(Message.Level.ERROR, errorMessage, errorContent); + req.setAttribute("unicorn_message", mess); + (new IndexAction()).doGet(req, resp); + + } else { + this.createError(resp, aException, mapOfSpecificParameter, mapOfOutputParameter); + } + } } @@ -234,8 +253,13 @@ } catch (final Exception aException) { ObserveAction.logger.error("Exception : " + aException.getMessage(), aException); - this.createError(resp, aException, - mapOfSpecificParameter, mapOfOutputParameter); + + if (mapOfOutputParameter.get("format").equals("xhtml10")) { + (new IndexAction()).doGet(req, resp); + } else { + this.createError(resp, aException, mapOfSpecificParameter, mapOfOutputParameter); + } + } finally { if ("true".equals(Property.get("DELETE_UPLOADED_FILES")) && aFileItemUploaded != null
Received on Monday, 31 August 2009 15:00:27 UTC