From gordonp at dev.open-bio.org Wed Mar 17 16:03:06 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:03:06 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172003.o2HK3606010088@dev.open-bio.org> gordonp Wed Mar 17 16:03:06 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv10056/src/main/ca/ucalgary/seahawk/resources Added Files: RegexFilterBeanShell XPathFilterBeanShell Log Message: Taverna beanshell inserted into workflows generated by Seahawk to perform conditional filtering of data moby-live/Java/src/main/ca/ucalgary/seahawk/resources RegexFilterBeanShell,NONE,1.1 XPathFilterBeanShell,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 16:04:28 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:04:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172004.o2HK4Str010150@dev.open-bio.org> gordonp Wed Mar 17 16:04:28 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv10118/src/main/ca/ucalgary/seahawk/resources Added Files: t2flowDispatchStack.xml Log Message: Boilerplate XML used for processors added to T2Flow (Taverna) workflows generated by Seahawk moby-live/Java/src/main/ca/ucalgary/seahawk/resources t2flowDispatchStack.xml,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 16:05:46 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:05:46 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172005.o2HK5kIH010369@dev.open-bio.org> gordonp Wed Mar 17 16:05:45 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images In directory dev.open-bio.org:/tmp/cvs-serv10337/src/main/ca/ucalgary/seahawk/resources/images Added Files: search.gif search_d.gif Log Message: Icon for filter/search button on Seahawk main GUI moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images search.gif,NONE,1.1 search_d.gif,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 16:08:25 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:08:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172008.o2HK8PwS010475@dev.open-bio.org> gordonp Wed Mar 17 16:08:25 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv10443/src/main/ca/ucalgary/seahawk/util Added Files: FilterSearch.java XPathOption.java Log Message: Stores info needed for the search/filter functionality of Seahawk moby-live/Java/src/main/ca/ucalgary/seahawk/util FilterSearch.java,NONE,1.1 XPathOption.java,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 16:09:20 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:09:20 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172009.o2HK9KJ9010539@dev.open-bio.org> gordonp Wed Mar 17 16:09:20 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test In directory dev.open-bio.org:/tmp/cvs-serv10507/src/main/ca/ucalgary/services/test Added Files: keggOut.xml mobyKeyword.xml Log Message: XML file for testing service functionality moby-live/Java/src/main/ca/ucalgary/services/test keggOut.xml,NONE,1.1 mobyKeyword.xml,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 16:10:34 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:10:34 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172010.o2HKAY8Q010641@dev.open-bio.org> gordonp Wed Mar 17 16:10:34 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util In directory dev.open-bio.org:/tmp/cvs-serv10609/src/main/ca/ucalgary/services/util Added Files: MultiPartFormOutputStream.java Log Message: Utilities for dealing with multipart-encoded CGI form submissions moby-live/Java/src/main/ca/ucalgary/services/util MultiPartFormOutputStream.java,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 16:12:04 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:12:04 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172012.o2HKC4oh010705@dev.open-bio.org> gordonp Wed Mar 17 16:12:04 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources In directory dev.open-bio.org:/tmp/cvs-serv10673/src/main/ca/ucalgary/services/resources Added Files: grayOut.js Log Message: Utility script to make a Web opage non-interactive and gray...used by Daggoo during CGI to Moby Service wrapping moby-live/Java/src/main/ca/ucalgary/services/resources grayOut.js,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 16:14:30 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:14:30 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172014.o2HKEUhK010789@dev.open-bio.org> gordonp Wed Mar 17 16:14:30 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/test In directory dev.open-bio.org:/tmp/cvs-serv10757/src/main/ca/ucalgary/services/util/test Added Files: OntologyQuery.wsdl efetch_seq.wsdl Log Message: Test case for WSDL service wrapping moby-live/Java/src/main/ca/ucalgary/services/util/test OntologyQuery.wsdl,NONE,1.1 efetch_seq.wsdl,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 16:16:49 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:16:49 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172016.o2HKGnfi011203@dev.open-bio.org> gordonp Wed Mar 17 16:16:49 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services In directory dev.open-bio.org:/tmp/cvs-serv11171/src/main/ca/ucalgary/services Added Files: CGIServlet.java WrappingServlet.java Log Message: Part of legacy to Moby service wrapping system, Daggoo moby-live/Java/src/main/ca/ucalgary/services CGIServlet.java,NONE,1.1 WrappingServlet.java,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 16:17:39 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:17:39 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172017.o2HKHdei011275@dev.open-bio.org> gordonp Wed Mar 17 16:17:39 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources In directory dev.open-bio.org:/tmp/cvs-serv11211/src/main/ca/ucalgary/services/resources Modified Files: floatingframe.js Log Message: Updates related to major overhaul of Moby service wrapping system, Daggoo moby-live/Java/src/main/ca/ucalgary/services/resources floatingframe.js,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources/floatingframe.js,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources/floatingframe.js 2009/08/17 21:14:00 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources/floatingframe.js 2010/03/17 20:17:39 1.3 @@ -41,8 +41,8 @@ el.style=el; } el.sP = function(x,y){ - this.style.left=x; - this.style.top=y; + this.style.left=x+"px"; + this.style.top=y+"px"; }; if(horizontalPos=="fromright"){ @@ -107,7 +107,7 @@ /* Get the servlet message */ window.showHint = function(){ /* _dataAction is a special parameter whose values comes from ca.ucalgary.services.util.DataRecorder.PASSTHROUGH_ACTION */ - var url = "?_dataAction=hint"; + var url = "%SERVLET_URL%?_dataAction=hint"; url = url + "&sid="+Math.random(); /* The random ID is so IE doesn't cache the GET request */ xmlHttp.onreadystatechange=stateChanged; @@ -119,7 +119,7 @@ function pasteEvent(fieldObj){ /* _dataAction is a special parameter whose values comes from ca.ucalgary.services.util.DataRecorder.PASSTHROUGH_ACTION */ - var url = "?sid="+Math.random()+"&_dataAction=pasteEvent&field="+fieldObj.name; + var url = "%SERVLET_URL%?sid="+Math.random()+"&_dataAction=pasteEvent&field="+fieldObj.name; actionXmlHttp.open("GET",url,true); actionXmlHttp.send(null); From gordonp at dev.open-bio.org Wed Mar 17 16:17:39 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:17:39 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172017.o2HKHd0n011255@dev.open-bio.org> gordonp Wed Mar 17 16:17:39 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services In directory dev.open-bio.org:/tmp/cvs-serv11211/src/main/ca/ucalgary/services Modified Files: CGIService.java SoapServlet.java WSDLService.java Log Message: Updates related to major overhaul of Moby service wrapping system, Daggoo moby-live/Java/src/main/ca/ucalgary/services CGIService.java,1.7,1.8 SoapServlet.java,1.7,1.8 WSDLService.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/CGIService.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/CGIService.java 2008/03/13 23:06:48 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/CGIService.java 2010/03/17 20:17:39 1.8 @@ -1,5 +1,6 @@ package ca.ucalgary.services; +import ca.ucalgary.services.util.CGIUtils; import ca.ucalgary.services.util.XHTMLForm; import org.biomoby.service.MobyServlet; @@ -10,7 +11,6 @@ import org.apache.commons.httpclient.methods.*; import org.apache.commons.httpclient.methods.multipart.*; import org.apache.commons.httpclient.params.*; -import org.apache.commons.httpclient.util.URIUtil; import java.io.*; import java.net.URL; @@ -68,7 +68,7 @@ if(!(mobyData instanceof MobyDataObject) && !(mobyData instanceof MobyDataObjectSet)){ throw new MobyException("The Moby parameter '" + paramName + - "' is not a priary input as expected (" + + "' is not a primary input as expected (" + "found " + mobyData.getClass().getName() + ")"); } @@ -101,16 +101,17 @@ method = new PostMethod(formConfig.getFormAction()); if(XHTMLForm.MULTIPART.toLowerCase().equals( formConfig.getFormEncodingType().toLowerCase())){ - ((PostMethod) method).setRequestEntity(getMultipartRequest(formDataInstanceMap, - method.getParams())); + ((PostMethod) method).setRequestEntity(CGIUtils.getMultipartRequest(formDataInstanceMap, + method.getParams(), + formConfig.getFormFiles())); } else{ - ((PostMethod) method).setRequestBody(getNameValuePairs(formDataInstanceMap)); + ((PostMethod) method).setRequestBody(CGIUtils.getNameValuePairs(formDataInstanceMap)); } } // If not POST, assume GET else{ - method = new GetMethod(formConfig.getFormAction()+"?"+getURLQuery(formDataInstanceMap)); + method = new GetMethod(formConfig.getFormAction()+"?"+CGIUtils.getURLQuery(formDataInstanceMap)); } int statusCode; @@ -170,45 +171,6 @@ return createServiceFromConfig(request, formConfig); } - protected MultipartRequestEntity getMultipartRequest(Map dataInstances, - HttpMethodParams params){ - Part[] parts = new Part[dataInstances.size()]; - List fileTypeInputs = formConfig.getFormFiles(); - int i = 0; - for(Map.Entry formInput: dataInstances.entrySet()){ - String formInputName = formInput.getKey(); - if(fileTypeInputs.contains(formInputName)){ - parts[i++] = new FilePart(formInputName, - new ByteArrayPartSource(formInputName, - formInput.getValue())); - } - else{ - parts[i++] = new StringPart(formInputName, new String(formInput.getValue())); - } - } - return new MultipartRequestEntity(parts, params); - } - - protected NameValuePair[] getNameValuePairs(Map dataInstances){ - NameValuePair[] data = new NameValuePair[dataInstances.size()]; - int i = 0; - for(Map.Entry formField: dataInstances.entrySet()){ - data[i++] = new NameValuePair(formField.getKey(), - formField.getValue() == null ? "" : new String(formField.getValue())); - } - return data; - } - - protected String getURLQuery(Map dataInstances) throws URIException{ - String[] queryItems = new String[dataInstances.size()]; - int i = 0; - for(Map.Entry formField: dataInstances.entrySet()){ - queryItems[i++] = URIUtil.encodeWithinQuery(formField.getKey()) + "=" + - URIUtil.encodeWithinQuery(new String(formField.getValue())); - } - return XHTMLForm.join("+", queryItems); - } - public String createInputSpecString(XHTMLForm form){ Map ins = form.getPrimaryInputs(); // Create a reverse map so we can look up where a moby param =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.java 2009/08/27 21:37:32 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.java 2010/03/17 20:17:39 1.8 @@ -25,13 +25,8 @@ * can be extended using stylesheets and registering a DataRecorder (e.g. Daggoo registers PBERecorder to get * its functionality), please see the documentation at http://biomoby.open-bio.org/CVS_CONTENT/moby-live/Java/docs/soapServlet.html */ -public class SoapServlet extends HttpServlet{ +public class SoapServlet extends WrappingServlet{ - public static final String DATARECORDER_CONTEXTPARAM = "dataRecorder"; // how users spec a DataRecorder in the web.xml - - public static final String SERVICE_SPEC_PARAM = "service"; - public static final String WSDL_HTTP_PARAM = "wsdl"; - public static final String ID_PARAM = "seahawkId"; private static final String ARRAY_TYPE_SENTINEL = "ar_TyPe"; private static final String BASIC_TYPE_SENTINEL = "baSIc_TyPe"; private static final String BASIC_NAME_SENTINEL = "baSIc_naMe"; @@ -50,11 +45,8 @@ private static final String SQUOTE_OPTION = "single quotes ('...')"; private static DocumentBuilder docBuilder; - private Transformer indentationTransformer; - - private static Logger logger = Logger.getLogger("ca.ucalgary.services.SoapServlet"); - private DataRecorder recorder = null; + private static Logger logger = Logger.getLogger(SoapServlet.class.getName()); static{ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -74,146 +66,29 @@ URL u = getClass().getClassLoader().getResource(INDENTATION_XSL_RESOURCE); if(u != null){ // for pretty copying of SOAP response XML - indentationTransformer = transformerFactory.newTransformer(new StreamSource(u.openStream())); + setResponseTransformer(transformerFactory.newTransformer(new StreamSource(u.openStream()))); } else{ // verbatim copy as backup plan - indentationTransformer = transformerFactory.newTransformer(); - } - if(recorder != null){ - recorder.setTransformer(indentationTransformer); + setResponseTransformer(transformerFactory.newTransformer()); } } catch (Exception e){ logger.log(Level.SEVERE, "Could not create an XSLT transformer: " + e, e); } - - // See if the user has specified a DataRecorder to be used (customization and/or recording of - // user interaction and Web Service response). - String dataRecorderClassName = null; - javax.servlet.ServletContext context = getServletContext(); - if(context != null){ - if(context.getInitParameter(DATARECORDER_CONTEXTPARAM) != null){ - dataRecorderClassName = context.getInitParameter(DATARECORDER_CONTEXTPARAM); - } - } - javax.servlet.ServletConfig config = getServletConfig(); - if(config != null){ - if(config.getInitParameter(DATARECORDER_CONTEXTPARAM) != null){ - dataRecorderClassName = config.getInitParameter(DATARECORDER_CONTEXTPARAM); - } - } - if(dataRecorderClassName != null){ - DataRecorder dataRecorder = null; - - try{ - // This line can throw many different exception if you didn't get the class right! - Class drClass = getClass().getClassLoader().loadClass(dataRecorderClassName); - if(drClass == null){ - throw new ClassNotFoundException("The DataRecorder class to run (" + - dataRecorderClassName + - ") was not found, please ensure that the web.xml is up-to-date."); - } - dataRecorder = (DataRecorder) drClass.newInstance(); - } catch(Exception e){ - System.err.println("The DataRecorder implementing class was not specified properly in the web.xml file:"); - e.printStackTrace(); - throw new ServletException("Invalid web.xml, the parameter 'dataRecorder' was not useable"); - } - setRecorder(dataRecorder); - } - } - - public void setRecorder(DataRecorder r){ - recorder = r; - if(indentationTransformer != null){ - recorder.setTransformer(indentationTransformer); - } - } - - public DataRecorder getRecorder(){ - return recorder; } /** - * Gets are for form creation + * Post is for service submission (if the wsdl URL is provided) */ - public void doGet(HttpServletRequest request, - HttpServletResponse response) - throws ServletException, java.io.IOException{ - - if(request.getSession(false) == null && recorder != null){ - recorder.startRecording(request); //should set up a session - } - - String action = request.getParameter(DataRecorder.PASSTHROUGH_ACTION); - if(action != null && action.trim().length() > 0){ - // Delegate to the seahawk action recorder for wrapping - recorder.doGet(request, response); - return; - } - - String endpoint = request.getParameter(WSDL_HTTP_PARAM); - if(recorder != null && recorder.shouldIntercept(request)){ - recorder.interceptRequest(request, response); - } - else if(endpoint == null || endpoint.trim().length() == 0){ // Normal web-browser form fill-in - writeInputForm(request, response); - } - else{ - writeServiceForm(request, response, endpoint); - } - } - - /** - * Post is for service submission (if the wsdl URL is provided), or the PBERecorder (any other case) - */ - public void doPost(HttpServletRequest request, - HttpServletResponse response){ - - java.io.PrintStream out = null; - try{ - out = new java.io.PrintStream(response.getOutputStream()); - } - catch(java.io.IOException ioe){ - logger.log(Level.SEVERE, "While getting servlet output stream (for HTML form response to client)", ioe); - return; - } - - // Find out the info needed to build the JAX-WS client - if(recorder != null && recorder.shouldIntercept(request)){ - //if(wsdlLoc == null || wsdlLoc.trim().length() == 0){ - // if(recorder != null){ - recorder.interceptRequest(request, response); - return; - } - String wsdlLoc = request.getParameter(WSDL_HTTP_PARAM); - if(wsdlLoc == null || wsdlLoc.trim().length() == 0){ - response.setContentType("text/html"); - out.print("Error"+ - "\n"+ - "No '"+WSDL_HTTP_PARAM+"' parameter (the location of the WSDL document)" + - "was specified in the POST request, and " + - (recorder == null ? "no data recorder is associated with this servlet" : - "the data recorder did not want to intercept the POST") +""); - - } - URL url = null; - try{ - url = new URL(wsdlLoc); - } catch(Exception e){ - out.print("Error\n"+ - "\n"+ - "

The URL specified (" + - wsdlLoc + ") could not be parsed


");
-	    e.printStackTrace(out);
-	    out.print("
\n"); - return; - } + public void callService(HttpServletRequest request, + HttpServletResponse response, + URL url, //url of wsdl file + PrintStream out){ String serviceSpec = request.getParameter(SERVICE_SPEC_PARAM); - if(wsdlLoc == null || wsdlLoc.trim().length() == 0){ + if(serviceSpec == null || serviceSpec.trim().length() == 0){ out.print("Error\n"+ "\n"+ "No '"+SERVICE_SPEC_PARAM+"' parameter (specifying " + @@ -278,7 +153,7 @@ for (Enumeration e = request.getParameterNames(); e.hasMoreElements();){ String paramName = (String) e.nextElement(); if(SERVICE_SPEC_PARAM.equals(paramName) || - WSDL_HTTP_PARAM.equals(paramName) || + SRC_PARAM.equals(paramName) || ID_PARAM.equals(paramName)){ continue; } @@ -403,7 +278,7 @@ answer = recorder.markupResponse(resultSource, request); } catch(Exception e){ //todo - answer = "
Exception in PBE system:\n"+e.toString()+"\n";
+		answer = "
Exception in DataRecorder subsystem:\n"+e.toString()+"\n";
 		for(StackTraceElement ste: e.getStackTrace()){
 		    answer += ste.toString()+"\n";
 		}	    
@@ -414,8 +289,9 @@
 	    // Does two duties: fixes indentation, and outputs to a Java stream we can print easily
 	    ByteArrayOutputStream stringResult = new ByteArrayOutputStream();
 	    try{
-		synchronized(indentationTransformer){
-		    indentationTransformer.transform(resultSource, 
+		Transformer responseTransformer = getResponseTransformer();
+		synchronized(responseTransformer){
+		    responseTransformer.transform(resultSource, 
 						     new javax.xml.transform.stream.StreamResult(stringResult));
 		}
 	    } catch(Exception e){
@@ -440,52 +316,24 @@
 
     // Asks for the WSDL file
     private void writeInputForm(HttpServletRequest request,
-				HttpServletResponse response){
-	java.io.OutputStream out = null;
-	response.setContentType("text/html");
-	try{
-	    out = response.getOutputStream();
-	}
-	catch(java.io.IOException ioe){
-	    logger.log(Level.SEVERE, "While getting servlet output stream (for HTML form response to client)", ioe);
-	    return;
-	}
-
-	try{
-	    out.write("Generic SOAP Client\n".getBytes());
-	    out.write("Enter the URL of the WSDL file below: 
").getBytes()); - out.write("
".getBytes()); - } - catch(java.io.IOException ioe){ - logger.log(Level.SEVERE, "While printing HTML form to servlet output stream", ioe); - return; - } + HttpServletResponse response, + PrintStream out){ + out.print("Generic SOAP Client\n"); + out.print("Enter the URL of the WSDL file below:
"); + out.print("
"); } // Presents the WSDL file as a CGI form - private void writeServiceForm(HttpServletRequest request, - HttpServletResponse response, - String endpoint){ - java.io.PrintStream out = null; - response.setContentType("text/html"); - try{ - out = new java.io.PrintStream(response.getOutputStream()); - } - catch(java.io.IOException ioe){ - log("While getting servlet output stream (for HTML form response to client)", ioe); - return; - } - - URL url = null; - try{ - url = new URL(endpoint); - } catch(Exception e){ - out.print("Parsing Error\n"+ - "\n" + - "

The URL specified (" + endpoint + ") could not be parsed


");
-	    e.printStackTrace(out);
-	    out.print("
\n"); + protected void writeServiceForm(HttpServletRequest request, + HttpServletResponse response, + URL url, + PrintStream out){ + + // Normal web-browser form fill-in, ask for the WSDL to wrap + // Useful so this servlet can standalone and borker WSDL services. + if(url == null){ + writeInputForm(request, response, out); return; } @@ -496,7 +344,7 @@ out.print(recorder.getHead(request)); } // allow the recorder to insert any body events required - out.print("\n\n"); + out.print("\n\n"); if(recorder != null){ out.print(recorder.getBody(request)); } @@ -1010,7 +858,7 @@ portQName.getNamespaceURI() + " " + portQName.getLocalPart() + " "; out.print("

"+ opQName.getLocalPart()+"

\n"+ - "\n"); + "\n"); Map partsMap = msg2Parts.get(messageQName); if(partsMap == null){ System.err.println("Got null parts map for message " + messageQName); @@ -1335,23 +1183,6 @@ } /** - * Links the form inputs to javascript capture actions, if a recorder is available - */ - private String rec(){ - if(recorder != null){ - return recorder.getOnEventText(); - } - return ""; - } - - private String sub(){ - if(recorder != null){ - return recorder.getOnSubmitText(); - } - return ""; - } - - /** * Expand any import or include statements in-place. */ public static void doImports(Document doc, URL baseURL) throws Exception{ @@ -1449,13 +1280,4 @@ } } } - - public static class MyNodeList implements NodeList{ - private Vector nodes; - public MyNodeList(){nodes = new Vector();} - public int getLength(){return nodes.size();} - public Node item(int index){return nodes.elementAt(index);} - public void add(Node n){nodes.add(n);} - public void add(NodeList n){for(int i=0;i gordonp Wed Mar 17 16:17:39 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test In directory dev.open-bio.org:/tmp/cvs-serv11211/src/main/ca/ucalgary/services/test Modified Files: CGIServiceTestCase.java SoapServletTestCase.java Log Message: Updates related to major overhaul of Moby service wrapping system, Daggoo moby-live/Java/src/main/ca/ucalgary/services/test CGIServiceTestCase.java,1.1,1.2 SoapServletTestCase.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/CGIServiceTestCase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/CGIServiceTestCase.java 2008/02/14 03:04:44 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/CGIServiceTestCase.java 2010/03/17 20:17:39 1.2 @@ -26,7 +26,8 @@ */ public class CGIServiceTestCase extends MobyServletTestCase{ private final static String CGITEST_CLASS_NAME = "ca.ucalgary.services.CGIService"; - private final static String CGITEST_MOBY_XML = "ca/ucalgary/services/test/mobyDNASeq.xml"; + //private final static String CGITEST_MOBY_XML = "ca/ucalgary/services/test/mobyDNASeq.xml"; + private final static String CGITEST_MOBY_XML = "ca/ucalgary/services/test/mobyKeyword.xml"; public CGIServiceTestCase(String name){ super(name); @@ -70,4 +71,4 @@ public static void main(String[] args){ junit.textui.TestRunner.run(suite()); } -} \ No newline at end of file +} =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/SoapServletTestCase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/SoapServletTestCase.java 2009/08/20 19:52:09 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/SoapServletTestCase.java 2010/03/17 20:17:39 1.3 @@ -36,7 +36,7 @@ } TestHttpServletRequest request = new TestHttpServletRequest(); - request.setParameter(SoapServlet.WSDL_HTTP_PARAM, "http://soap.genome.jp/KEGG.wsdl"); + request.setParameter(SoapServlet.SRC_PARAM, "http://soap.genome.jp/KEGG.wsdl"); request.setParameter(SoapServlet.SERVICE_SPEC_PARAM, "SOAP/KEGG KEGG SOAP/KEGG KEGGPort " + "SOAP/KEGG get_compounds_by_enzyme SOAP/KEGG#get_compounds_by_enzyme " + "get_compounds_by_enzyme rpc encoded"); @@ -69,7 +69,7 @@ } TestHttpServletRequest request = new TestHttpServletRequest(); - request.setParameter(SoapServlet.WSDL_HTTP_PARAM, "http://www.ebi.ac.uk/ontology-lookup/OntologyQuery.wsdl"); + request.setParameter(SoapServlet.SRC_PARAM, "http://www.ebi.ac.uk/ontology-lookup/OntologyQuery.wsdl"); request.setParameter(SoapServlet.SERVICE_SPEC_PARAM, "http://www.ebi.ac.uk/ontology-lookup/OntologyQuery QueryService " + "http://www.ebi.ac.uk/ontology-lookup/OntologyQuery OntologyQuery " + "http://www.ebi.ac.uk/ontology-lookup/OntologyQuery getTermsByName " + @@ -93,7 +93,7 @@ out.getBuffer().toString()); } TestHttpServletRequest request2 = new TestHttpServletRequest(); - request2.setParameter(SoapServlet.WSDL_HTTP_PARAM, "http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/eutils.wsdl"); + request2.setParameter(SoapServlet.SRC_PARAM, "http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/eutils.wsdl"); request2.setParameter(SoapServlet.SERVICE_SPEC_PARAM, "http://www.ncbi.nlm.nih.gov/soap/eutils/ eUtilsService " + "http://www.ncbi.nlm.nih.gov/soap/eutils/ eUtilsServiceSoap " + "http://www.ncbi.nlm.nih.gov/soap/eutils/espell eSpellRequest " + From gordonp at dev.open-bio.org Wed Mar 17 16:20:09 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:20:09 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172020.o2HKK9pL011425@dev.open-bio.org> gordonp Wed Mar 17 16:20:09 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv11393/src/main/ca/ucalgary/seahawk/gui Added Files: WorkflowPreviewDialog.java WorkflowPreviewListener.java Log Message: Now the user sees the workflow (depends on Ruby script on remote host) before saving moby-live/Java/src/main/ca/ucalgary/seahawk/gui WorkflowPreviewDialog.java,NONE,1.1 WorkflowPreviewListener.java,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 16:20:48 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:20:48 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172020.o2HKKmXT011503@dev.open-bio.org> gordonp Wed Mar 17 16:20:47 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv11471/src/main/ca/ucalgary/seahawk/gui Added Files: FilterSearchWidget.java Log Message: GUI component (removable bottom bar) of Seahawk interface moby-live/Java/src/main/ca/ucalgary/seahawk/gui FilterSearchWidget.java,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 16:21:55 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:21:55 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172021.o2HKLt9L011579@dev.open-bio.org> gordonp Wed Mar 17 16:21:55 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test In directory dev.open-bio.org:/tmp/cvs-serv11511/src/main/ca/ucalgary/seahawk/gui/test Modified Files: SeahawkTestCase.java Log Message: Interface updates related to new search/filter and workflow generation/preview functions moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test SeahawkTestCase.java,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java 2009/06/09 19:26:15 1.12 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java 2010/03/17 20:21:55 1.13 @@ -35,7 +35,7 @@ private final static String TEST_MS_EXCEL_FILE = "ca/ucalgary/seahawk/gui/test/twohybrid_uetz.xls"; private final static String TEST_MOBYEX_XML = "ca/ucalgary/seahawk/gui/test/moby_exception.xml"; private final static String TEST_MOBY_XML = "ca/ucalgary/seahawk/gui/test/allDataTypes.xml"; - private final static String TEST_WSDL_FILE = "ca/ucalgary/seahawk/gui/test/efetch_seq.wsdl"; + private final static String TEST_WSDL_FILE = "http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/efetch_seq.wsdl"; private final static String TEST_EXTERNAL_URL = "http://www.google.com/"; private final static String TEST_DNA_SEQ = "AAGCTTGGCCAACGTAAATCTTTCGGCGGCA"; private final static String TEST_AA_SEQ = "MPGGFILAIDEGTTSARAIIYNQDLEVLGIGQYDFPQHYPSP"; @@ -527,7 +527,7 @@ // Checks to make sure the Moby-wrapping of WSDL forms works fine public void testWSDL() throws Exception{ - URL wsdlResource = getClass().getClassLoader().getResource(TEST_WSDL_FILE); + URL wsdlResource = TEST_WSDL_FILE.startsWith("http://") ? new URL(TEST_WSDL_FILE) : getClass().getClassLoader().getResource(TEST_WSDL_FILE); assertNotNull("Could not find test WSDL resource " + TEST_WSDL_FILE, wsdlResource); contentGUI.loadPaneFromURL(wsdlResource, true); try{ @@ -802,13 +802,13 @@ sleep(2000); //just to ensure HTML rendering finishes } - public void testRunServiceSecondariesAndSCUFL() throws Exception{ + public void testRunServiceSecondariesAndWorkflow() throws Exception{ try{ - findService(TEST_DNA_SEQ, "Bioinformatics", "..."); + findService(TEST_DNA_SEQ, "BasicGFFSequenceFeature", "..."); } catch(Exception e){ e.printStackTrace(); fail("Error while a finding service ending with \"...\" " + - "(secondary input) under \"Analysis\" in the popup"); + "(secondary input) under \"BasicGFFSequenceFeature\" in the popup"); } fillInSecondariesAndExecute(); @@ -824,9 +824,9 @@ // Since we ran a real service, we can make a Taverna workflow out of the tab history File testFile = File.createTempFile("test-seahawk", ""); testFile.deleteOnExit(); - MobySaveDialog.exportSCUFL(contentGUI.getCurrentPane(), testFile); + MobySaveDialog.exportWorkflow(contentGUI.getCurrentPane(), testFile); sleep(1000); - assertTrue("The SCUFL saved data file was empty", testFile.length() != 0); + assertTrue("The workflow saved data file was empty", testFile.length() != 0); } public void fillInSecondariesAndExecute() throws Exception{ @@ -1079,7 +1079,7 @@ suite.addTest(new SeahawkTestCase("testPrint")); //done suite.addTest(new SeahawkTestCase("testNavigationButtons")); //done suite.addTest(new SeahawkTestCase("testRunAsynchronousService")); //done - suite.addTest(new SeahawkTestCase("testRunServiceSecondariesAndSCUFL")); //done + suite.addTest(new SeahawkTestCase("testRunServiceSecondariesAndWorkflow")); //done suite.addTest(new SeahawkTestCase("testHighlightOptions"));//done suite.addTest(new SeahawkTestCase("testUserPreferences"));//done suite.addTest(new SeahawkTestCase("testExternalBrowser"));//done From gordonp at dev.open-bio.org Wed Mar 17 16:21:55 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:21:55 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172021.o2HKLtxB011603@dev.open-bio.org> gordonp Wed Mar 17 16:21:55 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv11511/src/main/ca/ucalgary/seahawk/resources Modified Files: moby2HTML.xsl mobyBuilderRules.xml Log Message: Interface updates related to new search/filter and workflow generation/preview functions moby-live/Java/src/main/ca/ucalgary/seahawk/resources moby2HTML.xsl,1.4,1.5 mobyBuilderRules.xml,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/moby2HTML.xsl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/moby2HTML.xsl 2007/07/28 03:47:41 1.4 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/moby2HTML.xsl 2010/03/17 20:21:55 1.5 @@ -218,18 +218,20 @@ - ID : () + + ID : () - + String : ():
-
+ - :
+ + ():
=================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml 2009/08/17 21:31:52 1.9 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml 2010/03/17 20:21:55 1.10 @@ -3,6 +3,9 @@ http://www.bioxml.info/dtd/agave.dtd http://www.bioxml.info/dtd/tigrxml.dtd http://www.bioxml.info/dtd/Bioseq.dtd +http://www.biomedcentral.com/xml/article.dtd +http://dtd.nlm.nih.gov/publishing/2.0/journalpublishing.dtd +http://genmapp.org/GPML/2008a (HEADER\s+.*?(\S+)\n @@ -98,10 +101,11 @@ + urn:lsid:bioxml.info:mobyLiftingSchemaMapping:URL2Link ((?:http|ftp|file):// ([^/\x20\r\t\n]+)? # host name (non-whitespace, non-slash), maybe \S*?) # rest of the URL until - ([,\.\)\(]\s|\z) # trailing punctuation and whitespace, or just EOD + ([,\.\)\(]?\s|\z) # trailing punctuation and whitespace, or just EOD $1 @@ -140,6 +144,28 @@ + + bmcarticle:pubid[@idtype="pmpid"]/text() + + $1 + + + + + bmcarticle:pubid[@idtype="doi"]/text() + + $1 + + + + + ncbiarticle:article-id[@pub-id-type="doi"]/text() + + $1 + + + + (?:[KC]OG|[kc]og):?\s*(\d{4}) @@ -153,7 +179,7 @@ urn:lsid:bioxml.info:mobyLiftingSchemaMapping:prefixedDOI2DOI (?:DOI|doi|[Dd]igital\s+[Oo]bject\s+[Ii][Dd](?:entifier))\s*:?\s*(10\.\d+/[^%"\#\x20\t\r\n]+) - $1 + $1 @@ -218,6 +244,14 @@ + + + gpml:Xref[@Database="Entrez Gene"]/@ID + + $1 + + + ([NXYZ][CMP]_\d{6}) From gordonp at dev.open-bio.org Wed Mar 17 16:21:55 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:21:55 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172021.o2HKLtro011631@dev.open-bio.org> gordonp Wed Mar 17 16:21:55 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv11511/src/main/ca/ucalgary/seahawk/services Modified Files: DaggooClient.java MobyClient.java Log Message: Interface updates related to new search/filter and workflow generation/preview functions moby-live/Java/src/main/ca/ucalgary/seahawk/services DaggooClient.java,1.1,1.2 MobyClient.java,1.24,1.25 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/DaggooClient.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/DaggooClient.java 2009/06/09 19:52:02 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/DaggooClient.java 2010/03/17 20:21:55 1.2 @@ -21,57 +21,109 @@ public class DaggooClient{ private static Logger logger = Logger.getLogger(DaggooClient.class.getName()); + /** + * The three outcomes possible from asking the user about the URL dropped on Seahawk. + */ + public enum Action {WRAP, CALL, VIEW, NOTHING} + public static boolean acceptAnExistingWrapper(URL u, MobyContentPane dropTargetPane){ + // by default, do not provide view vs. wrap option + return acceptAnExistingWrapper(u, dropTargetPane, false) != Action.WRAP; + // all actions except wrap are handled by this method + } + + /** + * Presents the user with a dialog showing all Moby services (wrappers) that exist for the provided URL. + * This method will handle calling of existing services and viewing the form. Only a return of Action.WRAP + * is actionable for the caller. + * + * @param u the URL containing the form/wsdl doc to wrap + * @param dropTargetPane the Seahawk GUI element onto which the URL was dropped + * @param giveViewOption provide extra option to just view the page in Seahawk, rather than wrap the service + */ + public static Action acceptAnExistingWrapper(URL u, MobyContentPane dropTargetPane, boolean giveViewOption){ // Before wrapping the WSDL, see if there are already services wrapping it (in Daggoo). // If so, ask the user if they want to use one of those instead. try{ String existingServices = HTMLUtils.getURLContents(new URL(PBERecorder.getProxyBaseUrl()+ "lookup/"+Registration.OP_SPEC_DOC_PARAM+ "/"+u)); - if(existingServices == null || existingServices.length() == 0){ - return false; // no existing wrappers - } - String registryURL = SeahawkOptions.getRegistry() == null ? - CentralImpl.getDefaultURL() : - SeahawkOptions.getRegistry().getEndpoint(); Vector choices = new Vector(); - for(String line: existingServices.split("\n")){ - String[] fields = line.split("\t"); - if(fields.length != 4){ - throw new Exception("Did not get lines with 4 tab-delimited fields " + - "from Daggoo lookup service. The offending line is " + line); - } - if(!fields[1].equals(registryURL)){ - logger.log(Level.INFO, - "Skipping service in different registry (" + - fields[1] + ") than the current one in Seahawk (" + - registryURL + ")"); - continue; + if(existingServices != null && existingServices.length() != 0){ + String registryURL = SeahawkOptions.getRegistry() == null ? + CentralImpl.getDefaultURL() : + SeahawkOptions.getRegistry().getEndpoint(); + for(String line: existingServices.split("\n")){ + String[] fields = line.split("\t"); + if(fields.length != 4){ + throw new Exception("Did not get lines with 4 tab-delimited fields " + + "from Daggoo lookup service. The offending line is " + line); + } + if(!fields[1].equals(registryURL)){ + logger.log(Level.INFO, + "Skipping service in different registry (" + + fields[1] + ") than the current one in Seahawk (" + + registryURL + ")"); + continue; + } + choices.add(fields[3]+" ("+fields[2]+")"); } - choices.add(fields[3]+" ("+fields[2]+")"); - } - if(choices.isEmpty()){ - return false; // none in the registry we need } //todo: add "Don't show me this dialog again" option? - Object selectedValue = JOptionPane.showInputDialog(dropTargetPane, - "The services below wrap the same page as " + - "you just dragged into Seahawk.\n Would you like to " + - "call one instead of wrapping the page again?", - "Existing Wrapper Services", - JOptionPane.INFORMATION_MESSAGE, null, - choices.toArray(), choices.get(0)); - if(selectedValue == null){ - // cancel - return false; + Object selectedValue = null; + if(!giveViewOption){ + if(choices.isEmpty()){ + return Action.WRAP; // none in the registry we need + } + selectedValue = JOptionPane.showInputDialog(dropTargetPane, + "The services below wrap the same page as " + + "you just dragged into Seahawk.\n Would you like to " + + "call one instead of wrapping the page again?", + "Existing Wrapper Services", + JOptionPane.INFORMATION_MESSAGE, null, + choices.toArray(), choices.get(0)); + if(selectedValue == null){ + // cancel = wrap it yourself instead of using one of the service options presented + return Action.WRAP; + } + } + else{ // give user three options: call service, wrap service or view URL contents in Seahawk + Action action = Action.NOTHING; + if(choices.isEmpty()){ // still give option to wrap or view contents if no services exist + int choice = JOptionPane.showOptionDialog(dropTargetPane, + "What would you like to do with this Web page?", "Wrap or View?", + JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, + null, new String[]{"Create a service", "View page contents"}, + "Create a service"); + if(choice == JOptionPane.CLOSED_OPTION){ + return Action.NOTHING; + } + else if(choice == 0){ + return Action.WRAP; + } + else{ + action = Action.VIEW; + } + } + else{ + + } + if(action == Action.VIEW){ + // load the page for viewing. Normally gotoURL would cause recursion on this method, so + // we disable wrapping temporarily to avoid this. + dropTargetPane.setWrappingEnabled(false); + dropTargetPane.gotoURL(u, true); + dropTargetPane.setWrappingEnabled(true); + return Action.VIEW; + } } // todo: actually call service System.err.println("Running the existing wrapper " + selectedValue); } catch(Exception e){ logger.log(Level.WARNING, "Cannot show the user existing service options", e); - return false; + return Action.VIEW; } - return true; //if we got here, the user accepted an existing service + return Action.CALL; //if we got here, the user accepted an existing service } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2009/08/18 18:22:07 1.24 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2010/03/17 20:21:55 1.25 @@ -17,6 +17,7 @@ import java.net.URL; import java.net.MalformedURLException; import java.util.*; +import java.util.logging.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.xml.parsers.*; @@ -36,6 +37,7 @@ public static final String PREFIX_ATTR = "value"; public static final String ARTICLENAME_RULE_TAG = "articlename"; public static final String NAMESPACE_RULE_TAG = "namespace"; + public static final String NAMESPACE_MODEL_ATTR = "model"; public static final String NAMESPACE_VALUE_TAG = "ns"; public static final String NAMESPACE_VALUE_ATTR = "value"; public static final String DATATYPE_RULE_TAG = "datatype"; @@ -71,7 +73,7 @@ private Registry registry; private URL dataMappingXMLURL; private DocumentBuilder docBuilder; - private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobyClient.class); + private static Logger logger = Logger.getLogger(MobyClient.class.getName()); private int serviceLevel = MobyService.UNCHECKED; @@ -272,7 +274,8 @@ Vector regexStrings = new Vector(); Vector urlRegexStrings = new Vector(); Vector xpathStrings = new Vector(); - Map namespaceMap = new HashMap(); + Map namespaceMap = new HashMap(); // moby nanmespaces -> production rules + Map modelMap = new HashMap(); // Semantic Web URIs -> production rules Map memberMap = new HashMap(); String dataTypeString = null; String articleNameString = null; @@ -297,7 +300,7 @@ addXPathString(ruleMember, xpathStrings); } else if(isNamespaceRule(ruleMember)){ - addNamespaceMapping(ruleMember, namespaceMap); + addNamespaceMapping(ruleMember, namespaceMap, modelMap); } else if(isArticleNameRule(ruleMember)){ if(articleNameString != null && articleNameString.length() != 0){ @@ -607,13 +610,14 @@ memberRuleName}); } - protected void addNamespaceMapping(Element nsTag, Map namespaceStrings) throws Exception{ + protected void addNamespaceMapping(Element nsTag, Map namespaceStrings, Map modelStrings) throws Exception{ if(!isNamespaceRule(nsTag)){ throw new Exception("Element provided to createNamespaceMapping (" + (nsTag == null ? null : nsTag.getLocalName()) + ") was not a namespace rule element"); } + NodeList ruleSpecs = nsTag.getChildNodes(); for(int i = 0; i < ruleSpecs.getLength(); i++){ Node specNode = ruleSpecs.item(i); @@ -625,7 +629,8 @@ Element ruleSpec = (Element) specNode; String specName = ruleSpec.getLocalName(); if(NAMESPACE_VALUE_TAG.equals(specName)){ - String keyName = ruleSpec.getAttribute(NAMESPACE_VALUE_ATTR); + String keyName = ruleSpec.getAttribute(NAMESPACE_VALUE_ATTR); // moby namespace + String modelURI = ruleSpec.getAttribute(NAMESPACE_MODEL_ATTR); // Semantic Web URI String valueRule = ruleSpec.getTextContent(); if(valueRule == null || valueRule.length() == 0){ throw new Exception("Element " + NAMESPACE_VALUE_TAG + @@ -636,7 +641,12 @@ "namespace '" + keyName + "'"); continue; } - namespaceStrings.put(keyName, valueRule); + if(keyName != null && keyName.length() != 0){ + namespaceStrings.put(keyName, valueRule); + } + if(modelURI != null && modelURI.length() != 0){ + modelStrings.put(modelURI, valueRule); + } } else{ System.err.println("Skipping unexpected "+NAMESPACE_RULE_TAG+" child node " + specName); @@ -1336,7 +1346,7 @@ mobyDataServiceAssocInstances[i] = new MobyDataObjectSetSAI((MobyDataObjectSet) mdos[i], mService); } else{ - logger.warn("MobyClient could not handle service-associating an instance of " + mdos[i].getClass()); + logger.log(Level.WARNING, "MobyClient could not handle service-associating an instance of " + mdos[i].getClass()); System.err.println("MobyClient could not handle service-associating an instance of " + mdos[i].getClass()); } } @@ -1694,7 +1704,8 @@ builderNameMap.put(urn, mcb); } }catch(Exception e){ - logger.warn("Could not create XPath select statement from '" + + logger.log(Level.WARNING, + "Could not create XPath select statement from '" + xpath_exp + "': " + e.getMessage()); System.err.println("Could not create XPath select statement from '" + xpath_exp + "': " + e); From gordonp at dev.open-bio.org Wed Mar 17 16:53:12 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:53:12 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172053.o2HKrCYa012479@dev.open-bio.org> gordonp Wed Mar 17 16:53:12 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util In directory dev.open-bio.org:/tmp/cvs-serv12447/src/main/ca/ucalgary/services/util Added Files: CGIUtils.java Log Message: Methods to simplify CGI posting done in Daggoo moby-live/Java/src/main/ca/ucalgary/services/util CGIUtils.java,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 16:55:51 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:55:51 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172055.o2HKtpvo012611@dev.open-bio.org> gordonp Wed Mar 17 16:55:51 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv12571/src/main/org/biomoby/client Modified Files: MobyRequest.java MobyRequestEvent.java Log Message: Updates to pass sent data around with response (used by Seahawk PbE system) moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.44,1.45 MobyRequestEvent.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2009/07/15 18:35:30 1.44 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2010/03/17 20:55:51 1.45 @@ -373,7 +373,7 @@ // Inform the handler that some data has been added to the response (for incremental display?) if(handler != null){ - MobyRequestEvent mre = new MobyRequestEvent(finalContents, this, mservice, null, requestId); + MobyRequestEvent mre = new MobyRequestEvent(finalContents, this, mservice, inData, null, requestId); StringWriter xmlWriter = new StringWriter(); MobyDataUtils.toXMLDocument(xmlWriter, finalContents); @@ -412,10 +412,20 @@ * @return the id that the callback event will return from getID(), allowing a client to distinguish between multiple concurrent invocation callbacks */ public synchronized int invokeService(MobyRequestEventHandler handler){ - int id = autoID++; + final int id = autoID++; - Thread t = new InvocationThread(this, inputData, handler, id); // see internal class definition below - t.start(); + try{ + Thread t = new InvocationThread(this, inputData, handler, id); // see internal class definition below + t.start(); + } catch(final Exception e){ + // Launching callback in new Thread avoids possible deadlocks caused by handler + // calling invokeService() again as a retry + final MobyRequestEventHandler h = handler; + final MobyContentInstance i = inputData; + final MobyService s = getService(); + final MobyRequest t = this; + (new Thread(){public void run(){h.processEvent(new MobyRequestEvent(i, t, s, null, e, id));}}).start(); + } return id; } @@ -424,24 +434,29 @@ // the handler specified in the invocation. class InvocationThread extends Thread { MobyContentInstance data; + ByteArrayOutputStream dataXML; MobyService mservice; MobyRequest mobyRequest; MobyRequestEventHandler handler; int requestId; - InvocationThread(MobyRequest mr, MobyContentInstance inData, MobyRequestEventHandler h, int id){ + InvocationThread(MobyRequest mr, MobyContentInstance inData, MobyRequestEventHandler h, int id) throws Exception{ data = inData; mobyRequest = mr; mservice = mobyRequest.getService(); handler = h; requestId = id; + dataXML = new ByteArrayOutputStream(); + MobyDataUtils.toXMLDocument(dataXML, data); + // Name the thread after the service being run, mostly for ease of debugging setName(mservice.getName()+requestId); } public void run() { - MobyRequestEvent requestEvent = new MobyRequestEvent(data, mobyRequest, mservice, null, requestId); + + MobyRequestEvent requestEvent = new MobyRequestEvent(data, mobyRequest, mservice, data, null, requestId); // Tell the handler we're starting the request, with the given data handler.start(requestEvent); @@ -452,13 +467,14 @@ content = mobyRequest.invokeService(data, contentsXML, handler, requestId); //RPC call... } catch(Exception e){ - responseEvent = new MobyRequestEvent(content, mobyRequest, mservice, e, requestId); + responseEvent = new MobyRequestEvent(content, mobyRequest, mservice, data, e, requestId); } catch(Error err){ - responseEvent = new MobyRequestEvent(content, mobyRequest, mservice, err, requestId); + responseEvent = new MobyRequestEvent(content, mobyRequest, mservice, data, err, requestId); } + if(responseEvent == null){ - responseEvent = new MobyRequestEvent(content, mobyRequest, mservice, null, requestId); + responseEvent = new MobyRequestEvent(content, mobyRequest, mservice, data, null, requestId); } // We've got the raw XML laying around, so why not provide it unmolested to the callback? responseEvent.setContentsXML(contentsXML.toString()); @@ -480,37 +496,6 @@ } /** - * This method retrieves from Moby Central a copy of the WSDL document for the service - * (or uses an internally cached copy from a previous invocation), and sets the variables for the - * SOAP call appropriately so you can consequently call performSOAPRequest. - */ -//PG protected Call getServiceFromWSDL() throws MobyException, NoSuccessException{ -// String wsdl = null; - -// // Since this is how we retrieve a service from Central, use the same values as the key to the hash -// String wsdlCacheKey = mobyService.getName() + "@" + mobyService.getAuthority(); - -// // This is the same call as last time, so we don't need to change the setup -// if(wsdlCacheKey.equals(lastWsdlCacheKey)){ -// return setCallFromWSDL((String) wsdlCache.get(wsdlCacheKey)); -// } -// // We haven't encountered this service yet -// else if(!wsdlCache.containsKey(wsdlCacheKey)){ -// wsdl = mobyCentral.getServiceWSDL(mobyService.getName(), mobyService.getAuthority()); -// wsdlCache.put(wsdlCacheKey, wsdl); -// } -// // We've dealt with this one before -// else{ -// wsdl = (String) wsdlCache.get(wsdlCacheKey); -// } - -// lastWsdlCacheKey = wsdlCacheKey; // Keep track of the last invocation - - // Get ready to do SOAP -//PG return setCallFromWSDL(null); -// } - - /** * Creates the SOAP Call that will be invoked later. This should be based on the WSDL document * and parameter information from the MobyService, but these are currently not up to snuff. */ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEvent.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEvent.java 2007/06/08 14:04:27 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEvent.java 2010/03/17 20:55:51 1.6 @@ -18,17 +18,19 @@ protected int eventID; protected MobyContentInstance contents; protected MobyRequest originatingMobyRequest; + protected MobyContentInstance originatingMobyRequestInputData; protected String dataPayloadXML; protected MobyService service; protected Throwable exception; private static int nextEventID = 0; - public MobyRequestEvent(MobyContentInstance mci, MobyRequest requestSource, MobyService serv, Throwable e, int id){ + public MobyRequestEvent(MobyContentInstance mci, MobyRequest requestSource, MobyService serv, MobyContentInstance serviceInput, Throwable e, int id){ consumed = false; done = false; - contents = mci; + contents = mci; originatingMobyRequest = requestSource; + originatingMobyRequestInputData = serviceInput; exception = e; eventID = id; service = serv; @@ -42,6 +44,24 @@ } /** + * This method should be used instead of getSource().getInput() because the MobyRequest object may have multiple + * concurrent threads using it, meaning that the inputXML is not necessarily what it was when the service was + * invoked. + * + * @return if a Moby client waiting for a service response, this data is the payload given as input to the service + */ + public MobyContentInstance getSourceInput(){ + return originatingMobyRequestInputData; + } + + /** + * @param inputXML the Moby XML sent to the service this event is refering to. + */ + public void setSourceInput(MobyContentInstance inputPayload){ + originatingMobyRequestInputData = inputPayload; + } + + /** * @return the contents of the MOBY request or response (depending on whether MobyRequest is acting as a client or server) */ public MobyContentInstance getContent(){ From gordonp at dev.open-bio.org Wed Mar 17 16:57:28 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:57:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172057.o2HKvSO4012677@dev.open-bio.org> gordonp Wed Mar 17 16:57:28 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory dev.open-bio.org:/tmp/cvs-serv12641/src/main/org/biomoby/shared Modified Files: MobyData.java Log Message: Added methods to allow association of a random application-specific objects with the Moby data moby-live/Java/src/main/org/biomoby/shared MobyData.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyData.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyData.java 2008/01/07 22:11:36 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyData.java 2010/03/17 20:57:28 1.7 @@ -25,6 +25,9 @@ protected String name; protected String id = null; + /** Convenience for applications to associate any data with the Moby objects as needed for the + application's particular purpose. Inspired by Java3D's scenegraph customization method. */ + protected Object userData = null; /************************************************************************** * Default constructor. @@ -54,6 +57,24 @@ public void setId (String value) { id = value; } + + /** + * Retrieves any application-specific data that may have been stored in association with this Moby object. + * The returned object has nothing to do with the Moby protocol itself. See setUserData() for more details. + */ + public Object getUserData(){ + return userData; + } + + /** + * Allows developers to track their application-specific information alongside the Moby functionality. + * Provided for application developers' convenience: data stored using this routine is completely + * ignore by the Moby core libraries. If you want to store Moby data, use the routines defined in various + * subclasses of this class (e.g. MobyDataObject). + */ + public void setUserData(Object data){ + userData = data; + } /************************************************************************** * Must be overwritten by a subclass. From gordonp at dev.open-bio.org Wed Mar 17 16:57:59 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:57:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172057.o2HKvxFs012721@dev.open-bio.org> gordonp Wed Mar 17 16:57:59 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv12685/src/main/org/biomoby/shared/data Modified Files: MobyDataInstance.java Log Message: Added methods to allow association of a random application-specific objects with the Moby data moby-live/Java/src/main/org/biomoby/shared/data MobyDataInstance.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInstance.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInstance.java 2006/07/07 04:12:40 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInstance.java 2010/03/17 20:57:59 1.4 @@ -36,6 +36,20 @@ */ public Object getObject(); + /** + * Retrieves any application-specific data that may have been stored in association with this Moby object. + * The returned object has nothing to do with the Moby protocol itself. See setUserData() for more details. + */ + public Object getUserData(); + + /** + * Allows developers to track their application-specific information alongside the Moby functionality. + * Provided for application developers' convenience: data stored using this routine is completely + * ignore by the Moby core libraries. If you want to store Moby data, use the routines defined in various + * subclasses of this class (e.g. MobyDataObject). + */ + public void setUserData(Object data); + public void setName(String name); public String getName(); } From gordonp at dev.open-bio.org Wed Mar 17 16:58:33 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:58:33 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172058.o2HKwXY1012769@dev.open-bio.org> gordonp Wed Mar 17 16:58:33 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv12729/src/main/org/biomoby/shared/data Modified Files: MobyDataObjectSAI.java MobyDataObjectSetSAI.java Log Message: Added methods to allow association of a random application-specific objects with the Moby data moby-live/Java/src/main/org/biomoby/shared/data MobyDataObjectSAI.java,1.4,1.5 MobyDataObjectSetSAI.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSAI.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSAI.java 2008/01/07 22:11:36 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSAI.java 2010/03/17 20:58:33 1.5 @@ -78,6 +78,14 @@ dataInstance.setXmlMode(mode); } + public Object getUserData(){ + return dataInstance.getUserData(); + } + + public void setUserData(Object data){ + dataInstance.setUserData(data); + } + public String getValue(){ return dataInstance.getValue(); } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSetSAI.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSetSAI.java 2007/12/06 23:42:55 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSetSAI.java 2010/03/17 20:58:33 1.5 @@ -96,6 +96,14 @@ return dataInstance.getElements(); } + public Object getUserData(){ + return dataInstance.getUserData(); + } + + public void setUserData(Object data){ + dataInstance.setUserData(data); + } + public Object getObject(){ return dataInstance.getObject(); } From gordonp at dev.open-bio.org Wed Mar 17 16:59:15 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:59:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172059.o2HKxFdq012835@dev.open-bio.org> gordonp Wed Mar 17 16:59:15 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv12799/src/main/org/biomoby/shared/data Modified Files: MobyDataUtils.java Log Message: Fixed error messages moby-live/Java/src/main/org/biomoby/shared/data MobyDataUtils.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataUtils.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/shared/data/MobyDataUtils.java 2007/08/23 14:41:43 1.9 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataUtils.java 2010/03/17 20:59:15 1.10 @@ -196,9 +196,10 @@ throw new MobyException("The passed in element was null"); } if(!MobyTags.MOBY.equals(doc_root.getLocalName())){ - throw new MobyException("The XML document's root element (" + + throw new MobyException("The XML document's root element (local " + doc_root.getLocalName() + - ") was not " + MobyTags.MOBY); + ", qualified " + doc_root.getNodeName() + + " ) was not " + MobyTags.MOBY); } NodeList envelope = null; if(!MobyPrefixResolver.MOBY_XML_NAMESPACE.equals(doc_root.getNamespaceURI())){ From gordonp at dev.open-bio.org Wed Mar 17 17:00:14 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 17:00:14 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172100.o2HL0Ek7013173@dev.open-bio.org> gordonp Wed Mar 17 17:00:14 EDT 2010 Update of /home/repository/moby/moby-live/Java/xmls In directory dev.open-bio.org:/tmp/cvs-serv13117/xmls Modified Files: project.pom Log Message: Added Apache Commons' fileupload, and the jTidy packages moby-live/Java/xmls project.pom,1.18,1.19 =================================================================== RCS file: /home/repository/moby/moby-live/Java/xmls/project.pom,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- /home/repository/moby/moby-live/Java/xmls/project.pom 2009/11/29 18:33:11 1.18 +++ /home/repository/moby/moby-live/Java/xmls/project.pom 2010/03/17 21:00:14 1.19 @@ -535,6 +535,18 @@ 1.0 + + commons-fileupload + commons-fileupload + 1.2 + + + + jtidy + jtidy + 4aug2000r7-dev + + From gordonp at dev.open-bio.org Wed Mar 17 17:14:31 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 17:14:31 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172114.o2HLEVlf013504@dev.open-bio.org> gordonp Wed Mar 17 17:14:31 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/webapps/WEB-INF In directory dev.open-bio.org:/tmp/cvs-serv13468/src/webapps/WEB-INF Modified Files: cgiweb.xml Log Message: Made local test resource for CGI wrapping to Moby service moby-live/Java/src/webapps/WEB-INF cgiweb.xml,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/webapps/WEB-INF/cgiweb.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/webapps/WEB-INF/cgiweb.xml 2008/02/14 05:45:42 1.2 +++ /home/repository/moby/moby-live/Java/src/webapps/WEB-INF/cgiweb.xml 2010/03/17 21:14:31 1.3 @@ -25,7 +25,8 @@ is the key parameter to change. --> htmlFormURL - http://biomoby.open-bio.org/CVS_CONTENT/moby-live/Java/src/main/ca/ucalgary/services/util/test/osprey_pcr.html + ca/ucalgary/services/util/test/osprey_pcr.html + From gordonp at dev.open-bio.org Fri Mar 26 14:08:19 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 26 Mar 2010 14:08:19 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003261808.o2QI8JvD003003@dev.open-bio.org> gordonp Fri Mar 26 14:08:18 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory dev.open-bio.org:/tmp/cvs-serv2967/src/main/org/biomoby/shared Modified Files: MobyDataType.java Log Message: Fixed registry association with objects returned by getDataType method (was always null) moby-live/Java/src/main/org/biomoby/shared MobyDataType.java,1.26,1.27 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2008/10/30 02:33:25 1.26 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2010/03/26 18:08:18 1.27 @@ -116,6 +116,9 @@ } try{ datatypes = central.getDataTypes(); + for(MobyDataType type: datatypes){ + type.setRegistry(reg); // isn't set properly by the parser called above + } datatypesMapByURL.put(reg == null ? "" : reg.getEndpoint(), datatypes); } catch(Exception e){ @@ -369,7 +372,7 @@ * Searches the ontology lineage of the current data type against the data type corresponding to the provided name. */ public boolean inheritsFrom(String otherTypeName){ - return inheritsFrom(getDataType(otherTypeName)); + return inheritsFrom(getDataType(otherTypeName, getRegistry())); } /** From gordonp at dev.open-bio.org Fri Mar 26 15:52:01 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 26 Mar 2010 15:52:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003261952.o2QJq1Um006052@dev.open-bio.org> gordonp Fri Mar 26 15:52:00 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv6016/src/main/org/biomoby/client Modified Files: CentralImpl.java Log Message: Got rid of 'Central class is' message unless moby.debug system variable is set moby-live/Java/src/main/org/biomoby/client CentralImpl.java,1.62,1.63 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java 2010/02/09 02:07:24 1.62 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java 2010/03/26 19:52:00 1.63 @@ -1904,7 +1904,9 @@ } } try{ - System.err.println("Central class is "+className); + if(Boolean.getBoolean("moby.debug")){ + System.err.println("Central class is "+className+ " for " + reg); + } Class clazz = Class.forName(className); if(reg == null){ // should use default nullary c-tor defaultCentrals.put("", (CentralImpl) clazz.newInstance()); From gordonp at dev.open-bio.org Mon Mar 29 12:38:33 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 12:38:33 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291638.o2TGcXfG004765@dev.open-bio.org> gordonp Mon Mar 29 12:38:33 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util In directory dev.open-bio.org:/tmp/cvs-serv4729/src/main/ca/ucalgary/services/util Modified Files: IOUtils.java Log Message: Payload reporting moved from warning to info level moby-live/Java/src/main/ca/ucalgary/services/util IOUtils.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/IOUtils.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/IOUtils.java 2010/03/17 20:17:39 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/IOUtils.java 2010/03/29 16:38:33 1.3 @@ -91,7 +91,7 @@ // } if(sb.length() < 10000){ - logger.log(Level.WARNING, sb); + logger.log(Level.INFO, sb); } Document respDoc = getDocBuilder().parse(new ByteArrayInputStream(byteBuffer.toByteArray())); NodeList bodyList = respDoc.getElementsByTagNameNS("http://schemas.xmlsoap.org/soap/envelope/", From gordonp at dev.open-bio.org Mon Mar 29 15:46:19 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:46:19 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291946.o2TJkJQ2010128@dev.open-bio.org> gordonp Mon Mar 29 15:46:18 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv10092/src/main/ca/ucalgary/seahawk/gui Modified Files: FileAndTextTransferHandler.java Log Message: Pushed debug statements to proper logging moby-live/Java/src/main/ca/ucalgary/seahawk/gui FileAndTextTransferHandler.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java 2009/06/09 19:33:15 1.9 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java 2010/03/29 19:46:18 1.10 @@ -70,7 +70,9 @@ URL u = HTMLUtils.checkForURLShortcut(file); // Was it a shortcut file after all? if(u != null){ - System.err.println("Dropped item appears to be a URL shortcut..."); + if(Boolean.getBoolean("moby.debug")){ + System.err.println("Dropped item appears to be a URL shortcut..."); + } if(clipboard != null){ clipboard.addCollectionData(u); } @@ -80,7 +82,9 @@ } // Any other type of file is loaded as-is else{ - System.err.println("Dropped item appears to be a file..."); + if(Boolean.getBoolean("moby.debug")){ + System.err.println("Dropped item appears to be a file..."); + } if(clipboard != null){ clipboard.addCollectionData(file.toURI().toURL()); } @@ -106,7 +110,9 @@ // Not a URL, oh well, move on to string handling... } if(u != null){ - System.err.println("Dropped item appears to be a URL..."); + if(Boolean.getBoolean("moby.debug")){ + System.err.println("Dropped item appears to be a URL..."); + } if(clipboard != null){ clipboard.addCollectionData(u); } @@ -127,7 +133,9 @@ // the proper object to load MobyContentInstance content = HTMLUtils.checkForMobyXML(text); if(content != null){ - System.err.println("Dropped item appears to be moby xml..."); + if(Boolean.getBoolean("moby.debug")){ + System.err.println("Dropped item appears to be moby xml..."); + } if(clipboard != null){ clipboard.addCollectionData(content); } From gordonp at dev.open-bio.org Mon Mar 29 15:47:02 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:47:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291947.o2TJl2Ss010172@dev.open-bio.org> gordonp Mon Mar 29 15:47:02 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv10136/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentClipboard.java Log Message: Updated to reflect DataRecorder -> DataFlowRecorder name change moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentClipboard.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.java 2009/06/09 19:32:23 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.java 2010/03/29 19:47:02 1.8 @@ -48,7 +48,7 @@ private MobyDataInstance itemToDelete; private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobyContentClipboard.class); public MobyContentClipboard(MobyContentGUI cGUI, MobyServicesGUI sGUI, JTabbedPane parentComponent, - DataRecorder recorder, JLabel statusBar){ + DataFlowRecorder recorder, JLabel statusBar){ super(cGUI, sGUI, parentComponent, recorder, statusBar); ClassLoader cl = getClass().getClassLoader(); From gordonp at dev.open-bio.org Mon Mar 29 15:48:29 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:48:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291948.o2TJmTjm010216@dev.open-bio.org> gordonp Mon Mar 29 15:48:28 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv10180/src/main/org/biomoby/client Modified Files: CentralImpl.java Log Message: Updated to standard META-INF/services mechanism to get CentralImpl moby-live/Java/src/main/org/biomoby/client CentralImpl.java,1.63,1.64 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java 2010/03/26 19:52:00 1.63 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java 2010/03/29 19:48:28 1.64 @@ -128,7 +128,7 @@ * default class should be instantiated in order to create a Central Implementation * when getDefaultCentral() is called. */ - public static final String CENTRAL_IMPL_RESOURCE_NAME = "org.biomoby.shared.CentralDefaultImpl"; + public static final String CENTRAL_IMPL_RESOURCE_NAME = "org.biomoby.client.CentralImpl"; /** The class to use for getDefaultCentral if all else fails */ public static final String DEFAULT_CENTRAL_IMPL_CLASSNAME = "org.biomoby.client.CentralDigestCachedImpl"; private static Logger logger = Logger.getLogger("org.biomoby.client.CentralImpl"); @@ -1886,7 +1886,7 @@ String className = DEFAULT_CENTRAL_IMPL_CLASSNAME; ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - URL resURL = classLoader.getResource("META-INF/"+CENTRAL_IMPL_RESOURCE_NAME); + URL resURL = classLoader.getResource("META-INF/services/"+CENTRAL_IMPL_RESOURCE_NAME); if(resURL != null){ System.err.println("Loading "+resURL); try{ From gordonp at dev.open-bio.org Mon Mar 29 15:49:32 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:49:32 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291949.o2TJnV87010300@dev.open-bio.org> gordonp Mon Mar 29 15:49:31 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services In directory dev.open-bio.org:/tmp/cvs-serv10264/src/main/ca/ucalgary/services Modified Files: CGIServlet.java Log Message: Made jTidy quiet moby-live/Java/src/main/ca/ucalgary/services CGIServlet.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/CGIServlet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/CGIServlet.java 2010/03/17 20:16:49 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/CGIServlet.java 2010/03/29 19:49:31 1.2 @@ -62,6 +62,7 @@ Tidy tidy = new Tidy(); tidy.setXHTML(true); + tidy.setQuiet(true); tidy.setShowWarnings(false); Document htmlDoc = tidy.parseDOM(is, null); From gordonp at dev.open-bio.org Mon Mar 29 15:49:53 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:49:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291949.o2TJnrFQ010344@dev.open-bio.org> gordonp Mon Mar 29 15:49:52 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv10308/src/main/ca/ucalgary/seahawk/util Modified Files: FilterSearch.java Log Message: Fixed id and article name xpaths moby-live/Java/src/main/ca/ucalgary/seahawk/util FilterSearch.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/FilterSearch.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/FilterSearch.java 2010/03/17 20:08:25 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/FilterSearch.java 2010/03/29 19:49:52 1.2 @@ -54,12 +54,12 @@ elementNames.put("//"+data.getLocalName(), "element " + data.getLocalName()); } else if(data.getAttribute(MobyTags.OBJ_ID).length() > 0){ // or an id - elementNames.put("//*[@id]", "ID"); + elementNames.put("//*/@id", "ID"); } } if(articleName != null && articleName.trim().length() != 0 && !memberNames.containsKey(articleName)){ - memberNames.put("//*[@"+MobyTags.ARTICLENAME+"='"+articleName+"'", "field "+articleName); + memberNames.put("//*[@"+MobyTags.ARTICLENAME+"='"+articleName+"']", "field "+articleName); } } } From gordonp at dev.open-bio.org Mon Mar 29 15:50:54 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:50:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291950.o2TJosZ7010388@dev.open-bio.org> gordonp Mon Mar 29 15:50:54 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv10352/src/main/ca/ucalgary/seahawk/util Modified Files: PrintableJEditorPane.java Log Message: Now extends JTextArea to allow fancier display manipulation moby-live/Java/src/main/ca/ucalgary/seahawk/util PrintableJEditorPane.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/PrintableJEditorPane.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/PrintableJEditorPane.java 2007/02/08 16:59:58 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/PrintableJEditorPane.java 2010/03/29 19:50:54 1.3 @@ -6,7 +6,7 @@ import java.awt.print.PageFormat; import java.awt.print.Printable; import java.awt.print.PrinterException; -import javax.swing.JEditorPane; +import javax.swing.JTextPane; import javax.swing.RepaintManager; /** @@ -14,7 +14,7 @@ * * @author Paul Gordon (gordonp at ucalgary.ca) */ -public class PrintableJEditorPane extends JEditorPane implements Printable{ +public class PrintableJEditorPane extends JTextPane implements Printable{ public int print (Graphics g, PageFormat pf, int pageIndex) throws PrinterException{ Graphics2D g2 = (Graphics2D) g; From gordonp at dev.open-bio.org Mon Mar 29 15:51:52 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:51:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291951.o2TJpqlD010432@dev.open-bio.org> gordonp Mon Mar 29 15:51:51 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv10396/src/main/ca/ucalgary/seahawk/resources Modified Files: moby2HTML.xsl Log Message: Added span elements to facilitate Seahawk grey-out/highlight of filter function moby-live/Java/src/main/ca/ucalgary/seahawk/resources moby2HTML.xsl,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/moby2HTML.xsl,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/moby2HTML.xsl 2010/03/17 20:21:55 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/moby2HTML.xsl 2010/03/29 19:51:51 1.6 @@ -172,9 +172,10 @@ + - +
@@ -219,26 +220,26 @@ - ID : () + ID : () - String : ():
+ String : ():
- ():
+ ():
-
MOBY Data for query
+ From gordonp at dev.open-bio.org Mon Mar 29 15:52:30 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:52:30 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291952.o2TJqUuB010476@dev.open-bio.org> gordonp Mon Mar 29 15:52:30 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv10440/src/main/ca/ucalgary/seahawk/gui Modified Files: WorkflowPreviewDialog.java Log Message: DataRecorder -> DataFlowRecorder moby-live/Java/src/main/ca/ucalgary/seahawk/gui WorkflowPreviewDialog.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/WorkflowPreviewDialog.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/WorkflowPreviewDialog.java 2010/03/17 20:20:09 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/WorkflowPreviewDialog.java 2010/03/29 19:52:30 1.2 @@ -14,7 +14,7 @@ import java.net.*; import java.util.*; import javax.swing.*; -import ca.ucalgary.seahawk.util.DataRecorder; +import ca.ucalgary.seahawk.util.DataFlowRecorder; import ca.ucalgary.seahawk.util.FilterSearch; public class WorkflowPreviewDialog extends JDialog implements ActionListener{ @@ -32,23 +32,23 @@ private WorkflowPreviewListener listener; private ByteArrayOutputStream byteArrayBuffer; private String workflowName; - private DataRecorder dataRecorder; + private DataFlowRecorder dataFlowRecorder; private Map resultList; - public WorkflowPreviewDialog(Frame owner, Map resultList, DataRecorder dataRecorder, + public WorkflowPreviewDialog(Frame owner, Map resultList, DataFlowRecorder dataFlowRecorder, String workflowName, WorkflowPreviewListener wpl) throws Exception{ super(owner, "Workflow Preview", true); this.workflowName = workflowName; - this.dataRecorder = dataRecorder; + this.dataFlowRecorder = dataFlowRecorder; this.resultList = resultList; String workflowTitle = workflowName; String workflowDescription = null; String workflowAuthor = null; byteArrayBuffer = new ByteArrayOutputStream(); - dataRecorder.exportWorkflow(resultList, byteArrayBuffer, workflowName, workflowTitle, - workflowDescription, workflowAuthor, DataRecorder.T2FLOW); + dataFlowRecorder.exportWorkflow(resultList, byteArrayBuffer, workflowName, workflowTitle, + workflowDescription, workflowAuthor, DataFlowRecorder.T2FLOW); ByteArrayOutputStream pngData = new ByteArrayOutputStream(); @@ -133,13 +133,13 @@ byteArrayBuffer = new ByteArrayOutputStream(); // recreate the workflow with the additional metadata try{ - dataRecorder.exportWorkflow(resultList, - byteArrayBuffer, - workflowName, - workflowTitle, - workflowDescription, - workflowAuthor, - DataRecorder.T2FLOW); + dataFlowRecorder.exportWorkflow(resultList, + byteArrayBuffer, + workflowName, + workflowTitle, + workflowDescription, + workflowAuthor, + DataFlowRecorder.T2FLOW); }catch(Exception ex){ ex.printStackTrace(); JOptionPane.showMessageDialog(null, From gordonp at dev.open-bio.org Mon Mar 29 15:53:16 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:53:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291953.o2TJrGqt010520@dev.open-bio.org> gordonp Mon Mar 29 15:53:16 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv10484/src/main/ca/ucalgary/seahawk/gui Modified Files: MobySaveDialog.java Log Message: Updated to reflect DataRecorder -> DataFlowRecorder name change moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobySaveDialog.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java 2010/03/17 20:21:55 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java 2010/03/29 19:53:16 1.8 @@ -193,7 +193,7 @@ try { // See if there is more than one result tab open - DataRecorder dataRecorder = null; + DataFlowRecorder dataRecorder = null; Map resultsToProduce = new LinkedHashMap(); boolean currentTabHasResults = false; javax.swing.JTabbedPane tabbedPane = tab.getTabbedPaneParent(); @@ -201,7 +201,7 @@ MobyContentPane document = (MobyContentPane) tabbedPane.getComponentAt(tabIndex); if(document.hasXMLSource()){ if(dataRecorder == null){ - dataRecorder = document.getDataRecorder(); + dataRecorder = document.getDataFlowRecorder(); } if(document == tab){ currentTabHasResults = true; @@ -215,7 +215,7 @@ } } if(dataRecorder == null){ - JOptionPane.showMessageDialog(null, "Could not find the DataRecorder needed for " + + JOptionPane.showMessageDialog(null, "Could not find the DataFlowRecorder needed for " + "workflow export. Please contact gordonp at ucalgary.ca " + "with this error message.", "Internal Error", From gordonp at dev.open-bio.org Mon Mar 29 15:54:36 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:54:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291954.o2TJsajU010604@dev.open-bio.org> gordonp Mon Mar 29 15:54:36 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv10568/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentPane.java Log Message: Filter update moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentPane.java,1.22,1.23 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2010/03/17 20:21:55 1.22 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2010/03/29 19:54:36 1.23 @@ -12,6 +12,7 @@ import org.biomoby.client.MobyRequest; import org.biomoby.client.MobyRequestEvent; import org.biomoby.client.MobyRequestEventHandler; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.*; import org.biomoby.shared.data.*; import org.biomoby.shared.parser.MobyTags; @@ -23,13 +24,28 @@ import javax.xml.parsers.*; import javax.xml.transform.*; import javax.xml.transform.stream.*; - import javax.xml.xpath.*; import javax.swing.*; import javax.swing.event.*; - -import java.awt.*; +import javax.swing.text.AttributeSet; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.DefaultHighlighter; +import javax.swing.text.Highlighter; +import javax.swing.text.Style; +import javax.swing.text.StyleConstants; +import javax.swing.text.StyledDocument; +import javax.swing.text.html.HTML; +import javax.swing.text.html.HTMLDocument; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Desktop; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Toolkit; import java.awt.datatransfer.*; import java.awt.print.*; import java.awt.event.*; @@ -37,6 +53,7 @@ import java.net.URL; import java.net.URLConnection; import java.util.*; +import java.util.regex.*; /** * Text area contained in a Seahawk GUI tab. Displays HTML, RTF, text etc. using a JEditorPane. @@ -83,7 +100,16 @@ private int lastClickY = 1; private boolean hasFailed = false; private boolean isContentsXML = false; - private DataRecorder dataRecorder; + private DataFlowRecorder dataRecorder; + private List xPtrsReferencedInNextService; + private Map filteredData; //Map + private boolean filterChanged; + private Document currentDoc; //the doc DOM being actively filtered + private NodeList currentSelectedData = null; + private String currentSelectionXPath = null; + private List filterableNodes = null; // List + private List origStyles = null; + private boolean firstDocRendering = true; // Next two items used for service wrapping private JMenuItem createServicePopupItem; @@ -114,8 +140,22 @@ private final static String wsServletPath = "/SOAPServlet"; private static Acme.Serve.Serve servletContainer; private static Map id2GuiMap; + private static DocumentBuilder docBuilder; + private static XPathFactory xPathFactory; + + static{ + xPathFactory = XPathFactory.newInstance(); + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + try{ + docBuilder = dbf.newDocumentBuilder(); + } catch(Exception e){ + logger.warn("Cannot get XML parser from configuration", e); + } + } - public MobyContentPane(MobyContentGUI cGUI, MobyServicesGUI sGUI, JTabbedPane parentComponent, DataRecorder recorder, JLabel statusBar){ + public MobyContentPane(MobyContentGUI cGUI, MobyServicesGUI sGUI, JTabbedPane parentComponent, DataFlowRecorder recorder, JLabel statusBar){ tabbedPane = parentComponent; status = statusBar; contentGUI = cGUI; @@ -158,6 +198,8 @@ historyTabLabels = new HashMap(); filterHistory = new HashMap(); deletedFilters = new HashMap(); + xPtrsReferencedInNextService = new Vector(); + filteredData = new HashMap(); ClassLoader cl = getClass().getClassLoader(); if(cl == null){ @@ -198,7 +240,7 @@ return tabbedPane; } - public DataRecorder getDataRecorder(){ + public DataFlowRecorder getDataFlowRecorder(){ return dataRecorder; } @@ -391,7 +433,7 @@ } })); new Thread(){public void run(){srv.serve();}}.start(); - + PBERecorder recorder = new PBERecorder(); recorder.setGUIMap(id2GuiMap); servlet.setRecorder(recorder); @@ -400,6 +442,9 @@ srv.addServlet(servletPath, servlet); // our deployment } else if(contentGUI.getServletContainer().getServlet(servletPath) == null){ + PBERecorder recorder = new PBERecorder(); + recorder.setGUIMap(id2GuiMap); + servlet.setRecorder(recorder); contentGUI.getServletContainer().addServlet(servletPath, servlet); } @@ -694,12 +739,21 @@ } // If this page has a filter associated with it before reload it try{ + currentDoc = null; // get rid of previous in-memory doc use for interactive filtering, if any + currentSelectedData = null; + currentSelectionXPath = null; + filterableNodes = null; + origStyles = null; + firstDocRendering = true; + editorPane.getHighlighter().removeAllHighlights(); + if(filterHistory.containsKey(url)){ setFilterVisible(true); } else{ setFilterVisible(false); } + filterChanged = false; } catch(Exception e){ logger.warn("Could not enable filter history for this document: "+e.getMessage(), e); } @@ -729,17 +783,69 @@ } public boolean canGoForward(){ - return historyIndex < history.size()-1; + return historyIndex < history.size()-1 && isFilterForwardConsistent(); + } + + /** + * If the filter condition has changed since the next service was originally called, + * only allow navigation to that document (service results) again if the new filter allows + * the data used in the original call to pass (for logical dataflow consistency). + */ + public boolean isFilterForwardConsistent(){ + // If there is no forward doc, it is consistent I suppose + if(historyIndex == history.size()-1){ + contentGUI.setForwardButtonToolTip(null); + return true; + } + // If no filter on current doc, we must be okay to go forward + if(getFilter() == null){ + contentGUI.setForwardButtonToolTip(null); + return true; + } + + // Get the data from this doc used as the input to the forward document + if(xPtrsReferencedInNextService == null){ + try{ + xPtrsReferencedInNextService = DataUtils.getInputXPtrs(history.elementAt(historyIndex+1), history.elementAt(historyIndex)); + } catch(Exception e){ + logger.error("Cannot get the provenance data from "+history.elementAt(historyIndex+1), e); + } + + } + // See if all the particular data from this doc that was used in the next service is still avaialble after + // applying the current version of the filter + for(String usedxPtr: xPtrsReferencedInNextService){ + for(String filteredXPtr: filteredData.keySet()){ + if(usedxPtr.equals(filteredXPtr) || + usedxPtr.startsWith(filteredXPtr+"/")){ + // the data used in the next service is filtered in the current view, not consistent to allow forward button + // give the person a reason the forward is disabled + contentGUI.setForwardButtonToolTip("Cannot go forward to next doc, the corresponding service
"+ + "depended on input data that is now filtered. Reset the data filter
"+ + "to be able to go forward again"); + return false; + } + } + } + + // If they differ, check that the forward doc's input src is not filtered out currently + contentGUI.setForwardButtonToolTip(null); + return true; } public void goForward(){ if(canGoForward()){ + if(filterChanged){ + DataUtils.updateInputFilter(history.elementAt(historyIndex+1), history.elementAt(historyIndex), getFilter()); + } gotoURL(history.elementAt(++historyIndex), false); + xPtrsReferencedInNextService = null; } } public void goBackward(){ if(canGoBack()){ + xPtrsReferencedInNextService = null; gotoURL(history.elementAt(--historyIndex), false); } } @@ -889,7 +995,7 @@ } try { - URL outputURL = dataRecorder.saveOutputData(mre); + URL outputURL = DataUtils.saveOutputData(mre); gotoURL(outputURL, true); } catch (Exception e) { failed("Could not write a local file"); @@ -1009,8 +1115,13 @@ logger.warn("Failed: could not get hyperlink host: " + targetURL); } else if(isMobyURL(targetURL)){ - status.setText("Retrieving service list for selected data"); - showMobyOptions(targetURL); + if(isLinkEnabled(targetURL)){ + status.setText("Retrieving service list for selected data"); + showMobyOptions(targetURL); + } + else{ + status.setText("Change the data filter to re-enable this link"); + } } // External, hopefully HTML link else{ @@ -1023,7 +1134,12 @@ overHyperlink = true; lastHyperlinkHovered = targetURL; if(isMobyURL(targetURL)){ - status.setText("Click to discover more Moby services, or drag onto a Web form"); + if(isLinkEnabled(targetURL)){ + status.setText("Click to discover more Moby services, or drag onto a Web form"); + } + else{ + status.setText("This link is current disabled because of the data filter."); + } } else if(targetURL == null){ String desc = he.getDescription(); @@ -1042,6 +1158,19 @@ } } + private boolean isLinkEnabled(URL url){ + String ref = url.getRef(); + if(ref == null || ref.length() == 0){ + return true; + } + for(String disabledXPtr: filteredData.keySet()){ + if(ref.equals(disabledXPtr) || ref.startsWith(disabledXPtr+"/")){ + return false; + } + } + return true; + } + public MobyDataInstance getDraggedData(){ return urlToMobyData(lastHyperlinkDragged); } @@ -1054,9 +1183,8 @@ String docFragID = targetURL.getRef(); // We store the xpath in the anchor part of the URL // Complex case, load the doc fragment from the MOBY XML source file - if(docFragID != null && docFragID.length() > 0 && contentGUI.getDocumentBuilder() != null && - !targetURL.getHost().equals("moby")){ - return loadMobyDataFromXPointer(targetURL); + if(docFragID != null && docFragID.length() > 0 && !targetURL.getHost().equals("moby")){ + return DataUtils.loadMobyDataFromXPointer(targetURL, filterHistory.get(getCurrentURL())); } // Simple case, build the object using the values encoded in the URL itself @@ -1208,164 +1336,334 @@ return mobyData; } - protected MobyDataInstance loadMobyDataFromXPointer(URL targetURL){ - // Are we dealing with a simple object or a complex one? - MobyDataInstance mobyData = null; - - // Find the DOM fragment corresponding to the MOBY ID anchor specified - // in the link URL by using an XPath statement on the source MOBY doc - //System.err.println("Retrieving complex object from XPointer " + targetURL); - - // A child Xpointer is of the form /1/2/1/1, specifying the DOM child - // descent path from the root node to get to the target node. The - // equivalent XPath is /*[1]/*[2]/*[1]/*[1] - String childXPath = targetURL.getRef().replaceAll("/(\\d+)", "/*[$1]"); - URL currentURL = null; - try{currentURL = new URL(targetURL.toString().replaceAll("#"+targetURL.getRef(), ""));} - catch(Exception e){ - logger.error("Couldn't extract referenceless URL from " + targetURL); - } - // Build the DOM - Element mobyDOMRoot = null; - Document domDoc = null; - try{ - domDoc = contentGUI.getDocumentBuilder().parse(targetURL.openStream()); - } catch(org.xml.sax.SAXException saxe){ - logger.error("The document defining the MOBY data " + - "could not be parsed: " + saxe); - return null; - } catch(java.io.IOException ioe){ - logger.error("The document defining the MOBY data " + - " could not be read (from " + targetURL + "): " + ioe); + /** + * Gets the filter criteria currently being applied to the document being viewed. + * + * @return null unless there is a currently a non-blank filter criteria + */ + public FilterSearch getFilter(){ + if(getCurrentURL() == null){ return null; } - - if(domDoc != null){ - mobyDOMRoot = domDoc.getDocumentElement(); + FilterSearch fs = filterHistory.get(getCurrentURL()); + if(fs != null && fs.getFilterRegex().length() > 0){ + return fs; } - if(mobyDOMRoot == null){ - logger.warn("Error: Could not get MOBY document as DOM from source URL " - + targetURL + " (empty or malformed document?)"); - return null; + return null; + } + + /** + * Determine the parts of the XML document matching the FilterSearch criteria, and filter the view accordingly. + */ + public void applyFilter(boolean apply){ + if(!filterChanged){ + filterChanged = true; } - - // Build and run the XPath statement - Element mobyObject = null; - NodeList idSearchResult = null; - Object xobject = null; - try{ - xobject = XPathFactory.newInstance().newXPath().evaluate(childXPath, - new InputSource(targetURL.openStream()), - XPathConstants.NODESET); - - // Check the results - if(xobject != null){ - idSearchResult = (NodeList) xobject; + filteredData.clear(); + + if(currentDoc == null){ // parse the doc into memory if not already there + try{ + currentDoc = docBuilder.parse(getCurrentURL().openStream()); + } catch(Exception e){ + logger.error("Could not parse Moby document " + getCurrentURL(), e); + return; + } + } + // Filter out any moby jobs, parameters, collection members or HAS members that aren't in the matchingNodes + if(filterableNodes == null){ + filterableNodes = new Vector(); + NodeList nodes = currentDoc.getElementsByTagNameNS(MobyTags.MOBY_XML_NS, MobyTags.MOBYDATA); + for(int i = 0; i < nodes.getLength(); i++){ + filterableNodes.add(getXPtr(nodes.item(i))); + addHASXPtrs(filterableNodes, (Element) nodes.item(i)); + } + + // Collections + nodes = currentDoc.getElementsByTagNameNS(MobyTags.MOBY_XML_NS, MobyTags.COLLECTION); + for(int i = 0; i < nodes.getLength(); i++){ + String collectionXPtr = getXPtr(nodes.item(i)); + NodeList collectionMembers = nodes.item(i).getChildNodes(); + int nonElementCnt = 0; + for(int j = 0; j < collectionMembers.getLength(); j++){ + if(!(collectionMembers.item(j) instanceof Element)){ + nonElementCnt++; + continue; + } + filterableNodes.add(collectionXPtr+"/"+(j-nonElementCnt+1)+"/1"); + } + } + } + + if(!apply || !filterHistory.containsKey(getCurrentURL()) || + (filterHistory.containsKey(getCurrentURL()) && + filterHistory.get(getCurrentURL()).getFilterRegex().toString().length() == 0)){ + // Show whole doc if no filter or if filter is blank, so nothing to do here + if(firstDocRendering){ + firstDocRendering = false; } else{ - logger.warn("Could not find Moby object in document " + currentURL + - ", referred to by the reference ID in Moby link " + targetURL + - " (document changed?)"); - return null; + displayFilterEffect(); //need to cleanup previous state } + return; } - catch(Exception e){// Syntax error - logger.error("Error: Could not search Moby data instance for XPath " + - childXPath + "):" + e); - return null; + // Otherwise make a list of xpointers to data that should be grayed out + FilterSearch fs = filterHistory.get(getCurrentURL()); + XPathOption xsel = fs.getSelectedXPath(); + + // Find all the matching data + XPath xpath = xPathFactory.newXPath(); + // Find the applicable DOM nodes if not yet found, or if selection criteria have changed + if(currentSelectedData == null || currentSelectionXPath == null || !currentSelectionXPath.equals(xsel.getXPath())){ + currentSelectionXPath = xsel.getXPath(); + try{ + currentSelectedData = (NodeList) xpath.evaluate(currentSelectionXPath, currentDoc, XPathConstants.NODESET); + } catch(Exception e){ + logger.error("Could not evaluate XPath (" + xsel.getXPath() + ") over " + getCurrentURL(), e); + return; + } + // System.err.println("There are " + currentSelectedData.getLength() + + // " items selected in the document using XPath " + currentSelectionXPath); } - if(idSearchResult.getLength() == 0){ - logger.warn("Error: Could not find Moby data instance with XPath (" + childXPath + - " in " + targetURL); - return null; + // Find just the data subset also matching the regex + Map matchingXPtrs = new LinkedHashMap(); + // Build the FSA only once, for efficiency + Pattern regex = Pattern.compile(fs.getFilterRegex().toString(), Pattern.MULTILINE); + for(int i = 0; i < currentSelectedData.getLength(); i++){ + Node node = currentSelectedData.item(i); + if(node instanceof Element){ + if(regex.matcher(((Element) node).getTextContent()).find()){ + matchingXPtrs.put(getXPtr(node), Boolean.TRUE); + } + else{ + matchingXPtrs.put(getXPtr(node), Boolean.FALSE); + } + //System.err.println("Adding " + getXPtr(node) + " as " + matchingXPtrs.get(getXPtr(node))); + } + else if(node instanceof Attr){ + if(regex.matcher(((Attr) node).getValue()).find()){ + // Mark the element to which the attribute belongs + matchingXPtrs.put(getXPtr(((Attr) node).getOwnerElement()), Boolean.TRUE); + } + else{ + matchingXPtrs.put(getXPtr(((Attr) node).getOwnerElement()), Boolean.FALSE); + } + } + else{ + logger.warn("Found filter xpath result item that was not an Element or Attribute as expected ("+ + node.getClass().getName()+")"); + } } - if(idSearchResult.getLength() > 1){ - logger.warn("Error: Moby data instance could not beresolved because " + - "there are multiple elements with XPath " + childXPath + " in " + - currentURL); - return null; + + Map parentMatchingXPtrs = new LinkedHashMap(); + for(String currXPtr: filterableNodes){ + for(Map.Entry matchingXPtr: matchingXPtrs.entrySet()){ + if(matchingXPtr.getKey().startsWith(currXPtr+"/")){ // a parent of the matching data + // No positive example yet? + if(!parentMatchingXPtrs.containsKey(currXPtr) || !parentMatchingXPtrs.get(currXPtr).booleanValue()){ + //System.err.println("Adding "+ matchingXPtr.getValue() + " for " + currXPtr); + parentMatchingXPtrs.put(currXPtr, matchingXPtr.getValue()); + } + } + } } - if(!(idSearchResult.item(0) instanceof Element)){ - logger.warn("Error: Moby data instance with XPath " + childXPath + " in " + - currentURL + " was not an element as required!"); - return null; + + matchingXPtrs.putAll(parentMatchingXPtrs); + for(String currXPtr: matchingXPtrs.keySet()){ + // Is part of the selection criteria, but doesn't match the regex + if(!matchingXPtrs.get(currXPtr).booleanValue()){ + filteredData.put(currXPtr, "todo"); + } } - mobyObject = (Element) idSearchResult.item(0); + + //todo: filter objects without the HAS field at all... - // Create the Java MOBY API object based on the linked document DOM fragment - try{ - MobyDataInstance mdi = MobyDataObject.createInstanceFromDOM(mobyObject, SeahawkOptions.getRegistry()); - if(mdi instanceof MobyDataObject){ - mobyData = mdi; + // apply gray out in the document display + displayFilterEffect(); + } + + // If any moby object member is in a HAS relationship, add it to the list of filterable items + private void addHASXPtrs(List filterList, Element object){ + String tagName = object.getLocalName(); + boolean isContainer = false; + MobyDataType mobyDataType = null; + if(tagName.equals(MobyTags.MOBYDATA) || tagName.equals(MobyTags.COLLECTION) || tagName.equals(MobyTags.SIMPLE) || + tagName.equals(MobyTags.CROSSREFERENCE)){ + isContainer = true; + } + else{ + mobyDataType = MobyDataType.getDataType(tagName, SeahawkOptions.getRegistry()); + if(mobyDataType == null){ + logger.warn("Found datatype unknown to the registry ("+object.getLocalName()+")"); + return; } - else if(mdi instanceof MobyDataObjectSet){ - mobyData = mdi; + } + + NodeList members = object.getChildNodes(); + for(int i = 0; i < members.getLength(); i++){ + if(!(members.item(i) instanceof Element)){ + continue; + } + + Element member = (Element) members.item(i); + addHASXPtrs(filterList, member); + + if(!isContainer){ + String memberName = member.getAttribute(MobyTags.ARTICLENAME); + MobyRelationship membership = mobyDataType.getChild(memberName); + //System.err.println("Relationship for " + tagName + " member " + memberName + + // " is " + (membership == null ? null : membership.getRelationshipType())); + if(membership != null && membership.getRelationshipType() == Central.iHAS){ + filterList.add(getXPtr(member)); + } } - else{ - logger.warn("Error: Moby data instance retrieved with XPath " + childXPath + " in " + - currentURL + " was not a primary MOBY input object as expected"); - return null; - } - - // To avoid misinterpretation of primitive datatypes as Objects with any namespace in queries for - // services, add a token namespace to get reasonable service results. - if(mobyData instanceof MobyDataObject && ((MobyDataObject) mobyData).getPrimaryNamespace() == null){ - ((MobyDataObject) mobyData).setPrimaryNamespace(new MobyNamespace("unknown")); - } - - // For workflow creation, etc. associate the potential input data with its source generalized XPath - // Also, if there is currently a filter on the doc, store it too as useful info for workflow creation. - StringBuilder userData = new StringBuilder(); - userData.append(targetURL.getProtocol()+":"+targetURL.getPath() + - "#" + elementInContextToNameBasedXPath(mobyObject)); - // todo: get rid of ref part of url for lookup - logger.warn("Looking up filter info for "+ currentURL); - if(filterHistory.containsKey(currentURL)){ - FilterSearch fs = filterHistory.get(currentURL); - logger.warn("Found filter info for "+ currentURL + ": " + fs); - if(fs.getFilterRegex().length() > 0){ - XPathOption xsel = fs.getSelectedXPath(); - userData.append("\t"+fs.getFilterRegex()+"\t"+xsel.getXPath()+"\t"+xsel.getDesc()); - } - } - mobyData.setUserData(userData.toString()); - } - catch(MobyException mobye){ // Logic error - logger.error("Error: Could not construct Moby data instance from document fragment: " + - mobye); - mobye.printStackTrace(); } - - return mobyData; } - /** - * Gets the filter criteria currently being applied to the document being viewed. - * - * @return null unless there is a currently a non-blank filter criteria - */ - public FilterSearch getFilter(){ - if(getCurrentURL() == null){ - return null; + // Recursively ascend the DOM tree and find out our place in its branching structure + private String getXPtr(Node n){ + if(n == null || n instanceof Document){ + return ""; } - FilterSearch fs = filterHistory.get(getCurrentURL()); - if(fs != null && fs.getFilterRegex().length() > 0){ - return fs; + Node parent = n.getParentNode(); + + NodeList children = parent.getChildNodes(); + int nonElementCnt = 0; + for(int i = 0; i < children.getLength(); i++){ + if(!(children.item(i) instanceof Element)){ + nonElementCnt++; + continue; + } + if(n == children.item(i)){ + return getXPtr(parent)+"/"+(i-nonElementCnt+1); + } } return null; } /** - * Restrict the view of the XML document to the parts matching the FilterSearch criteria + * Gray out parts of the HTML view if they are part of the filtered data. */ - public void applyFilter(boolean apply){ - if(!apply || !filterHistory.containsKey(getCurrentURL()) || - (filterHistory.containsKey(getCurrentURL()) && - filterHistory.get(getCurrentURL()).getFilterRegex().toString().length() == 0)){ - // Show whole doc if no filter or if filter is blank + private void displayFilterEffect(){ + + HTMLDocument d = (HTMLDocument) editorPane.getStyledDocument(); + + if(origStyles == null){ + // Store a copy of the doc's default rendering for all elements with xpointer + // (i.e. filterable elements) before doing any filter display mods, + // as this allows us to remove the filter easily without reloading the document. + origStyles = new Vector(); + for(String filterable: filterableNodes){ + javax.swing.text.Element el = d.getElement(filterable); + origStyles.add(d.getParagraphElement(el.getStartOffset()).getAttributes()); + } + firstDocRendering = false; + } + // Restore the original document appearance before applying the current filter... + else{ + Iterator origAttIter = origStyles.iterator(); + // Restore text data + for(String filterable: filterableNodes){ + javax.swing.text.AbstractDocument.AbstractElement el = + (javax.swing.text.AbstractDocument.AbstractElement) d.getElement(filterable); + javax.swing.text.SimpleAttributeSet plain = new javax.swing.text.SimpleAttributeSet(); + d.setParagraphAttributes(el.getStartOffset(), el.getEndOffset()-el.getStartOffset()+1, origAttIter.next(), true); + } + // Restore hyperlinks to default (blue underlined) appearance + javax.swing.text.SimpleAttributeSet blueAttrSet = new javax.swing.text.SimpleAttributeSet(); + blueAttrSet.addAttribute(StyleConstants.Foreground, Color.blue); + blueAttrSet.addAttribute(StyleConstants.Underline, Boolean.TRUE); + for(HTMLDocument.Iterator it = d.getIterator(HTML.Tag.A); it.isValid(); it.next()) { + String link = (String) it.getAttributes().getAttribute(HTML.Attribute.HREF); + if(link == null){ + continue; + } + d.setCharacterAttributes(it.getStartOffset(), it.getEndOffset()-it.getStartOffset()+1, blueAttrSet, false); + } + } + + javax.swing.text.SimpleAttributeSet grayAttrSet = new javax.swing.text.SimpleAttributeSet(); + grayAttrSet.addAttribute(StyleConstants.Foreground, Color.lightGray); + grayAttrSet.addAttribute(StyleConstants.Underline, Boolean.FALSE); + + // Gray out hyperlinks that are for filtered data or their children + for(HTMLDocument.Iterator it = d.getIterator(HTML.Tag.A); it.isValid(); it.next()) { + String link = (String) it.getAttributes().getAttribute(HTML.Attribute.HREF); + if(link == null || link.indexOf("#") == -1){ + continue; + } + link = link.replaceFirst("^.*#(.*)$", "$1"); // just get the ref + + for(Map.Entry dataToFilter: filteredData.entrySet()){ + if(link.equals(dataToFilter.getKey()) || link.startsWith(dataToFilter.getKey()+"/")){ + d.setCharacterAttributes(it.getStartOffset(), it.getEndOffset()-it.getStartOffset()+1, grayAttrSet, false); + } + } + } + + // Gray out the mismatched textual data + for(Map.Entry dataToFilter: filteredData.entrySet()){ + + //System.err.println("Filtering "+dataToFilter.getKey()); + javax.swing.text.AbstractDocument.AbstractElement htmlDiv = + (javax.swing.text.AbstractDocument.AbstractElement) d.getElement(dataToFilter.getKey()); + if(htmlDiv == null){ + logger.error("Could not find HTML element with expected id "+dataToFilter.getKey()); + continue; + } + int areaStart = htmlDiv.getStartOffset(); + int areaEnd = htmlDiv.getEndOffset(); + d.setParagraphAttributes(areaStart, areaEnd-areaStart+1, grayAttrSet, false); } + + // Highlight the matches + Highlighter h = editorPane.getHighlighter(); + h.removeAllHighlights(); //get rid of old highlights + FilterSearch fs = filterHistory.get(getCurrentURL()); + int matchCount = 0; + if(fs != null && fs.getFilterRegex().length() > 0){ + try{ + javax.swing.text.LayeredHighlighter.LayerPainter painter = + new DefaultHighlighter.DefaultHighlightPainter(Color.yellow); + Pattern p = Pattern.compile(fs.getFilterRegex().toString(), Pattern.MULTILINE); + for(String filterable: filterableNodes){ + javax.swing.text.Element el = d.getElement(filterable); + String fragment = d.getText(el.getStartOffset(), + el.getEndOffset() - el.getStartOffset()); + Matcher matcher = p.matcher(fragment); + while (matcher.find()) { + h.addHighlight(el.getStartOffset() + matcher.start(), + el.getStartOffset() + matcher.end(), + painter); + matchCount++; + } + } + } catch(Exception e){ + logger.error("Could not apply match highlights", e); + } + } + status.setText(" Found "+matchCount+" match"+(matchCount == 1 ? "": "es")); + + // Update the ability to press the forward button, based on the new filter criteria + contentGUI.updateHistoryButtons(); + } + + private List getHyperlinkElements(javax.swing.text.Element el){ + List links = new Vector(); + for(int i = 0; i < el.getElementCount(); i++){ + javax.swing.text.Element childEl = el.getElement(i); + System.err.println("Found child element " + childEl.getName()); + if(HTML.Tag.A.equals(childEl.getName())){ + links.add(childEl); + } + else{ + for(int j = 0; j < childEl.getElementCount(); j++){ + links.addAll(getHyperlinkElements(childEl.getElement(j))); + } + } + } + return links; } /** @@ -1384,7 +1682,7 @@ filterHistory.put(getCurrentURL(), new FilterSearch(getCurrentURL(), contentGUI.getDocumentBuilder())); } } - logger.warn("Setting filter to "+filterHistory.get(getCurrentURL()) + " for " +getCurrentURL()); + logger.debug("Setting filter to "+filterHistory.get(getCurrentURL()) + " for " +getCurrentURL()); filterSearchWidget.setFilter(filterHistory.get(getCurrentURL())); searchPanel.add(filterSearchWidget); searchPanel.revalidate(); @@ -1396,7 +1694,7 @@ deletedFilters.put(getCurrentURL(), filterHistory.remove(getCurrentURL())); } filterSearchWidget.setFilter(null); - applyFilter(false); // no filter GUI = no filter effect + if(canFilter()){applyFilter(false);} // no filter GUI = no filter effect searchPanel.remove(filterSearchWidget); searchPanel.revalidate(); revalidate(); @@ -1404,63 +1702,6 @@ } /** - * Generalizes the element instance into an XPath retrieving it and all - * similarly nested elements (based on traversing the parent nodes and prepending their names) - */ - protected String elementInContextToNameBasedXPath(Element targetElement){ - String xpath = ""; - - for(Element currentElement = targetElement; - currentElement != null; - currentElement = (Element) currentElement.getParentNode()){ - String elName = currentElement.getLocalName(); - // top level parameters' names are important - String articleName = currentElement.getAttributeNS(MobyTags.MOBY_XML_NS, MobyTags.ARTICLENAME); - if(articleName == null || articleName.trim().length() == 0){ - articleName = currentElement.getAttribute(MobyTags.ARTICLENAME); - } - - if(elName.equals(MobyTags.SIMPLE)){ - xpath = "/"+MobyTags.SIMPLE+"[@"+MobyTags.ARTICLENAME + " = '" + - articleName+"']" +xpath; - } - - else if(elName.equals(MobyTags.COLLECTION)){ - xpath = "/"+MobyTags.COLLECTION+"[@"+MobyTags.ARTICLENAME + " = '" + - articleName +"']"+xpath; - } - else if(elName.equals(MobyTags.MOBYOBJECT)){ - // Obviously, assume a base object is interesting based on its namespace - xpath = "/*[@"+MobyTags.OBJ_NAMESPACE + " = '" + - currentElement.getAttribute(MobyTags.OBJ_NAMESPACE)+"']" + xpath; - } - else if(elName.equals(MobyTags.MOBYFLOAT) || - elName.equals(MobyTags.MOBYSTRING) || - elName.equals(MobyTags.MOBYBOOLEAN) || - elName.equals(MobyTags.MOBYINTEGER) || - elName.equals(MobyTags.MOBYDATETIME)){ - // Assume that it isn't the primitive type, but rather the articleName - // that makes it appropriate to use. - xpath = "/*[@"+MobyTags.ARTICLENAME + " = '" + - articleName+"']" + xpath; - } - else{ - // It's a complex type. Assume the type is why we are picking it. - // TODO: In future we may want to check if a parent type is allowed in - // this slot, and generalize to that. May also want to check that there isn't more - // than one member of this type at this level in a HAS relationship... - // in that case we probably want to go by articleName to catch the full semantics - xpath = "/"+elName + xpath; - } - if(!(currentElement.getParentNode() instanceof Element)){ - break; // reached document node - } - } - - return xpath; - } - - /** * This method tries to figure out what kinds of MOBY Data could be * created from the string given. e.g. Keywords, DNASequence, etc. */ @@ -1638,14 +1879,13 @@ dragging = true; // so we don't export many times in a row while dragging lastHyperlinkDragged = lastHyperlinkHovered; status.setText("Drop the hyperlink onto a Web form field to populate it"); - System.err.println("Dragging "+lastHyperlinkDragged); getTransferHandler().exportToClipboard(this, Toolkit.getDefaultToolkit().getSystemClipboard(), TransferHandler.COPY); getTransferHandler().exportAsDrag(this, e, TransferHandler.COPY); } else if(!dragging){ - System.err.println("Dragging with no hyperlink activated"); + //System.err.println("Dragging with no hyperlink activated"); } } From gordonp at dev.open-bio.org Mon Mar 29 15:55:22 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:55:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291955.o2TJtMt4010648@dev.open-bio.org> gordonp Mon Mar 29 15:55:22 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv10612/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentHelpPane.java Log Message: DataRecorder -> DataFlowRecorder moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentHelpPane.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentHelpPane.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentHelpPane.java 2010/03/17 20:21:55 1.4 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentHelpPane.java 2010/03/29 19:55:22 1.5 @@ -1,7 +1,7 @@ package ca.ucalgary.seahawk.gui; -import ca.ucalgary.seahawk.util.DataRecorder; +import ca.ucalgary.seahawk.util.DataFlowRecorder; import org.biomoby.client.MobyRequestEventHandler; import org.biomoby.shared.data.MobyContentInstance; @@ -41,7 +41,7 @@ private static URL helpHTMLURL; private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobyContentHelpPane.class); public MobyContentHelpPane(MobyContentGUI cGUI, MobyServicesGUI sGUI, JTabbedPane parentComponent, - DataRecorder recorder, JLabel statusBar){ + DataFlowRecorder recorder, JLabel statusBar){ super(cGUI, sGUI, parentComponent, recorder, statusBar); // So JFCUnit tests can find it From gordonp at dev.open-bio.org Mon Mar 29 15:55:39 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:55:39 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291955.o2TJtdws010692@dev.open-bio.org> gordonp Mon Mar 29 15:55:39 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv10656/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentGUI.java Log Message: DataRecorder -> DataFlowRecorder moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentGUI.java,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2010/03/17 20:21:55 1.20 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2010/03/29 19:55:39 1.21 @@ -38,6 +38,7 @@ // Variables used to coordinate component finding with the unit test cases public final static String BACK_BUTTON_NAME = "MCGbackButton"; public final static String FORWARD_BUTTON_NAME = "MCGforwardButton"; + public final static String FORWARD_BUTTON_MSG = "Go to next document in this tab's history"; public final static String OPEN_BUTTON_NAME = "MCGopenButton"; public final static String SAVE_BUTTON_NAME = "MCGsaveButton"; public final static String FILTER_BUTTON_NAME = "MCGfilterButton"; @@ -86,7 +87,7 @@ private DocumentBuilder docBuilder = null; private MobyContentClipboard clipboard; private MobyContentHelpPane helpPane; - private DataRecorder dataRecorder; // used for workflow export, etc. + private DataFlowRecorder dataRecorder; // used for workflow export, etc. private SeahawkOptionsGUI settingsGUI; private boolean setup; @@ -132,7 +133,7 @@ forwardButton = new JButton(new ImageIcon(cl.getResource("ca/ucalgary/seahawk/resources/images/forward.gif"))); forwardButton.setDisabledIcon(new ImageIcon(cl.getResource("ca/ucalgary/seahawk/resources/images/forward_d.gif"))); - forwardButton.setToolTipText("Go to next document in this tab's history"); + forwardButton.setToolTipText(FORWARD_BUTTON_MSG); forwardButton.setPreferredSize(buttonSize); forwardButton.setEnabled(false); forwardButton.addActionListener(this); @@ -217,7 +218,7 @@ tabbedPane.addKeyListener(this); try{ - dataRecorder = new DataRecorder(servicesGUI.getMobyCentralImpl()); + dataRecorder = new DataFlowRecorder(servicesGUI.getMobyCentralImpl()); } catch(Exception e){ e.printStackTrace(); } @@ -598,7 +599,14 @@ } } - private void updateHistoryButtons(){ + /** + * Allow others to set the forward navigation button message. If set the null, the default tooltip is used. + */ + public void setForwardButtonToolTip(String msg){ + forwardButton.setToolTipText(msg == null ? FORWARD_BUTTON_MSG : msg); + } + + public void updateHistoryButtons(){ MobyContentPane pane = (MobyContentPane) tabbedPane.getSelectedComponent(); if(pane != null){ backwardButton.setEnabled(pane.canGoBack()); @@ -793,8 +801,8 @@ MobyContentInstance result = request.invokeService(); ByteArrayOutputStream inputXML = new ByteArrayOutputStream(); MobyDataUtils.toXMLDocument(inputXML, inEnvelope); - URL resultURL = dataRecorder.saveOutputData(result, services[0], //for tracking purposes - inEnvelope, central.getRegistryEndpoint()); + URL resultURL = DataUtils.saveOutputData(result, services[0], //for tracking purposes + inEnvelope, central.getRegistryEndpoint()); for(int i = 0; i < tabbedPane.getTabCount(); i++){ MobyContentPane pane = (MobyContentPane) tabbedPane.getComponentAt(i); From gordonp at dev.open-bio.org Mon Mar 29 15:58:17 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:58:17 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291958.o2TJwHUM010776@dev.open-bio.org> gordonp Mon Mar 29 15:58:17 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv10744/src/main/ca/ucalgary/seahawk/util Added Files: DataFlowRecorder.java DataUtils.java Log Message: Initial commit of new dataflow export code moby-live/Java/src/main/ca/ucalgary/seahawk/util DataFlowRecorder.java,NONE,1.1 DataUtils.java,NONE,1.1 From gordonp at dev.open-bio.org Mon Mar 29 16:42:48 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 16:42:48 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003292042.o2TKgmq1012131@dev.open-bio.org> gordonp Mon Mar 29 16:42:48 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv12095/src/main/org/biomoby/client Modified Files: MobyRequest.java Log Message: Now using proper system protery check for moby.debug moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.45,1.46 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2010/03/17 20:55:51 1.45 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2010/03/29 20:42:48 1.46 @@ -120,7 +120,7 @@ debugPS.println("Syntax error encountered while compiling XPath " + "statements for internal use (code bug?): " + xpee); } - setDebugMode(System.getProperty("moby.debug") != null); + setDebugMode(Boolean.getBoolean("moby.debug")); } public void setAuthentication(String user, String password){ From gordonp at dev.open-bio.org Mon Mar 29 16:50:25 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 16:50:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003292050.o2TKoPsY012552@dev.open-bio.org> gordonp Mon Mar 29 16:50:25 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv12519/src/main/ca/ucalgary/seahawk/util Removed Files: DataRecorder.java Log Message: Replaced with DataFlowRecorder moby-live/Java/src/main/ca/ucalgary/seahawk/util DataRecorder.java,1.3,NONE rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/RCS/DataRecorder.java,v: No such file or directory From gordonp at dev.open-bio.org Mon Mar 29 16:53:05 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 16:53:05 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003292053.o2TKr50L012596@dev.open-bio.org> gordonp Mon Mar 29 16:53:04 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv12560/src/main/ca/ucalgary/seahawk/util Modified Files: DataFlowRecorder.java Log Message: Fixed old DataRecorder refs in documentation moby-live/Java/src/main/ca/ucalgary/seahawk/util DataFlowRecorder.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataFlowRecorder.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataFlowRecorder.java 2010/03/29 19:58:17 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataFlowRecorder.java 2010/03/29 20:53:04 1.2 @@ -48,7 +48,7 @@ public DataFlowRecorder(Central mobyCtr) throws Exception{ if(mobyCtr == null){ - throw new IllegalArgumentException("Moby Central object passed to DataRecorder was null"); + throw new IllegalArgumentException("Moby Central object passed to DataFlowRecorder was null"); } mobyCentral = mobyCtr; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -67,12 +67,12 @@ * @param resultDocuments the output of the workflow to backtrace * @param outputStream where to write the output * @param workflowName to be used as a label in the workflow - * @param format the format to write the workflow in (currently, only DataRecorder.T2FLOW works) + * @param format the format to write the workflow in (currently, only DataFlowRecorder.T2FLOW works) */ public void exportWorkflow(Map resultDocuments, OutputStream outputStream, String workflowName, String workflowTitle, String workflowDescription, String workflowAuthor, int format) throws Exception{ if(format != TAVERNA15 && format != T2FLOW){ throw new IllegalArgumentException("The export format for the workflow was " + - "not DataRecorder.TAVERNA15 nor DataRecorder.T2FLOW as expected, found " + format); + "not DataFlowRecorder.TAVERNA15 nor DataFlowRecorder.T2FLOW as expected, found " + format); } if(outputStream == null){ throw new IllegalArgumentException("The output stream for workflow exporting was null, aborting export"); @@ -720,7 +720,7 @@ } // Retrieves the port name that can be used in a datalink. Since it is of local - // scope, we can just call it the same as the moby param. DataRecorder sets up provenance + // scope, we can just call it the same as the moby param. DataFlowRecorder sets up provenance // URLs (during calls to saveInput) of the form URLOfMobyXML#/path/based/on/Simple[@articleName = "foo"]/datatype // We also pass in the processors and datalinks because we may need to add some ourselves // When extra processors are added to filter a collection by namespace, etc. From gordonp at dev.open-bio.org Mon Mar 29 16:56:21 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 16:56:21 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003292056.o2TKuL4q012680@dev.open-bio.org> gordonp Mon Mar 29 16:56:21 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util In directory dev.open-bio.org:/tmp/cvs-serv12644/src/main/ca/ucalgary/services/util Modified Files: XHTMLForm.java Log Message: Fixed javadoc param moby-live/Java/src/main/ca/ucalgary/services/util XHTMLForm.java,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/XHTMLForm.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/XHTMLForm.java 2010/03/17 20:17:39 1.10 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/XHTMLForm.java 2010/03/29 20:56:21 1.11 @@ -89,7 +89,7 @@ } /** - * @param url the location of the remote Web form that will be wrapped into a Moby Service + * @param formUrl the location of the remote Web form that will be wrapped into a Moby Service */ public XHTMLForm(URL formUrl) throws Exception{ this(); From gordonp at dev.open-bio.org Mon Mar 29 16:59:54 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 16:59:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003292059.o2TKxswN012764@dev.open-bio.org> gordonp Mon Mar 29 16:59:54 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util In directory dev.open-bio.org:/tmp/cvs-serv12728/src/main/ca/ucalgary/services/util Modified Files: PBERecorder.java Log Message: Javadoc updates moby-live/Java/src/main/ca/ucalgary/services/util PBERecorder.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/PBERecorder.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/PBERecorder.java 2010/03/17 20:17:39 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/PBERecorder.java 2010/03/29 20:59:54 1.4 @@ -32,6 +32,8 @@ /** * This class controls the interaction between the web browser and Seahawk via the pasting actions. + * The tracking of Moby data in a demonstration usage of a web service or html form is used + * to generalize the invocation details into a Moby wrapper for the legacy service. */ public class PBERecorder implements DataRecorder{ private Map sessionId2gui; // link the http session with the GUI @@ -134,11 +136,6 @@ } } - /** - * @param t an XSLT transformer that is used to make results presentable (e.g. indentation). If null, an identity transform is used. - * - * @throws Exception if an XSLT transformer was not provided, and one could not be created - */ public PBERecorder(){ sessionId2gui = new HashMap(); sessionId2SourceMap = new HashMap(); From gordonp at dev.open-bio.org Mon Mar 29 17:01:17 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 17:01:17 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003292101.o2TL1HXT013042@dev.open-bio.org> gordonp Mon Mar 29 17:01:16 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv13006/src/main/org/biomoby/client Modified Files: MobyRequestEvent.java Log Message: Javadoc update moby-live/Java/src/main/org/biomoby/client MobyRequestEvent.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEvent.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEvent.java 2010/03/17 20:55:51 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEvent.java 2010/03/29 21:01:16 1.7 @@ -55,7 +55,7 @@ } /** - * @param inputXML the Moby XML sent to the service this event is refering to. + * @param inputPayload the Moby message envelope sent to the service this event is refering to. */ public void setSourceInput(MobyContentInstance inputPayload){ originatingMobyRequestInputData = inputPayload; From gordonp at dev.open-bio.org Tue Mar 30 15:14:05 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Tue, 30 Mar 2010 15:14:05 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003301914.o2UJE5LQ018610@dev.open-bio.org> gordonp Tue Mar 30 15:14:04 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/minnow In directory dev.open-bio.org:/tmp/cvs-serv18574/src/main/ca/ucalgary/minnow Modified Files: MinJarMaker.java Log Message: Changes to allow secondary JAR dumping from JARs in the classpath, before worked only for class files moby-live/Java/src/main/ca/ucalgary/minnow MinJarMaker.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/minnow/MinJarMaker.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/minnow/MinJarMaker.java 2008/10/30 02:33:24 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/minnow/MinJarMaker.java 2010/03/30 19:14:04 1.6 @@ -299,73 +299,84 @@ String path = pathElement + File.separator + pathSuffix; File classFile = new File(path); if(classFile.isFile()){ - long len = classFile.length(); - byte data[] = new byte[(int)len]; - FileInputStream fin = new FileInputStream(classFile); - int r = fin.read(data); - if (r != len){ - throw new IOException( "Could only read "+r+" of "+len+" bytes from "+classFile ); - } - fin.close(); - if(Boolean.getBoolean(VERBOSE)){ - System.err.println("[Loaded " + name + " from " + classFile.getCanonicalPath() + "]"); - } - return data; + return getClassBytesFromFile(classFile, name); } else{ // If it's not a file, maybe it's in a JAR File f = new File(pathElement); if(f.isFile()){ - JarFile jarFile = null; - try{ - jarFile = new JarFile(f); + byte[] bytes = getClassBytesFromJar(f, pathSuffix); + if(bytes != null){ + return bytes; } - catch(Exception e){ - System.err.println("Class path element " + pathElement + - " was not a directory, or a valid JAR file"); - continue; - } - - JarEntry je = jarFile.getJarEntry(pathSuffix); - if(je == null){ - continue; - } - long classSize = je.getSize(); - - InputStream classStream = jarFile.getInputStream(je); - byte[] classBytes = null; - // NOTE: This if case is commented out because false file sizes are sometimes - // reported, which leads to invalid class definitions -// if(classSize != -1){ // We know the size of the class already - -// classBytes = new byte[(int) classSize]; //classes better not be bigger than 2 GB! -// // Slurp it up in one shot -// classStream.read(classBytes, 0, (int) classSize); -// if(Boolean.getBoolean(VERBOSE)){ -// System.err.println("[Loaded " + name + " from " + f.getCanonicalPath() + "]"); -// } -// return classBytes; -// } -// else{ - - byte[] byteBufferChunk = new byte[1024]; - ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream(); - for(int r = classStream.read(byteBufferChunk, 0, 1024); - r != -1; - r = classStream.read(byteBufferChunk, 0, 1024)){ - byteBuffer.write(byteBufferChunk, 0, r); - } - if(Boolean.getBoolean(VERBOSE)){ - System.err.println("[Loaded " + name + " from " + f.getCanonicalPath() + "]"); - } - return byteBuffer.toByteArray(); -// } } - } } + return null; + } + + protected byte[] getClassBytesFromFile(File classFile, String name) throws IOException{ + long len = classFile.length(); + byte[] data = new byte[(int)len]; // 2G limit + FileInputStream fin = new FileInputStream(classFile); + int r = fin.read(data); + if (r != len){ + throw new IOException( "Could only read "+r+" of "+len+" bytes from "+classFile ); + } + fin.close(); + if(Boolean.getBoolean(VERBOSE)){ + System.err.println("[Loaded " + name + " from " + classFile.getCanonicalPath() + "]"); + } + return data; + } + + protected byte[] getClassBytesFromJar(File f, String entryName) throws IOException{ + try{ + return getClassBytesFromJar(new JarFile(f), entryName); + } + catch(Exception e){ + System.err.println("Class path element " + f.getCanonicalPath() + + " was not a directory, or a valid JAR file"); + return null; + } + } + + protected byte[] getClassBytesFromJar(JarFile jarFile, String entryName) throws IOException{ + JarEntry je = jarFile.getJarEntry(entryName); + if(je == null){ + return null; + } + long classSize = je.getSize(); + + InputStream classStream = jarFile.getInputStream(je); + byte[] classBytes = null; + // NOTE: This if case is commented out because false file sizes are sometimes + // reported, which leads to invalid class definitions + // This has to do with different versions of compression algorithms being used by different JAR makers. + // + // if(classSize != -1){ // We know the size of the class already - return null; + // classBytes = new byte[(int) classSize]; //classes better not be bigger than 2 GB! + // // Slurp it up in one shot + // classStream.read(classBytes, 0, (int) classSize); + // if(Boolean.getBoolean(VERBOSE)){ + // System.err.println("[Loaded " + name + " from " + f.getCanonicalPath() + "]"); + // } + // return classBytes; + // } + // else{ + + byte[] byteBufferChunk = new byte[1024]; + ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream(); + for(int r = classStream.read(byteBufferChunk, 0, 1024); + r != -1; + r = classStream.read(byteBufferChunk, 0, 1024)){ + byteBuffer.write(byteBufferChunk, 0, r); + } + if(Boolean.getBoolean(VERBOSE)){ + System.err.println("[Loaded " + entryName + " from " + jarFile.getName() + "]"); + } + return byteBuffer.toByteArray(); } protected URL getResourceURL(String name){ @@ -696,6 +707,7 @@ } } // Only get to here if the save was successful + //System.err.println("Saved "+relativePath); savedClasses.put(relativePath, "saved"); } jout.close(); @@ -718,6 +730,7 @@ StringTokenizer classPathTokens = new StringTokenizer(System.getProperty("jarmaker.class.path"), File.pathSeparator); while(classPathTokens.hasMoreElements()){ String classPathElement = classPathTokens.nextToken(); + System.err.println("Dumping secondary JAR for "+classPathElement); try{ dumpSecondaryJar(new File(classPathElement), classPathElement, (new File(jarfile)).getParent()); } @@ -744,10 +757,13 @@ * already benn included in the main dumpJar call. */ private void dumpSecondaryJar(File classPath, String classPrefix, String jarFilePrefix) throws Exception{ - if(classPath.isDirectory()){ - JarOutputStream jarFile = null; - String packageName = null; - if(classPrefix.equals(classPath.toString())){ + boolean isDir = classPath.isDirectory(); + JarOutputStream jarFile = null; + String packageName = null; + List entries = new Vector(); // files or jar entries + JarFile srcJarFile = null; + if(isDir){ + if(classPrefix.equals(classPath.toString()) || (classPrefix+File.separator).equals(classPath.toString())){ packageName = "no-package"; } else{ @@ -755,112 +771,155 @@ } File[] contents = classPath.listFiles(); for(int i = 0; i < contents.length; i++){ - String relativePath = contents[i].toString().substring(classPrefix.length()+1); - if(savedClasses.containsKey(relativePath) || // already saved - contents[i].getName().startsWith(".") || // or not interesting - contents[i].getName().startsWith("TEST-") || // JUnit output files - contents[i].getName().endsWith("~") || //emacs scratch file - contents[i].getName().endsWith(".java") || - contents[i].getName().endsWith(".jar") || - contents[i].getName().equals("META-INF") || //this one causes null pointers in jarsigner - contents[i].getName().equals("testdata") || - contents[i].getName().equals("deployment") || - contents[i].getName().equals("CVS")){ - continue; - } - else if(contents[i].isDirectory()){ - dumpSecondaryJar(contents[i], classPrefix, jarFilePrefix); - continue; - } - else if(jarFile == null){ // Need to create the jar file - String jarFileName = jarFilePrefix + File.separator; //in same dir as main jar file dump - jarFileName += packageName; - jarFileName += ".jar"; - File destinationFile = new File(jarFileName); - if(destinationFile.exists()){ - System.err.println("Updating jar file " + jarFileName); - - // Byte-for-byte copy the existing JAR to a temp file - File tmpJarFile = File.createTempFile("MinJarMaker", ".jar"); - InputStream origInStream = new FileInputStream(destinationFile); - OutputStream tmpOutStream = new FileOutputStream(tmpJarFile); - copyFile(tmpOutStream, origInStream); - tmpOutStream.close(); - origInStream.close(); - - // Then start writing the data out to the destination file, to be appended to later on too - JarInputStream existingJar = new JarInputStream(new FileInputStream(tmpJarFile)); - jarFile = new JarOutputStream(new FileOutputStream( destinationFile )); - jarFile.setLevel(9); //best compression - for(JarEntry je = existingJar.getNextJarEntry(); je != null; je = existingJar.getNextJarEntry()){ - try{ - jarFile.putNextEntry( je ); - }catch(java.util.zip.ZipException ze){ - System.err.println("Skipping existing entry " + je); - continue; - } - /*jar i/o works on a per entry basis, so copy File copies one entry*/ - copyFile(jarFile, existingJar); - jarFile.closeEntry(); + //System.err.println("Adding "+contents[i]); + entries.add(contents[i]); + } + } + else{ // Get the classes from another JAR + //System.err.println(classPath+" is a JAR"); + packageName = classPath.getName().replaceFirst(".jar$",""); // JAR file name without path or suffix + JarInputStream srcJarStream = null; + try{ + srcJarFile = new JarFile(classPath); + srcJarStream = new JarInputStream(new FileInputStream(classPath)); + } catch(Exception e){ + System.err.println("Skipping class path element that is neither a directory " + + "nor a valid JAR file " + e); + return; + } + try{ + for(JarEntry je = srcJarStream.getNextJarEntry(); je != null; je = srcJarStream.getNextJarEntry()){ + entries.add(je); + } + } catch(Exception e){ + System.err.println("Error while reading from JAR file "+classPath); + e.printStackTrace(); + return; + } + } + + for(Object entry: entries){ + String relativePath = entry instanceof JarEntry ? ((JarEntry) entry).getName() : + entry.toString().substring(classPrefix.length()+1); + //System.err.println("Checking status of "+relativePath); + + if(savedClasses.containsKey(relativePath) || // already saved + relativePath.startsWith(".") || // or not interesting + relativePath.startsWith("TEST-") || // JUnit output files + relativePath.endsWith("~") || //emacs scratch file + relativePath.endsWith(".java") || + relativePath.endsWith(".jar") || + relativePath.equals("META-INF") || //this one causes null pointers in jarsigner + relativePath.equals("testdata") || + relativePath.equals("deployment") || + relativePath.equals("CVS")){ + //System.err.println("Skipping " + relativePath); + continue; + } + else if(entry instanceof File && ((File) entry).isDirectory()){ //recurse for subdirs + //System.err.println("Recursing for " + relativePath); + dumpSecondaryJar((File) entry, classPrefix, jarFilePrefix); + continue; + } + else if(jarFile == null){ // Need to create the jar file + String jarFileName = jarFilePrefix + File.separator; //in same dir as main jar file dump + jarFileName += packageName; + jarFileName += ".jar"; + File destinationFile = new File(jarFileName); + if(destinationFile.exists()){ + //System.err.println("Updating jar file " + jarFileName); + + // Byte-for-byte copy the existing JAR to a temp file + File tmpJarFile = File.createTempFile("MinJarMaker", ".jar"); + InputStream origInStream = new FileInputStream(destinationFile); + OutputStream tmpOutStream = new FileOutputStream(tmpJarFile); + copyFile(tmpOutStream, origInStream); + tmpOutStream.close(); + origInStream.close(); + + // Then start writing the data out to the destination file, to be appended to later on too + JarInputStream existingJar = new JarInputStream(new FileInputStream(tmpJarFile)); + jarFile = new JarOutputStream(new FileOutputStream( destinationFile )); + jarFile.setLevel(9); //best compression + for(JarEntry je = existingJar.getNextJarEntry(); je != null; je = existingJar.getNextJarEntry()){ + try{ + // By the way, there is no good way to check if a JAR already contains a + jarFile.putNextEntry( je ); + }catch(java.util.zip.ZipException ze){ + System.err.println("Skipping existing entry " + je); + continue; } - tmpJarFile.delete(); - } - else{ - System.err.println("Creating jar file " + jarFileName); - jarFile = new JarOutputStream(new FileOutputStream( destinationFile )); - jarFile.setLevel(9); //best compression - if(webStartIndexWriter != null){ - // If it's a package that's going to have each class enumerated, - // use the short id as the part name - if(corePackages.containsKey(packageName)){ - webStartIndexWriter.write("\n"); - } - // Otherwise it's only going to be used once, so use the full name - // for clarity's sake - else{ - webStartIndexWriter.write("\n"); - } + /*jar i/o works on a per entry basis, so copy File copies one entry*/ + copyFile(jarFile, existingJar); + jarFile.closeEntry(); + } + tmpJarFile.delete(); + } + else{ + System.err.println("Creating jar file " + jarFileName); + jarFile = new JarOutputStream(new FileOutputStream( destinationFile )); + jarFile.setLevel(9); //best compression + if(webStartIndexWriter != null){ + // If it's a package that's going to have each class enumerated, + // use the short id as the part name + if(corePackages.containsKey(packageName)){ + webStartIndexWriter.write("\n"); + } + // Otherwise it's only going to be used once, so use the full name + // for clarity's sake + else{ + webStartIndexWriter.write("\n"); } } } - // A file to add to the jar, not necessarily a class (could be a resource), - // so it's a bit of a misnomer. - String className = relativePath; - if(relativePath.endsWith(".class")){ - className = relativePath.substring(0, relativePath.length()-6).replace('/', '.'); //chops off .class - } - //System.err.println("Adding " + relativePath); - if(webStartIndexWriter != null){ - // The package is split between the core jar and this jar, so we need to - // enumerate each class explicitly that isn't part of the core - if(packageName.equals("no-package")){ - webStartIndexWriter.write("\n"); - } - else if(corePackages.containsKey(packageName)){ - webStartIndexWriter.write("\n"); - } - // Is this a purely secondary package that we haven't made an index for yet? - else if(!secondaryPackageWritten.containsKey(packageName)){ - webStartIndexWriter.write("\n"); - secondaryPackageWritten.put(packageName, "written"); - } - } - try{ - jarFile.putNextEntry(new JarEntry(relativePath)); - copyFile(jarFile, contents[i].toString()); - jarFile.closeEntry(); - } - catch(java.util.zip.ZipException ze2){ - System.err.println("Skipping duplicate entry: " + ze2); - } - savedClasses.put(relativePath, "saved2"); } - if(jarFile != null){ //We saved something - jarFile.close(); + // A file to add to the jar, not necessarily a class (could be a resource), + // so it's a bit of a misnomer. + String className = relativePath; + if(relativePath.endsWith(".class")){ + className = relativePath.substring(0, relativePath.length()-6).replace('/', '.'); //chops off .class + } + //System.err.println("Adding " + relativePath); + if(webStartIndexWriter != null){ + // The package is split between the core jar and this jar, so we need to + // enumerate each class explicitly that isn't part of the core + if(packageName.equals("no-package")){ + webStartIndexWriter.write("\n"); + } + else if(corePackages.containsKey(packageName)){ + webStartIndexWriter.write("\n"); + } + // Is this a purely secondary package that we haven't made an index for yet? + else if(!secondaryPackageWritten.containsKey(packageName)){ + webStartIndexWriter.write("\n"); + secondaryPackageWritten.put(packageName, "written"); + } + } + try{ + jarFile.putNextEntry(new JarEntry(relativePath)); + if(entry instanceof JarEntry){ + //copyFile(jarFile, srcJarFile.getInputStream((JarEntry) entry)); + // Use the line below, not above, because different JARs are zipped differently, so we need to + // get the bytes then rewrite them rather than copy zip entries to ensure entry sizes are correct, + // reflecting the output JAR file's compression scheme, etc. + copyFile(jarFile, getClassBytesFromJar(srcJarFile, relativePath)); + } + else{ + copyFile(jarFile, entry.toString()); + } + jarFile.closeEntry(); + } + catch(java.util.zip.ZipException ze2){ + System.err.println("Skipping duplicate entry: " + ze2); + ze2.printStackTrace(); } + savedClasses.put(relativePath, "saved2"); + } + if(jarFile != null){ //We saved something + jarFile.close(); } } From gordonp at dev.open-bio.org Wed Mar 17 20:03:06 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:03:06 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172003.o2HK3606010088@dev.open-bio.org> gordonp Wed Mar 17 16:03:06 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv10056/src/main/ca/ucalgary/seahawk/resources Added Files: RegexFilterBeanShell XPathFilterBeanShell Log Message: Taverna beanshell inserted into workflows generated by Seahawk to perform conditional filtering of data moby-live/Java/src/main/ca/ucalgary/seahawk/resources RegexFilterBeanShell,NONE,1.1 XPathFilterBeanShell,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 20:04:28 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:04:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172004.o2HK4Str010150@dev.open-bio.org> gordonp Wed Mar 17 16:04:28 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv10118/src/main/ca/ucalgary/seahawk/resources Added Files: t2flowDispatchStack.xml Log Message: Boilerplate XML used for processors added to T2Flow (Taverna) workflows generated by Seahawk moby-live/Java/src/main/ca/ucalgary/seahawk/resources t2flowDispatchStack.xml,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 20:05:46 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:05:46 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172005.o2HK5kIH010369@dev.open-bio.org> gordonp Wed Mar 17 16:05:45 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images In directory dev.open-bio.org:/tmp/cvs-serv10337/src/main/ca/ucalgary/seahawk/resources/images Added Files: search.gif search_d.gif Log Message: Icon for filter/search button on Seahawk main GUI moby-live/Java/src/main/ca/ucalgary/seahawk/resources/images search.gif,NONE,1.1 search_d.gif,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 20:08:25 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:08:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172008.o2HK8PwS010475@dev.open-bio.org> gordonp Wed Mar 17 16:08:25 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv10443/src/main/ca/ucalgary/seahawk/util Added Files: FilterSearch.java XPathOption.java Log Message: Stores info needed for the search/filter functionality of Seahawk moby-live/Java/src/main/ca/ucalgary/seahawk/util FilterSearch.java,NONE,1.1 XPathOption.java,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 20:09:20 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:09:20 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172009.o2HK9KJ9010539@dev.open-bio.org> gordonp Wed Mar 17 16:09:20 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test In directory dev.open-bio.org:/tmp/cvs-serv10507/src/main/ca/ucalgary/services/test Added Files: keggOut.xml mobyKeyword.xml Log Message: XML file for testing service functionality moby-live/Java/src/main/ca/ucalgary/services/test keggOut.xml,NONE,1.1 mobyKeyword.xml,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 20:10:34 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:10:34 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172010.o2HKAY8Q010641@dev.open-bio.org> gordonp Wed Mar 17 16:10:34 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util In directory dev.open-bio.org:/tmp/cvs-serv10609/src/main/ca/ucalgary/services/util Added Files: MultiPartFormOutputStream.java Log Message: Utilities for dealing with multipart-encoded CGI form submissions moby-live/Java/src/main/ca/ucalgary/services/util MultiPartFormOutputStream.java,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 20:12:04 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:12:04 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172012.o2HKC4oh010705@dev.open-bio.org> gordonp Wed Mar 17 16:12:04 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources In directory dev.open-bio.org:/tmp/cvs-serv10673/src/main/ca/ucalgary/services/resources Added Files: grayOut.js Log Message: Utility script to make a Web opage non-interactive and gray...used by Daggoo during CGI to Moby Service wrapping moby-live/Java/src/main/ca/ucalgary/services/resources grayOut.js,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 20:14:30 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:14:30 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172014.o2HKEUhK010789@dev.open-bio.org> gordonp Wed Mar 17 16:14:30 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/test In directory dev.open-bio.org:/tmp/cvs-serv10757/src/main/ca/ucalgary/services/util/test Added Files: OntologyQuery.wsdl efetch_seq.wsdl Log Message: Test case for WSDL service wrapping moby-live/Java/src/main/ca/ucalgary/services/util/test OntologyQuery.wsdl,NONE,1.1 efetch_seq.wsdl,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 20:16:49 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:16:49 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172016.o2HKGnfi011203@dev.open-bio.org> gordonp Wed Mar 17 16:16:49 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services In directory dev.open-bio.org:/tmp/cvs-serv11171/src/main/ca/ucalgary/services Added Files: CGIServlet.java WrappingServlet.java Log Message: Part of legacy to Moby service wrapping system, Daggoo moby-live/Java/src/main/ca/ucalgary/services CGIServlet.java,NONE,1.1 WrappingServlet.java,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 20:17:39 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:17:39 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172017.o2HKHdei011275@dev.open-bio.org> gordonp Wed Mar 17 16:17:39 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources In directory dev.open-bio.org:/tmp/cvs-serv11211/src/main/ca/ucalgary/services/resources Modified Files: floatingframe.js Log Message: Updates related to major overhaul of Moby service wrapping system, Daggoo moby-live/Java/src/main/ca/ucalgary/services/resources floatingframe.js,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources/floatingframe.js,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources/floatingframe.js 2009/08/17 21:14:00 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources/floatingframe.js 2010/03/17 20:17:39 1.3 @@ -41,8 +41,8 @@ el.style=el; } el.sP = function(x,y){ - this.style.left=x; - this.style.top=y; + this.style.left=x+"px"; + this.style.top=y+"px"; }; if(horizontalPos=="fromright"){ @@ -107,7 +107,7 @@ /* Get the servlet message */ window.showHint = function(){ /* _dataAction is a special parameter whose values comes from ca.ucalgary.services.util.DataRecorder.PASSTHROUGH_ACTION */ - var url = "?_dataAction=hint"; + var url = "%SERVLET_URL%?_dataAction=hint"; url = url + "&sid="+Math.random(); /* The random ID is so IE doesn't cache the GET request */ xmlHttp.onreadystatechange=stateChanged; @@ -119,7 +119,7 @@ function pasteEvent(fieldObj){ /* _dataAction is a special parameter whose values comes from ca.ucalgary.services.util.DataRecorder.PASSTHROUGH_ACTION */ - var url = "?sid="+Math.random()+"&_dataAction=pasteEvent&field="+fieldObj.name; + var url = "%SERVLET_URL%?sid="+Math.random()+"&_dataAction=pasteEvent&field="+fieldObj.name; actionXmlHttp.open("GET",url,true); actionXmlHttp.send(null); From gordonp at dev.open-bio.org Wed Mar 17 20:17:39 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:17:39 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172017.o2HKHd0n011255@dev.open-bio.org> gordonp Wed Mar 17 16:17:39 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services In directory dev.open-bio.org:/tmp/cvs-serv11211/src/main/ca/ucalgary/services Modified Files: CGIService.java SoapServlet.java WSDLService.java Log Message: Updates related to major overhaul of Moby service wrapping system, Daggoo moby-live/Java/src/main/ca/ucalgary/services CGIService.java,1.7,1.8 SoapServlet.java,1.7,1.8 WSDLService.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/CGIService.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/CGIService.java 2008/03/13 23:06:48 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/CGIService.java 2010/03/17 20:17:39 1.8 @@ -1,5 +1,6 @@ package ca.ucalgary.services; +import ca.ucalgary.services.util.CGIUtils; import ca.ucalgary.services.util.XHTMLForm; import org.biomoby.service.MobyServlet; @@ -10,7 +11,6 @@ import org.apache.commons.httpclient.methods.*; import org.apache.commons.httpclient.methods.multipart.*; import org.apache.commons.httpclient.params.*; -import org.apache.commons.httpclient.util.URIUtil; import java.io.*; import java.net.URL; @@ -68,7 +68,7 @@ if(!(mobyData instanceof MobyDataObject) && !(mobyData instanceof MobyDataObjectSet)){ throw new MobyException("The Moby parameter '" + paramName + - "' is not a priary input as expected (" + + "' is not a primary input as expected (" + "found " + mobyData.getClass().getName() + ")"); } @@ -101,16 +101,17 @@ method = new PostMethod(formConfig.getFormAction()); if(XHTMLForm.MULTIPART.toLowerCase().equals( formConfig.getFormEncodingType().toLowerCase())){ - ((PostMethod) method).setRequestEntity(getMultipartRequest(formDataInstanceMap, - method.getParams())); + ((PostMethod) method).setRequestEntity(CGIUtils.getMultipartRequest(formDataInstanceMap, + method.getParams(), + formConfig.getFormFiles())); } else{ - ((PostMethod) method).setRequestBody(getNameValuePairs(formDataInstanceMap)); + ((PostMethod) method).setRequestBody(CGIUtils.getNameValuePairs(formDataInstanceMap)); } } // If not POST, assume GET else{ - method = new GetMethod(formConfig.getFormAction()+"?"+getURLQuery(formDataInstanceMap)); + method = new GetMethod(formConfig.getFormAction()+"?"+CGIUtils.getURLQuery(formDataInstanceMap)); } int statusCode; @@ -170,45 +171,6 @@ return createServiceFromConfig(request, formConfig); } - protected MultipartRequestEntity getMultipartRequest(Map dataInstances, - HttpMethodParams params){ - Part[] parts = new Part[dataInstances.size()]; - List fileTypeInputs = formConfig.getFormFiles(); - int i = 0; - for(Map.Entry formInput: dataInstances.entrySet()){ - String formInputName = formInput.getKey(); - if(fileTypeInputs.contains(formInputName)){ - parts[i++] = new FilePart(formInputName, - new ByteArrayPartSource(formInputName, - formInput.getValue())); - } - else{ - parts[i++] = new StringPart(formInputName, new String(formInput.getValue())); - } - } - return new MultipartRequestEntity(parts, params); - } - - protected NameValuePair[] getNameValuePairs(Map dataInstances){ - NameValuePair[] data = new NameValuePair[dataInstances.size()]; - int i = 0; - for(Map.Entry formField: dataInstances.entrySet()){ - data[i++] = new NameValuePair(formField.getKey(), - formField.getValue() == null ? "" : new String(formField.getValue())); - } - return data; - } - - protected String getURLQuery(Map dataInstances) throws URIException{ - String[] queryItems = new String[dataInstances.size()]; - int i = 0; - for(Map.Entry formField: dataInstances.entrySet()){ - queryItems[i++] = URIUtil.encodeWithinQuery(formField.getKey()) + "=" + - URIUtil.encodeWithinQuery(new String(formField.getValue())); - } - return XHTMLForm.join("+", queryItems); - } - public String createInputSpecString(XHTMLForm form){ Map ins = form.getPrimaryInputs(); // Create a reverse map so we can look up where a moby param =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.java 2009/08/27 21:37:32 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.java 2010/03/17 20:17:39 1.8 @@ -25,13 +25,8 @@ * can be extended using stylesheets and registering a DataRecorder (e.g. Daggoo registers PBERecorder to get * its functionality), please see the documentation at http://biomoby.open-bio.org/CVS_CONTENT/moby-live/Java/docs/soapServlet.html */ -public class SoapServlet extends HttpServlet{ +public class SoapServlet extends WrappingServlet{ - public static final String DATARECORDER_CONTEXTPARAM = "dataRecorder"; // how users spec a DataRecorder in the web.xml - - public static final String SERVICE_SPEC_PARAM = "service"; - public static final String WSDL_HTTP_PARAM = "wsdl"; - public static final String ID_PARAM = "seahawkId"; private static final String ARRAY_TYPE_SENTINEL = "ar_TyPe"; private static final String BASIC_TYPE_SENTINEL = "baSIc_TyPe"; private static final String BASIC_NAME_SENTINEL = "baSIc_naMe"; @@ -50,11 +45,8 @@ private static final String SQUOTE_OPTION = "single quotes ('...')"; private static DocumentBuilder docBuilder; - private Transformer indentationTransformer; - - private static Logger logger = Logger.getLogger("ca.ucalgary.services.SoapServlet"); - private DataRecorder recorder = null; + private static Logger logger = Logger.getLogger(SoapServlet.class.getName()); static{ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -74,146 +66,29 @@ URL u = getClass().getClassLoader().getResource(INDENTATION_XSL_RESOURCE); if(u != null){ // for pretty copying of SOAP response XML - indentationTransformer = transformerFactory.newTransformer(new StreamSource(u.openStream())); + setResponseTransformer(transformerFactory.newTransformer(new StreamSource(u.openStream()))); } else{ // verbatim copy as backup plan - indentationTransformer = transformerFactory.newTransformer(); - } - if(recorder != null){ - recorder.setTransformer(indentationTransformer); + setResponseTransformer(transformerFactory.newTransformer()); } } catch (Exception e){ logger.log(Level.SEVERE, "Could not create an XSLT transformer: " + e, e); } - - // See if the user has specified a DataRecorder to be used (customization and/or recording of - // user interaction and Web Service response). - String dataRecorderClassName = null; - javax.servlet.ServletContext context = getServletContext(); - if(context != null){ - if(context.getInitParameter(DATARECORDER_CONTEXTPARAM) != null){ - dataRecorderClassName = context.getInitParameter(DATARECORDER_CONTEXTPARAM); - } - } - javax.servlet.ServletConfig config = getServletConfig(); - if(config != null){ - if(config.getInitParameter(DATARECORDER_CONTEXTPARAM) != null){ - dataRecorderClassName = config.getInitParameter(DATARECORDER_CONTEXTPARAM); - } - } - if(dataRecorderClassName != null){ - DataRecorder dataRecorder = null; - - try{ - // This line can throw many different exception if you didn't get the class right! - Class drClass = getClass().getClassLoader().loadClass(dataRecorderClassName); - if(drClass == null){ - throw new ClassNotFoundException("The DataRecorder class to run (" + - dataRecorderClassName + - ") was not found, please ensure that the web.xml is up-to-date."); - } - dataRecorder = (DataRecorder) drClass.newInstance(); - } catch(Exception e){ - System.err.println("The DataRecorder implementing class was not specified properly in the web.xml file:"); - e.printStackTrace(); - throw new ServletException("Invalid web.xml, the parameter 'dataRecorder' was not useable"); - } - setRecorder(dataRecorder); - } - } - - public void setRecorder(DataRecorder r){ - recorder = r; - if(indentationTransformer != null){ - recorder.setTransformer(indentationTransformer); - } - } - - public DataRecorder getRecorder(){ - return recorder; } /** - * Gets are for form creation + * Post is for service submission (if the wsdl URL is provided) */ - public void doGet(HttpServletRequest request, - HttpServletResponse response) - throws ServletException, java.io.IOException{ - - if(request.getSession(false) == null && recorder != null){ - recorder.startRecording(request); //should set up a session - } - - String action = request.getParameter(DataRecorder.PASSTHROUGH_ACTION); - if(action != null && action.trim().length() > 0){ - // Delegate to the seahawk action recorder for wrapping - recorder.doGet(request, response); - return; - } - - String endpoint = request.getParameter(WSDL_HTTP_PARAM); - if(recorder != null && recorder.shouldIntercept(request)){ - recorder.interceptRequest(request, response); - } - else if(endpoint == null || endpoint.trim().length() == 0){ // Normal web-browser form fill-in - writeInputForm(request, response); - } - else{ - writeServiceForm(request, response, endpoint); - } - } - - /** - * Post is for service submission (if the wsdl URL is provided), or the PBERecorder (any other case) - */ - public void doPost(HttpServletRequest request, - HttpServletResponse response){ - - java.io.PrintStream out = null; - try{ - out = new java.io.PrintStream(response.getOutputStream()); - } - catch(java.io.IOException ioe){ - logger.log(Level.SEVERE, "While getting servlet output stream (for HTML form response to client)", ioe); - return; - } - - // Find out the info needed to build the JAX-WS client - if(recorder != null && recorder.shouldIntercept(request)){ - //if(wsdlLoc == null || wsdlLoc.trim().length() == 0){ - // if(recorder != null){ - recorder.interceptRequest(request, response); - return; - } - String wsdlLoc = request.getParameter(WSDL_HTTP_PARAM); - if(wsdlLoc == null || wsdlLoc.trim().length() == 0){ - response.setContentType("text/html"); - out.print("Error"+ - "\n"+ - "No '"+WSDL_HTTP_PARAM+"' parameter (the location of the WSDL document)" + - "was specified in the POST request, and " + - (recorder == null ? "no data recorder is associated with this servlet" : - "the data recorder did not want to intercept the POST") +""); - - } - URL url = null; - try{ - url = new URL(wsdlLoc); - } catch(Exception e){ - out.print("Error\n"+ - "\n"+ - "

The URL specified (" + - wsdlLoc + ") could not be parsed


");
-	    e.printStackTrace(out);
-	    out.print("
\n"); - return; - } + public void callService(HttpServletRequest request, + HttpServletResponse response, + URL url, //url of wsdl file + PrintStream out){ String serviceSpec = request.getParameter(SERVICE_SPEC_PARAM); - if(wsdlLoc == null || wsdlLoc.trim().length() == 0){ + if(serviceSpec == null || serviceSpec.trim().length() == 0){ out.print("Error\n"+ "\n"+ "No '"+SERVICE_SPEC_PARAM+"' parameter (specifying " + @@ -278,7 +153,7 @@ for (Enumeration e = request.getParameterNames(); e.hasMoreElements();){ String paramName = (String) e.nextElement(); if(SERVICE_SPEC_PARAM.equals(paramName) || - WSDL_HTTP_PARAM.equals(paramName) || + SRC_PARAM.equals(paramName) || ID_PARAM.equals(paramName)){ continue; } @@ -403,7 +278,7 @@ answer = recorder.markupResponse(resultSource, request); } catch(Exception e){ //todo - answer = "
Exception in PBE system:\n"+e.toString()+"\n";
+		answer = "
Exception in DataRecorder subsystem:\n"+e.toString()+"\n";
 		for(StackTraceElement ste: e.getStackTrace()){
 		    answer += ste.toString()+"\n";
 		}	    
@@ -414,8 +289,9 @@
 	    // Does two duties: fixes indentation, and outputs to a Java stream we can print easily
 	    ByteArrayOutputStream stringResult = new ByteArrayOutputStream();
 	    try{
-		synchronized(indentationTransformer){
-		    indentationTransformer.transform(resultSource, 
+		Transformer responseTransformer = getResponseTransformer();
+		synchronized(responseTransformer){
+		    responseTransformer.transform(resultSource, 
 						     new javax.xml.transform.stream.StreamResult(stringResult));
 		}
 	    } catch(Exception e){
@@ -440,52 +316,24 @@
 
     // Asks for the WSDL file
     private void writeInputForm(HttpServletRequest request,
-				HttpServletResponse response){
-	java.io.OutputStream out = null;
-	response.setContentType("text/html");
-	try{
-	    out = response.getOutputStream();
-	}
-	catch(java.io.IOException ioe){
-	    logger.log(Level.SEVERE, "While getting servlet output stream (for HTML form response to client)", ioe);
-	    return;
-	}
-
-	try{
-	    out.write("Generic SOAP Client\n".getBytes());
-	    out.write("Enter the URL of the WSDL file below: ").getBytes());
-	    out.write("".getBytes());
-	}
-	catch(java.io.IOException ioe){
-	    logger.log(Level.SEVERE, "While printing HTML form to servlet output stream", ioe);
-	    return;
-	}	
+				HttpServletResponse response,
+				PrintStream out){
+	out.print("Generic SOAP Client\n");
+	out.print("Enter the URL of the WSDL file below: 
"); + out.print(""); } // Presents the WSDL file as a CGI form - private void writeServiceForm(HttpServletRequest request, - HttpServletResponse response, - String endpoint){ - java.io.PrintStream out = null; - response.setContentType("text/html"); - try{ - out = new java.io.PrintStream(response.getOutputStream()); - } - catch(java.io.IOException ioe){ - log("While getting servlet output stream (for HTML form response to client)", ioe); - return; - } - - URL url = null; - try{ - url = new URL(endpoint); - } catch(Exception e){ - out.print("Parsing Error\n"+ - "\n" + - "

The URL specified (" + endpoint + ") could not be parsed


");
-	    e.printStackTrace(out);
-	    out.print("
\n"); + protected void writeServiceForm(HttpServletRequest request, + HttpServletResponse response, + URL url, + PrintStream out){ + + // Normal web-browser form fill-in, ask for the WSDL to wrap + // Useful so this servlet can standalone and borker WSDL services. + if(url == null){ + writeInputForm(request, response, out); return; } @@ -496,7 +344,7 @@ out.print(recorder.getHead(request)); } // allow the recorder to insert any body events required - out.print("\n\n"); + out.print("\n\n"); if(recorder != null){ out.print(recorder.getBody(request)); } @@ -1010,7 +858,7 @@ portQName.getNamespaceURI() + " " + portQName.getLocalPart() + " "; out.print("

"+ opQName.getLocalPart()+"

\n"+ - "\n"); + "\n"); Map partsMap = msg2Parts.get(messageQName); if(partsMap == null){ System.err.println("Got null parts map for message " + messageQName); @@ -1335,23 +1183,6 @@ } /** - * Links the form inputs to javascript capture actions, if a recorder is available - */ - private String rec(){ - if(recorder != null){ - return recorder.getOnEventText(); - } - return ""; - } - - private String sub(){ - if(recorder != null){ - return recorder.getOnSubmitText(); - } - return ""; - } - - /** * Expand any import or include statements in-place. */ public static void doImports(Document doc, URL baseURL) throws Exception{ @@ -1449,13 +1280,4 @@ } } } - - public static class MyNodeList implements NodeList{ - private Vector nodes; - public MyNodeList(){nodes = new Vector();} - public int getLength(){return nodes.size();} - public Node item(int index){return nodes.elementAt(index);} - public void add(Node n){nodes.add(n);} - public void add(NodeList n){for(int i=0;i gordonp Wed Mar 17 16:17:39 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test In directory dev.open-bio.org:/tmp/cvs-serv11211/src/main/ca/ucalgary/services/test Modified Files: CGIServiceTestCase.java SoapServletTestCase.java Log Message: Updates related to major overhaul of Moby service wrapping system, Daggoo moby-live/Java/src/main/ca/ucalgary/services/test CGIServiceTestCase.java,1.1,1.2 SoapServletTestCase.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/CGIServiceTestCase.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/CGIServiceTestCase.java 2008/02/14 03:04:44 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/CGIServiceTestCase.java 2010/03/17 20:17:39 1.2 @@ -26,7 +26,8 @@ */ public class CGIServiceTestCase extends MobyServletTestCase{ private final static String CGITEST_CLASS_NAME = "ca.ucalgary.services.CGIService"; - private final static String CGITEST_MOBY_XML = "ca/ucalgary/services/test/mobyDNASeq.xml"; + //private final static String CGITEST_MOBY_XML = "ca/ucalgary/services/test/mobyDNASeq.xml"; + private final static String CGITEST_MOBY_XML = "ca/ucalgary/services/test/mobyKeyword.xml"; public CGIServiceTestCase(String name){ super(name); @@ -70,4 +71,4 @@ public static void main(String[] args){ junit.textui.TestRunner.run(suite()); } -} \ No newline at end of file +} =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/SoapServletTestCase.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/SoapServletTestCase.java 2009/08/20 19:52:09 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/SoapServletTestCase.java 2010/03/17 20:17:39 1.3 @@ -36,7 +36,7 @@ } TestHttpServletRequest request = new TestHttpServletRequest(); - request.setParameter(SoapServlet.WSDL_HTTP_PARAM, "http://soap.genome.jp/KEGG.wsdl"); + request.setParameter(SoapServlet.SRC_PARAM, "http://soap.genome.jp/KEGG.wsdl"); request.setParameter(SoapServlet.SERVICE_SPEC_PARAM, "SOAP/KEGG KEGG SOAP/KEGG KEGGPort " + "SOAP/KEGG get_compounds_by_enzyme SOAP/KEGG#get_compounds_by_enzyme " + "get_compounds_by_enzyme rpc encoded"); @@ -69,7 +69,7 @@ } TestHttpServletRequest request = new TestHttpServletRequest(); - request.setParameter(SoapServlet.WSDL_HTTP_PARAM, "http://www.ebi.ac.uk/ontology-lookup/OntologyQuery.wsdl"); + request.setParameter(SoapServlet.SRC_PARAM, "http://www.ebi.ac.uk/ontology-lookup/OntologyQuery.wsdl"); request.setParameter(SoapServlet.SERVICE_SPEC_PARAM, "http://www.ebi.ac.uk/ontology-lookup/OntologyQuery QueryService " + "http://www.ebi.ac.uk/ontology-lookup/OntologyQuery OntologyQuery " + "http://www.ebi.ac.uk/ontology-lookup/OntologyQuery getTermsByName " + @@ -93,7 +93,7 @@ out.getBuffer().toString()); } TestHttpServletRequest request2 = new TestHttpServletRequest(); - request2.setParameter(SoapServlet.WSDL_HTTP_PARAM, "http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/eutils.wsdl"); + request2.setParameter(SoapServlet.SRC_PARAM, "http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/eutils.wsdl"); request2.setParameter(SoapServlet.SERVICE_SPEC_PARAM, "http://www.ncbi.nlm.nih.gov/soap/eutils/ eUtilsService " + "http://www.ncbi.nlm.nih.gov/soap/eutils/ eUtilsServiceSoap " + "http://www.ncbi.nlm.nih.gov/soap/eutils/espell eSpellRequest " + From gordonp at dev.open-bio.org Wed Mar 17 20:20:09 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:20:09 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172020.o2HKK9pL011425@dev.open-bio.org> gordonp Wed Mar 17 16:20:09 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv11393/src/main/ca/ucalgary/seahawk/gui Added Files: WorkflowPreviewDialog.java WorkflowPreviewListener.java Log Message: Now the user sees the workflow (depends on Ruby script on remote host) before saving moby-live/Java/src/main/ca/ucalgary/seahawk/gui WorkflowPreviewDialog.java,NONE,1.1 WorkflowPreviewListener.java,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 20:20:48 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:20:48 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172020.o2HKKmXT011503@dev.open-bio.org> gordonp Wed Mar 17 16:20:47 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv11471/src/main/ca/ucalgary/seahawk/gui Added Files: FilterSearchWidget.java Log Message: GUI component (removable bottom bar) of Seahawk interface moby-live/Java/src/main/ca/ucalgary/seahawk/gui FilterSearchWidget.java,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 20:21:55 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:21:55 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172021.o2HKLt9L011579@dev.open-bio.org> gordonp Wed Mar 17 16:21:55 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test In directory dev.open-bio.org:/tmp/cvs-serv11511/src/main/ca/ucalgary/seahawk/gui/test Modified Files: SeahawkTestCase.java Log Message: Interface updates related to new search/filter and workflow generation/preview functions moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test SeahawkTestCase.java,1.12,1.13 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java 2009/06/09 19:26:15 1.12 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/test/SeahawkTestCase.java 2010/03/17 20:21:55 1.13 @@ -35,7 +35,7 @@ private final static String TEST_MS_EXCEL_FILE = "ca/ucalgary/seahawk/gui/test/twohybrid_uetz.xls"; private final static String TEST_MOBYEX_XML = "ca/ucalgary/seahawk/gui/test/moby_exception.xml"; private final static String TEST_MOBY_XML = "ca/ucalgary/seahawk/gui/test/allDataTypes.xml"; - private final static String TEST_WSDL_FILE = "ca/ucalgary/seahawk/gui/test/efetch_seq.wsdl"; + private final static String TEST_WSDL_FILE = "http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/efetch_seq.wsdl"; private final static String TEST_EXTERNAL_URL = "http://www.google.com/"; private final static String TEST_DNA_SEQ = "AAGCTTGGCCAACGTAAATCTTTCGGCGGCA"; private final static String TEST_AA_SEQ = "MPGGFILAIDEGTTSARAIIYNQDLEVLGIGQYDFPQHYPSP"; @@ -527,7 +527,7 @@ // Checks to make sure the Moby-wrapping of WSDL forms works fine public void testWSDL() throws Exception{ - URL wsdlResource = getClass().getClassLoader().getResource(TEST_WSDL_FILE); + URL wsdlResource = TEST_WSDL_FILE.startsWith("http://") ? new URL(TEST_WSDL_FILE) : getClass().getClassLoader().getResource(TEST_WSDL_FILE); assertNotNull("Could not find test WSDL resource " + TEST_WSDL_FILE, wsdlResource); contentGUI.loadPaneFromURL(wsdlResource, true); try{ @@ -802,13 +802,13 @@ sleep(2000); //just to ensure HTML rendering finishes } - public void testRunServiceSecondariesAndSCUFL() throws Exception{ + public void testRunServiceSecondariesAndWorkflow() throws Exception{ try{ - findService(TEST_DNA_SEQ, "Bioinformatics", "..."); + findService(TEST_DNA_SEQ, "BasicGFFSequenceFeature", "..."); } catch(Exception e){ e.printStackTrace(); fail("Error while a finding service ending with \"...\" " + - "(secondary input) under \"Analysis\" in the popup"); + "(secondary input) under \"BasicGFFSequenceFeature\" in the popup"); } fillInSecondariesAndExecute(); @@ -824,9 +824,9 @@ // Since we ran a real service, we can make a Taverna workflow out of the tab history File testFile = File.createTempFile("test-seahawk", ""); testFile.deleteOnExit(); - MobySaveDialog.exportSCUFL(contentGUI.getCurrentPane(), testFile); + MobySaveDialog.exportWorkflow(contentGUI.getCurrentPane(), testFile); sleep(1000); - assertTrue("The SCUFL saved data file was empty", testFile.length() != 0); + assertTrue("The workflow saved data file was empty", testFile.length() != 0); } public void fillInSecondariesAndExecute() throws Exception{ @@ -1079,7 +1079,7 @@ suite.addTest(new SeahawkTestCase("testPrint")); //done suite.addTest(new SeahawkTestCase("testNavigationButtons")); //done suite.addTest(new SeahawkTestCase("testRunAsynchronousService")); //done - suite.addTest(new SeahawkTestCase("testRunServiceSecondariesAndSCUFL")); //done + suite.addTest(new SeahawkTestCase("testRunServiceSecondariesAndWorkflow")); //done suite.addTest(new SeahawkTestCase("testHighlightOptions"));//done suite.addTest(new SeahawkTestCase("testUserPreferences"));//done suite.addTest(new SeahawkTestCase("testExternalBrowser"));//done From gordonp at dev.open-bio.org Wed Mar 17 20:21:55 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:21:55 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172021.o2HKLtxB011603@dev.open-bio.org> gordonp Wed Mar 17 16:21:55 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv11511/src/main/ca/ucalgary/seahawk/resources Modified Files: moby2HTML.xsl mobyBuilderRules.xml Log Message: Interface updates related to new search/filter and workflow generation/preview functions moby-live/Java/src/main/ca/ucalgary/seahawk/resources moby2HTML.xsl,1.4,1.5 mobyBuilderRules.xml,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/moby2HTML.xsl,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/moby2HTML.xsl 2007/07/28 03:47:41 1.4 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/moby2HTML.xsl 2010/03/17 20:21:55 1.5 @@ -218,18 +218,20 @@ - ID : () + + ID : () - + String : ():
-
+ - :
+ + ():
=================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml 2009/08/17 21:31:52 1.9 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml 2010/03/17 20:21:55 1.10 @@ -3,6 +3,9 @@ http://www.bioxml.info/dtd/agave.dtd http://www.bioxml.info/dtd/tigrxml.dtd http://www.bioxml.info/dtd/Bioseq.dtd +http://www.biomedcentral.com/xml/article.dtd +http://dtd.nlm.nih.gov/publishing/2.0/journalpublishing.dtd +http://genmapp.org/GPML/2008a (HEADER\s+.*?(\S+)\n @@ -98,10 +101,11 @@ + urn:lsid:bioxml.info:mobyLiftingSchemaMapping:URL2Link ((?:http|ftp|file):// ([^/\x20\r\t\n]+)? # host name (non-whitespace, non-slash), maybe \S*?) # rest of the URL until - ([,\.\)\(]\s|\z) # trailing punctuation and whitespace, or just EOD + ([,\.\)\(]?\s|\z) # trailing punctuation and whitespace, or just EOD $1 @@ -140,6 +144,28 @@ + + bmcarticle:pubid[@idtype="pmpid"]/text() + + $1 + + + + + bmcarticle:pubid[@idtype="doi"]/text() + + $1 + + + + + ncbiarticle:article-id[@pub-id-type="doi"]/text() + + $1 + + + + (?:[KC]OG|[kc]og):?\s*(\d{4}) @@ -153,7 +179,7 @@ urn:lsid:bioxml.info:mobyLiftingSchemaMapping:prefixedDOI2DOI (?:DOI|doi|[Dd]igital\s+[Oo]bject\s+[Ii][Dd](?:entifier))\s*:?\s*(10\.\d+/[^%"\#\x20\t\r\n]+) - $1 + $1 @@ -218,6 +244,14 @@ + + + gpml:Xref[@Database="Entrez Gene"]/@ID + + $1 + + + ([NXYZ][CMP]_\d{6}) From gordonp at dev.open-bio.org Wed Mar 17 20:21:55 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:21:55 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172021.o2HKLtro011631@dev.open-bio.org> gordonp Wed Mar 17 16:21:55 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv11511/src/main/ca/ucalgary/seahawk/services Modified Files: DaggooClient.java MobyClient.java Log Message: Interface updates related to new search/filter and workflow generation/preview functions moby-live/Java/src/main/ca/ucalgary/seahawk/services DaggooClient.java,1.1,1.2 MobyClient.java,1.24,1.25 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/DaggooClient.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/DaggooClient.java 2009/06/09 19:52:02 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/DaggooClient.java 2010/03/17 20:21:55 1.2 @@ -21,57 +21,109 @@ public class DaggooClient{ private static Logger logger = Logger.getLogger(DaggooClient.class.getName()); + /** + * The three outcomes possible from asking the user about the URL dropped on Seahawk. + */ + public enum Action {WRAP, CALL, VIEW, NOTHING} + public static boolean acceptAnExistingWrapper(URL u, MobyContentPane dropTargetPane){ + // by default, do not provide view vs. wrap option + return acceptAnExistingWrapper(u, dropTargetPane, false) != Action.WRAP; + // all actions except wrap are handled by this method + } + + /** + * Presents the user with a dialog showing all Moby services (wrappers) that exist for the provided URL. + * This method will handle calling of existing services and viewing the form. Only a return of Action.WRAP + * is actionable for the caller. + * + * @param u the URL containing the form/wsdl doc to wrap + * @param dropTargetPane the Seahawk GUI element onto which the URL was dropped + * @param giveViewOption provide extra option to just view the page in Seahawk, rather than wrap the service + */ + public static Action acceptAnExistingWrapper(URL u, MobyContentPane dropTargetPane, boolean giveViewOption){ // Before wrapping the WSDL, see if there are already services wrapping it (in Daggoo). // If so, ask the user if they want to use one of those instead. try{ String existingServices = HTMLUtils.getURLContents(new URL(PBERecorder.getProxyBaseUrl()+ "lookup/"+Registration.OP_SPEC_DOC_PARAM+ "/"+u)); - if(existingServices == null || existingServices.length() == 0){ - return false; // no existing wrappers - } - String registryURL = SeahawkOptions.getRegistry() == null ? - CentralImpl.getDefaultURL() : - SeahawkOptions.getRegistry().getEndpoint(); Vector choices = new Vector(); - for(String line: existingServices.split("\n")){ - String[] fields = line.split("\t"); - if(fields.length != 4){ - throw new Exception("Did not get lines with 4 tab-delimited fields " + - "from Daggoo lookup service. The offending line is " + line); - } - if(!fields[1].equals(registryURL)){ - logger.log(Level.INFO, - "Skipping service in different registry (" + - fields[1] + ") than the current one in Seahawk (" + - registryURL + ")"); - continue; + if(existingServices != null && existingServices.length() != 0){ + String registryURL = SeahawkOptions.getRegistry() == null ? + CentralImpl.getDefaultURL() : + SeahawkOptions.getRegistry().getEndpoint(); + for(String line: existingServices.split("\n")){ + String[] fields = line.split("\t"); + if(fields.length != 4){ + throw new Exception("Did not get lines with 4 tab-delimited fields " + + "from Daggoo lookup service. The offending line is " + line); + } + if(!fields[1].equals(registryURL)){ + logger.log(Level.INFO, + "Skipping service in different registry (" + + fields[1] + ") than the current one in Seahawk (" + + registryURL + ")"); + continue; + } + choices.add(fields[3]+" ("+fields[2]+")"); } - choices.add(fields[3]+" ("+fields[2]+")"); - } - if(choices.isEmpty()){ - return false; // none in the registry we need } //todo: add "Don't show me this dialog again" option? - Object selectedValue = JOptionPane.showInputDialog(dropTargetPane, - "The services below wrap the same page as " + - "you just dragged into Seahawk.\n Would you like to " + - "call one instead of wrapping the page again?", - "Existing Wrapper Services", - JOptionPane.INFORMATION_MESSAGE, null, - choices.toArray(), choices.get(0)); - if(selectedValue == null){ - // cancel - return false; + Object selectedValue = null; + if(!giveViewOption){ + if(choices.isEmpty()){ + return Action.WRAP; // none in the registry we need + } + selectedValue = JOptionPane.showInputDialog(dropTargetPane, + "The services below wrap the same page as " + + "you just dragged into Seahawk.\n Would you like to " + + "call one instead of wrapping the page again?", + "Existing Wrapper Services", + JOptionPane.INFORMATION_MESSAGE, null, + choices.toArray(), choices.get(0)); + if(selectedValue == null){ + // cancel = wrap it yourself instead of using one of the service options presented + return Action.WRAP; + } + } + else{ // give user three options: call service, wrap service or view URL contents in Seahawk + Action action = Action.NOTHING; + if(choices.isEmpty()){ // still give option to wrap or view contents if no services exist + int choice = JOptionPane.showOptionDialog(dropTargetPane, + "What would you like to do with this Web page?", "Wrap or View?", + JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, + null, new String[]{"Create a service", "View page contents"}, + "Create a service"); + if(choice == JOptionPane.CLOSED_OPTION){ + return Action.NOTHING; + } + else if(choice == 0){ + return Action.WRAP; + } + else{ + action = Action.VIEW; + } + } + else{ + + } + if(action == Action.VIEW){ + // load the page for viewing. Normally gotoURL would cause recursion on this method, so + // we disable wrapping temporarily to avoid this. + dropTargetPane.setWrappingEnabled(false); + dropTargetPane.gotoURL(u, true); + dropTargetPane.setWrappingEnabled(true); + return Action.VIEW; + } } // todo: actually call service System.err.println("Running the existing wrapper " + selectedValue); } catch(Exception e){ logger.log(Level.WARNING, "Cannot show the user existing service options", e); - return false; + return Action.VIEW; } - return true; //if we got here, the user accepted an existing service + return Action.CALL; //if we got here, the user accepted an existing service } } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2009/08/18 18:22:07 1.24 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2010/03/17 20:21:55 1.25 @@ -17,6 +17,7 @@ import java.net.URL; import java.net.MalformedURLException; import java.util.*; +import java.util.logging.*; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.xml.parsers.*; @@ -36,6 +37,7 @@ public static final String PREFIX_ATTR = "value"; public static final String ARTICLENAME_RULE_TAG = "articlename"; public static final String NAMESPACE_RULE_TAG = "namespace"; + public static final String NAMESPACE_MODEL_ATTR = "model"; public static final String NAMESPACE_VALUE_TAG = "ns"; public static final String NAMESPACE_VALUE_ATTR = "value"; public static final String DATATYPE_RULE_TAG = "datatype"; @@ -71,7 +73,7 @@ private Registry registry; private URL dataMappingXMLURL; private DocumentBuilder docBuilder; - private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobyClient.class); + private static Logger logger = Logger.getLogger(MobyClient.class.getName()); private int serviceLevel = MobyService.UNCHECKED; @@ -272,7 +274,8 @@ Vector regexStrings = new Vector(); Vector urlRegexStrings = new Vector(); Vector xpathStrings = new Vector(); - Map namespaceMap = new HashMap(); + Map namespaceMap = new HashMap(); // moby nanmespaces -> production rules + Map modelMap = new HashMap(); // Semantic Web URIs -> production rules Map memberMap = new HashMap(); String dataTypeString = null; String articleNameString = null; @@ -297,7 +300,7 @@ addXPathString(ruleMember, xpathStrings); } else if(isNamespaceRule(ruleMember)){ - addNamespaceMapping(ruleMember, namespaceMap); + addNamespaceMapping(ruleMember, namespaceMap, modelMap); } else if(isArticleNameRule(ruleMember)){ if(articleNameString != null && articleNameString.length() != 0){ @@ -607,13 +610,14 @@ memberRuleName}); } - protected void addNamespaceMapping(Element nsTag, Map namespaceStrings) throws Exception{ + protected void addNamespaceMapping(Element nsTag, Map namespaceStrings, Map modelStrings) throws Exception{ if(!isNamespaceRule(nsTag)){ throw new Exception("Element provided to createNamespaceMapping (" + (nsTag == null ? null : nsTag.getLocalName()) + ") was not a namespace rule element"); } + NodeList ruleSpecs = nsTag.getChildNodes(); for(int i = 0; i < ruleSpecs.getLength(); i++){ Node specNode = ruleSpecs.item(i); @@ -625,7 +629,8 @@ Element ruleSpec = (Element) specNode; String specName = ruleSpec.getLocalName(); if(NAMESPACE_VALUE_TAG.equals(specName)){ - String keyName = ruleSpec.getAttribute(NAMESPACE_VALUE_ATTR); + String keyName = ruleSpec.getAttribute(NAMESPACE_VALUE_ATTR); // moby namespace + String modelURI = ruleSpec.getAttribute(NAMESPACE_MODEL_ATTR); // Semantic Web URI String valueRule = ruleSpec.getTextContent(); if(valueRule == null || valueRule.length() == 0){ throw new Exception("Element " + NAMESPACE_VALUE_TAG + @@ -636,7 +641,12 @@ "namespace '" + keyName + "'"); continue; } - namespaceStrings.put(keyName, valueRule); + if(keyName != null && keyName.length() != 0){ + namespaceStrings.put(keyName, valueRule); + } + if(modelURI != null && modelURI.length() != 0){ + modelStrings.put(modelURI, valueRule); + } } else{ System.err.println("Skipping unexpected "+NAMESPACE_RULE_TAG+" child node " + specName); @@ -1336,7 +1346,7 @@ mobyDataServiceAssocInstances[i] = new MobyDataObjectSetSAI((MobyDataObjectSet) mdos[i], mService); } else{ - logger.warn("MobyClient could not handle service-associating an instance of " + mdos[i].getClass()); + logger.log(Level.WARNING, "MobyClient could not handle service-associating an instance of " + mdos[i].getClass()); System.err.println("MobyClient could not handle service-associating an instance of " + mdos[i].getClass()); } } @@ -1694,7 +1704,8 @@ builderNameMap.put(urn, mcb); } }catch(Exception e){ - logger.warn("Could not create XPath select statement from '" + + logger.log(Level.WARNING, + "Could not create XPath select statement from '" + xpath_exp + "': " + e.getMessage()); System.err.println("Could not create XPath select statement from '" + xpath_exp + "': " + e); From gordonp at dev.open-bio.org Wed Mar 17 20:53:12 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:53:12 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172053.o2HKrCYa012479@dev.open-bio.org> gordonp Wed Mar 17 16:53:12 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util In directory dev.open-bio.org:/tmp/cvs-serv12447/src/main/ca/ucalgary/services/util Added Files: CGIUtils.java Log Message: Methods to simplify CGI posting done in Daggoo moby-live/Java/src/main/ca/ucalgary/services/util CGIUtils.java,NONE,1.1 From gordonp at dev.open-bio.org Wed Mar 17 20:55:51 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:55:51 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172055.o2HKtpvo012611@dev.open-bio.org> gordonp Wed Mar 17 16:55:51 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv12571/src/main/org/biomoby/client Modified Files: MobyRequest.java MobyRequestEvent.java Log Message: Updates to pass sent data around with response (used by Seahawk PbE system) moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.44,1.45 MobyRequestEvent.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2009/07/15 18:35:30 1.44 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2010/03/17 20:55:51 1.45 @@ -373,7 +373,7 @@ // Inform the handler that some data has been added to the response (for incremental display?) if(handler != null){ - MobyRequestEvent mre = new MobyRequestEvent(finalContents, this, mservice, null, requestId); + MobyRequestEvent mre = new MobyRequestEvent(finalContents, this, mservice, inData, null, requestId); StringWriter xmlWriter = new StringWriter(); MobyDataUtils.toXMLDocument(xmlWriter, finalContents); @@ -412,10 +412,20 @@ * @return the id that the callback event will return from getID(), allowing a client to distinguish between multiple concurrent invocation callbacks */ public synchronized int invokeService(MobyRequestEventHandler handler){ - int id = autoID++; + final int id = autoID++; - Thread t = new InvocationThread(this, inputData, handler, id); // see internal class definition below - t.start(); + try{ + Thread t = new InvocationThread(this, inputData, handler, id); // see internal class definition below + t.start(); + } catch(final Exception e){ + // Launching callback in new Thread avoids possible deadlocks caused by handler + // calling invokeService() again as a retry + final MobyRequestEventHandler h = handler; + final MobyContentInstance i = inputData; + final MobyService s = getService(); + final MobyRequest t = this; + (new Thread(){public void run(){h.processEvent(new MobyRequestEvent(i, t, s, null, e, id));}}).start(); + } return id; } @@ -424,24 +434,29 @@ // the handler specified in the invocation. class InvocationThread extends Thread { MobyContentInstance data; + ByteArrayOutputStream dataXML; MobyService mservice; MobyRequest mobyRequest; MobyRequestEventHandler handler; int requestId; - InvocationThread(MobyRequest mr, MobyContentInstance inData, MobyRequestEventHandler h, int id){ + InvocationThread(MobyRequest mr, MobyContentInstance inData, MobyRequestEventHandler h, int id) throws Exception{ data = inData; mobyRequest = mr; mservice = mobyRequest.getService(); handler = h; requestId = id; + dataXML = new ByteArrayOutputStream(); + MobyDataUtils.toXMLDocument(dataXML, data); + // Name the thread after the service being run, mostly for ease of debugging setName(mservice.getName()+requestId); } public void run() { - MobyRequestEvent requestEvent = new MobyRequestEvent(data, mobyRequest, mservice, null, requestId); + + MobyRequestEvent requestEvent = new MobyRequestEvent(data, mobyRequest, mservice, data, null, requestId); // Tell the handler we're starting the request, with the given data handler.start(requestEvent); @@ -452,13 +467,14 @@ content = mobyRequest.invokeService(data, contentsXML, handler, requestId); //RPC call... } catch(Exception e){ - responseEvent = new MobyRequestEvent(content, mobyRequest, mservice, e, requestId); + responseEvent = new MobyRequestEvent(content, mobyRequest, mservice, data, e, requestId); } catch(Error err){ - responseEvent = new MobyRequestEvent(content, mobyRequest, mservice, err, requestId); + responseEvent = new MobyRequestEvent(content, mobyRequest, mservice, data, err, requestId); } + if(responseEvent == null){ - responseEvent = new MobyRequestEvent(content, mobyRequest, mservice, null, requestId); + responseEvent = new MobyRequestEvent(content, mobyRequest, mservice, data, null, requestId); } // We've got the raw XML laying around, so why not provide it unmolested to the callback? responseEvent.setContentsXML(contentsXML.toString()); @@ -480,37 +496,6 @@ } /** - * This method retrieves from Moby Central a copy of the WSDL document for the service - * (or uses an internally cached copy from a previous invocation), and sets the variables for the - * SOAP call appropriately so you can consequently call performSOAPRequest. - */ -//PG protected Call getServiceFromWSDL() throws MobyException, NoSuccessException{ -// String wsdl = null; - -// // Since this is how we retrieve a service from Central, use the same values as the key to the hash -// String wsdlCacheKey = mobyService.getName() + "@" + mobyService.getAuthority(); - -// // This is the same call as last time, so we don't need to change the setup -// if(wsdlCacheKey.equals(lastWsdlCacheKey)){ -// return setCallFromWSDL((String) wsdlCache.get(wsdlCacheKey)); -// } -// // We haven't encountered this service yet -// else if(!wsdlCache.containsKey(wsdlCacheKey)){ -// wsdl = mobyCentral.getServiceWSDL(mobyService.getName(), mobyService.getAuthority()); -// wsdlCache.put(wsdlCacheKey, wsdl); -// } -// // We've dealt with this one before -// else{ -// wsdl = (String) wsdlCache.get(wsdlCacheKey); -// } - -// lastWsdlCacheKey = wsdlCacheKey; // Keep track of the last invocation - - // Get ready to do SOAP -//PG return setCallFromWSDL(null); -// } - - /** * Creates the SOAP Call that will be invoked later. This should be based on the WSDL document * and parameter information from the MobyService, but these are currently not up to snuff. */ =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEvent.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEvent.java 2007/06/08 14:04:27 1.5 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEvent.java 2010/03/17 20:55:51 1.6 @@ -18,17 +18,19 @@ protected int eventID; protected MobyContentInstance contents; protected MobyRequest originatingMobyRequest; + protected MobyContentInstance originatingMobyRequestInputData; protected String dataPayloadXML; protected MobyService service; protected Throwable exception; private static int nextEventID = 0; - public MobyRequestEvent(MobyContentInstance mci, MobyRequest requestSource, MobyService serv, Throwable e, int id){ + public MobyRequestEvent(MobyContentInstance mci, MobyRequest requestSource, MobyService serv, MobyContentInstance serviceInput, Throwable e, int id){ consumed = false; done = false; - contents = mci; + contents = mci; originatingMobyRequest = requestSource; + originatingMobyRequestInputData = serviceInput; exception = e; eventID = id; service = serv; @@ -42,6 +44,24 @@ } /** + * This method should be used instead of getSource().getInput() because the MobyRequest object may have multiple + * concurrent threads using it, meaning that the inputXML is not necessarily what it was when the service was + * invoked. + * + * @return if a Moby client waiting for a service response, this data is the payload given as input to the service + */ + public MobyContentInstance getSourceInput(){ + return originatingMobyRequestInputData; + } + + /** + * @param inputXML the Moby XML sent to the service this event is refering to. + */ + public void setSourceInput(MobyContentInstance inputPayload){ + originatingMobyRequestInputData = inputPayload; + } + + /** * @return the contents of the MOBY request or response (depending on whether MobyRequest is acting as a client or server) */ public MobyContentInstance getContent(){ From gordonp at dev.open-bio.org Wed Mar 17 20:57:28 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:57:28 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172057.o2HKvSO4012677@dev.open-bio.org> gordonp Wed Mar 17 16:57:28 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory dev.open-bio.org:/tmp/cvs-serv12641/src/main/org/biomoby/shared Modified Files: MobyData.java Log Message: Added methods to allow association of a random application-specific objects with the Moby data moby-live/Java/src/main/org/biomoby/shared MobyData.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyData.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyData.java 2008/01/07 22:11:36 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyData.java 2010/03/17 20:57:28 1.7 @@ -25,6 +25,9 @@ protected String name; protected String id = null; + /** Convenience for applications to associate any data with the Moby objects as needed for the + application's particular purpose. Inspired by Java3D's scenegraph customization method. */ + protected Object userData = null; /************************************************************************** * Default constructor. @@ -54,6 +57,24 @@ public void setId (String value) { id = value; } + + /** + * Retrieves any application-specific data that may have been stored in association with this Moby object. + * The returned object has nothing to do with the Moby protocol itself. See setUserData() for more details. + */ + public Object getUserData(){ + return userData; + } + + /** + * Allows developers to track their application-specific information alongside the Moby functionality. + * Provided for application developers' convenience: data stored using this routine is completely + * ignore by the Moby core libraries. If you want to store Moby data, use the routines defined in various + * subclasses of this class (e.g. MobyDataObject). + */ + public void setUserData(Object data){ + userData = data; + } /************************************************************************** * Must be overwritten by a subclass. From gordonp at dev.open-bio.org Wed Mar 17 20:57:59 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:57:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172057.o2HKvxFs012721@dev.open-bio.org> gordonp Wed Mar 17 16:57:59 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv12685/src/main/org/biomoby/shared/data Modified Files: MobyDataInstance.java Log Message: Added methods to allow association of a random application-specific objects with the Moby data moby-live/Java/src/main/org/biomoby/shared/data MobyDataInstance.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInstance.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInstance.java 2006/07/07 04:12:40 1.3 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataInstance.java 2010/03/17 20:57:59 1.4 @@ -36,6 +36,20 @@ */ public Object getObject(); + /** + * Retrieves any application-specific data that may have been stored in association with this Moby object. + * The returned object has nothing to do with the Moby protocol itself. See setUserData() for more details. + */ + public Object getUserData(); + + /** + * Allows developers to track their application-specific information alongside the Moby functionality. + * Provided for application developers' convenience: data stored using this routine is completely + * ignore by the Moby core libraries. If you want to store Moby data, use the routines defined in various + * subclasses of this class (e.g. MobyDataObject). + */ + public void setUserData(Object data); + public void setName(String name); public String getName(); } From gordonp at dev.open-bio.org Wed Mar 17 20:58:33 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:58:33 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172058.o2HKwXY1012769@dev.open-bio.org> gordonp Wed Mar 17 16:58:33 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv12729/src/main/org/biomoby/shared/data Modified Files: MobyDataObjectSAI.java MobyDataObjectSetSAI.java Log Message: Added methods to allow association of a random application-specific objects with the Moby data moby-live/Java/src/main/org/biomoby/shared/data MobyDataObjectSAI.java,1.4,1.5 MobyDataObjectSetSAI.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSAI.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSAI.java 2008/01/07 22:11:36 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSAI.java 2010/03/17 20:58:33 1.5 @@ -78,6 +78,14 @@ dataInstance.setXmlMode(mode); } + public Object getUserData(){ + return dataInstance.getUserData(); + } + + public void setUserData(Object data){ + dataInstance.setUserData(data); + } + public String getValue(){ return dataInstance.getValue(); } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSetSAI.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSetSAI.java 2007/12/06 23:42:55 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataObjectSetSAI.java 2010/03/17 20:58:33 1.5 @@ -96,6 +96,14 @@ return dataInstance.getElements(); } + public Object getUserData(){ + return dataInstance.getUserData(); + } + + public void setUserData(Object data){ + dataInstance.setUserData(data); + } + public Object getObject(){ return dataInstance.getObject(); } From gordonp at dev.open-bio.org Wed Mar 17 20:59:15 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 16:59:15 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172059.o2HKxFdq012835@dev.open-bio.org> gordonp Wed Mar 17 16:59:15 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data In directory dev.open-bio.org:/tmp/cvs-serv12799/src/main/org/biomoby/shared/data Modified Files: MobyDataUtils.java Log Message: Fixed error messages moby-live/Java/src/main/org/biomoby/shared/data MobyDataUtils.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataUtils.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/shared/data/MobyDataUtils.java 2007/08/23 14:41:43 1.9 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/data/MobyDataUtils.java 2010/03/17 20:59:15 1.10 @@ -196,9 +196,10 @@ throw new MobyException("The passed in element was null"); } if(!MobyTags.MOBY.equals(doc_root.getLocalName())){ - throw new MobyException("The XML document's root element (" + + throw new MobyException("The XML document's root element (local " + doc_root.getLocalName() + - ") was not " + MobyTags.MOBY); + ", qualified " + doc_root.getNodeName() + + " ) was not " + MobyTags.MOBY); } NodeList envelope = null; if(!MobyPrefixResolver.MOBY_XML_NAMESPACE.equals(doc_root.getNamespaceURI())){ From gordonp at dev.open-bio.org Wed Mar 17 21:00:14 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 17:00:14 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172100.o2HL0Ek7013173@dev.open-bio.org> gordonp Wed Mar 17 17:00:14 EDT 2010 Update of /home/repository/moby/moby-live/Java/xmls In directory dev.open-bio.org:/tmp/cvs-serv13117/xmls Modified Files: project.pom Log Message: Added Apache Commons' fileupload, and the jTidy packages moby-live/Java/xmls project.pom,1.18,1.19 =================================================================== RCS file: /home/repository/moby/moby-live/Java/xmls/project.pom,v retrieving revision 1.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- /home/repository/moby/moby-live/Java/xmls/project.pom 2009/11/29 18:33:11 1.18 +++ /home/repository/moby/moby-live/Java/xmls/project.pom 2010/03/17 21:00:14 1.19 @@ -535,6 +535,18 @@ 1.0 + + commons-fileupload + commons-fileupload + 1.2 + + + + jtidy + jtidy + 4aug2000r7-dev + + From gordonp at dev.open-bio.org Wed Mar 17 21:14:31 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 17 Mar 2010 17:14:31 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003172114.o2HLEVlf013504@dev.open-bio.org> gordonp Wed Mar 17 17:14:31 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/webapps/WEB-INF In directory dev.open-bio.org:/tmp/cvs-serv13468/src/webapps/WEB-INF Modified Files: cgiweb.xml Log Message: Made local test resource for CGI wrapping to Moby service moby-live/Java/src/webapps/WEB-INF cgiweb.xml,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/webapps/WEB-INF/cgiweb.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/webapps/WEB-INF/cgiweb.xml 2008/02/14 05:45:42 1.2 +++ /home/repository/moby/moby-live/Java/src/webapps/WEB-INF/cgiweb.xml 2010/03/17 21:14:31 1.3 @@ -25,7 +25,8 @@ is the key parameter to change. --> htmlFormURL - http://biomoby.open-bio.org/CVS_CONTENT/moby-live/Java/src/main/ca/ucalgary/services/util/test/osprey_pcr.html + ca/ucalgary/services/util/test/osprey_pcr.html + From gordonp at dev.open-bio.org Fri Mar 26 18:08:19 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 26 Mar 2010 14:08:19 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003261808.o2QI8JvD003003@dev.open-bio.org> gordonp Fri Mar 26 14:08:18 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared In directory dev.open-bio.org:/tmp/cvs-serv2967/src/main/org/biomoby/shared Modified Files: MobyDataType.java Log Message: Fixed registry association with objects returned by getDataType method (was always null) moby-live/Java/src/main/org/biomoby/shared MobyDataType.java,1.26,1.27 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2008/10/30 02:33:25 1.26 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/shared/MobyDataType.java 2010/03/26 18:08:18 1.27 @@ -116,6 +116,9 @@ } try{ datatypes = central.getDataTypes(); + for(MobyDataType type: datatypes){ + type.setRegistry(reg); // isn't set properly by the parser called above + } datatypesMapByURL.put(reg == null ? "" : reg.getEndpoint(), datatypes); } catch(Exception e){ @@ -369,7 +372,7 @@ * Searches the ontology lineage of the current data type against the data type corresponding to the provided name. */ public boolean inheritsFrom(String otherTypeName){ - return inheritsFrom(getDataType(otherTypeName)); + return inheritsFrom(getDataType(otherTypeName, getRegistry())); } /** From gordonp at dev.open-bio.org Fri Mar 26 19:52:01 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Fri, 26 Mar 2010 15:52:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003261952.o2QJq1Um006052@dev.open-bio.org> gordonp Fri Mar 26 15:52:00 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv6016/src/main/org/biomoby/client Modified Files: CentralImpl.java Log Message: Got rid of 'Central class is' message unless moby.debug system variable is set moby-live/Java/src/main/org/biomoby/client CentralImpl.java,1.62,1.63 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java 2010/02/09 02:07:24 1.62 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java 2010/03/26 19:52:00 1.63 @@ -1904,7 +1904,9 @@ } } try{ - System.err.println("Central class is "+className); + if(Boolean.getBoolean("moby.debug")){ + System.err.println("Central class is "+className+ " for " + reg); + } Class clazz = Class.forName(className); if(reg == null){ // should use default nullary c-tor defaultCentrals.put("", (CentralImpl) clazz.newInstance()); From gordonp at dev.open-bio.org Mon Mar 29 16:38:33 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 12:38:33 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291638.o2TGcXfG004765@dev.open-bio.org> gordonp Mon Mar 29 12:38:33 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util In directory dev.open-bio.org:/tmp/cvs-serv4729/src/main/ca/ucalgary/services/util Modified Files: IOUtils.java Log Message: Payload reporting moved from warning to info level moby-live/Java/src/main/ca/ucalgary/services/util IOUtils.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/IOUtils.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/IOUtils.java 2010/03/17 20:17:39 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/IOUtils.java 2010/03/29 16:38:33 1.3 @@ -91,7 +91,7 @@ // } if(sb.length() < 10000){ - logger.log(Level.WARNING, sb); + logger.log(Level.INFO, sb); } Document respDoc = getDocBuilder().parse(new ByteArrayInputStream(byteBuffer.toByteArray())); NodeList bodyList = respDoc.getElementsByTagNameNS("http://schemas.xmlsoap.org/soap/envelope/", From gordonp at dev.open-bio.org Mon Mar 29 19:46:19 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:46:19 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291946.o2TJkJQ2010128@dev.open-bio.org> gordonp Mon Mar 29 15:46:18 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv10092/src/main/ca/ucalgary/seahawk/gui Modified Files: FileAndTextTransferHandler.java Log Message: Pushed debug statements to proper logging moby-live/Java/src/main/ca/ucalgary/seahawk/gui FileAndTextTransferHandler.java,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java 2009/06/09 19:33:15 1.9 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/FileAndTextTransferHandler.java 2010/03/29 19:46:18 1.10 @@ -70,7 +70,9 @@ URL u = HTMLUtils.checkForURLShortcut(file); // Was it a shortcut file after all? if(u != null){ - System.err.println("Dropped item appears to be a URL shortcut..."); + if(Boolean.getBoolean("moby.debug")){ + System.err.println("Dropped item appears to be a URL shortcut..."); + } if(clipboard != null){ clipboard.addCollectionData(u); } @@ -80,7 +82,9 @@ } // Any other type of file is loaded as-is else{ - System.err.println("Dropped item appears to be a file..."); + if(Boolean.getBoolean("moby.debug")){ + System.err.println("Dropped item appears to be a file..."); + } if(clipboard != null){ clipboard.addCollectionData(file.toURI().toURL()); } @@ -106,7 +110,9 @@ // Not a URL, oh well, move on to string handling... } if(u != null){ - System.err.println("Dropped item appears to be a URL..."); + if(Boolean.getBoolean("moby.debug")){ + System.err.println("Dropped item appears to be a URL..."); + } if(clipboard != null){ clipboard.addCollectionData(u); } @@ -127,7 +133,9 @@ // the proper object to load MobyContentInstance content = HTMLUtils.checkForMobyXML(text); if(content != null){ - System.err.println("Dropped item appears to be moby xml..."); + if(Boolean.getBoolean("moby.debug")){ + System.err.println("Dropped item appears to be moby xml..."); + } if(clipboard != null){ clipboard.addCollectionData(content); } From gordonp at dev.open-bio.org Mon Mar 29 19:47:02 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:47:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291947.o2TJl2Ss010172@dev.open-bio.org> gordonp Mon Mar 29 15:47:02 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv10136/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentClipboard.java Log Message: Updated to reflect DataRecorder -> DataFlowRecorder name change moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentClipboard.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.java 2009/06/09 19:32:23 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentClipboard.java 2010/03/29 19:47:02 1.8 @@ -48,7 +48,7 @@ private MobyDataInstance itemToDelete; private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobyContentClipboard.class); public MobyContentClipboard(MobyContentGUI cGUI, MobyServicesGUI sGUI, JTabbedPane parentComponent, - DataRecorder recorder, JLabel statusBar){ + DataFlowRecorder recorder, JLabel statusBar){ super(cGUI, sGUI, parentComponent, recorder, statusBar); ClassLoader cl = getClass().getClassLoader(); From gordonp at dev.open-bio.org Mon Mar 29 19:48:29 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:48:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291948.o2TJmTjm010216@dev.open-bio.org> gordonp Mon Mar 29 15:48:28 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv10180/src/main/org/biomoby/client Modified Files: CentralImpl.java Log Message: Updated to standard META-INF/services mechanism to get CentralImpl moby-live/Java/src/main/org/biomoby/client CentralImpl.java,1.63,1.64 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java,v retrieving revision 1.63 retrieving revision 1.64 diff -u -r1.63 -r1.64 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java 2010/03/26 19:52:00 1.63 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralImpl.java 2010/03/29 19:48:28 1.64 @@ -128,7 +128,7 @@ * default class should be instantiated in order to create a Central Implementation * when getDefaultCentral() is called. */ - public static final String CENTRAL_IMPL_RESOURCE_NAME = "org.biomoby.shared.CentralDefaultImpl"; + public static final String CENTRAL_IMPL_RESOURCE_NAME = "org.biomoby.client.CentralImpl"; /** The class to use for getDefaultCentral if all else fails */ public static final String DEFAULT_CENTRAL_IMPL_CLASSNAME = "org.biomoby.client.CentralDigestCachedImpl"; private static Logger logger = Logger.getLogger("org.biomoby.client.CentralImpl"); @@ -1886,7 +1886,7 @@ String className = DEFAULT_CENTRAL_IMPL_CLASSNAME; ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - URL resURL = classLoader.getResource("META-INF/"+CENTRAL_IMPL_RESOURCE_NAME); + URL resURL = classLoader.getResource("META-INF/services/"+CENTRAL_IMPL_RESOURCE_NAME); if(resURL != null){ System.err.println("Loading "+resURL); try{ From gordonp at dev.open-bio.org Mon Mar 29 19:49:32 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:49:32 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291949.o2TJnV87010300@dev.open-bio.org> gordonp Mon Mar 29 15:49:31 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services In directory dev.open-bio.org:/tmp/cvs-serv10264/src/main/ca/ucalgary/services Modified Files: CGIServlet.java Log Message: Made jTidy quiet moby-live/Java/src/main/ca/ucalgary/services CGIServlet.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/CGIServlet.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/CGIServlet.java 2010/03/17 20:16:49 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/CGIServlet.java 2010/03/29 19:49:31 1.2 @@ -62,6 +62,7 @@ Tidy tidy = new Tidy(); tidy.setXHTML(true); + tidy.setQuiet(true); tidy.setShowWarnings(false); Document htmlDoc = tidy.parseDOM(is, null); From gordonp at dev.open-bio.org Mon Mar 29 19:49:53 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:49:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291949.o2TJnrFQ010344@dev.open-bio.org> gordonp Mon Mar 29 15:49:52 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv10308/src/main/ca/ucalgary/seahawk/util Modified Files: FilterSearch.java Log Message: Fixed id and article name xpaths moby-live/Java/src/main/ca/ucalgary/seahawk/util FilterSearch.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/FilterSearch.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/FilterSearch.java 2010/03/17 20:08:25 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/FilterSearch.java 2010/03/29 19:49:52 1.2 @@ -54,12 +54,12 @@ elementNames.put("//"+data.getLocalName(), "element " + data.getLocalName()); } else if(data.getAttribute(MobyTags.OBJ_ID).length() > 0){ // or an id - elementNames.put("//*[@id]", "ID"); + elementNames.put("//*/@id", "ID"); } } if(articleName != null && articleName.trim().length() != 0 && !memberNames.containsKey(articleName)){ - memberNames.put("//*[@"+MobyTags.ARTICLENAME+"='"+articleName+"'", "field "+articleName); + memberNames.put("//*[@"+MobyTags.ARTICLENAME+"='"+articleName+"']", "field "+articleName); } } } From gordonp at dev.open-bio.org Mon Mar 29 19:50:54 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:50:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291950.o2TJosZ7010388@dev.open-bio.org> gordonp Mon Mar 29 15:50:54 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv10352/src/main/ca/ucalgary/seahawk/util Modified Files: PrintableJEditorPane.java Log Message: Now extends JTextArea to allow fancier display manipulation moby-live/Java/src/main/ca/ucalgary/seahawk/util PrintableJEditorPane.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/PrintableJEditorPane.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/PrintableJEditorPane.java 2007/02/08 16:59:58 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/PrintableJEditorPane.java 2010/03/29 19:50:54 1.3 @@ -6,7 +6,7 @@ import java.awt.print.PageFormat; import java.awt.print.Printable; import java.awt.print.PrinterException; -import javax.swing.JEditorPane; +import javax.swing.JTextPane; import javax.swing.RepaintManager; /** @@ -14,7 +14,7 @@ * * @author Paul Gordon (gordonp at ucalgary.ca) */ -public class PrintableJEditorPane extends JEditorPane implements Printable{ +public class PrintableJEditorPane extends JTextPane implements Printable{ public int print (Graphics g, PageFormat pf, int pageIndex) throws PrinterException{ Graphics2D g2 = (Graphics2D) g; From gordonp at dev.open-bio.org Mon Mar 29 19:51:52 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:51:52 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291951.o2TJpqlD010432@dev.open-bio.org> gordonp Mon Mar 29 15:51:51 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv10396/src/main/ca/ucalgary/seahawk/resources Modified Files: moby2HTML.xsl Log Message: Added span elements to facilitate Seahawk grey-out/highlight of filter function moby-live/Java/src/main/ca/ucalgary/seahawk/resources moby2HTML.xsl,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/moby2HTML.xsl,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/moby2HTML.xsl 2010/03/17 20:21:55 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/moby2HTML.xsl 2010/03/29 19:51:51 1.6 @@ -172,9 +172,10 @@ + -
(ID :)
+
@@ -219,26 +220,26 @@ - ID : () + ID : () - String : ():
+ String : ():
- ():
+ ():
-
MOBY Data for query
+ From gordonp at dev.open-bio.org Mon Mar 29 19:52:30 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:52:30 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291952.o2TJqUuB010476@dev.open-bio.org> gordonp Mon Mar 29 15:52:30 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv10440/src/main/ca/ucalgary/seahawk/gui Modified Files: WorkflowPreviewDialog.java Log Message: DataRecorder -> DataFlowRecorder moby-live/Java/src/main/ca/ucalgary/seahawk/gui WorkflowPreviewDialog.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/WorkflowPreviewDialog.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/WorkflowPreviewDialog.java 2010/03/17 20:20:09 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/WorkflowPreviewDialog.java 2010/03/29 19:52:30 1.2 @@ -14,7 +14,7 @@ import java.net.*; import java.util.*; import javax.swing.*; -import ca.ucalgary.seahawk.util.DataRecorder; +import ca.ucalgary.seahawk.util.DataFlowRecorder; import ca.ucalgary.seahawk.util.FilterSearch; public class WorkflowPreviewDialog extends JDialog implements ActionListener{ @@ -32,23 +32,23 @@ private WorkflowPreviewListener listener; private ByteArrayOutputStream byteArrayBuffer; private String workflowName; - private DataRecorder dataRecorder; + private DataFlowRecorder dataFlowRecorder; private Map resultList; - public WorkflowPreviewDialog(Frame owner, Map resultList, DataRecorder dataRecorder, + public WorkflowPreviewDialog(Frame owner, Map resultList, DataFlowRecorder dataFlowRecorder, String workflowName, WorkflowPreviewListener wpl) throws Exception{ super(owner, "Workflow Preview", true); this.workflowName = workflowName; - this.dataRecorder = dataRecorder; + this.dataFlowRecorder = dataFlowRecorder; this.resultList = resultList; String workflowTitle = workflowName; String workflowDescription = null; String workflowAuthor = null; byteArrayBuffer = new ByteArrayOutputStream(); - dataRecorder.exportWorkflow(resultList, byteArrayBuffer, workflowName, workflowTitle, - workflowDescription, workflowAuthor, DataRecorder.T2FLOW); + dataFlowRecorder.exportWorkflow(resultList, byteArrayBuffer, workflowName, workflowTitle, + workflowDescription, workflowAuthor, DataFlowRecorder.T2FLOW); ByteArrayOutputStream pngData = new ByteArrayOutputStream(); @@ -133,13 +133,13 @@ byteArrayBuffer = new ByteArrayOutputStream(); // recreate the workflow with the additional metadata try{ - dataRecorder.exportWorkflow(resultList, - byteArrayBuffer, - workflowName, - workflowTitle, - workflowDescription, - workflowAuthor, - DataRecorder.T2FLOW); + dataFlowRecorder.exportWorkflow(resultList, + byteArrayBuffer, + workflowName, + workflowTitle, + workflowDescription, + workflowAuthor, + DataFlowRecorder.T2FLOW); }catch(Exception ex){ ex.printStackTrace(); JOptionPane.showMessageDialog(null, From gordonp at dev.open-bio.org Mon Mar 29 19:53:16 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:53:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291953.o2TJrGqt010520@dev.open-bio.org> gordonp Mon Mar 29 15:53:16 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv10484/src/main/ca/ucalgary/seahawk/gui Modified Files: MobySaveDialog.java Log Message: Updated to reflect DataRecorder -> DataFlowRecorder name change moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobySaveDialog.java,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java 2010/03/17 20:21:55 1.7 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java 2010/03/29 19:53:16 1.8 @@ -193,7 +193,7 @@ try { // See if there is more than one result tab open - DataRecorder dataRecorder = null; + DataFlowRecorder dataRecorder = null; Map resultsToProduce = new LinkedHashMap(); boolean currentTabHasResults = false; javax.swing.JTabbedPane tabbedPane = tab.getTabbedPaneParent(); @@ -201,7 +201,7 @@ MobyContentPane document = (MobyContentPane) tabbedPane.getComponentAt(tabIndex); if(document.hasXMLSource()){ if(dataRecorder == null){ - dataRecorder = document.getDataRecorder(); + dataRecorder = document.getDataFlowRecorder(); } if(document == tab){ currentTabHasResults = true; @@ -215,7 +215,7 @@ } } if(dataRecorder == null){ - JOptionPane.showMessageDialog(null, "Could not find the DataRecorder needed for " + + JOptionPane.showMessageDialog(null, "Could not find the DataFlowRecorder needed for " + "workflow export. Please contact gordonp at ucalgary.ca " + "with this error message.", "Internal Error", From gordonp at dev.open-bio.org Mon Mar 29 19:54:36 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:54:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291954.o2TJsajU010604@dev.open-bio.org> gordonp Mon Mar 29 15:54:36 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv10568/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentPane.java Log Message: Filter update moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentPane.java,1.22,1.23 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v retrieving revision 1.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2010/03/17 20:21:55 1.22 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2010/03/29 19:54:36 1.23 @@ -12,6 +12,7 @@ import org.biomoby.client.MobyRequest; import org.biomoby.client.MobyRequestEvent; import org.biomoby.client.MobyRequestEventHandler; +import org.biomoby.registry.meta.Registry; import org.biomoby.shared.*; import org.biomoby.shared.data.*; import org.biomoby.shared.parser.MobyTags; @@ -23,13 +24,28 @@ import javax.xml.parsers.*; import javax.xml.transform.*; import javax.xml.transform.stream.*; - import javax.xml.xpath.*; import javax.swing.*; import javax.swing.event.*; - -import java.awt.*; +import javax.swing.text.AttributeSet; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.DefaultHighlighter; +import javax.swing.text.Highlighter; +import javax.swing.text.Style; +import javax.swing.text.StyleConstants; +import javax.swing.text.StyledDocument; +import javax.swing.text.html.HTML; +import javax.swing.text.html.HTMLDocument; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Cursor; +import java.awt.Desktop; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Toolkit; import java.awt.datatransfer.*; import java.awt.print.*; import java.awt.event.*; @@ -37,6 +53,7 @@ import java.net.URL; import java.net.URLConnection; import java.util.*; +import java.util.regex.*; /** * Text area contained in a Seahawk GUI tab. Displays HTML, RTF, text etc. using a JEditorPane. @@ -83,7 +100,16 @@ private int lastClickY = 1; private boolean hasFailed = false; private boolean isContentsXML = false; - private DataRecorder dataRecorder; + private DataFlowRecorder dataRecorder; + private List xPtrsReferencedInNextService; + private Map filteredData; //Map + private boolean filterChanged; + private Document currentDoc; //the doc DOM being actively filtered + private NodeList currentSelectedData = null; + private String currentSelectionXPath = null; + private List filterableNodes = null; // List + private List origStyles = null; + private boolean firstDocRendering = true; // Next two items used for service wrapping private JMenuItem createServicePopupItem; @@ -114,8 +140,22 @@ private final static String wsServletPath = "/SOAPServlet"; private static Acme.Serve.Serve servletContainer; private static Map id2GuiMap; + private static DocumentBuilder docBuilder; + private static XPathFactory xPathFactory; + + static{ + xPathFactory = XPathFactory.newInstance(); + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + dbf.setNamespaceAware(true); + try{ + docBuilder = dbf.newDocumentBuilder(); + } catch(Exception e){ + logger.warn("Cannot get XML parser from configuration", e); + } + } - public MobyContentPane(MobyContentGUI cGUI, MobyServicesGUI sGUI, JTabbedPane parentComponent, DataRecorder recorder, JLabel statusBar){ + public MobyContentPane(MobyContentGUI cGUI, MobyServicesGUI sGUI, JTabbedPane parentComponent, DataFlowRecorder recorder, JLabel statusBar){ tabbedPane = parentComponent; status = statusBar; contentGUI = cGUI; @@ -158,6 +198,8 @@ historyTabLabels = new HashMap(); filterHistory = new HashMap(); deletedFilters = new HashMap(); + xPtrsReferencedInNextService = new Vector(); + filteredData = new HashMap(); ClassLoader cl = getClass().getClassLoader(); if(cl == null){ @@ -198,7 +240,7 @@ return tabbedPane; } - public DataRecorder getDataRecorder(){ + public DataFlowRecorder getDataFlowRecorder(){ return dataRecorder; } @@ -391,7 +433,7 @@ } })); new Thread(){public void run(){srv.serve();}}.start(); - + PBERecorder recorder = new PBERecorder(); recorder.setGUIMap(id2GuiMap); servlet.setRecorder(recorder); @@ -400,6 +442,9 @@ srv.addServlet(servletPath, servlet); // our deployment } else if(contentGUI.getServletContainer().getServlet(servletPath) == null){ + PBERecorder recorder = new PBERecorder(); + recorder.setGUIMap(id2GuiMap); + servlet.setRecorder(recorder); contentGUI.getServletContainer().addServlet(servletPath, servlet); } @@ -694,12 +739,21 @@ } // If this page has a filter associated with it before reload it try{ + currentDoc = null; // get rid of previous in-memory doc use for interactive filtering, if any + currentSelectedData = null; + currentSelectionXPath = null; + filterableNodes = null; + origStyles = null; + firstDocRendering = true; + editorPane.getHighlighter().removeAllHighlights(); + if(filterHistory.containsKey(url)){ setFilterVisible(true); } else{ setFilterVisible(false); } + filterChanged = false; } catch(Exception e){ logger.warn("Could not enable filter history for this document: "+e.getMessage(), e); } @@ -729,17 +783,69 @@ } public boolean canGoForward(){ - return historyIndex < history.size()-1; + return historyIndex < history.size()-1 && isFilterForwardConsistent(); + } + + /** + * If the filter condition has changed since the next service was originally called, + * only allow navigation to that document (service results) again if the new filter allows + * the data used in the original call to pass (for logical dataflow consistency). + */ + public boolean isFilterForwardConsistent(){ + // If there is no forward doc, it is consistent I suppose + if(historyIndex == history.size()-1){ + contentGUI.setForwardButtonToolTip(null); + return true; + } + // If no filter on current doc, we must be okay to go forward + if(getFilter() == null){ + contentGUI.setForwardButtonToolTip(null); + return true; + } + + // Get the data from this doc used as the input to the forward document + if(xPtrsReferencedInNextService == null){ + try{ + xPtrsReferencedInNextService = DataUtils.getInputXPtrs(history.elementAt(historyIndex+1), history.elementAt(historyIndex)); + } catch(Exception e){ + logger.error("Cannot get the provenance data from "+history.elementAt(historyIndex+1), e); + } + + } + // See if all the particular data from this doc that was used in the next service is still avaialble after + // applying the current version of the filter + for(String usedxPtr: xPtrsReferencedInNextService){ + for(String filteredXPtr: filteredData.keySet()){ + if(usedxPtr.equals(filteredXPtr) || + usedxPtr.startsWith(filteredXPtr+"/")){ + // the data used in the next service is filtered in the current view, not consistent to allow forward button + // give the person a reason the forward is disabled + contentGUI.setForwardButtonToolTip("Cannot go forward to next doc, the corresponding service
"+ + "depended on input data that is now filtered. Reset the data filter
"+ + "to be able to go forward again"); + return false; + } + } + } + + // If they differ, check that the forward doc's input src is not filtered out currently + contentGUI.setForwardButtonToolTip(null); + return true; } public void goForward(){ if(canGoForward()){ + if(filterChanged){ + DataUtils.updateInputFilter(history.elementAt(historyIndex+1), history.elementAt(historyIndex), getFilter()); + } gotoURL(history.elementAt(++historyIndex), false); + xPtrsReferencedInNextService = null; } } public void goBackward(){ if(canGoBack()){ + xPtrsReferencedInNextService = null; gotoURL(history.elementAt(--historyIndex), false); } } @@ -889,7 +995,7 @@ } try { - URL outputURL = dataRecorder.saveOutputData(mre); + URL outputURL = DataUtils.saveOutputData(mre); gotoURL(outputURL, true); } catch (Exception e) { failed("Could not write a local file"); @@ -1009,8 +1115,13 @@ logger.warn("Failed: could not get hyperlink host: " + targetURL); } else if(isMobyURL(targetURL)){ - status.setText("Retrieving service list for selected data"); - showMobyOptions(targetURL); + if(isLinkEnabled(targetURL)){ + status.setText("Retrieving service list for selected data"); + showMobyOptions(targetURL); + } + else{ + status.setText("Change the data filter to re-enable this link"); + } } // External, hopefully HTML link else{ @@ -1023,7 +1134,12 @@ overHyperlink = true; lastHyperlinkHovered = targetURL; if(isMobyURL(targetURL)){ - status.setText("Click to discover more Moby services, or drag onto a Web form"); + if(isLinkEnabled(targetURL)){ + status.setText("Click to discover more Moby services, or drag onto a Web form"); + } + else{ + status.setText("This link is current disabled because of the data filter."); + } } else if(targetURL == null){ String desc = he.getDescription(); @@ -1042,6 +1158,19 @@ } } + private boolean isLinkEnabled(URL url){ + String ref = url.getRef(); + if(ref == null || ref.length() == 0){ + return true; + } + for(String disabledXPtr: filteredData.keySet()){ + if(ref.equals(disabledXPtr) || ref.startsWith(disabledXPtr+"/")){ + return false; + } + } + return true; + } + public MobyDataInstance getDraggedData(){ return urlToMobyData(lastHyperlinkDragged); } @@ -1054,9 +1183,8 @@ String docFragID = targetURL.getRef(); // We store the xpath in the anchor part of the URL // Complex case, load the doc fragment from the MOBY XML source file - if(docFragID != null && docFragID.length() > 0 && contentGUI.getDocumentBuilder() != null && - !targetURL.getHost().equals("moby")){ - return loadMobyDataFromXPointer(targetURL); + if(docFragID != null && docFragID.length() > 0 && !targetURL.getHost().equals("moby")){ + return DataUtils.loadMobyDataFromXPointer(targetURL, filterHistory.get(getCurrentURL())); } // Simple case, build the object using the values encoded in the URL itself @@ -1208,164 +1336,334 @@ return mobyData; } - protected MobyDataInstance loadMobyDataFromXPointer(URL targetURL){ - // Are we dealing with a simple object or a complex one? - MobyDataInstance mobyData = null; - - // Find the DOM fragment corresponding to the MOBY ID anchor specified - // in the link URL by using an XPath statement on the source MOBY doc - //System.err.println("Retrieving complex object from XPointer " + targetURL); - - // A child Xpointer is of the form /1/2/1/1, specifying the DOM child - // descent path from the root node to get to the target node. The - // equivalent XPath is /*[1]/*[2]/*[1]/*[1] - String childXPath = targetURL.getRef().replaceAll("/(\\d+)", "/*[$1]"); - URL currentURL = null; - try{currentURL = new URL(targetURL.toString().replaceAll("#"+targetURL.getRef(), ""));} - catch(Exception e){ - logger.error("Couldn't extract referenceless URL from " + targetURL); - } - // Build the DOM - Element mobyDOMRoot = null; - Document domDoc = null; - try{ - domDoc = contentGUI.getDocumentBuilder().parse(targetURL.openStream()); - } catch(org.xml.sax.SAXException saxe){ - logger.error("The document defining the MOBY data " + - "could not be parsed: " + saxe); - return null; - } catch(java.io.IOException ioe){ - logger.error("The document defining the MOBY data " + - " could not be read (from " + targetURL + "): " + ioe); + /** + * Gets the filter criteria currently being applied to the document being viewed. + * + * @return null unless there is a currently a non-blank filter criteria + */ + public FilterSearch getFilter(){ + if(getCurrentURL() == null){ return null; } - - if(domDoc != null){ - mobyDOMRoot = domDoc.getDocumentElement(); + FilterSearch fs = filterHistory.get(getCurrentURL()); + if(fs != null && fs.getFilterRegex().length() > 0){ + return fs; } - if(mobyDOMRoot == null){ - logger.warn("Error: Could not get MOBY document as DOM from source URL " - + targetURL + " (empty or malformed document?)"); - return null; + return null; + } + + /** + * Determine the parts of the XML document matching the FilterSearch criteria, and filter the view accordingly. + */ + public void applyFilter(boolean apply){ + if(!filterChanged){ + filterChanged = true; } - - // Build and run the XPath statement - Element mobyObject = null; - NodeList idSearchResult = null; - Object xobject = null; - try{ - xobject = XPathFactory.newInstance().newXPath().evaluate(childXPath, - new InputSource(targetURL.openStream()), - XPathConstants.NODESET); - - // Check the results - if(xobject != null){ - idSearchResult = (NodeList) xobject; + filteredData.clear(); + + if(currentDoc == null){ // parse the doc into memory if not already there + try{ + currentDoc = docBuilder.parse(getCurrentURL().openStream()); + } catch(Exception e){ + logger.error("Could not parse Moby document " + getCurrentURL(), e); + return; + } + } + // Filter out any moby jobs, parameters, collection members or HAS members that aren't in the matchingNodes + if(filterableNodes == null){ + filterableNodes = new Vector(); + NodeList nodes = currentDoc.getElementsByTagNameNS(MobyTags.MOBY_XML_NS, MobyTags.MOBYDATA); + for(int i = 0; i < nodes.getLength(); i++){ + filterableNodes.add(getXPtr(nodes.item(i))); + addHASXPtrs(filterableNodes, (Element) nodes.item(i)); + } + + // Collections + nodes = currentDoc.getElementsByTagNameNS(MobyTags.MOBY_XML_NS, MobyTags.COLLECTION); + for(int i = 0; i < nodes.getLength(); i++){ + String collectionXPtr = getXPtr(nodes.item(i)); + NodeList collectionMembers = nodes.item(i).getChildNodes(); + int nonElementCnt = 0; + for(int j = 0; j < collectionMembers.getLength(); j++){ + if(!(collectionMembers.item(j) instanceof Element)){ + nonElementCnt++; + continue; + } + filterableNodes.add(collectionXPtr+"/"+(j-nonElementCnt+1)+"/1"); + } + } + } + + if(!apply || !filterHistory.containsKey(getCurrentURL()) || + (filterHistory.containsKey(getCurrentURL()) && + filterHistory.get(getCurrentURL()).getFilterRegex().toString().length() == 0)){ + // Show whole doc if no filter or if filter is blank, so nothing to do here + if(firstDocRendering){ + firstDocRendering = false; } else{ - logger.warn("Could not find Moby object in document " + currentURL + - ", referred to by the reference ID in Moby link " + targetURL + - " (document changed?)"); - return null; + displayFilterEffect(); //need to cleanup previous state } + return; } - catch(Exception e){// Syntax error - logger.error("Error: Could not search Moby data instance for XPath " + - childXPath + "):" + e); - return null; + // Otherwise make a list of xpointers to data that should be grayed out + FilterSearch fs = filterHistory.get(getCurrentURL()); + XPathOption xsel = fs.getSelectedXPath(); + + // Find all the matching data + XPath xpath = xPathFactory.newXPath(); + // Find the applicable DOM nodes if not yet found, or if selection criteria have changed + if(currentSelectedData == null || currentSelectionXPath == null || !currentSelectionXPath.equals(xsel.getXPath())){ + currentSelectionXPath = xsel.getXPath(); + try{ + currentSelectedData = (NodeList) xpath.evaluate(currentSelectionXPath, currentDoc, XPathConstants.NODESET); + } catch(Exception e){ + logger.error("Could not evaluate XPath (" + xsel.getXPath() + ") over " + getCurrentURL(), e); + return; + } + // System.err.println("There are " + currentSelectedData.getLength() + + // " items selected in the document using XPath " + currentSelectionXPath); } - if(idSearchResult.getLength() == 0){ - logger.warn("Error: Could not find Moby data instance with XPath (" + childXPath + - " in " + targetURL); - return null; + // Find just the data subset also matching the regex + Map matchingXPtrs = new LinkedHashMap(); + // Build the FSA only once, for efficiency + Pattern regex = Pattern.compile(fs.getFilterRegex().toString(), Pattern.MULTILINE); + for(int i = 0; i < currentSelectedData.getLength(); i++){ + Node node = currentSelectedData.item(i); + if(node instanceof Element){ + if(regex.matcher(((Element) node).getTextContent()).find()){ + matchingXPtrs.put(getXPtr(node), Boolean.TRUE); + } + else{ + matchingXPtrs.put(getXPtr(node), Boolean.FALSE); + } + //System.err.println("Adding " + getXPtr(node) + " as " + matchingXPtrs.get(getXPtr(node))); + } + else if(node instanceof Attr){ + if(regex.matcher(((Attr) node).getValue()).find()){ + // Mark the element to which the attribute belongs + matchingXPtrs.put(getXPtr(((Attr) node).getOwnerElement()), Boolean.TRUE); + } + else{ + matchingXPtrs.put(getXPtr(((Attr) node).getOwnerElement()), Boolean.FALSE); + } + } + else{ + logger.warn("Found filter xpath result item that was not an Element or Attribute as expected ("+ + node.getClass().getName()+")"); + } } - if(idSearchResult.getLength() > 1){ - logger.warn("Error: Moby data instance could not beresolved because " + - "there are multiple elements with XPath " + childXPath + " in " + - currentURL); - return null; + + Map parentMatchingXPtrs = new LinkedHashMap(); + for(String currXPtr: filterableNodes){ + for(Map.Entry matchingXPtr: matchingXPtrs.entrySet()){ + if(matchingXPtr.getKey().startsWith(currXPtr+"/")){ // a parent of the matching data + // No positive example yet? + if(!parentMatchingXPtrs.containsKey(currXPtr) || !parentMatchingXPtrs.get(currXPtr).booleanValue()){ + //System.err.println("Adding "+ matchingXPtr.getValue() + " for " + currXPtr); + parentMatchingXPtrs.put(currXPtr, matchingXPtr.getValue()); + } + } + } } - if(!(idSearchResult.item(0) instanceof Element)){ - logger.warn("Error: Moby data instance with XPath " + childXPath + " in " + - currentURL + " was not an element as required!"); - return null; + + matchingXPtrs.putAll(parentMatchingXPtrs); + for(String currXPtr: matchingXPtrs.keySet()){ + // Is part of the selection criteria, but doesn't match the regex + if(!matchingXPtrs.get(currXPtr).booleanValue()){ + filteredData.put(currXPtr, "todo"); + } } - mobyObject = (Element) idSearchResult.item(0); + + //todo: filter objects without the HAS field at all... - // Create the Java MOBY API object based on the linked document DOM fragment - try{ - MobyDataInstance mdi = MobyDataObject.createInstanceFromDOM(mobyObject, SeahawkOptions.getRegistry()); - if(mdi instanceof MobyDataObject){ - mobyData = mdi; + // apply gray out in the document display + displayFilterEffect(); + } + + // If any moby object member is in a HAS relationship, add it to the list of filterable items + private void addHASXPtrs(List filterList, Element object){ + String tagName = object.getLocalName(); + boolean isContainer = false; + MobyDataType mobyDataType = null; + if(tagName.equals(MobyTags.MOBYDATA) || tagName.equals(MobyTags.COLLECTION) || tagName.equals(MobyTags.SIMPLE) || + tagName.equals(MobyTags.CROSSREFERENCE)){ + isContainer = true; + } + else{ + mobyDataType = MobyDataType.getDataType(tagName, SeahawkOptions.getRegistry()); + if(mobyDataType == null){ + logger.warn("Found datatype unknown to the registry ("+object.getLocalName()+")"); + return; } - else if(mdi instanceof MobyDataObjectSet){ - mobyData = mdi; + } + + NodeList members = object.getChildNodes(); + for(int i = 0; i < members.getLength(); i++){ + if(!(members.item(i) instanceof Element)){ + continue; + } + + Element member = (Element) members.item(i); + addHASXPtrs(filterList, member); + + if(!isContainer){ + String memberName = member.getAttribute(MobyTags.ARTICLENAME); + MobyRelationship membership = mobyDataType.getChild(memberName); + //System.err.println("Relationship for " + tagName + " member " + memberName + + // " is " + (membership == null ? null : membership.getRelationshipType())); + if(membership != null && membership.getRelationshipType() == Central.iHAS){ + filterList.add(getXPtr(member)); + } } - else{ - logger.warn("Error: Moby data instance retrieved with XPath " + childXPath + " in " + - currentURL + " was not a primary MOBY input object as expected"); - return null; - } - - // To avoid misinterpretation of primitive datatypes as Objects with any namespace in queries for - // services, add a token namespace to get reasonable service results. - if(mobyData instanceof MobyDataObject && ((MobyDataObject) mobyData).getPrimaryNamespace() == null){ - ((MobyDataObject) mobyData).setPrimaryNamespace(new MobyNamespace("unknown")); - } - - // For workflow creation, etc. associate the potential input data with its source generalized XPath - // Also, if there is currently a filter on the doc, store it too as useful info for workflow creation. - StringBuilder userData = new StringBuilder(); - userData.append(targetURL.getProtocol()+":"+targetURL.getPath() + - "#" + elementInContextToNameBasedXPath(mobyObject)); - // todo: get rid of ref part of url for lookup - logger.warn("Looking up filter info for "+ currentURL); - if(filterHistory.containsKey(currentURL)){ - FilterSearch fs = filterHistory.get(currentURL); - logger.warn("Found filter info for "+ currentURL + ": " + fs); - if(fs.getFilterRegex().length() > 0){ - XPathOption xsel = fs.getSelectedXPath(); - userData.append("\t"+fs.getFilterRegex()+"\t"+xsel.getXPath()+"\t"+xsel.getDesc()); - } - } - mobyData.setUserData(userData.toString()); - } - catch(MobyException mobye){ // Logic error - logger.error("Error: Could not construct Moby data instance from document fragment: " + - mobye); - mobye.printStackTrace(); } - - return mobyData; } - /** - * Gets the filter criteria currently being applied to the document being viewed. - * - * @return null unless there is a currently a non-blank filter criteria - */ - public FilterSearch getFilter(){ - if(getCurrentURL() == null){ - return null; + // Recursively ascend the DOM tree and find out our place in its branching structure + private String getXPtr(Node n){ + if(n == null || n instanceof Document){ + return ""; } - FilterSearch fs = filterHistory.get(getCurrentURL()); - if(fs != null && fs.getFilterRegex().length() > 0){ - return fs; + Node parent = n.getParentNode(); + + NodeList children = parent.getChildNodes(); + int nonElementCnt = 0; + for(int i = 0; i < children.getLength(); i++){ + if(!(children.item(i) instanceof Element)){ + nonElementCnt++; + continue; + } + if(n == children.item(i)){ + return getXPtr(parent)+"/"+(i-nonElementCnt+1); + } } return null; } /** - * Restrict the view of the XML document to the parts matching the FilterSearch criteria + * Gray out parts of the HTML view if they are part of the filtered data. */ - public void applyFilter(boolean apply){ - if(!apply || !filterHistory.containsKey(getCurrentURL()) || - (filterHistory.containsKey(getCurrentURL()) && - filterHistory.get(getCurrentURL()).getFilterRegex().toString().length() == 0)){ - // Show whole doc if no filter or if filter is blank + private void displayFilterEffect(){ + + HTMLDocument d = (HTMLDocument) editorPane.getStyledDocument(); + + if(origStyles == null){ + // Store a copy of the doc's default rendering for all elements with xpointer + // (i.e. filterable elements) before doing any filter display mods, + // as this allows us to remove the filter easily without reloading the document. + origStyles = new Vector(); + for(String filterable: filterableNodes){ + javax.swing.text.Element el = d.getElement(filterable); + origStyles.add(d.getParagraphElement(el.getStartOffset()).getAttributes()); + } + firstDocRendering = false; + } + // Restore the original document appearance before applying the current filter... + else{ + Iterator origAttIter = origStyles.iterator(); + // Restore text data + for(String filterable: filterableNodes){ + javax.swing.text.AbstractDocument.AbstractElement el = + (javax.swing.text.AbstractDocument.AbstractElement) d.getElement(filterable); + javax.swing.text.SimpleAttributeSet plain = new javax.swing.text.SimpleAttributeSet(); + d.setParagraphAttributes(el.getStartOffset(), el.getEndOffset()-el.getStartOffset()+1, origAttIter.next(), true); + } + // Restore hyperlinks to default (blue underlined) appearance + javax.swing.text.SimpleAttributeSet blueAttrSet = new javax.swing.text.SimpleAttributeSet(); + blueAttrSet.addAttribute(StyleConstants.Foreground, Color.blue); + blueAttrSet.addAttribute(StyleConstants.Underline, Boolean.TRUE); + for(HTMLDocument.Iterator it = d.getIterator(HTML.Tag.A); it.isValid(); it.next()) { + String link = (String) it.getAttributes().getAttribute(HTML.Attribute.HREF); + if(link == null){ + continue; + } + d.setCharacterAttributes(it.getStartOffset(), it.getEndOffset()-it.getStartOffset()+1, blueAttrSet, false); + } + } + + javax.swing.text.SimpleAttributeSet grayAttrSet = new javax.swing.text.SimpleAttributeSet(); + grayAttrSet.addAttribute(StyleConstants.Foreground, Color.lightGray); + grayAttrSet.addAttribute(StyleConstants.Underline, Boolean.FALSE); + + // Gray out hyperlinks that are for filtered data or their children + for(HTMLDocument.Iterator it = d.getIterator(HTML.Tag.A); it.isValid(); it.next()) { + String link = (String) it.getAttributes().getAttribute(HTML.Attribute.HREF); + if(link == null || link.indexOf("#") == -1){ + continue; + } + link = link.replaceFirst("^.*#(.*)$", "$1"); // just get the ref + + for(Map.Entry dataToFilter: filteredData.entrySet()){ + if(link.equals(dataToFilter.getKey()) || link.startsWith(dataToFilter.getKey()+"/")){ + d.setCharacterAttributes(it.getStartOffset(), it.getEndOffset()-it.getStartOffset()+1, grayAttrSet, false); + } + } + } + + // Gray out the mismatched textual data + for(Map.Entry dataToFilter: filteredData.entrySet()){ + + //System.err.println("Filtering "+dataToFilter.getKey()); + javax.swing.text.AbstractDocument.AbstractElement htmlDiv = + (javax.swing.text.AbstractDocument.AbstractElement) d.getElement(dataToFilter.getKey()); + if(htmlDiv == null){ + logger.error("Could not find HTML element with expected id "+dataToFilter.getKey()); + continue; + } + int areaStart = htmlDiv.getStartOffset(); + int areaEnd = htmlDiv.getEndOffset(); + d.setParagraphAttributes(areaStart, areaEnd-areaStart+1, grayAttrSet, false); } + + // Highlight the matches + Highlighter h = editorPane.getHighlighter(); + h.removeAllHighlights(); //get rid of old highlights + FilterSearch fs = filterHistory.get(getCurrentURL()); + int matchCount = 0; + if(fs != null && fs.getFilterRegex().length() > 0){ + try{ + javax.swing.text.LayeredHighlighter.LayerPainter painter = + new DefaultHighlighter.DefaultHighlightPainter(Color.yellow); + Pattern p = Pattern.compile(fs.getFilterRegex().toString(), Pattern.MULTILINE); + for(String filterable: filterableNodes){ + javax.swing.text.Element el = d.getElement(filterable); + String fragment = d.getText(el.getStartOffset(), + el.getEndOffset() - el.getStartOffset()); + Matcher matcher = p.matcher(fragment); + while (matcher.find()) { + h.addHighlight(el.getStartOffset() + matcher.start(), + el.getStartOffset() + matcher.end(), + painter); + matchCount++; + } + } + } catch(Exception e){ + logger.error("Could not apply match highlights", e); + } + } + status.setText(" Found "+matchCount+" match"+(matchCount == 1 ? "": "es")); + + // Update the ability to press the forward button, based on the new filter criteria + contentGUI.updateHistoryButtons(); + } + + private List getHyperlinkElements(javax.swing.text.Element el){ + List links = new Vector(); + for(int i = 0; i < el.getElementCount(); i++){ + javax.swing.text.Element childEl = el.getElement(i); + System.err.println("Found child element " + childEl.getName()); + if(HTML.Tag.A.equals(childEl.getName())){ + links.add(childEl); + } + else{ + for(int j = 0; j < childEl.getElementCount(); j++){ + links.addAll(getHyperlinkElements(childEl.getElement(j))); + } + } + } + return links; } /** @@ -1384,7 +1682,7 @@ filterHistory.put(getCurrentURL(), new FilterSearch(getCurrentURL(), contentGUI.getDocumentBuilder())); } } - logger.warn("Setting filter to "+filterHistory.get(getCurrentURL()) + " for " +getCurrentURL()); + logger.debug("Setting filter to "+filterHistory.get(getCurrentURL()) + " for " +getCurrentURL()); filterSearchWidget.setFilter(filterHistory.get(getCurrentURL())); searchPanel.add(filterSearchWidget); searchPanel.revalidate(); @@ -1396,7 +1694,7 @@ deletedFilters.put(getCurrentURL(), filterHistory.remove(getCurrentURL())); } filterSearchWidget.setFilter(null); - applyFilter(false); // no filter GUI = no filter effect + if(canFilter()){applyFilter(false);} // no filter GUI = no filter effect searchPanel.remove(filterSearchWidget); searchPanel.revalidate(); revalidate(); @@ -1404,63 +1702,6 @@ } /** - * Generalizes the element instance into an XPath retrieving it and all - * similarly nested elements (based on traversing the parent nodes and prepending their names) - */ - protected String elementInContextToNameBasedXPath(Element targetElement){ - String xpath = ""; - - for(Element currentElement = targetElement; - currentElement != null; - currentElement = (Element) currentElement.getParentNode()){ - String elName = currentElement.getLocalName(); - // top level parameters' names are important - String articleName = currentElement.getAttributeNS(MobyTags.MOBY_XML_NS, MobyTags.ARTICLENAME); - if(articleName == null || articleName.trim().length() == 0){ - articleName = currentElement.getAttribute(MobyTags.ARTICLENAME); - } - - if(elName.equals(MobyTags.SIMPLE)){ - xpath = "/"+MobyTags.SIMPLE+"[@"+MobyTags.ARTICLENAME + " = '" + - articleName+"']" +xpath; - } - - else if(elName.equals(MobyTags.COLLECTION)){ - xpath = "/"+MobyTags.COLLECTION+"[@"+MobyTags.ARTICLENAME + " = '" + - articleName +"']"+xpath; - } - else if(elName.equals(MobyTags.MOBYOBJECT)){ - // Obviously, assume a base object is interesting based on its namespace - xpath = "/*[@"+MobyTags.OBJ_NAMESPACE + " = '" + - currentElement.getAttribute(MobyTags.OBJ_NAMESPACE)+"']" + xpath; - } - else if(elName.equals(MobyTags.MOBYFLOAT) || - elName.equals(MobyTags.MOBYSTRING) || - elName.equals(MobyTags.MOBYBOOLEAN) || - elName.equals(MobyTags.MOBYINTEGER) || - elName.equals(MobyTags.MOBYDATETIME)){ - // Assume that it isn't the primitive type, but rather the articleName - // that makes it appropriate to use. - xpath = "/*[@"+MobyTags.ARTICLENAME + " = '" + - articleName+"']" + xpath; - } - else{ - // It's a complex type. Assume the type is why we are picking it. - // TODO: In future we may want to check if a parent type is allowed in - // this slot, and generalize to that. May also want to check that there isn't more - // than one member of this type at this level in a HAS relationship... - // in that case we probably want to go by articleName to catch the full semantics - xpath = "/"+elName + xpath; - } - if(!(currentElement.getParentNode() instanceof Element)){ - break; // reached document node - } - } - - return xpath; - } - - /** * This method tries to figure out what kinds of MOBY Data could be * created from the string given. e.g. Keywords, DNASequence, etc. */ @@ -1638,14 +1879,13 @@ dragging = true; // so we don't export many times in a row while dragging lastHyperlinkDragged = lastHyperlinkHovered; status.setText("Drop the hyperlink onto a Web form field to populate it"); - System.err.println("Dragging "+lastHyperlinkDragged); getTransferHandler().exportToClipboard(this, Toolkit.getDefaultToolkit().getSystemClipboard(), TransferHandler.COPY); getTransferHandler().exportAsDrag(this, e, TransferHandler.COPY); } else if(!dragging){ - System.err.println("Dragging with no hyperlink activated"); + //System.err.println("Dragging with no hyperlink activated"); } } From gordonp at dev.open-bio.org Mon Mar 29 19:55:22 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:55:22 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291955.o2TJtMt4010648@dev.open-bio.org> gordonp Mon Mar 29 15:55:22 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv10612/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentHelpPane.java Log Message: DataRecorder -> DataFlowRecorder moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentHelpPane.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentHelpPane.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentHelpPane.java 2010/03/17 20:21:55 1.4 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentHelpPane.java 2010/03/29 19:55:22 1.5 @@ -1,7 +1,7 @@ package ca.ucalgary.seahawk.gui; -import ca.ucalgary.seahawk.util.DataRecorder; +import ca.ucalgary.seahawk.util.DataFlowRecorder; import org.biomoby.client.MobyRequestEventHandler; import org.biomoby.shared.data.MobyContentInstance; @@ -41,7 +41,7 @@ private static URL helpHTMLURL; private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobyContentHelpPane.class); public MobyContentHelpPane(MobyContentGUI cGUI, MobyServicesGUI sGUI, JTabbedPane parentComponent, - DataRecorder recorder, JLabel statusBar){ + DataFlowRecorder recorder, JLabel statusBar){ super(cGUI, sGUI, parentComponent, recorder, statusBar); // So JFCUnit tests can find it From gordonp at dev.open-bio.org Mon Mar 29 19:55:39 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:55:39 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291955.o2TJtdws010692@dev.open-bio.org> gordonp Mon Mar 29 15:55:39 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv10656/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentGUI.java Log Message: DataRecorder -> DataFlowRecorder moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentGUI.java,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2010/03/17 20:21:55 1.20 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentGUI.java 2010/03/29 19:55:39 1.21 @@ -38,6 +38,7 @@ // Variables used to coordinate component finding with the unit test cases public final static String BACK_BUTTON_NAME = "MCGbackButton"; public final static String FORWARD_BUTTON_NAME = "MCGforwardButton"; + public final static String FORWARD_BUTTON_MSG = "Go to next document in this tab's history"; public final static String OPEN_BUTTON_NAME = "MCGopenButton"; public final static String SAVE_BUTTON_NAME = "MCGsaveButton"; public final static String FILTER_BUTTON_NAME = "MCGfilterButton"; @@ -86,7 +87,7 @@ private DocumentBuilder docBuilder = null; private MobyContentClipboard clipboard; private MobyContentHelpPane helpPane; - private DataRecorder dataRecorder; // used for workflow export, etc. + private DataFlowRecorder dataRecorder; // used for workflow export, etc. private SeahawkOptionsGUI settingsGUI; private boolean setup; @@ -132,7 +133,7 @@ forwardButton = new JButton(new ImageIcon(cl.getResource("ca/ucalgary/seahawk/resources/images/forward.gif"))); forwardButton.setDisabledIcon(new ImageIcon(cl.getResource("ca/ucalgary/seahawk/resources/images/forward_d.gif"))); - forwardButton.setToolTipText("Go to next document in this tab's history"); + forwardButton.setToolTipText(FORWARD_BUTTON_MSG); forwardButton.setPreferredSize(buttonSize); forwardButton.setEnabled(false); forwardButton.addActionListener(this); @@ -217,7 +218,7 @@ tabbedPane.addKeyListener(this); try{ - dataRecorder = new DataRecorder(servicesGUI.getMobyCentralImpl()); + dataRecorder = new DataFlowRecorder(servicesGUI.getMobyCentralImpl()); } catch(Exception e){ e.printStackTrace(); } @@ -598,7 +599,14 @@ } } - private void updateHistoryButtons(){ + /** + * Allow others to set the forward navigation button message. If set the null, the default tooltip is used. + */ + public void setForwardButtonToolTip(String msg){ + forwardButton.setToolTipText(msg == null ? FORWARD_BUTTON_MSG : msg); + } + + public void updateHistoryButtons(){ MobyContentPane pane = (MobyContentPane) tabbedPane.getSelectedComponent(); if(pane != null){ backwardButton.setEnabled(pane.canGoBack()); @@ -793,8 +801,8 @@ MobyContentInstance result = request.invokeService(); ByteArrayOutputStream inputXML = new ByteArrayOutputStream(); MobyDataUtils.toXMLDocument(inputXML, inEnvelope); - URL resultURL = dataRecorder.saveOutputData(result, services[0], //for tracking purposes - inEnvelope, central.getRegistryEndpoint()); + URL resultURL = DataUtils.saveOutputData(result, services[0], //for tracking purposes + inEnvelope, central.getRegistryEndpoint()); for(int i = 0; i < tabbedPane.getTabCount(); i++){ MobyContentPane pane = (MobyContentPane) tabbedPane.getComponentAt(i); From gordonp at dev.open-bio.org Mon Mar 29 19:58:17 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 15:58:17 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003291958.o2TJwHUM010776@dev.open-bio.org> gordonp Mon Mar 29 15:58:17 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv10744/src/main/ca/ucalgary/seahawk/util Added Files: DataFlowRecorder.java DataUtils.java Log Message: Initial commit of new dataflow export code moby-live/Java/src/main/ca/ucalgary/seahawk/util DataFlowRecorder.java,NONE,1.1 DataUtils.java,NONE,1.1 From gordonp at dev.open-bio.org Mon Mar 29 20:42:48 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 16:42:48 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003292042.o2TKgmq1012131@dev.open-bio.org> gordonp Mon Mar 29 16:42:48 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv12095/src/main/org/biomoby/client Modified Files: MobyRequest.java Log Message: Now using proper system protery check for moby.debug moby-live/Java/src/main/org/biomoby/client MobyRequest.java,1.45,1.46 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java,v retrieving revision 1.45 retrieving revision 1.46 diff -u -r1.45 -r1.46 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2010/03/17 20:55:51 1.45 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequest.java 2010/03/29 20:42:48 1.46 @@ -120,7 +120,7 @@ debugPS.println("Syntax error encountered while compiling XPath " + "statements for internal use (code bug?): " + xpee); } - setDebugMode(System.getProperty("moby.debug") != null); + setDebugMode(Boolean.getBoolean("moby.debug")); } public void setAuthentication(String user, String password){ From gordonp at dev.open-bio.org Mon Mar 29 20:50:25 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 16:50:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003292050.o2TKoPsY012552@dev.open-bio.org> gordonp Mon Mar 29 16:50:25 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv12519/src/main/ca/ucalgary/seahawk/util Removed Files: DataRecorder.java Log Message: Replaced with DataFlowRecorder moby-live/Java/src/main/ca/ucalgary/seahawk/util DataRecorder.java,1.3,NONE rcsdiff: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/RCS/DataRecorder.java,v: No such file or directory From gordonp at dev.open-bio.org Mon Mar 29 20:53:05 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 16:53:05 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003292053.o2TKr50L012596@dev.open-bio.org> gordonp Mon Mar 29 16:53:04 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv12560/src/main/ca/ucalgary/seahawk/util Modified Files: DataFlowRecorder.java Log Message: Fixed old DataRecorder refs in documentation moby-live/Java/src/main/ca/ucalgary/seahawk/util DataFlowRecorder.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataFlowRecorder.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataFlowRecorder.java 2010/03/29 19:58:17 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataFlowRecorder.java 2010/03/29 20:53:04 1.2 @@ -48,7 +48,7 @@ public DataFlowRecorder(Central mobyCtr) throws Exception{ if(mobyCtr == null){ - throw new IllegalArgumentException("Moby Central object passed to DataRecorder was null"); + throw new IllegalArgumentException("Moby Central object passed to DataFlowRecorder was null"); } mobyCentral = mobyCtr; DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -67,12 +67,12 @@ * @param resultDocuments the output of the workflow to backtrace * @param outputStream where to write the output * @param workflowName to be used as a label in the workflow - * @param format the format to write the workflow in (currently, only DataRecorder.T2FLOW works) + * @param format the format to write the workflow in (currently, only DataFlowRecorder.T2FLOW works) */ public void exportWorkflow(Map resultDocuments, OutputStream outputStream, String workflowName, String workflowTitle, String workflowDescription, String workflowAuthor, int format) throws Exception{ if(format != TAVERNA15 && format != T2FLOW){ throw new IllegalArgumentException("The export format for the workflow was " + - "not DataRecorder.TAVERNA15 nor DataRecorder.T2FLOW as expected, found " + format); + "not DataFlowRecorder.TAVERNA15 nor DataFlowRecorder.T2FLOW as expected, found " + format); } if(outputStream == null){ throw new IllegalArgumentException("The output stream for workflow exporting was null, aborting export"); @@ -720,7 +720,7 @@ } // Retrieves the port name that can be used in a datalink. Since it is of local - // scope, we can just call it the same as the moby param. DataRecorder sets up provenance + // scope, we can just call it the same as the moby param. DataFlowRecorder sets up provenance // URLs (during calls to saveInput) of the form URLOfMobyXML#/path/based/on/Simple[@articleName = "foo"]/datatype // We also pass in the processors and datalinks because we may need to add some ourselves // When extra processors are added to filter a collection by namespace, etc. From gordonp at dev.open-bio.org Mon Mar 29 20:56:21 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 16:56:21 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003292056.o2TKuL4q012680@dev.open-bio.org> gordonp Mon Mar 29 16:56:21 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util In directory dev.open-bio.org:/tmp/cvs-serv12644/src/main/ca/ucalgary/services/util Modified Files: XHTMLForm.java Log Message: Fixed javadoc param moby-live/Java/src/main/ca/ucalgary/services/util XHTMLForm.java,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/XHTMLForm.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/XHTMLForm.java 2010/03/17 20:17:39 1.10 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/XHTMLForm.java 2010/03/29 20:56:21 1.11 @@ -89,7 +89,7 @@ } /** - * @param url the location of the remote Web form that will be wrapped into a Moby Service + * @param formUrl the location of the remote Web form that will be wrapped into a Moby Service */ public XHTMLForm(URL formUrl) throws Exception{ this(); From gordonp at dev.open-bio.org Mon Mar 29 20:59:54 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 16:59:54 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003292059.o2TKxswN012764@dev.open-bio.org> gordonp Mon Mar 29 16:59:54 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util In directory dev.open-bio.org:/tmp/cvs-serv12728/src/main/ca/ucalgary/services/util Modified Files: PBERecorder.java Log Message: Javadoc updates moby-live/Java/src/main/ca/ucalgary/services/util PBERecorder.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/PBERecorder.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/PBERecorder.java 2010/03/17 20:17:39 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/PBERecorder.java 2010/03/29 20:59:54 1.4 @@ -32,6 +32,8 @@ /** * This class controls the interaction between the web browser and Seahawk via the pasting actions. + * The tracking of Moby data in a demonstration usage of a web service or html form is used + * to generalize the invocation details into a Moby wrapper for the legacy service. */ public class PBERecorder implements DataRecorder{ private Map sessionId2gui; // link the http session with the GUI @@ -134,11 +136,6 @@ } } - /** - * @param t an XSLT transformer that is used to make results presentable (e.g. indentation). If null, an identity transform is used. - * - * @throws Exception if an XSLT transformer was not provided, and one could not be created - */ public PBERecorder(){ sessionId2gui = new HashMap(); sessionId2SourceMap = new HashMap(); From gordonp at dev.open-bio.org Mon Mar 29 21:01:17 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 29 Mar 2010 17:01:17 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003292101.o2TL1HXT013042@dev.open-bio.org> gordonp Mon Mar 29 17:01:16 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv13006/src/main/org/biomoby/client Modified Files: MobyRequestEvent.java Log Message: Javadoc update moby-live/Java/src/main/org/biomoby/client MobyRequestEvent.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEvent.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEvent.java 2010/03/17 20:55:51 1.6 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/MobyRequestEvent.java 2010/03/29 21:01:16 1.7 @@ -55,7 +55,7 @@ } /** - * @param inputXML the Moby XML sent to the service this event is refering to. + * @param inputPayload the Moby message envelope sent to the service this event is refering to. */ public void setSourceInput(MobyContentInstance inputPayload){ originatingMobyRequestInputData = inputPayload; From gordonp at dev.open-bio.org Tue Mar 30 19:14:05 2010 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Tue, 30 Mar 2010 15:14:05 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <201003301914.o2UJE5LQ018610@dev.open-bio.org> gordonp Tue Mar 30 15:14:04 EDT 2010 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/minnow In directory dev.open-bio.org:/tmp/cvs-serv18574/src/main/ca/ucalgary/minnow Modified Files: MinJarMaker.java Log Message: Changes to allow secondary JAR dumping from JARs in the classpath, before worked only for class files moby-live/Java/src/main/ca/ucalgary/minnow MinJarMaker.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/minnow/MinJarMaker.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/minnow/MinJarMaker.java 2008/10/30 02:33:24 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/minnow/MinJarMaker.java 2010/03/30 19:14:04 1.6 @@ -299,73 +299,84 @@ String path = pathElement + File.separator + pathSuffix; File classFile = new File(path); if(classFile.isFile()){ - long len = classFile.length(); - byte data[] = new byte[(int)len]; - FileInputStream fin = new FileInputStream(classFile); - int r = fin.read(data); - if (r != len){ - throw new IOException( "Could only read "+r+" of "+len+" bytes from "+classFile ); - } - fin.close(); - if(Boolean.getBoolean(VERBOSE)){ - System.err.println("[Loaded " + name + " from " + classFile.getCanonicalPath() + "]"); - } - return data; + return getClassBytesFromFile(classFile, name); } else{ // If it's not a file, maybe it's in a JAR File f = new File(pathElement); if(f.isFile()){ - JarFile jarFile = null; - try{ - jarFile = new JarFile(f); + byte[] bytes = getClassBytesFromJar(f, pathSuffix); + if(bytes != null){ + return bytes; } - catch(Exception e){ - System.err.println("Class path element " + pathElement + - " was not a directory, or a valid JAR file"); - continue; - } - - JarEntry je = jarFile.getJarEntry(pathSuffix); - if(je == null){ - continue; - } - long classSize = je.getSize(); - - InputStream classStream = jarFile.getInputStream(je); - byte[] classBytes = null; - // NOTE: This if case is commented out because false file sizes are sometimes - // reported, which leads to invalid class definitions -// if(classSize != -1){ // We know the size of the class already - -// classBytes = new byte[(int) classSize]; //classes better not be bigger than 2 GB! -// // Slurp it up in one shot -// classStream.read(classBytes, 0, (int) classSize); -// if(Boolean.getBoolean(VERBOSE)){ -// System.err.println("[Loaded " + name + " from " + f.getCanonicalPath() + "]"); -// } -// return classBytes; -// } -// else{ - - byte[] byteBufferChunk = new byte[1024]; - ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream(); - for(int r = classStream.read(byteBufferChunk, 0, 1024); - r != -1; - r = classStream.read(byteBufferChunk, 0, 1024)){ - byteBuffer.write(byteBufferChunk, 0, r); - } - if(Boolean.getBoolean(VERBOSE)){ - System.err.println("[Loaded " + name + " from " + f.getCanonicalPath() + "]"); - } - return byteBuffer.toByteArray(); -// } } - } } + return null; + } + + protected byte[] getClassBytesFromFile(File classFile, String name) throws IOException{ + long len = classFile.length(); + byte[] data = new byte[(int)len]; // 2G limit + FileInputStream fin = new FileInputStream(classFile); + int r = fin.read(data); + if (r != len){ + throw new IOException( "Could only read "+r+" of "+len+" bytes from "+classFile ); + } + fin.close(); + if(Boolean.getBoolean(VERBOSE)){ + System.err.println("[Loaded " + name + " from " + classFile.getCanonicalPath() + "]"); + } + return data; + } + + protected byte[] getClassBytesFromJar(File f, String entryName) throws IOException{ + try{ + return getClassBytesFromJar(new JarFile(f), entryName); + } + catch(Exception e){ + System.err.println("Class path element " + f.getCanonicalPath() + + " was not a directory, or a valid JAR file"); + return null; + } + } + + protected byte[] getClassBytesFromJar(JarFile jarFile, String entryName) throws IOException{ + JarEntry je = jarFile.getJarEntry(entryName); + if(je == null){ + return null; + } + long classSize = je.getSize(); + + InputStream classStream = jarFile.getInputStream(je); + byte[] classBytes = null; + // NOTE: This if case is commented out because false file sizes are sometimes + // reported, which leads to invalid class definitions + // This has to do with different versions of compression algorithms being used by different JAR makers. + // + // if(classSize != -1){ // We know the size of the class already - return null; + // classBytes = new byte[(int) classSize]; //classes better not be bigger than 2 GB! + // // Slurp it up in one shot + // classStream.read(classBytes, 0, (int) classSize); + // if(Boolean.getBoolean(VERBOSE)){ + // System.err.println("[Loaded " + name + " from " + f.getCanonicalPath() + "]"); + // } + // return classBytes; + // } + // else{ + + byte[] byteBufferChunk = new byte[1024]; + ByteArrayOutputStream byteBuffer = new ByteArrayOutputStream(); + for(int r = classStream.read(byteBufferChunk, 0, 1024); + r != -1; + r = classStream.read(byteBufferChunk, 0, 1024)){ + byteBuffer.write(byteBufferChunk, 0, r); + } + if(Boolean.getBoolean(VERBOSE)){ + System.err.println("[Loaded " + entryName + " from " + jarFile.getName() + "]"); + } + return byteBuffer.toByteArray(); } protected URL getResourceURL(String name){ @@ -696,6 +707,7 @@ } } // Only get to here if the save was successful + //System.err.println("Saved "+relativePath); savedClasses.put(relativePath, "saved"); } jout.close(); @@ -718,6 +730,7 @@ StringTokenizer classPathTokens = new StringTokenizer(System.getProperty("jarmaker.class.path"), File.pathSeparator); while(classPathTokens.hasMoreElements()){ String classPathElement = classPathTokens.nextToken(); + System.err.println("Dumping secondary JAR for "+classPathElement); try{ dumpSecondaryJar(new File(classPathElement), classPathElement, (new File(jarfile)).getParent()); } @@ -744,10 +757,13 @@ * already benn included in the main dumpJar call. */ private void dumpSecondaryJar(File classPath, String classPrefix, String jarFilePrefix) throws Exception{ - if(classPath.isDirectory()){ - JarOutputStream jarFile = null; - String packageName = null; - if(classPrefix.equals(classPath.toString())){ + boolean isDir = classPath.isDirectory(); + JarOutputStream jarFile = null; + String packageName = null; + List entries = new Vector(); // files or jar entries + JarFile srcJarFile = null; + if(isDir){ + if(classPrefix.equals(classPath.toString()) || (classPrefix+File.separator).equals(classPath.toString())){ packageName = "no-package"; } else{ @@ -755,112 +771,155 @@ } File[] contents = classPath.listFiles(); for(int i = 0; i < contents.length; i++){ - String relativePath = contents[i].toString().substring(classPrefix.length()+1); - if(savedClasses.containsKey(relativePath) || // already saved - contents[i].getName().startsWith(".") || // or not interesting - contents[i].getName().startsWith("TEST-") || // JUnit output files - contents[i].getName().endsWith("~") || //emacs scratch file - contents[i].getName().endsWith(".java") || - contents[i].getName().endsWith(".jar") || - contents[i].getName().equals("META-INF") || //this one causes null pointers in jarsigner - contents[i].getName().equals("testdata") || - contents[i].getName().equals("deployment") || - contents[i].getName().equals("CVS")){ - continue; - } - else if(contents[i].isDirectory()){ - dumpSecondaryJar(contents[i], classPrefix, jarFilePrefix); - continue; - } - else if(jarFile == null){ // Need to create the jar file - String jarFileName = jarFilePrefix + File.separator; //in same dir as main jar file dump - jarFileName += packageName; - jarFileName += ".jar"; - File destinationFile = new File(jarFileName); - if(destinationFile.exists()){ - System.err.println("Updating jar file " + jarFileName); - - // Byte-for-byte copy the existing JAR to a temp file - File tmpJarFile = File.createTempFile("MinJarMaker", ".jar"); - InputStream origInStream = new FileInputStream(destinationFile); - OutputStream tmpOutStream = new FileOutputStream(tmpJarFile); - copyFile(tmpOutStream, origInStream); - tmpOutStream.close(); - origInStream.close(); - - // Then start writing the data out to the destination file, to be appended to later on too - JarInputStream existingJar = new JarInputStream(new FileInputStream(tmpJarFile)); - jarFile = new JarOutputStream(new FileOutputStream( destinationFile )); - jarFile.setLevel(9); //best compression - for(JarEntry je = existingJar.getNextJarEntry(); je != null; je = existingJar.getNextJarEntry()){ - try{ - jarFile.putNextEntry( je ); - }catch(java.util.zip.ZipException ze){ - System.err.println("Skipping existing entry " + je); - continue; - } - /*jar i/o works on a per entry basis, so copy File copies one entry*/ - copyFile(jarFile, existingJar); - jarFile.closeEntry(); + //System.err.println("Adding "+contents[i]); + entries.add(contents[i]); + } + } + else{ // Get the classes from another JAR + //System.err.println(classPath+" is a JAR"); + packageName = classPath.getName().replaceFirst(".jar$",""); // JAR file name without path or suffix + JarInputStream srcJarStream = null; + try{ + srcJarFile = new JarFile(classPath); + srcJarStream = new JarInputStream(new FileInputStream(classPath)); + } catch(Exception e){ + System.err.println("Skipping class path element that is neither a directory " + + "nor a valid JAR file " + e); + return; + } + try{ + for(JarEntry je = srcJarStream.getNextJarEntry(); je != null; je = srcJarStream.getNextJarEntry()){ + entries.add(je); + } + } catch(Exception e){ + System.err.println("Error while reading from JAR file "+classPath); + e.printStackTrace(); + return; + } + } + + for(Object entry: entries){ + String relativePath = entry instanceof JarEntry ? ((JarEntry) entry).getName() : + entry.toString().substring(classPrefix.length()+1); + //System.err.println("Checking status of "+relativePath); + + if(savedClasses.containsKey(relativePath) || // already saved + relativePath.startsWith(".") || // or not interesting + relativePath.startsWith("TEST-") || // JUnit output files + relativePath.endsWith("~") || //emacs scratch file + relativePath.endsWith(".java") || + relativePath.endsWith(".jar") || + relativePath.equals("META-INF") || //this one causes null pointers in jarsigner + relativePath.equals("testdata") || + relativePath.equals("deployment") || + relativePath.equals("CVS")){ + //System.err.println("Skipping " + relativePath); + continue; + } + else if(entry instanceof File && ((File) entry).isDirectory()){ //recurse for subdirs + //System.err.println("Recursing for " + relativePath); + dumpSecondaryJar((File) entry, classPrefix, jarFilePrefix); + continue; + } + else if(jarFile == null){ // Need to create the jar file + String jarFileName = jarFilePrefix + File.separator; //in same dir as main jar file dump + jarFileName += packageName; + jarFileName += ".jar"; + File destinationFile = new File(jarFileName); + if(destinationFile.exists()){ + //System.err.println("Updating jar file " + jarFileName); + + // Byte-for-byte copy the existing JAR to a temp file + File tmpJarFile = File.createTempFile("MinJarMaker", ".jar"); + InputStream origInStream = new FileInputStream(destinationFile); + OutputStream tmpOutStream = new FileOutputStream(tmpJarFile); + copyFile(tmpOutStream, origInStream); + tmpOutStream.close(); + origInStream.close(); + + // Then start writing the data out to the destination file, to be appended to later on too + JarInputStream existingJar = new JarInputStream(new FileInputStream(tmpJarFile)); + jarFile = new JarOutputStream(new FileOutputStream( destinationFile )); + jarFile.setLevel(9); //best compression + for(JarEntry je = existingJar.getNextJarEntry(); je != null; je = existingJar.getNextJarEntry()){ + try{ + // By the way, there is no good way to check if a JAR already contains a + jarFile.putNextEntry( je ); + }catch(java.util.zip.ZipException ze){ + System.err.println("Skipping existing entry " + je); + continue; } - tmpJarFile.delete(); - } - else{ - System.err.println("Creating jar file " + jarFileName); - jarFile = new JarOutputStream(new FileOutputStream( destinationFile )); - jarFile.setLevel(9); //best compression - if(webStartIndexWriter != null){ - // If it's a package that's going to have each class enumerated, - // use the short id as the part name - if(corePackages.containsKey(packageName)){ - webStartIndexWriter.write("\n"); - } - // Otherwise it's only going to be used once, so use the full name - // for clarity's sake - else{ - webStartIndexWriter.write("\n"); - } + /*jar i/o works on a per entry basis, so copy File copies one entry*/ + copyFile(jarFile, existingJar); + jarFile.closeEntry(); + } + tmpJarFile.delete(); + } + else{ + System.err.println("Creating jar file " + jarFileName); + jarFile = new JarOutputStream(new FileOutputStream( destinationFile )); + jarFile.setLevel(9); //best compression + if(webStartIndexWriter != null){ + // If it's a package that's going to have each class enumerated, + // use the short id as the part name + if(corePackages.containsKey(packageName)){ + webStartIndexWriter.write("\n"); + } + // Otherwise it's only going to be used once, so use the full name + // for clarity's sake + else{ + webStartIndexWriter.write("\n"); } } } - // A file to add to the jar, not necessarily a class (could be a resource), - // so it's a bit of a misnomer. - String className = relativePath; - if(relativePath.endsWith(".class")){ - className = relativePath.substring(0, relativePath.length()-6).replace('/', '.'); //chops off .class - } - //System.err.println("Adding " + relativePath); - if(webStartIndexWriter != null){ - // The package is split between the core jar and this jar, so we need to - // enumerate each class explicitly that isn't part of the core - if(packageName.equals("no-package")){ - webStartIndexWriter.write("\n"); - } - else if(corePackages.containsKey(packageName)){ - webStartIndexWriter.write("\n"); - } - // Is this a purely secondary package that we haven't made an index for yet? - else if(!secondaryPackageWritten.containsKey(packageName)){ - webStartIndexWriter.write("\n"); - secondaryPackageWritten.put(packageName, "written"); - } - } - try{ - jarFile.putNextEntry(new JarEntry(relativePath)); - copyFile(jarFile, contents[i].toString()); - jarFile.closeEntry(); - } - catch(java.util.zip.ZipException ze2){ - System.err.println("Skipping duplicate entry: " + ze2); - } - savedClasses.put(relativePath, "saved2"); } - if(jarFile != null){ //We saved something - jarFile.close(); + // A file to add to the jar, not necessarily a class (could be a resource), + // so it's a bit of a misnomer. + String className = relativePath; + if(relativePath.endsWith(".class")){ + className = relativePath.substring(0, relativePath.length()-6).replace('/', '.'); //chops off .class + } + //System.err.println("Adding " + relativePath); + if(webStartIndexWriter != null){ + // The package is split between the core jar and this jar, so we need to + // enumerate each class explicitly that isn't part of the core + if(packageName.equals("no-package")){ + webStartIndexWriter.write("\n"); + } + else if(corePackages.containsKey(packageName)){ + webStartIndexWriter.write("\n"); + } + // Is this a purely secondary package that we haven't made an index for yet? + else if(!secondaryPackageWritten.containsKey(packageName)){ + webStartIndexWriter.write("\n"); + secondaryPackageWritten.put(packageName, "written"); + } + } + try{ + jarFile.putNextEntry(new JarEntry(relativePath)); + if(entry instanceof JarEntry){ + //copyFile(jarFile, srcJarFile.getInputStream((JarEntry) entry)); + // Use the line below, not above, because different JARs are zipped differently, so we need to + // get the bytes then rewrite them rather than copy zip entries to ensure entry sizes are correct, + // reflecting the output JAR file's compression scheme, etc. + copyFile(jarFile, getClassBytesFromJar(srcJarFile, relativePath)); + } + else{ + copyFile(jarFile, entry.toString()); + } + jarFile.closeEntry(); + } + catch(java.util.zip.ZipException ze2){ + System.err.println("Skipping duplicate entry: " + ze2); + ze2.printStackTrace(); } + savedClasses.put(relativePath, "saved2"); + } + if(jarFile != null){ //We saved something + jarFile.close(); } }
(ID :)