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

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 UTC