[MOBY-guts] biomoby commit
Paul Gordon
gordonp at pub.open-bio.org
Mon Apr 18 17:29:43 UTC 2005
gordonp
Mon Apr 18 13:29:43 EDT 2005
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client
In directory pub.open-bio.org:/tmp/cvs-serv10452/src/main/org/biomoby/client
Modified Files:
MobyRequest.java
Log Message:
Updates to handle XML modes better
moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.9,1.10
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2005/04/07 22:45:10 1.9
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2005/04/18 17:29:43 1.10
@@ -50,7 +50,7 @@
* <a href="http://ws.apache.org/axis/index.html">Apache
* Axis</a> Web services framework, as well as Apache Xalan. There are code comments for the
* few lines that rely on Axis classes rather than the JAX-RPC interfaces.
- *
+ *
* @author Paul Gordon gordonp at ucalgary.ca
*/
public class MobyRequest{
@@ -180,9 +180,13 @@
}
/**
- * Sets the input data for the MOBY service request.
+ * Sets the input data for the MOBY service request. The length of the input array, and the
+ * number of input parameters required by the service must be equal when invokeService() is called.
* This method strictly enforces that the input be of the appropriate type for the service.
*
+ * Note that there is no requirement to use MobyDataInstance.setXmlMode() before passing in
+ * data, this class will temporarily set the XML mode of the data when it is required.
+ *
* @throws IllegalArgumentException if the input does not fit the criteria of the service (e.g. wrong data type)
*/
public void setInput(MobyDataInstance[] data) throws IllegalArgumentException{
@@ -190,6 +194,14 @@
}
/**
+ * Convenience method to run services that take one argument.
+ */
+ public void setInput(MobyDataInstance datum) throws IllegalArgumentException{
+ inputData = new MobyDataInstance[1];
+ inputData[0] = datum;
+ }
+
+ /**
* @return the MobyService that will be executed when invokeService is called
*/
public MobyDataInstance[] getInput(){
@@ -257,13 +269,13 @@
MobyData[] requiredInputData = mobyService.getPrimaryInputs();
if(requiredInputData == null){
- if(inputData != null){
+ if(inputData != null && inputData.length != 0){
throw new MobyException("Service invocation expects no input parameters, " +
- "but setInput has not been called with a null argument");
+ "but setInput has not been called with a null or zero-length array argument");
}
return; // otherwise there are no parameters to check
}
- if(inputData == null){
+ if(inputData == null || inputData.length == 0){
throw new MobyException("Service invocation expects " + requiredInputData.length + " input " +
"parameters, but setInput has not been called to provide any input");
}
@@ -569,6 +581,11 @@
// Real input data payload
if(data != null){
for(int i = 0; i < data.length; i++){
+ int oldXmlMode = data[i].getXmlMode();
+ if(oldXmlMode != MobyDataInstance.SERVICE_XML_MODE){
+ data[i].setXmlMode(MobyDataInstance.SERVICE_XML_MODE);
+ }
+
if(data[i] instanceof MobyDataSimpleInstance){
mobyRequest += ((MobyDataSimpleInstance) data[i]).toXML();
}
@@ -581,6 +598,11 @@
"MobyDataSimpleInstance or a " +
"MobyDataSetInstance (found " + data[i] + ")");
}
+
+ // Restore the old XML mode setting if not service mode
+ if(oldXmlMode != MobyDataInstance.SERVICE_XML_MODE){
+ data[i].setXmlMode(oldXmlMode);
+ }
}
}
More information about the MOBY-guts
mailing list