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

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

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Tue, 08 Sep 2009 15:15:29 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1Ml2Pp-0008M1-Mc@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/action
In directory hutz:/tmp/cvs-serv32099/src/org/w3c/unicorn/action

Modified Files:
	ObserveAction.java 
Log Message:
check mandatory parameters presence (ucn_uri OR ucn_text + ucn_text_mime OR ucn_file) and that they are not empty
+ an error is displayed in case of an empty or missing parameter 

Index: ObserveAction.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/ObserveAction.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- ObserveAction.java	8 Sep 2009 14:58:41 -0000	1.18
+++ ObserveAction.java	8 Sep 2009 15:15:27 -0000	1.19
@@ -196,13 +196,31 @@
 		}
 		
 		if (reqParams.containsKey(paramPrefix + "uri")) {
-			//TODO vérifier que n'est pas vide
+			if (reqParams.get(paramPrefix + "uri").equals("")) {
+				Message mess = new Message(Message.Level.ERROR, "$message_empty_uri", null);
+				createError(req, resp, mess, mapOfSpecificParameter, mapOfOutputParameter);
+				return;
+			}
 		} else if (reqParams.containsKey(paramPrefix + "text")) {
-			//TODO vérifier que n'est pas vide + vérifier présence de ucn_text_mime
+			if (reqParams.get(paramPrefix + "text").equals("")) {
+				Message mess = new Message(Message.Level.ERROR, "$message_empty_direct_input", null);
+				createError(req, resp, mess, mapOfSpecificParameter, mapOfOutputParameter);
+				return;
+			} else if (!reqParams.containsKey(paramPrefix + "text_mime")) {
+				Message mess = new Message(Message.Level.ERROR, "$message_missing_mime_type", null);
+				createError(req, resp, mess, mapOfSpecificParameter, mapOfOutputParameter);
+				return;
+			}
 		} else if (reqParams.containsKey(paramPrefix + "file")) {
-			//TODO vérifier que n'est pas vide
+			if (((FileItem) reqParams.get(paramPrefix + "file")).getSize() == 0) {
+				Message mess = new Message(Message.Level.ERROR, "$message_no_or_empty_file", null);
+				createError(req, resp, mess, mapOfSpecificParameter, mapOfOutputParameter);
+				return;
+			}
 		} else {
-			//TODO aucun des 3 paramètres n'est présent -> erreur
+			Message mess = new Message(Message.Level.ERROR, "$message_nothing_to_validate", null);
+			createError(req, resp, mess, mapOfSpecificParameter, mapOfOutputParameter);
+			return;
 		}
 		
 		try {
Received on Tuesday, 8 September 2009 15:15:42 GMT

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