W3C home > Mailing lists > Public > www-validator-cvs@w3.org > September 2009

2006/unicorn/src/org/w3c/unicorn/action ObserveAction.java,1.17,1.18

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Tue, 08 Sep 2009 14:58:44 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1Ml29c-00078U-1n@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/action
In directory hutz:/tmp/cvs-serv27416/src/org/w3c/unicorn/action

Modified Files:
	ObserveAction.java 
Log Message:
moved initialization code to the beginning of doGet to avoid NPE in case of FileUploadException
+ use of Message(Exception) constructor

Index: ObserveAction.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/ObserveAction.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- ObserveAction.java	8 Sep 2009 14:44:48 -0000	1.17
+++ ObserveAction.java	8 Sep 2009 14:58:41 -0000	1.18
@@ -74,15 +74,6 @@
 		
 		super.doGet(req, resp);
 		
-		Map<String, Object> reqParams;
-		try {
-			reqParams = getRequestParameters(req);
-		} catch (FileUploadException e) {
-			// TODO Auto-generated catch block
-			e.printStackTrace();
-			return;
-		}
-		
 		FileItem aFileItemUploaded = null;
 		Map<String, Object> mapOfStringObject = new LinkedHashMap<String, Object>();
 		Map<String, String> mapOfSpecificParameter = new Hashtable<String, String>();
@@ -90,6 +81,11 @@
 		ArrayList<Message> messages = new ArrayList<Message>();
 		UnicornCall aUnicornCall = new UnicornCall();
 		
+		mapOfOutputParameter.put("output", "simple");
+		mapOfOutputParameter.put("format", "xhtml10");
+		mapOfOutputParameter.put("charset", "UTF-8");
+		mapOfOutputParameter.put("mimetype", "text/html");
+		
 		String paramPrefix = Property.get("UNICORN_PARAMETER_PREFIX");
 		String outParamPrefix = Property.get("UNICORN_PARAMETER_OUTPUT_PREFIX");
 		String queryString = getQueryStringWithout(paramPrefix + "lang", req);
@@ -97,10 +93,13 @@
 		mapOfStringObject.put("queryString", queryString);
 		mapOfStringObject.put("messages", messages);
 		
-		mapOfOutputParameter.put("output", "simple");
-		mapOfOutputParameter.put("format", "xhtml10");
-		mapOfOutputParameter.put("charset", "UTF-8");
-		mapOfOutputParameter.put("mimetype", "text/html");
+		Map<String, Object> reqParams;
+		try {
+			reqParams = getRequestParameters(req);
+		} catch (FileUploadException e) {
+			createError(req, resp, new Message(e), mapOfSpecificParameter, mapOfOutputParameter);
+			return;
+		}
 		
 		for (String key : reqParams.keySet()) {
 			if (!key.startsWith(paramPrefix) && !key.startsWith(outParamPrefix)) {
@@ -214,14 +213,7 @@
 			createError(req, resp, mess, mapOfSpecificParameter, mapOfOutputParameter);
 		} catch (final Exception aException) {
 			logger.error("Exception : " + aException.getMessage(), aException);
-			
-			String errorContent = "";
-			errorContent += aException.getMessage() + "\n";
-			for (StackTraceElement stackTraceElement : aException.getStackTrace()) {
-				errorContent += stackTraceElement.toString() + "\n";
-			}
-			Message mess = new Message(Message.Level.ERROR, "$stack_trace_text", errorContent);
-			createError(req, resp, mess, mapOfSpecificParameter, mapOfOutputParameter);
+			createError(req, resp, new Message(aException), mapOfSpecificParameter, mapOfOutputParameter);
 		} finally {
 			if ("true".equals(Property.get("DELETE_UPLOADED_FILES"))
 					&& aFileItemUploaded != null) {
Received on Tuesday, 8 September 2009 14:58:53 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Thursday, 26 April 2012 12:55:14 GMT