[MOBY-guts] biomoby commit

Paul Gordon gordonp at dev.open-bio.org
Wed Nov 22 22:23:55 UTC 2006


gordonp
Wed Nov 22 17:23:55 EST 2006
Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/service
In directory dev.open-bio.org:/tmp/cvs-serv19867/src/main/org/biomoby/service

Modified Files:
	MobyServlet.java 
Log Message:
Changes to improve Seahawk Unit Test generality
moby-live/Java/src/main/org/biomoby/service MobyServlet.java,1.1,1.2
===================================================================
RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.java	2006/10/25 02:33:23	1.1
+++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/service/MobyServlet.java	2006/11/22 22:23:55	1.2
@@ -40,6 +40,9 @@
     public static final String MOBY_INPUT_PARAM = "mobyInput";
     public static final String MOBY_SECONDARY_PARAM = "mobySecondaryInput";
     public static final String MOBY_OUTPUT_PARAM = "mobyOutput";
+    public static final String MODE_HTTP_PARAM = "mode";
+    public static final String RDF_MODE = "rdf";
+    public static final String ADMIN_MODE = "admin";
     public static final int INIT_OUTPUT_BUFFER_SIZE = 100000;
 
     protected static MobyRequest mobyRequest;
@@ -56,6 +59,8 @@
 
     protected MobyContentInstance currentContent = null;
     protected boolean isInitialized = false;
+    /** Changing this value makes logging more or less verbose */
+    protected boolean isDebug = false;
 
     protected void doGet(HttpServletRequest request,
 			 HttpServletResponse response)
@@ -68,7 +73,44 @@
 	    }
 	}
 
+	// Depending on the argument given, print the RDF signature, 
+	// the admin page, or a Web interface to the program
+	String mode = request.getParameter(MODE_HTTP_PARAM);
+	if(mode == null){  // Normal web-browser form fill-in
+	    writeHTMLForm(request, response);
+	}
+	else if(mode.equals(RDF_MODE)){
+	    writeRDF(response);
+	}
+	else{  // Unrecognized, print form
+	    writeHTMLForm(request, response);
+	}
+    }
+
+    protected void writeHTMLForm(HttpServletRequest request,
+				 HttpServletResponse response){
+	java.io.OutputStream out = null;
+	response.setContentType("text/html");
+	try{
+	    out = response.getOutputStream();
+	}
+	catch(java.io.IOException ioe){
+	    log("While getting servlet output stream (for HTML form response to client)", ioe);
+	    return;
+	}
+
+	try{
+	    out.write("<html><body>This is where the HTML form would go</body></html>".getBytes());
+	}
+	catch(java.io.IOException ioe){
+	    log("While printing HTML form to servlet output stream", ioe);
+	    return;
+	}
+    }
+
+    protected void writeRDF(HttpServletResponse response){
 	java.io.OutputStream out = null;
+	response.setContentType("text/xml");
 	try{
 	    out = response.getOutputStream();
 	}
@@ -87,7 +129,13 @@
 	writer.setProperty("tab", "4");
 	writer.write(model, stream, null);
 	
-	out.write(stream.getOutput().getBytes());
+	try{
+	    out.write(stream.getOutput().getBytes());
+	}
+	catch(java.io.IOException ioe){
+	    log("While printing service RDF to servlet output stream", ioe);
+	    return;
+	}
     }
 
     protected void doPost(HttpServletRequest request,
@@ -474,6 +522,7 @@
  	    else{
  		mobyRequest = new MobyRequest(new CentralCachedCallsImpl());
  	    }
+	    mobyRequest.setDebugMode(isDebug);
 	    
 	}catch(Exception e){
 	    System.err.println("Could not create required resources:"+e);
@@ -482,7 +531,7 @@
 	isInitialized = true;
     }
 
-    private MobyService createServiceFromConfig(HttpServletRequest request) throws Exception{
+    private synchronized MobyService createServiceFromConfig(HttpServletRequest request) throws Exception{
 	MobyService service = new MobyService(getServletName());
 
 	Vector<MobyPrimaryData> inputTypes = new Vector<MobyPrimaryData>();
@@ -596,7 +645,7 @@
 	// When we POST this URL, the service is executed
 	service.setURL(endPointURL);
 	// When we GET this URL, the RDF is returned
-	service.setSignatureURL(endPointURL);
+	service.setSignatureURL(endPointURL+"?"+MODE_HTTP_PARAM+"="+RDF_MODE);
 	// Other fields (authoritative and contact info) are highly recommended, but optional
 	param = context.getInitParameter(MOBY_AUTHORITATIVE_PARAM);
 	if(param != null){




More information about the MOBY-guts mailing list