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

2006/unicorn/src/org/w3c/unicorn/action ObserveAction.java,1.32,1.33

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Thu, 17 Sep 2009 15:42:43 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1MoJ87-0004ir-GL@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn/action
In directory hutz:/tmp/cvs-serv18075/src/org/w3c/unicorn/action

Modified Files:
	ObserveAction.java 
Log Message:
make use of the new InputParameter classes

Index: ObserveAction.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/action/ObserveAction.java,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- ObserveAction.java	16 Sep 2009 16:45:38 -0000	1.32
+++ ObserveAction.java	17 Sep 2009 15:42:41 -0000	1.33
@@ -28,8 +28,10 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.w3c.unicorn.UnicornCall;
-import org.w3c.unicorn.contract.EnumInputMethod;
-import org.w3c.unicorn.exceptions.UnsupportedMimeTypeException;
+import org.w3c.unicorn.exceptions.UnicornException;
+import org.w3c.unicorn.input.DirectInputParameter;
+import org.w3c.unicorn.input.URIInputParameter;
+import org.w3c.unicorn.input.UploadInputParameter;
 import org.w3c.unicorn.output.OutputFactory;
 import org.w3c.unicorn.output.OutputFormater;
 import org.w3c.unicorn.output.OutputModule;
@@ -161,12 +163,7 @@
 				} else if (paramName.equals("uri")) {
 					logger.trace("Uri parameter: " + key + " - " + (String) reqParams.get(key));
 					String uri = (String) reqParams.get(key);
-					/*if (uri.startsWith("https://")) {
-						Message mess = new Message(Message.Level.ERROR, "Unicorn does not support https protocol for the moment.", null);
-						createError(req, resp, reqParams, mess, mapOfSpecificParameter, mapOfOutputParameter);
-						return;
-					}*/
-					// To allow other protocols change (https?) in (https?|ftp|rmtp) for example
+					// To allow other protocols change (https?) to (https?|ftp|rmtp) for example
 					Pattern urlPattern = Pattern.compile("^(https?)://([A-Z0-9][A-Z0-9_-]*)(\\.[A-Z0-9][A-Z0-9_-]*)*(:(\\d+))?([/#]\\p{ASCII}*)?", Pattern.CASE_INSENSITIVE);
 					if (!urlPattern.matcher(uri).matches()) {
 						if (uri.equals(""))
@@ -185,21 +182,21 @@
 							return;
 						}
 					}
-					aUnicornCall.setEnumInputMethod(EnumInputMethod.URI);
-					aUnicornCall.setDocumentName(uri);
-					aUnicornCall.setInputParameterValue(uri);
+					//aUnicornCall.setEnumInputMethod(EnumInputMethod.URI);
+					//aUnicornCall.setDocumentName(uri);
+					aUnicornCall.setInputParameter(new URIInputParameter(uri));
 				} else if (paramName.equals("text")) {
 					logger.trace("Text parameter: " + key + " - " + (String) reqParams.get(key));
-					aUnicornCall.setEnumInputMethod(EnumInputMethod.DIRECT);
-					aUnicornCall.setInputParameterValue((String) reqParams.get(key));
+					//aUnicornCall.setEnumInputMethod(EnumInputMethod.DIRECT);
+					aUnicornCall.setInputParameter(new DirectInputParameter((String) reqParams.get(key), (String) reqParams.get(paramPrefix + "text_mime")));
 				} else if (paramName.equals("file")) {
 					logger.trace("File parameter: " + key + " - " + reqParams.get(key).toString());
 					Object object = reqParams.get(key);
 					if (object instanceof FileItem) {
 						aFileItemUploaded = (FileItem) object;
-						aUnicornCall.setDocumentName(aFileItemUploaded.getName());
-						aUnicornCall.setInputParameterValue(aFileItemUploaded);
-						aUnicornCall.setEnumInputMethod(EnumInputMethod.UPLOAD);
+						//aUnicornCall.setDocumentName(aFileItemUploaded.getName());
+						aUnicornCall.setInputParameter(new UploadInputParameter(aFileItemUploaded));
+						//aUnicornCall.setEnumInputMethod(EnumInputMethod.UPLOAD);
 					} else {
 						// should be impossible (see getRequestParameters)
 						logger.warn("ucn_file is not of type FileItem!");
@@ -281,9 +278,12 @@
 		try {
 			aUnicornCall.doTask();
 			createOutput(req, resp, mapOfStringObject, aUnicornCall, mapOfSpecificParameter, mapOfOutputParameter);
-		} catch (final UnsupportedMimeTypeException aException) {
+		} /*catch (final UnsupportedMimeTypeException aException) {
 			Message mess = new Message(Message.Level.ERROR, "$message_unsupported_mime_type", null);
 			createError(req, resp, reqParams, mess, mapOfSpecificParameter, mapOfOutputParameter);
+		} */catch (final UnicornException ucnException) {
+			Message mess = ucnException.getUnicornMessage();
+			createError(req, resp, reqParams, mess, mapOfSpecificParameter, mapOfOutputParameter);
 		} catch (final Exception aException) {
 			logger.error("Exception : " + aException.getMessage(), aException);
 			createError(req, resp, reqParams, new Message(aException), mapOfSpecificParameter, mapOfOutputParameter);
Received on Thursday, 17 September 2009 15:42:54 GMT

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