[MOBY-guts] biomoby commit
Paul Gordon
gordonp at dev.open-bio.org
Mon Jan 7 22:04:17 UTC 2008
gordonp
Mon Jan 7 17:04:17 EST 2008
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client
In directory dev.open-bio.org:/tmp/cvs-serv14667/src/main/org/biomoby/client
Modified Files:
MobyRequest.java
Log Message:
Now we fill in default secondary (at Andreas' request), and fixed a potential null pointer exception
moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.31,1.32
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2007/12/14 23:04:31 1.31
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2008/01/07 22:04:17 1.32
@@ -737,11 +737,13 @@
}
}
- if(localResponseString != null && localResponseString.length() == 0){
- throw new MobyException("The MOBY payload has no text contents at all");
- }
- if(Character.isWhitespace(localResponseString.charAt(0))){
- localResponseString = localResponseString.trim();
+ if(localResponseString != null){
+ if(localResponseString.length() == 0){
+ throw new MobyException("The MOBY payload has no text contents at all");
+ }
+ if(Character.isWhitespace(localResponseString.charAt(0))){
+ localResponseString = localResponseString.trim();
+ }
}
// Check if the payload is an XML document. If not, try a last ditch effort
@@ -860,7 +862,8 @@
}
/**
- * Creates an XML representation of the data, renamed to fit the needs of the service if necessary.
+ * Creates an XML representation of the data, renamed to fit the needs of the service if necessary,
+ * and adding any secondary parameter default values if not already specified in the incoming data.
*
* @param data the array of input parameters to put in a MOBY XML request
*
@@ -869,7 +872,7 @@
public String convertMOBYDataToMOBYRequest(MobyContentInstance data) throws MobyException{
MobyData[] inputs = mobyService.getPrimaryInputs();
- MobyData[] secondaries = mobyService.getSecondaryInputs();
+ MobySecondaryData[] secondaries = mobyService.getSecondaryInputs();
Iterator queries = data.keySet().iterator();
// Make sure the number of input args is correct for each query being submitted
@@ -918,14 +921,22 @@
" primary input parameter(s), but takes " + inputs.length +
" (query " + queryName + ")");
}
- if(secondaries != null && secondaries.length != secondaryParams.size()){
- throw new MobyException("Service " + mobyService.getName() + " was provided " +
- secondaryParams.size() +
- " secondary input parameter(s), but takes " + secondaries.length +
- " (query " + queryName + ")");
+ if(secondaries != null){
+ // If no secondaries provided, fill them in by default
+ if(secondaries.length != 0 && secondaryParams.isEmpty()){
+ for(MobySecondaryData secondary: secondaries){
+ secondaryParams.put(secondary.getName(), new MobyDataSecondaryInstance(secondary));
+ }
+ }
+ else if(secondaries.length != secondaryParams.size()){
+ throw new MobyException("Service " + mobyService.getName() + " was provided " +
+ secondaryParams.size() +
+ " secondary input parameter(s), but takes " + secondaries.length +
+ " (query " + queryName + ")");
+ }
}
- // If there was one anonynmous input, assign the name automatically in
+ // If there was one anonymous input, assign the name automatically in
// the case the service requires it to be named. This is the only
// unambiguous case in which we can do this.
if(inputs.length == 1){
More information about the MOBY-guts
mailing list