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

2006/unicorn/src/org/w3c/unicorn UnicornCall.java,1.28,1.29

From: Thomas Gambet via cvs-syncmail <cvsmail@w3.org>
Date: Wed, 30 Sep 2009 14:58:25 +0000
To: www-validator-cvs@w3.org
Message-Id: <E1Mt0dN-0005sW-3O@lionel-hutz.w3.org>
Update of /sources/public/2006/unicorn/src/org/w3c/unicorn
In directory hutz:/tmp/cvs-serv22566/src/org/w3c/unicorn

Modified Files:
	UnicornCall.java 
Log Message:
fixed method negotiation was broken
+ changed InputModule constructor visibility to public

Index: UnicornCall.java
===================================================================
RCS file: /sources/public/2006/unicorn/src/org/w3c/unicorn/UnicornCall.java,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- UnicornCall.java	30 Sep 2009 13:40:36 -0000	1.28
+++ UnicornCall.java	30 Sep 2009 14:58:22 -0000	1.29
@@ -20,6 +20,7 @@
 import org.w3c.unicorn.contract.Observer;
 import org.w3c.unicorn.exceptions.UnicornException;
 import org.w3c.unicorn.input.InputParameter;
+import org.w3c.unicorn.input.*;
 import org.w3c.unicorn.request.Request;
 import org.w3c.unicorn.request.RequestList;
 import org.w3c.unicorn.response.Response;
@@ -170,8 +171,8 @@
 			// create a new request with input parameter
 			final Request aRequest = Request.createRequest(
 			// the corresponding best input module
-					//aInputFactory.getInputModule(aInputMethod.getMethod()),
-					inputParameter.getInputModule(),
+					//InputFactory.getInputModule(aInputMethod.getMethod()),
+					createInputModule(aInputMethod, inputParameter.getInputModule()),
 					// URL of the service to call
 					aInputMethod.getCallMethod().getURL().toString(),
 					// Name of the parameter holding resource information
@@ -548,4 +549,28 @@
 	public void setMessages(ArrayList<Message> messages) {
 		this.messages = messages;
 	}
+	
+	public InputModule createInputModule(InputMethod aInputMethod, InputModule inputModule) {
+		if (aInputMethod.getMethod() == inputModule.getEnumInputMethod()) {
+			return inputModule;
+		}
+		
+		try {
+			switch (aInputMethod.getMethod()) {
+			case DIRECT:
+				return new DirectInputModule(inputModule);
+			case UPLOAD:
+				return new FakeUploadInputModule(inputModule);
+				//return new FileItemInputModule(inputModule);
+			case URI:
+				return new URIInputModule(inputModule);
+			default:
+				return null;
+			}
+		} catch (IOException e) {
+			logger.error(e.getMessage(), e);
+			return null;
+		}
+	}
+
 }
\ No newline at end of file
Received on Wednesday, 30 September 2009 14:58:26 GMT

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