[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Thu Mar 13 23:02:22 UTC 2008


gordonp
Thu Mar 13 19:02:22 EDT 2008
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service
In directory dev.open-bio.org:/tmp/cvs-serv31429/src/main/org/biomoby/service

Modified Files:
	MobyServlet.java 
Log Message:
Extra parameter override configuration, and moby annotation parsing improved
moby-live/Java/src/main/org/biomoby/service MobyServlet.java,1.14,1.15
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.java	2008/02/14 06:08:31	1.14
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.java	2008/03/13 23:02:22	1.15
@@ -82,6 +82,7 @@
     // Only use for keep track of MobyServices if they have template values that are filled in at service invocation
     protected Map<Thread,MobyService> templatedServicesMap; 
     protected Map<Thread,MobyContentInstance> responseContentInstanceMap; 
+    protected Map<String,String> extraConfig;
 
     public void doGet(HttpServletRequest request,
 		      HttpServletResponse response)
@@ -308,6 +309,9 @@
 	    MobyPrimaryData param = template[i];
 	    MobyDataInstance nameMatch = job.get(param.getName());
 	    if(nameMatch == null){
+                MobyContentInstance mci = new MobyContentInstance();
+                mci.put(job);
+                MobyDataUtils.toXMLDocument(System.err, mci);
 		throw new IllegalArgumentException(errMessagePrefix + 
 					       ": required primary value \"" + param.getName() + 
 					       "\" in job " + job.getID() + " is missing");
@@ -738,6 +742,9 @@
     }
 
     protected String getCoCInitParameter(String paramName){
+        if(extraConfig != null && extraConfig.containsKey(paramName)){
+            return extraConfig.get(paramName);
+        }
 	javax.servlet.ServletConfig config = getServletConfig();
 	if(config != null){
 	    if(config.getInitParameter(paramName) != null){
@@ -753,6 +760,13 @@
 	return getInitParameter(paramName);
     }
 
+    public synchronized void setCoCInitParameter(String param, String value){
+        if(extraConfig == null){
+          extraConfig = new HashMap<String,String>();
+        }
+        extraConfig.put(param, value);
+    }
+
     public synchronized MobyService createServiceFromConfig(HttpServletRequest request) throws Exception{
 	MobyService service = new MobyService(getServiceName());
 
@@ -909,7 +923,7 @@
 	   param.indexOf(".") < 2 || param.indexOf(".") > param.length()-2 ||
 	   param.lastIndexOf("@") > param.lastIndexOf(".")){
 	    throw new Exception("Required " + MOBY_CONTACT_PARAM + 
-				" parameter in servlet config did not have the form \"name at mail.domain\")");
+				" parameter in servlet config did not have the form \"name at mail.domain\" (found "+param+")");
 	}
 	
 	service.setEmailContact(param);
@@ -985,7 +999,7 @@
      * e.g. <code>hits:Integer:100:[0,]</code>
      */
     public static MobySecondaryData stringToSecondaryDataTemplate(String template) throws Exception{
-	String[] fields = template.split(":");
+	String[] fields = template.split(":", -2); // -2 == don't strip trailing blank fields
 	if(fields.length < 3){
 	    throw new Exception("The parameter specification (" + 
 				template + ") must have the minimal form " +
@@ -1023,16 +1037,16 @@
 
 	// Ensure the [] are there, and strip them
 	if(spec.length() > 0){
-	    if(spec.indexOf('[') != 1 || spec.lastIndexOf(']') != spec.length()){
+	    if(spec.length() < 3 || spec.indexOf('[') != 0 || spec.lastIndexOf(']') != spec.length()-1){
 		throw new Exception("Parameter options specification (4th field of '" + 
 				    template + "') " +
 				    "does not have the required form '[...]', but rather: " + spec);
 	    }
-	    spec = spec.substring(1, spec.length());
+	    spec = spec.substring(1, spec.length()-1);
 	}
 	String[] specValues = new String[0];
 	if(spec.length() > 0){
-	    specValues = spec.split(",");
+	    specValues = spec.split(",", -2); // -2 == keep trailing blank values
 	}
 
 	if(dataType.equals(MobySecondaryData.INTEGER_TYPE) ||
@@ -1063,7 +1077,7 @@
 					    "is less than the minimum value specified");
 		    }
 		}
-		if(min != null){
+		if(max != null){
 		    if(max.compareTo(defaultNumber) < 0){
 			throw new Exception("Numeric parameter default (3rd field of " + template + "') " +
 					    "is greater than the maximum value specified");
@@ -1307,6 +1321,7 @@
             return;
 	}
 
+        
         MobyServlet servlet = new MobyServlet();
 	ClassLoader classLoader = servlet.getClass().getClassLoader();
         try{




More information about the MOBY-guts mailing list