From gordonp at dev.open-bio.org Thu Aug 6 10:36:32 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 6 Aug 2009 10:36:32 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908061436.n76EaWS5027349@dev.open-bio.org> gordonp Thu Aug 6 10:36:32 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services In directory dev.open-bio.org:/tmp/cvs-serv27313/src/main/ca/ucalgary/services Modified Files: SoapServlet.java Log Message: Fixed null pointer on initial GET when no data recorder was provided moby-live/Java/src/main/ca/ucalgary/services SoapServlet.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.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/SoapServlet.java 2009/06/09 19:44:34 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.java 2009/08/06 14:36:32 1.2 @@ -102,7 +102,7 @@ HttpServletResponse response) throws ServletException, java.io.IOException{ - if(request.getSession(false) == null){ + if(request.getSession(false) == null && recorder != null){ recorder.startRecording(request); //should set up a session } @@ -447,7 +447,7 @@ } try{ - out.write("Moby Service Definition Error\n".getBytes()); + out.write("Service Definition Error\n".getBytes()); out.write((""+answer+"").getBytes()); } catch(java.io.IOException ioe){ @@ -906,9 +906,9 @@ restrictions = element.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "extension"); if(restrictions.getLength() == 0){ - out.print("Error: Could not find the restriction or extension " + - "attribute for a simple type " + - " schema element " + elementName); + //out.print("Error: Could not find the restriction or extension " + + // "attribute for a simple type " + + // " schema element " + elementName); } } else{ @@ -1034,6 +1034,9 @@ dataType.getLocalPart(); Map subpartsMap = element2Members.get(dataType); if(subpartsMap == null){ + if(dataType.getNamespaceURI().equals("http://schemas.xmlsoap.org/soap/encoding/")){ + writeDataType(out, part.getKey(), part.getValue(), element2Members, ""); + } out.print("Error: cannot find definition for data type " + dataType); //"\nValid types are:"); // for(QName key: element2Members.keySet()){ @@ -1202,7 +1205,8 @@ dataType = new QName(dataType.getNamespaceURI(), datatype); } - if("http://www.w3.org/2001/XMLSchema".equals(dataType.getNamespaceURI())){ + if("http://www.w3.org/2001/XMLSchema".equals(dataType.getNamespaceURI()) || + "http://schemas.xmlsoap.org/soap/encoding/".equals(dataType.getNamespaceURI())){ if(!isArray){ if(memberName.equals(ARRAY_TYPE_SENTINEL)){ memberName = ""; // composite is an array, ignore the sentinel name From kawas at dev.open-bio.org Thu Aug 13 17:26:26 2009 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Thu, 13 Aug 2009 17:26:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908132126.n7DLQQPw002092@dev.open-bio.org> kawas Thu Aug 13 17:26:26 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/org/biomoby/client In directory dev.open-bio.org:/tmp/cvs-serv2055/src/main/org/biomoby/client Modified Files: CentralDigestCachedSimpleImpl.java Log Message: added a finally block to load/store that calls close() on the underlying file moby-live/Java/src/main/org/biomoby/client CentralDigestCachedSimpleImpl.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestCachedSimpleImpl.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/client/CentralDigestCachedSimpleImpl.java 2008/10/30 02:33:25 1.4 +++ /home/repository/moby/moby-live/Java/src/main/org/biomoby/client/CentralDigestCachedSimpleImpl.java 2009/08/13 21:26:26 1.5 @@ -319,13 +319,17 @@ throws MobyException { // File outputFile = new File (cache.getAbsolutePath() + File.separator + clean (name)); File outputFile = new File (cache.getAbsolutePath() + File.separator + name); + PrintWriter fileout = null; try { - PrintWriter fileout = + fileout = new PrintWriter (new BufferedOutputStream (new FileOutputStream (outputFile))); fileout.write (data); fileout.close(); } catch (IOException e) { throw new MobyException ("Cannot write to '" + outputFile.getAbsolutePath() + ". " + e.toString()); + } finally { + if (fileout != null) + fileout.close(); } } @@ -343,9 +347,10 @@ *************************************************************************/ protected static String load (File file) throws MobyException { + BufferedReader in = null; try { StringBuffer buf = new StringBuffer(); - BufferedReader in + in = new BufferedReader (new FileReader (file)); char[] buffer = new char[1024]; int charsRead; @@ -359,6 +364,11 @@ } catch (Throwable e) { // be prepare for "out-of-memory" error throw new MobyException ("Serious error when reading from cache. " + e.toString()); + } finally { + if (in != null) + try { + in.close(); + } catch (IOException e) {} } } From gordonp at dev.open-bio.org Mon Aug 17 17:08:08 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 17 Aug 2009 17:08:08 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908172108.n7HL8858025505@dev.open-bio.org> gordonp Mon Aug 17 17:08:08 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util In directory dev.open-bio.org:/tmp/cvs-serv25469/src/main/ca/ucalgary/services/util Modified Files: RuleCreator.java Log Message: Provide extra suggestions for XPaths based on sibling nodes moby-live/Java/src/main/ca/ucalgary/services/util RuleCreator.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/RuleCreator.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/util/RuleCreator.java 2009/06/09 19:36:09 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/RuleCreator.java 2009/08/17 21:08:08 1.2 @@ -55,7 +55,7 @@ " xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n"); rule.append(" "+discoveryXPath+"\n"); if(dataType != null && !dataType.equals(MobyTags.MOBYOBJECT)){ - rule.append(" "+dataType+""); + rule.append(" "); } if(!nsXPaths.isEmpty()){ rule.append(" \n"); @@ -128,6 +128,29 @@ suggestions.add("{-- @"+attrName+" not available --} -- Click the "+ attrName+" link, not the "+attrVal+" link in results XML to use it"); // todo: place attr in selection last + // suggest sibling nodes too + NodeList siblings = selectionNode.getParentNode().getChildNodes(); + for(int i = 0; siblings.getLength() < 50 && i < siblings.getLength(); i++){ + Node sibling = siblings.item(i); + if(sibling == selectionNode || !(sibling instanceof Element)){ + continue; + } + if(((Element) sibling).getTextContent().length() > 0){ + String suggestion = "../"+sibling.getNodeName()+"/text() -- The sibling node's text contents"; + if(!suggestions.contains(suggestion)){ + suggestions.add(suggestion); + } + } + NamedNodeMap sibAttrs = ((Element) sibling).getAttributes(); + for(int j = 0; j < sibAttrs.getLength(); j++){ + String otherAttrName = sibAttrs.item(i).getLocalName(); + String suggestion = "../"+sibling.getNodeName()+"/@"+otherAttrName+ + " -- The value of sibling node's attribute "+otherAttrName; + if(!suggestions.contains(suggestion)){ + suggestions.add(suggestion); + } + } + } } // element selection was based on a given attribute being present (excludes case above by logic, not regex) else if(byAttrNameMatcher.find()){ From gordonp at dev.open-bio.org Mon Aug 17 17:08:43 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 17 Aug 2009 17:08:43 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908172108.n7HL8h0f025549@dev.open-bio.org> gordonp Mon Aug 17 17:08:43 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util In directory dev.open-bio.org:/tmp/cvs-serv25513/src/main/ca/ucalgary/services/util Modified Files: XHTMLForm.java Log Message: Corrected javadoc moby-live/Java/src/main/ca/ucalgary/services/util XHTMLForm.java,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/XHTMLForm.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/XHTMLForm.java 2009/06/09 19:13:29 1.8 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/XHTMLForm.java 2009/08/17 21:08:43 1.9 @@ -88,20 +88,20 @@ * @param url the location of the remote Web form that will be wrapped into a Moby Service */ public XHTMLForm(URL url) throws Exception{ - formURL = url; - formFiles = new HashMap>(); formEncType = new HashMap(); formAction = new HashMap(); formMethod = new HashMap(); formSubmitOptions = new HashMap>(); formImageOptions = new HashMap>(); + formURL = url; + setSpecURL(formURL); parse(formURL.openStream()); } /** - * We run XPaths on the XML document, rather than reading line-by-line as in the parent class. + * We run XPaths on the XML document, rather than reading line-by-line */ protected void parse(InputStream is) throws Exception{ xhtmlDoc = docBuilder.parse(is); From gordonp at dev.open-bio.org Mon Aug 17 17:10:40 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 17 Aug 2009 17:10:40 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908172110.n7HLAeg0025597@dev.open-bio.org> gordonp Mon Aug 17 17:10:40 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util In directory dev.open-bio.org:/tmp/cvs-serv25557/src/main/ca/ucalgary/services/util Modified Files: WSDLConfig.java MobySpecWrapper.java Log Message: Replaced mobyServiceName2MobyXPathMap in WSDLConfig with more generic mobyServiceName2MobyParamRenameMap in MobySpecWrapper moby-live/Java/src/main/ca/ucalgary/services/util WSDLConfig.java,1.6,1.7 MobySpecWrapper.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/WSDLConfig.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/WSDLConfig.java 2009/06/09 19:14:52 1.6 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/WSDLConfig.java 2009/08/17 21:10:40 1.7 @@ -60,7 +60,6 @@ private Map mobyServiceName2Encoding; //literal or encoded private Map> mobyServiceName2InputXSDTypes; private Map> mobyServiceName2OutputXSDTypes; - private Map> mobyServiceName2MobyXPathMap; private LSIDResolver lsidResolver; private static Logger logger = Logger.getLogger("ca.ucalgary.services.util.WSDLConfig"); @@ -99,7 +98,6 @@ mobyServiceName2OpOutput = new HashMap(); mobyServiceName2InputXSDTypes = new HashMap>(); mobyServiceName2OutputXSDTypes = new HashMap>(); - mobyServiceName2MobyXPathMap = new HashMap>(); mobyServiceName2TargetNamespaceURI = new HashMap(); lsidResolver = new LSIDResolver(); @@ -1230,17 +1228,6 @@ mobyServiceName2OutputXSDTypes.put(currentService, types); } - public Map getMobyParams2DocXPaths(){ - return mobyServiceName2MobyXPathMap.get(currentService); - } - - /** - * Primarily for use by systems that allow renaming of params, since SAWSDL doesn't directly - */ - public void setMobyParams2DocXPaths(Map moby2xpaths){ - mobyServiceName2MobyXPathMap.put(currentService, moby2xpaths); - } - public String getTargetNamespaceURI(){ return mobyServiceName2TargetNamespaceURI.get(currentService); } =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/MobySpecWrapper.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/MobySpecWrapper.java 2009/06/09 19:16:41 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/MobySpecWrapper.java 2009/08/17 21:10:40 1.4 @@ -27,6 +27,7 @@ private Map> serviceOutputs; private Map> serviceOutputFormats; private Map> fixedParams; + private Map> mobyServiceName2MobyParamRenameMap; private Map unitTests; public MobySpecWrapper(){ @@ -44,9 +45,21 @@ serviceInputFormats = new HashMap>(); serviceSecondaryFormats = new HashMap>(); serviceOutputFormats = new HashMap>(); + mobyServiceName2MobyParamRenameMap = new HashMap>(); unitTests = new HashMap(); } + public Map getMobyParams2ServiceParams(){ + return mobyServiceName2MobyParamRenameMap.get(currentService); + } + + /** + * Primarily for use by systems that allow renaming of params, since SAWSDL doesn't directly + */ + public void setMobyParams2ServiceParams(Map mobyName2serviceName){ + mobyServiceName2MobyParamRenameMap.put(currentService, mobyName2serviceName); + } + public String[] getServiceNames(){ return providerURIs.keySet().toArray(new String[providerURIs.size()]); } From gordonp at dev.open-bio.org Mon Aug 17 17:11:47 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 17 Aug 2009 17:11:47 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908172111.n7HLBlH6025641@dev.open-bio.org> gordonp Mon Aug 17 17:11:47 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services In directory dev.open-bio.org:/tmp/cvs-serv25605/src/main/ca/ucalgary/services Modified Files: WSDLService.java Log Message: Replaced mobyServiceName2MobyXPathMap in WSDLConfig with more generic mobyServiceName2MobyParamRenameMap in MobySpecWrapper moby-live/Java/src/main/ca/ucalgary/services WSDLService.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/WSDLService.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/WSDLService.java 2009/06/09 19:19:39 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/WSDLService.java 2009/08/17 21:11:47 1.4 @@ -164,7 +164,7 @@ // This is the mapping of moby parameter names to WS request & response // xpaths for the transformed parameters - Map paramMap = wsdlConfig.getMobyParams2DocXPaths(); + Map paramMap = wsdlConfig.getMobyParams2ServiceParams(); Map ruleURIs = wsdlConfig.getPrimaryInputFormats(); for(MobyPrimaryData mobyInputTemplate: service.getPrimaryInputs()){ @@ -452,7 +452,7 @@ } } - Map paramMap = wsdlConfig.getMobyParams2DocXPaths(); + Map paramMap = wsdlConfig.getMobyParams2ServiceParams(); Map outParamURIs = wsdlConfig.getPrimaryOutputFormats(); // note, that because of the context, the xpath will probably fail if an xpath function is called NamespaceContextImpl targetNSContext = null; From gordonp at dev.open-bio.org Mon Aug 17 17:14:00 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 17 Aug 2009 17:14:00 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908172114.n7HLE0bk025709@dev.open-bio.org> gordonp Mon Aug 17 17:14:00 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources In directory dev.open-bio.org:/tmp/cvs-serv25673/src/main/ca/ucalgary/services/resources Modified Files: floatingframe.js Log Message: Reflects change of seahawkAction to new, more generic passthrough label _dataAction in SoapServlet moby-live/Java/src/main/ca/ucalgary/services/resources floatingframe.js,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources/floatingframe.js,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/resources/floatingframe.js 2009/06/09 19:42:55 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources/floatingframe.js 2009/08/17 21:14:00 1.2 @@ -106,7 +106,8 @@ /* Get the servlet message */ window.showHint = function(){ - var url = "?seahawkAction=hint"; + /* _dataAction is a special parameter whose values comes from ca.ucalgary.services.util.DataRecorder.PASSTHROUGH_ACTION */ + var url = "?_dataAction=hint"; url = url + "&sid="+Math.random(); /* The random ID is so IE doesn't cache the GET request */ xmlHttp.onreadystatechange=stateChanged; @@ -117,7 +118,8 @@ showHint(); function pasteEvent(fieldObj){ - var url = "?sid="+Math.random()+"&seahawkAction=pasteEvent&field="+fieldObj.name; + /* _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; actionXmlHttp.open("GET",url,true); actionXmlHttp.send(null); From gordonp at dev.open-bio.org Mon Aug 17 17:16:01 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 17 Aug 2009 17:16:01 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908172116.n7HLG1J3025753@dev.open-bio.org> gordonp Mon Aug 17 17:16:01 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services In directory dev.open-bio.org:/tmp/cvs-serv25717/src/main/ca/ucalgary/services Modified Files: SoapServlet.java Log Message: Refactoring and corrections to allow proper functioning when no data recorder is provided (just a vanilla WSDL proxy, not a PBE system) moby-live/Java/src/main/ca/ucalgary/services SoapServlet.java,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.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/SoapServlet.java 2009/08/06 14:36:32 1.2 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.java 2009/08/17 21:16:01 1.3 @@ -48,7 +48,7 @@ private static Logger logger = Logger.getLogger("ca.ucalgary.services.SoapServlet"); - private PBERecorder recorder = null; + private DataRecorder recorder = null; static{ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @@ -84,14 +84,14 @@ } } - public void setRecorder(PBERecorder r){ + public void setRecorder(DataRecorder r){ recorder = r; if(indentationTransformer != null){ recorder.setTransformer(indentationTransformer); } } - public PBERecorder getRecorder(){ + public DataRecorder getRecorder(){ return recorder; } @@ -106,7 +106,7 @@ recorder.startRecording(request); //should set up a session } - String action = request.getParameter("seahawkAction"); + 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); @@ -114,22 +114,8 @@ } String endpoint = request.getParameter(WSDL_HTTP_PARAM); - String xpath = request.getParameter(PBERecorder.RETURN_XPATH_PARAM); - String autocompleteRequest = request.getParameter(PBERecorder.AUTOCOMPLETE_PARAM); - String resource = request.getParameter(PBERecorder.RESOURCE_FILE_PARAM); - String raw = request.getParameter(PBERecorder.RAW_XPATH_PARAM); - if(raw != null && raw.trim().length() != 0 && recorder != null){ - recorder.getRawXml(request, response); - } - else if(resource != null && resource.trim().length() != 0 && recorder != null){ - recorder.getResource(request, response); - } - else if(xpath != null && xpath.trim().length() != 0){ - writeWrapperForm(request, response); - } - //AJAX call for autocomplete - else if(autocompleteRequest != null && autocompleteRequest.trim().length() != 0){ - writeAutocompleteReply(request, response, autocompleteRequest); + 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); @@ -155,19 +141,20 @@ } // 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){ - if(recorder != null){ - writeWrapperForm(request, response); - } - else{ - response.setContentType("text/html"); - out.print("ErrorNo '"+WSDL_HTTP_PARAM+"' parameter (the location of the WSDL document)" + - "was specified in the POST request, and no PBE recorder " + - "is associated with this servlet"); - - } - return; + response.setContentType("text/html"); + out.print("ErrorNo '"+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{ @@ -189,7 +176,7 @@ String[] serviceSpecs = serviceSpec.split(" "); if(serviceSpecs.length != 10){ out.print("ErrorThe '"+SERVICE_SPEC_PARAM+"' parameter (specifying " + - "the service/port/operation/action/use) did not contain 8 space-separated values as expected"); + "the service/port/operation/action/use) did not contain 10 space-separated values as expected"); return; } @@ -225,8 +212,8 @@ String messageNSURI = serviceSpecs[4]; String messageName = serviceSpecs[5]; String soapAction = serviceSpecs[6]; - String opName = serviceSpecs[7]; // literal or encoded - String style = serviceSpecs[8]; // literal or encoded + String opName = serviceSpecs[7]; + String style = serviceSpecs[8]; // doc or rpc String use = serviceSpecs[9]; // literal or encoded QName qName = "rpc".equals(style) ? @@ -380,82 +367,12 @@ } // Now, we don't want to show the output directly, instead escape all markup // so the end-user sees it - answer = "
"+answer.replaceAll("<", "<")+"
"; + answer = "
"+stringResult.toString().replaceAll("<", "<")+"
"; } out.print("Service Response"+answer+""); } - private void writeAutocompleteReply(HttpServletRequest request, - HttpServletResponse response, - String seed){ - java.io.OutputStream out = null; - response.setContentType("text/plain"); - 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; - } - - String answer = "No data recorder appears to be associated with Seahawk, " + - "please inform gordonp at ucalgary.ca that you got this autocomplete error."; - if(recorder != null){ - try{ - answer = recorder.autocomplete(request, seed); - } catch(Exception e){ - //todo - answer = e.toString(); - } - } - - try{ - out.write(answer.getBytes()); - } - catch(java.io.IOException ioe){ - logger.log(Level.SEVERE, "While printing HTML form to servlet output stream", ioe); - return; - } - } - - // This is called when the user has picked a part of the service response to return in the MOBY service being created - private void writeWrapperForm(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; - } - - String answer = "No data recorder appears to be associated with Seahawk, " + - "please inform gordonp at ucalgary.ca that you got this error."; - if(recorder != null){ - try{ - out.write(recorder.writeWrapperForm(request).getBytes()); - return; - } catch(Exception e){ - answer = "Error in PBE system:\n" + e.toString()+"\n"; - for(StackTraceElement ste: e.getStackTrace()){ - answer += ste.toString()+"\n"; - } - } - } - - try{ - out.write("Service Definition Error\n".getBytes()); - out.write((""+answer+"").getBytes()); - } - catch(java.io.IOException ioe){ - logger.log(Level.SEVERE, "While printing HTML form to servlet output stream", ioe); - return; - } - } - // Asks for the WSDL file private void writeInputForm(HttpServletRequest request, HttpServletResponse response){ @@ -1025,7 +942,6 @@ use = msg2Use.get(opQName); } - boolean actionGiven = false; for(Map.Entry part: partsMap.entrySet()){ // doc style, should be only one part if(!isRpcStyle){ // assume document style @@ -1038,10 +954,10 @@ writeDataType(out, part.getKey(), part.getValue(), element2Members, ""); } out.print("Error: cannot find definition for data type " + - dataType); //"\nValid types are:"); - // for(QName key: element2Members.keySet()){ -// out.print(" "+key); -// } + dataType + "\nValid types are:"); + for(QName key: element2Members.keySet()){ + out.print(" "+key); + } continue; } for(Map.Entry subpart: subpartsMap.entrySet()){ @@ -1050,12 +966,12 @@ } else{ // rpc style writeDataType(out, part.getKey(), part.getValue(), element2Members, ""); - if(!actionGiven){ - actionSpec = actionSpec + opQName.getNamespaceURI() + " " + opQName.getLocalPart(); - actionGiven = true; - } } } // for parts + // special condition for rpc calls, still need to give the op ns & name + if(isRpcStyle){ + actionSpec = actionSpec + opQName.getNamespaceURI() + " " + opQName.getLocalPart(); + } actionSpec = actionSpec + " " + op2Action.get(opQName) + " " + opQName.getLocalPart() + " " + style + " " + use; out.print(""); @@ -1139,7 +1055,7 @@ else{ tns = contextNode.lookupNamespaceURI(p[0]); } - if(p[0].equals("tns")){ // osmetimes the tns prefix is not declared, but used anyway + if(p[0].equals("tns")){ // sometimes the tns prefix is not declared, but used anyway return getTargetNSQName(p[1], contextNode); } else{ From gordonp at dev.open-bio.org Mon Aug 17 17:16:59 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 17 Aug 2009 17:16:59 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908172116.n7HLGxFr025815@dev.open-bio.org> gordonp Mon Aug 17 17:16:59 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util In directory dev.open-bio.org:/tmp/cvs-serv25783/src/main/ca/ucalgary/services/util Added Files: DataRecorder.java Log Message: Refactoring to provide generic DataRecorder callbacks during SoapServlet execution, was PBERecorder hardcoded before moby-live/Java/src/main/ca/ucalgary/services/util DataRecorder.java,NONE,1.1 From gordonp at dev.open-bio.org Mon Aug 17 17:17:13 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 17 Aug 2009 17:17:13 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908172117.n7HLHDLL025859@dev.open-bio.org> gordonp Mon Aug 17 17:17:13 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util In directory dev.open-bio.org:/tmp/cvs-serv25823/src/main/ca/ucalgary/services/util Modified Files: PBERecorder.java Log Message: Refactoring to provide generic DataRecorder callbacks during SoapServlet execution, was PBERecorder hardcoded before moby-live/Java/src/main/ca/ucalgary/services/util PBERecorder.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/PBERecorder.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/util/PBERecorder.java 2009/06/09 19:37:17 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/util/PBERecorder.java 2009/08/17 21:17:13 1.2 @@ -33,7 +33,7 @@ /** * This class controls the interaction between the web browser and Seahawk via the pasting actions. */ -public class PBERecorder{ +public class PBERecorder implements DataRecorder{ private Map sessionId2gui; // link the http session with the GUI private Map sessionId2dom; // link the http session with the results of the WSDL service private Map sessionId2wsdlSpec; // link the http session with the wsdl service/port/op def @@ -218,6 +218,107 @@ transformer = t; } + public boolean shouldIntercept(HttpServletRequest request){ + return request.getParameter(PBERecorder.RETURN_XPATH_PARAM) != null || + request.getParameter(PBERecorder.AUTOCOMPLETE_PARAM) != null || + request.getParameter(PBERecorder.RESOURCE_FILE_PARAM) != null || + request.getParameter(PBERecorder.RAW_XPATH_PARAM) != null; + // TODO: deal with wsdl-less POST, which need writeWrapperForm call + } + + public void interceptRequest(HttpServletRequest request, + HttpServletResponse response){ + + String xpath = request.getParameter(PBERecorder.RETURN_XPATH_PARAM); + String autocompleteRequest = request.getParameter(PBERecorder.AUTOCOMPLETE_PARAM); + String resource = request.getParameter(PBERecorder.RESOURCE_FILE_PARAM); + String raw = request.getParameter(PBERecorder.RAW_XPATH_PARAM); + + if(raw != null && raw.trim().length() != 0){ + getRawXml(request, response); + } + else if(resource != null && resource.trim().length() != 0){ + getResource(request, response); + } + //AJAX call for autocomplete + else if(autocompleteRequest != null && autocompleteRequest.trim().length() != 0){ + writeAutocompleteReply(request, response, autocompleteRequest); + } + else if(xpath != null && xpath.trim().length() != 0){ + writeWrapperForm(request, response); + } + // TODO: deal with wsdl-less POST, which need writeWrapperForm call + else{ + // Shouldn't get here unless shouldIntercept() was not checked before calling this method, + // or the logic of shouldIntercept() is inconsistent with that of this method. + + } + } + + private void writeAutocompleteReply(HttpServletRequest request, + HttpServletResponse response, + String seed){ + java.io.OutputStream out = null; + response.setContentType("text/plain"); + 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; + } + + String answer = ""; + try{ + answer = autocomplete(request, seed); + } catch(Exception e){ + //todo: make pretty, more verbose, etc., fit on one line for AJAX client + answer = e.toString(); + } + + try{ + out.write(answer.getBytes()); + } + catch(java.io.IOException ioe){ + logger.log(Level.SEVERE, "While printing HTML form to servlet output stream", ioe); + return; + } + } + + // This is called when the user has picked a part of the service response to return in the MOBY service being created + private void writeWrapperForm(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; + } + + String answer = ""; + try{ + out.write(writeWrapperForm(request).getBytes()); + return; + } catch(Exception e){ + answer = "Error in PBE system:\n" + e.toString()+"\n"; + for(StackTraceElement ste: e.getStackTrace()){ + answer += ste.toString()+"\n"; + } + } + + try{ + out.write("Service Definition Error\n".getBytes()); + out.write((""+answer+"").getBytes()); + } + catch(java.io.IOException ioe){ + logger.log(Level.SEVERE, "While printing HTML form to servlet output stream", ioe); + return; + } + } + /** * Called when data in a field is being updated via a paste event. */ @@ -227,7 +328,7 @@ MobyContentGUI gui = sessionId2gui.get(session.getId()); // datatype<->event unification for Seahawk->browser drag 'n' drop - String action = request.getParameter("seahawkAction"); + String action = request.getParameter(DataRecorder.PASSTHROUGH_ACTION); if(action.equals("pasteEvent")){ dataPasted(request); } @@ -252,7 +353,8 @@ try{ response.getOutputStream().write(statusMessage.getBytes()); } catch(Exception e){ - logger.log(Level.SEVERE, "Cannot write the response to a seahawkAction request", e); + logger.log(Level.SEVERE, "Cannot write the response to a " + + DataRecorder.PASSTHROUGH_ACTION + " request", e); } } @@ -391,7 +493,7 @@ "the service (probably an internal error): " + e); } - System.err.println(stringResult.toString()); + //System.err.println(stringResult.toString()); // Replace any enclosing tag with links that indicate the tag contents are of // interest based on tag or attribute name, or attribute value String markup = stringResult.toString().replaceAll(" ranges = new Vector(); @@ -460,7 +563,13 @@ } // literal string replacement String linkedElement = applyEdits(elementText, ranges, replacements); - markup = markup.replace(elementText, linkedElement); + newMarkup.append(markup.substring(markupLengthRemoved, elementMatcher.start())); + newMarkup.append(linkedElement); + //markup = elementMatcher.end() >= markup.length() ? "" : + // markup.substring(elementMatcher.end()-markupLengthRemoved); + markupLengthRemoved = elementMatcher.end(); + //elementMatcher = elementPattern.matcher(markup); + //markup = markup.replace(elementText, linkedElement); } } @@ -470,7 +579,7 @@ "Below, click the most indented element name, attribute name, or specific attribute value "+ "that you expect to be always present in a successful execution. You will then be taken to "+ "a form asking you about how you want this data returned using the Moby data types." + - ""+"
"+markup+"
"; + ""+"
"+newMarkup+"
"; } private void addEdit(Vector exciseRanges, int[] newRange, @@ -595,12 +704,16 @@ // give surrounding words (numChars worth total) around targetWord in text private String getContext(String text, String targetWord, int numChars){ + return getContext(text, targetWord, numChars, true); // true = use tool tips for ellipsis expansion + } + + private String getContext(String text, String targetWord, int numChars, boolean useToolTip){ text = text.replaceAll("\n",""); //new-line obvious messes up ajax one-line per response format if(text.length() < numChars){ return text; //can fit the whole thing } - + int start = 0; if(targetWord.length() > 0){ start = text.toLowerCase().indexOf(targetWord)-numChars/2; @@ -628,8 +741,8 @@ } } - String prefix = start == 0 ? "" : "..."; - String suffix = end == text.length() ? "" : "..."; + String prefix = start == 0 ? "" : (useToolTip ? "..." : "..."); + String suffix = end == text.length() ? "" : (useToolTip ? "..." : "..."); return prefix+text.substring(start, end)+suffix; } @@ -1228,15 +1341,30 @@ if(dataType.length() != 0){ MobyDataType dt = MobyDataType.getDataType(dataType, SeahawkOptions.getRegistry()); - // xpaths should be called foo-memberName foo-otherMemberName etc. - for(MobyRelationship relationship: dt.getAllChildren()){ - String memberName = relationship.getName(); - String memberXPath = request.getParameter(VALUE_XPATH_PARAM+memberName); + String dataTypeName = dt.getName(); + if(dataTypeName.equals(MobyTags.MOBYSTRING) || + dataTypeName.equals(MobyTags.MOBYFLOAT) || + dataTypeName.equals(MobyTags.MOBYINTEGER) || + dataTypeName.equals(MobyTags.MOBYBOOLEAN) || + dataTypeName.equals(MobyTags.MOBYDATETIME)){ // is it a primitive? no suffix in that case... + String memberXPath = request.getParameter(VALUE_XPATH_PARAM); if(memberXPath == null){ - throw new Exception("Cannot find XPath param ("+VALUE_XPATH_PARAM+memberName+ - ") for '"+dataType + "' data type's member " + memberName); + throw new Exception("Cannot find XPath param ("+VALUE_XPATH_PARAM+ + ") for the '"+dataTypeName + "' primitive value "); + } + memberMap.put(MobyComplexBuilder.PRIMITIVE_VALUE_SENTINEL, fixXPath(memberXPath, request)); // "" is special member name key for primitives + } + else{ + // xpaths should be called foo-memberName foo-otherMemberName etc. + for(MobyRelationship relationship: dt.getAllChildren()){ + String memberName = relationship.getName(); + String memberXPath = request.getParameter(VALUE_XPATH_PARAM+memberName); + if(memberXPath == null){ + throw new Exception("Cannot find XPath param ("+VALUE_XPATH_PARAM+memberName+ + ") for '"+dataType + "' data type's member " + memberName); + } + memberMap.put(memberName, fixXPath(memberXPath, request)); } - memberMap.put(memberName, memberXPath); } } else{ @@ -1496,12 +1624,12 @@ ex.printStackTrace(); } } - NodeList nl = e.getElementsByTagName("*"); - for(int i = 0; i < nl.getLength(); i++){ - Element child = (Element) nl.item(i); - System.err.println("Element " + child.getNodeName() + " ns " + child.getNamespaceURI() + - " for prefix " + child.getPrefix()); - } + // NodeList nl = e.getElementsByTagName("*"); +// for(int i = 0; i < nl.getLength(); i++){ +// Element child = (Element) nl.item(i); +// //System.err.println("Element " + child.getNodeName() + " ns " + child.getNamespaceURI() + +// // " for prefix " + child.getPrefix()); +// } } // The namespace prefixes used in the selection xpath will use the following node's prefix:ns mappings @@ -1528,7 +1656,7 @@ xPathResults = (NodeList) xPathObj.evaluate(fixXPath(xPath, request), domNode, XPathConstants.NODESET); numResults = xPathResults.getLength(); if(numResults == 0){ - result.append("[the selection XPath does " + + result.append("[the selection XPath ("+fixXPath(xPath, request)+") does " + "not select any data, please modify"+ "]\n"); //
\n"); } @@ -1544,7 +1672,8 @@ } //todo output xsd type: xPathResults.item(0).getNamespaceURI(), xPathResults.item(0).getLocalName; - Vector valXPathSuggestions = RuleCreator.suggestValueXPathsFromSelectionXPath(xPath, xPathResults.item(0)); + + Vector valXPathSuggestions = (numResults == 0 ? new Vector() : RuleCreator.suggestValueXPathsFromSelectionXPath(xPath, xPathResults.item(0))); String valueXPath = getParam(request, VALUE_XPATH_PARAM); String selectOptions = null; boolean suggestable = false; @@ -1567,9 +1696,14 @@ // If no value already, let's suggest the first one if(valueXPath.length() == 0){ - valueXPath = valXPathSuggestions.elementAt(0).replaceAll("(.*) -- .*", "$1"); - valXPathSuggestions.removeElementAt(0); - suggestable = true; + if(valXPathSuggestions.size() == 0){ + valueXPath = ""; + } + else{ + valueXPath = valXPathSuggestions.elementAt(0).replaceAll("(.*) -- .*", "$1"); + valXPathSuggestions.removeElementAt(0); + suggestable = true; + } } } // a custom XPath @@ -1799,7 +1933,8 @@ // we do this here rather than on the referring page because the regex code // used to generate the referring page links can't make the prefixes easily //return xPath.replaceAll("/([a-zA-Z_0-9\\-]+)(?=/|$|\\[)", "/"+XPATH_DEFAULT_NS_PREFIX+":$1"); - return xPath.replaceAll("/([a-zA-Z_0-9\\-]+)(?=/|$)", "/*[local-name() = '$1']"); + return xPath.replaceAll("/([a-zA-Z_0-9\\-]+)(?=/|$)", "/*[local-name() = '$1']") + .replaceAll("/([a-zA-Z_0-9\\-]+)\\[", "/*[local-name() = '$1' and "); } else{ return xPath; //rpc nodes usually have no namespace @@ -2179,13 +2314,13 @@ if(i == 0){ MobyNamespace ns = obj.getPrimaryNamespace(); if(ns != null){ - result.append(""); } } else{ - result.append(""); } From gordonp at dev.open-bio.org Mon Aug 17 17:24:29 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 17 Aug 2009 17:24:29 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908172124.n7HLOTCg025969@dev.open-bio.org> gordonp Mon Aug 17 17:24:29 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv25933/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentPane.java Log Message: Incomplete Taverna2 export, fixed related to DataRecorder refactoring moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentPane.java,1.19,1.20 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2009/06/09 22:20:54 1.19 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2009/08/17 21:24:29 1.20 @@ -216,7 +216,7 @@ // remove the last part of the xPath, which is actually the value, not the selection String valXPath = xPath.substring(xPath.lastIndexOf("/")+1); - xPath = xPath.substring(0, xPath.lastIndexOf("/")); + //xPath = xPath.substring(0, xPath.lastIndexOf("/")); //todo: MOBY_OUTPUT_NS_PARAM MOBY_OUTPUT_TYPE_PARAM String transformationParam = ""; @@ -324,6 +324,17 @@ private void launchInWebBrowser(URL u){ // Launch the browser with the form the servlet hosts try{ + /* Desktop desktop = Desktop.getDesktop(); + if(!desktop.isSupported(Desktop.Action.BROWSE)) { + editorPane.setText("Your Java does not support external browser launch. " + + "Please manually launch a browser and go to the URL " + + u); + } + desktop.browse(u.toURI()); + } catch (java.net.URISyntaxException urise){ + logger.error("Could not create URI from URL ("+u+"): " + urise); + } catch (java.io.IOException ioe){ + logger.error("Could not launch browser for form (" + u + "): " + ioe);*/ org.jdesktop.jdic.desktop.Desktop.browse(u); } catch (Exception e){ logger.error("Could not launch browser for form (" + u + "): " + e); @@ -603,8 +614,8 @@ * PBE recorder. */ public void exportDone(String valuePasted, String transformRuleURI){ - if(soapServlet != null && soapServlet.getRecorder() != null){ - soapServlet.getRecorder().dataCopied(getDraggedData(), valuePasted, transformRuleURI); + if(soapServlet != null && soapServlet.getRecorder() != null && (soapServlet.getRecorder() instanceof PBERecorder)){ + ((PBERecorder) soapServlet.getRecorder()).dataCopied(getDraggedData(), valuePasted, transformRuleURI); } } @@ -711,7 +722,7 @@ return hasFailed; } - public String toScufl() throws Exception{ + public String toScufl(String workflowName) throws Exception{ URL[] historyToExport = (URL[]) history.toArray(new URL[history.size()]); if(historyIndex != historyToExport.length-1){ // Shorten the array if we aren't currently on the last doc (i.e. @@ -721,7 +732,7 @@ historyToExport = truncatedHistory; } ByteArrayOutputStream output = new ByteArrayOutputStream(); - dataRecorder.exportWorkflow(historyToExport, output, DataRecorder.TAVERNA15); + dataRecorder.exportWorkflow(historyToExport, output, workflowName, DataRecorder.TAVERNA15); return output.toString(); } From gordonp at dev.open-bio.org Mon Aug 17 17:25:33 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 17 Aug 2009 17:25:33 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908172125.n7HLPXCQ026057@dev.open-bio.org> gordonp Mon Aug 17 17:25:33 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv26021/src/main/ca/ucalgary/seahawk/gui Modified Files: MobySaveDialog.java Log Message: Changes reflecting name-keeping in workflow saves moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobySaveDialog.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.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/seahawk/gui/MobySaveDialog.java 2007/12/06 18:50:15 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobySaveDialog.java 2009/08/17 21:25:33 1.6 @@ -154,7 +154,8 @@ public void run() { try { OutputStream ostream = new FileOutputStream(f); - String xml = tab.toScufl(); + String workflowName = f.getName().replaceFirst("\\.[^.]+$",""); //chop off .suffix + String xml = tab.toScufl(workflowName); ostream.write(xml.getBytes()); ostream.flush(); ostream.close(); From gordonp at dev.open-bio.org Mon Aug 17 17:27:30 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 17 Aug 2009 17:27:30 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908172127.n7HLRUBE026123@dev.open-bio.org> gordonp Mon Aug 17 17:27:30 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv26087/src/main/ca/ucalgary/seahawk/services Modified Files: MobyClient.java Log Message: Made less verbose, catches null text input, and fixed so primitive rules work properly moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.22,1.23 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.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/services/MobyClient.java 2009/06/09 19:25:12 1.22 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2009/08/17 21:27:30 1.23 @@ -316,9 +316,9 @@ continue; } dataTypeString = getDataType(ruleMember); - if(isPrimitiveDataType(dataTypeString)){ - addMemberMapping(ruleMember, memberMap, dataTypeString); - } +// if(isPrimitiveDataType(dataTypeString)){ +// addMemberMapping(ruleMember, memberMap, dataTypeString); +// } } else if(isMemberRule(ruleMember)){ addMemberMapping(ruleMember, memberMap, dataTypeString); @@ -343,7 +343,7 @@ if(memberMap.size() != 0){ System.err.println("Warning: ignoring member rules, since " + "no datatype was defined for the ruleset " + - "(base Obejct will be created)"); + "(base Object will be created)"); } for(int j = 0; j < xpathStrings.size(); j++){ @@ -686,6 +686,9 @@ public MobyDataObject[] getMobyObjects(String textData, MobyDataType targetDataType, MobyNamespace targetNS){ Vector objectVector = new Vector(); + if(textData == null){ + return new MobyDataObject[0]; + } for(Pattern pattern: regexMap.keySet()){ MobyComplexBuilder rule = regexMap.get(pattern); if((targetDataType == null || @@ -709,6 +712,7 @@ } } catch(Throwable t){ // Principally stack overflows System.err.println("Exception/Error ("+t+") while applying regex '"+pattern.pattern()+"' to text"); + t.printStackTrace(System.err); } } } @@ -1234,9 +1238,9 @@ } } }catch(javax.xml.xpath.XPathExpressionException xpe){ - System.err.println("Warning: Cannot select nodes due to exception "+ - "in XPath expression ("+xpath+"):" + xpe); - xpe.printStackTrace(); + //System.err.println("Warning: Cannot select nodes due to exception "+ + //"in XPath expression ("+xpath+"):" + xpe); + //xpe.printStackTrace(); return new Vector(); }catch(MobyException me){ System.err.println("Warning: Cannot create objects from select nodes due " + From gordonp at dev.open-bio.org Mon Aug 17 17:28:20 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 17 Aug 2009 17:28:20 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908172128.n7HLSKhu026189@dev.open-bio.org> gordonp Mon Aug 17 17:28:20 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util In directory dev.open-bio.org:/tmp/cvs-serv26153/src/main/ca/ucalgary/seahawk/util Modified Files: DataRecorder.java Log Message: Start of Taverna2 workflow export (not yet complete) moby-live/Java/src/main/ca/ucalgary/seahawk/util DataRecorder.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataRecorder.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/DataRecorder.java 2007/06/08 14:04:27 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/util/DataRecorder.java 2009/08/17 21:28:20 1.2 @@ -1,19 +1,27 @@ package ca.ucalgary.seahawk.util; import org.biomoby.client.MobyRequestEvent; +import org.biomoby.registry.meta.*; import org.biomoby.shared.*; import org.biomoby.shared.data.*; import org.w3c.dom.*; import javax.xml.parsers.*; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.*; import java.io.*; import java.net.URL; +import java.text.SimpleDateFormat; import java.util.*; public class DataRecorder{ public static final int TAVERNA15 = 167; + public static final int T2FLOW = 169; + public static final String T2FLOW_NS = "http://taverna.sf.net/2008/xml/t2flow"; + public static final String T2FLOW_DISPATCHXML = "ca/ucalgary/seahawk/resources/t2flowDispatchStack.xml"; public static final String PI_TARGET = "seahawk"; public static final String TEMP_FILE_PREFIX = "seahawk"; public static final String SERVICEID_ATTR = "service"; @@ -21,9 +29,12 @@ private static final String INPUT_SUFFIX = ".in.xml"; private Central mobyCentral; + private Map namesUsed; // keep count of workflow element name usage so as not to duplicate an ID private Map outputURL2InputURL; private Map requestID2InputURL; private DocumentBuilder docBuilder; + private static Element dispatchStack = null; + private static Transformer nullTransformer = null; public DataRecorder(Central mobyCtr) throws Exception{ if(mobyCtr == null){ @@ -32,6 +43,7 @@ mobyCentral = mobyCtr; docBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); + namesUsed = new HashMap(); outputURL2InputURL = new HashMap(); requestID2InputURL = new HashMap(); } @@ -81,9 +93,9 @@ * @param format the format to write the workflow in (current DataRecorder.TAVERNA15) */ public void exportWorkflow(URL endpointDocument, OutputStream outputStream, int format) throws Exception{ - if(format != TAVERNA15){ + if(format != TAVERNA15 && format != T2FLOW){ throw new IllegalArgumentException("The export format for the workflow was " + - "not DataRecorder.TAVERNA15 as expected, found " + format); + "not DataRecorder.TAVERNA15 nor DataRecorder.T2FLOW as expected, found " + format); } if(outputStream == null){ throw new IllegalArgumentException("The output stream for workflow exporting was null, aborting export"); @@ -101,17 +113,20 @@ throw new IOException("Could not open workflow endpoint document provided as input to workflow exporter: " + ioe); } - outputSCUFLHeader(outputStream); - - //TODO: Do an iterative traceback - - outputSCUFLFooter(outputStream); + if(format == TAVERNA15){ + outputSCUFLHeader(outputStream); + //TODO: Do an iterative traceback + outputSCUFLFooter(outputStream); + } + else{ + //TODO: Do an iterative traceback + } } - public void exportWorkflow(URL[] documentHistory, OutputStream outputStream, int format) throws Exception{ - if(format != TAVERNA15){ + public void exportWorkflow(URL[] documentHistory, OutputStream outputStream, String workflowName, int format) throws Exception{ + if(format != TAVERNA15 && format != T2FLOW){ throw new IllegalArgumentException("The export format for the workflow was " + - "not DataRecorder.TAVERNA15 as expected, found " + format); + "not DataRecorder.TAVERNA15 nor DataRecorder.T2FLOW as expected, found " + format); } if(outputStream == null){ throw new IllegalArgumentException("The output stream for workflow exporting was null, aborting export"); @@ -120,6 +135,360 @@ throw new IllegalArgumentException("The URL endpoint to export was null, aborting workflow export"); } + if(format == TAVERNA15){ + exportSCUFL(documentHistory, outputStream); + } + else{ + exportT2Flow(documentHistory, outputStream, workflowName); + } + } + + // Taverna 2.0+ format + private synchronized void exportT2Flow(URL[] documentHistory, OutputStream outputStream, String workflowName) + throws Exception{ + Document doc = docBuilder.newDocument(); + Element root = doc.createElementNS(T2FLOW_NS, "workflow"); + doc.appendChild(root); + root.setAttribute("version", "1"); + root.setAttribute("producedBy", "Seahawk 1.0"); + + Element dataflow = doc.createElementNS(T2FLOW_NS, "dataflow"); + dataflow.setAttribute("id", java.util.UUID.randomUUID().toString()); + dataflow.setAttribute("role", "top"); + root.appendChild(dataflow); + + Element name = doc.createElementNS(T2FLOW_NS, "name"); + name.appendChild(doc.createTextNode(workflowName)); + dataflow.appendChild(name); + + // set up the main sections, details to be filled in later + Element inputPorts = doc.createElementNS(T2FLOW_NS, "inputPorts"); + dataflow.appendChild(inputPorts); + Element outputPorts = doc.createElementNS(T2FLOW_NS, "outputPorts"); + dataflow.appendChild(outputPorts); + Element processors = doc.createElementNS(T2FLOW_NS, "processors"); + dataflow.appendChild(processors); + // no "conditions" tag applicable yet, skipping + Element datalinks = doc.createElementNS(T2FLOW_NS, "datalinks"); + dataflow.appendChild(datalinks); + + namesUsed.clear(); // internal Taverna label table + + for(int i = 0; i < documentHistory.length; i++){ + //MobyService service = getService(srcURL); + //inputPorts.appendChild(createPortElement()); + // add processor + //processors.appendChild(createProcessorElement()); + // add datalink + //datalinks.appendChild(createDataLinkElement()); + //outputPorts.appendChild(createPortElement()); + } + + // Serialize the DOM + getTransformer().transform(new DOMSource(root), new StreamResult(outputStream)); + } + + private Element createDataLinkElement(MobyService service1, MobyPrimaryData outParam, + MobyService service2, MobyPrimaryData inParam, + Document doc){ + Element datalink = doc.createElementNS(T2FLOW_NS, "datalink"); + + Element sink = doc.createElementNS(T2FLOW_NS, "sink"); + sink.setAttribute("type", "processor"); + datalink.appendChild(sink); + + Element processor = doc.createElementNS(T2FLOW_NS, "processor"); + processor.appendChild(doc.createTextNode(getProcessorName(service2))); + sink.appendChild(processor); + + Element port = doc.createElementNS(T2FLOW_NS, "port"); + port.appendChild(doc.createTextNode(getPortName(inParam))); + sink.appendChild(port); + + Element src = doc.createElementNS(T2FLOW_NS, "source"); + src.setAttribute("type", "processor"); + datalink.appendChild(src); + + Element processorSrc = doc.createElementNS(T2FLOW_NS, "processor"); + processorSrc.appendChild(doc.createTextNode(getProcessorName(service1))); + src.appendChild(processorSrc); + + Element portSrc = doc.createElementNS(T2FLOW_NS, "port"); + portSrc.appendChild(doc.createTextNode(getPortName(outParam))); + src.appendChild(portSrc); + + return datalink; + } + + private synchronized Transformer getTransformer() throws Exception{ + if(nullTransformer == null){ + nullTransformer = TransformerFactory.newInstance().newTransformer(); + } + return nullTransformer; + } + + //Ensures a unique name for the processor (same Moby service may be called more than once) + private String getProcessorName(MobyService service){ + String preferredName = service.getName(); + if(namesUsed.containsKey(preferredName)){ + namesUsed.put(preferredName, namesUsed.get(preferredName).intValue()+1); //increment + preferredName += namesUsed.get(preferredName); + } + else{ + namesUsed.put(preferredName, 1); // will be auto-boxed to Integer + } + return preferredName; + } + + //todo: mobyData('Object') or dataType(articleName) + private String getPortName(MobyPrimaryData data){ + return null; + } + + // Turn a Moby service call into a Taverna processor + private Element createProcessorElement(MobyService service, MobyDataJob sampleInput, Document doc) + throws Exception{ + Element processor = doc.createElementNS(T2FLOW_NS, "processor"); + Element name = doc.createElementNS(T2FLOW_NS, "name"); + name.appendChild(doc.createTextNode(getProcessorName(service))); + processor.appendChild(name); + + Element inputPorts = doc.createElementNS(T2FLOW_NS, "inputPorts"); + processor.appendChild(inputPorts); + for(MobyPrimaryData inParam: service.getPrimaryInputs()){ + Element port = doc.createElementNS(T2FLOW_NS, "port"); + inputPorts.appendChild(port); + + Element portName = doc.createElementNS(T2FLOW_NS, "name"); + portName.appendChild(doc.createTextNode(getPortName(inParam))); + port.appendChild(portName); + + Element depth = doc.createElementNS(T2FLOW_NS, "depth"); + depth.appendChild(doc.createTextNode("0")); + port.appendChild(depth); + } + + Element outputPorts = doc.createElementNS(T2FLOW_NS, "outputPorts"); + for(MobyPrimaryData outParam: service.getPrimaryOutputs()){ + Element port = doc.createElementNS(T2FLOW_NS, "port"); + outputPorts.appendChild(port); + + Element portName = doc.createElementNS(T2FLOW_NS, "name"); + portName.appendChild(doc.createTextNode(getPortName(outParam))); + port.appendChild(portName); + + Element depth = doc.createElementNS(T2FLOW_NS, "depth"); + depth.appendChild(doc.createTextNode("0")); + port.appendChild(depth); + + Element granularDepth = doc.createElementNS(T2FLOW_NS, "granularDepth"); + granularDepth.appendChild(doc.createTextNode("0")); + port.appendChild(granularDepth); + } + + processor.appendChild(doc.createElementNS(T2FLOW_NS, "annotations")); + + Element activities = doc.createElementNS(T2FLOW_NS, "activities"); + processor.appendChild(activities); + Element activity = doc.createElementNS(T2FLOW_NS, "activity"); + activities.appendChild(activity); + Element raven = doc.createElementNS(T2FLOW_NS, "raven"); + Element group = doc.createElementNS(T2FLOW_NS, "group"); + group.appendChild(doc.createTextNode("net.sf.taverna.t2.activities")); + raven.appendChild(group); + Element artifact = doc.createElementNS(T2FLOW_NS, "artifact"); + artifact.appendChild(doc.createTextNode("biomoby-activity")); + raven.appendChild(artifact); + Element version = doc.createElementNS(T2FLOW_NS, "version"); + version.appendChild(doc.createTextNode("0.8")); + raven.appendChild(version); + + Element clas = doc.createElementNS(T2FLOW_NS, "class"); + activity.appendChild(clas); + clas.appendChild(doc.createTextNode("net.sf.taverna.t2.activities.biomoby.BiomobyActivity")); + + Element inputMap = doc.createElementNS(T2FLOW_NS, "inputMap"); + activity.appendChild(inputMap); + for(MobyPrimaryData inParam: service.getPrimaryInputs()){ + Element map = doc.createElementNS(T2FLOW_NS, "map"); + map.setAttribute("from", getPortName(inParam)); //identity map + map.setAttribute("to", getPortName(inParam)); //identity map + inputMap.appendChild(map); + } + Element outputMap = doc.createElementNS(T2FLOW_NS, "outputMap"); + activity.appendChild(outputMap); + for(MobyPrimaryData outParam: service.getPrimaryOutputs()){ + Element map = doc.createElementNS(T2FLOW_NS, "map"); + map.setAttribute("from", getPortName(outParam)); //identity map + map.setAttribute("to", getPortName(outParam)); //identity map + outputMap.appendChild(map); + } + + Element configBean = doc.createElementNS(T2FLOW_NS, "configBean"); + configBean.setAttribute("encoding", "xstream"); + activity.appendChild(configBean); + Element BiomobyActivityConfigurationBean = + doc.createElementNS("", + "net.sf.taverna.t2.activities.biomoby.BiomobyActivityConfigurationBean"); + configBean.appendChild(BiomobyActivityConfigurationBean); + + MobyServiceType serviceType = service.getServiceType(); + String central = null; // url of Moby Central endpoint: check if the registry is dfined anywhere in the service + if(serviceType != null){ + if(serviceType.getRegistry() != null){ + central = serviceType.getRegistry().getEndpoint(); + } + } + if(central == null){ + for(MobyPrimaryData inParam: service.getPrimaryInputs()){ + if(inParam.getDataType().getRegistry() != null){ + central = inParam.getDataType().getRegistry().getEndpoint(); + break; + } + } + } + if(central == null){ // must be the default registry in this case + central = (new RegistriesList()).get(Registries.DEFAULT_REGISTRY_SYNONYM).getEndpoint(); + } + Element mobyEndpoint = doc.createElementNS("", "mobyEndpoint"); + mobyEndpoint.appendChild(doc.createTextNode(central == null ? "" : central)); + BiomobyActivityConfigurationBean.appendChild(mobyEndpoint); + + Element serviceName = doc.createElementNS("", "serviceName"); + serviceName.appendChild(doc.createTextNode(service.getName())); + BiomobyActivityConfigurationBean.appendChild(serviceName); + + Element authorityName = doc.createElementNS("", "authorityName"); + authorityName.appendChild(doc.createTextNode(service.getAuthority())); + + BiomobyActivityConfigurationBean.appendChild(doc.createElementNS("", "category")); + BiomobyActivityConfigurationBean.appendChild(doc.createElementNS("", "serviceType")); + + Element secondaries = doc.createElementNS("", "secondaries"); + BiomobyActivityConfigurationBean.appendChild(secondaries); + for(MobySecondaryData secParam: service.getSecondaryInputs()){ + Element entry = doc.createElementNS("", "entry"); + + Element stringName = doc.createElementNS("", "string"); + stringName.appendChild(doc.createTextNode(secParam.getName())); + entry.appendChild(stringName); + + // Did we override the default value for the secondary param in the example input? + Element stringValue = doc.createElementNS("", "string"); + if(sampleInput.containsKey(secParam.getName())){ + stringValue.appendChild(doc.createTextNode(((MobyDataSecondaryInstance) sampleInput.get(secParam.getName())).getValue())); + } + else{ // use the default defined in Moby Central + stringValue.appendChild(doc.createTextNode(secParam.getDefaultValue())); + } + entry.appendChild(stringValue); + + secondaries.appendChild(entry); + } + + // boiler-plate for all processors + processor.appendChild(getDispatchStack()); + + Element iterationStrategyStack = doc.createElementNS(T2FLOW_NS, "iterationStrategyStack"); + processor.appendChild(iterationStrategyStack); + Element iteration = doc.createElementNS(T2FLOW_NS, "iteration"); + iterationStrategyStack.appendChild(iteration); + Element strategy = doc.createElementNS(T2FLOW_NS, "strategy"); + iteration.appendChild(strategy); + Element cross = doc.createElementNS(T2FLOW_NS, "cross"); + strategy.appendChild(cross); + for(MobyPrimaryData inParam: service.getPrimaryInputs()){ + Element portRef = doc.createElementNS(T2FLOW_NS, "port"); + portRef.setAttribute("name", getPortName(inParam)); + portRef.setAttribute("depth", "0"); + cross.appendChild(portRef); + } + + return processor; + } + + // todo + private synchronized Element getDispatchStack() throws Exception{ + // first call, load the xml from the resource + if(dispatchStack == null){ + URL xmlURL = getClass().getClassLoader().getResource(T2FLOW_DISPATCHXML); + if(xmlURL == null){ + throw new Exception("Cannot find resource " + T2FLOW_DISPATCHXML); + } + Document domDoc = docBuilder.parse(xmlURL.openStream()); + dispatchStack = domDoc.getDocumentElement(); + } + return dispatchStack; + } + + // Describe a workflow input to Taverna + private Element createPortElement(String name, MobyDataInstance instance, MobyDataType dataType, Document doc){ + Element port = doc.createElementNS(T2FLOW_NS, "port"); + Element nameEl = doc.createElementNS(T2FLOW_NS, "name"); + nameEl.appendChild(doc.createTextNode(name)); + port.appendChild(nameEl); + + Element depth = doc.createElementNS(T2FLOW_NS, "depth"); + depth.appendChild(doc.createTextNode("0")); + port.appendChild(depth); + + Element granularDepth = doc.createElementNS(T2FLOW_NS, "granularDepth"); + granularDepth.appendChild(doc.createTextNode("0")); + port.appendChild(granularDepth); + + Element annotations = doc.createElementNS(T2FLOW_NS, "annotations"); + port.appendChild(annotations); + + Element annotation_chain = doc.createElementNS(T2FLOW_NS, "annotation_chain"); + annotation_chain.setAttribute("encoding", "xstream"); + + Element AnnotationChainImpl = doc.createElementNS("", "net.sf.taverna.t2.annotation.AnnotationChainImpl"); + annotation_chain.appendChild(AnnotationChainImpl); + + Element annotationAssertions = doc.createElementNS("", "annotationAssertions"); + AnnotationChainImpl.appendChild(annotationAssertions); + + Element AnnotationAssertionImpl = doc.createElementNS("", "net.sf.taverna.t2.annotation.AnnotationAssertionImpl"); + Element annotation_chainExample = (Element) annotation_chain.cloneNode(true); + Element annotation_chainDesc = (Element) annotation_chain.cloneNode(true); + annotations.appendChild(annotation_chainExample); + annotations.appendChild(annotation_chainDesc); + Element AnnotationAssertionImplExample = (Element) annotation_chainExample.getFirstChild().getFirstChild().getFirstChild(); + Element AnnotationAssertionImplDesc = (Element) annotation_chainDesc.getFirstChild().getFirstChild().getFirstChild(); + + Element annotationBeanExample = doc.createElementNS("", "annotationBean"); + annotationBeanExample.setAttribute("class", "net.sf.taverna.t2.annotation.annotationbeans.ExampleValue"); + AnnotationAssertionImplExample.appendChild(annotationBeanExample); + + Element textExample = doc.createElementNS("", "text"); + textExample.appendChild(doc.createTextNode(instance+" is an example input")); //todo: correct field + annotationBeanExample.appendChild(textExample); + + SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd' 'HH:mm:ss.SSS' GMT'"); + dateFormat.setTimeZone(new SimpleTimeZone(0, "GMT")); + Element dateExample = doc.createElementNS("", "date"); + dateExample.appendChild(doc.createTextNode(dateFormat.format(new Date()))); //now + AnnotationAssertionImplExample.appendChild(dateExample); + + AnnotationAssertionImplExample.appendChild(doc.createElementNS("","creators")); //blank + AnnotationAssertionImplExample.appendChild(doc.createElementNS("","curationEventList")); //blank + + Element annotationBeanDesc = doc.createElementNS("", "annotationBean"); + annotationBeanDesc.setAttribute("class", "net.sf.taverna.t2.annotation.annotationbeans.FreeTextDescription"); + AnnotationAssertionImplDesc.appendChild(annotationBeanDesc); + + Element textDesc = doc.createElementNS("", "text"); + textDesc.appendChild(doc.createTextNode(dataType.getDescription())); //todo: what if secondary? + annotationBeanDesc.appendChild(textDesc); + + AnnotationAssertionImplDesc.appendChild(dateExample.cloneNode(true)); //reuse data from example tag + AnnotationAssertionImplDesc.appendChild(doc.createElementNS("","creators")); //blank + AnnotationAssertionImplDesc.appendChild(doc.createElementNS("","curationEventList")); //blank + + return port; + } + + private void exportSCUFL(URL[] documentHistory, OutputStream outputStream) throws Exception{ outputSCUFLHeader(outputStream); // The first service to be called int i = 0; From gordonp at dev.open-bio.org Mon Aug 17 17:31:53 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 17 Aug 2009 17:31:53 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908172131.n7HLVr14026277@dev.open-bio.org> gordonp Mon Aug 17 17:31:52 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources In directory dev.open-bio.org:/tmp/cvs-serv26241/src/main/ca/ucalgary/seahawk/resources Modified Files: mobyBuilderRules.xml Log Message: Added a few rules, and Dublin Core IDs for rules moby-live/Java/src/main/ca/ucalgary/seahawk/resources mobyBuilderRules.xml,1.8,1.9 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml 2008/10/30 02:33:24 1.8 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/resources/mobyBuilderRules.xml 2009/08/17 21:31:52 1.9 @@ -1,11 +1,44 @@ - + http://www.bioxml.info/dtd/agave.dtd http://www.bioxml.info/dtd/tigrxml.dtd http://www.bioxml.info/dtd/Bioseq.dtd + +(HEADER\s+.*?(\S+)\n + (?:TITLE.*)? + (?:\nCOMPND.*)? + (?:\nSOURCE.*)? + (?:\nKEYWDS.*)? + (?:\nEXPDTA.*)? + (?:\nAUTHOR.*)? + (?:\nREVDAT.*)? + (?:\nREMARK.*)? + (?:\nSEQRES.*)? + (?:\nCRYST1.*)? + (?:\nORIGX1.*)? + (?:\nORIGX2.*)? + (?:\nORIGX3.*)? + (?:\nMASTER.*)? + \nEND)(?=\s|\n|\Z) + + $2 + + + $1 + + + + +(?:^|\n)\* \S+[^\n]*;\s+(\S+)\s*(?=\n|$) + + $1 + + + + urn:lsid:bioxml.info:mobyLiftingSchemaMapping:bareDNA2DNASequence \N*\s*(?:\N{10,}(?:\x20|\r|\t|\n)*)+\N* @@ -17,13 +50,17 @@ - \P*\s*(?:\P{10,}(?:\x20|\r|\t|\n)*)+\P* + urn:lsid:bioxml.info:mobyLiftingSchemaMapping:bareAA2AminoAcidSequence + (?:^|[^A-Za-z]) # some non-alphabetical boundary + (\P*\s*(?:\P{10,}(?:\x20|\r|\t|\n){2,})+\P*) # iupac or spacing + (?![A-Za-z]) # should not be followed by letters + '' - $0 - string-length('$0') + $1 + string-length('$1') @@ -113,6 +150,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 @@ -121,6 +159,7 @@ + urn:lsid:bioxml.info:mobyLiftingSchemaMapping:bareDOI2DOI (?:\s|\A|/)(10\.\d+/[A-Za-z]+[^%"\#\x20\t\r\n]+) $1 @@ -160,6 +199,7 @@ + urn:lsid:bioxml.info:mobyLiftingSchemaMapping:bareEC2MobyEC ([1-6]\.(?:[0-9]{1,2}|-)(?:\.[0-9]{1,3}|-){2}) @@ -169,7 +209,8 @@ - GeneID:(\d+) + urn:lsid:bioxml.info:mobyLiftingSchemaMapping:GeneId2EntrezGeneID + GeneID\s*:\s*(\d+) substring-after(./bioseq:fnote/bioseq:fval[starts-with(., "GeneID:")], "GeneID:") @@ -219,4 +260,11 @@ $1 + + + http://www.ncbi.nlm.nih.gov/sites/entrez\?Db=mesh&TermToSearch=(\d+) + + $1 + + From gordonp at dev.open-bio.org Mon Aug 17 17:48:25 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Mon, 17 Aug 2009 17:48:25 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908172148.n7HLmPVP026362@dev.open-bio.org> gordonp Mon Aug 17 17:48:24 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui In directory dev.open-bio.org:/tmp/cvs-serv26326/src/main/ca/ucalgary/seahawk/gui Modified Files: MobyContentPane.java Log Message: Randomized port for wrapping servlet to avoid problems when multiple people are wrapping at the same time on a single machine (e.g. a server) moby-live/Java/src/main/ca/ucalgary/seahawk/gui MobyContentPane.java,1.20,1.21 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.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/MobyContentPane.java 2009/08/17 21:24:29 1.20 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/gui/MobyContentPane.java 2009/08/17 21:48:24 1.21 @@ -92,7 +92,11 @@ private static org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(MobyContentPane.class); private static SoapServlet soapServlet; - private final int portNum = 8254; + + // Randomize the port used for the wrapping servlet: avoids problems + // when multiple people are wrapping on the same machine + private final int portNum = 8254+((int) (1000*Math.random())); + private final static String servletPath = "/SOAPServlet"; private static Acme.Serve.Serve servletContainer; private static Map id2GuiMap; From gordonp at dev.open-bio.org Tue Aug 18 14:22:07 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Tue, 18 Aug 2009 14:22:07 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908181822.n7IIM7IS030343@dev.open-bio.org> gordonp Tue Aug 18 14:22:07 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services In directory dev.open-bio.org:/tmp/cvs-serv30307/src/main/ca/ucalgary/seahawk/services Modified Files: MobyClient.java Log Message: Can take any CharSequence now for regexes, not just Strings (more convenient and efficient for StringBuffers to not use toString(), for example) moby-live/Java/src/main/ca/ucalgary/seahawk/services MobyClient.java,1.23,1.24 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2009/08/17 21:27:30 1.23 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/seahawk/services/MobyClient.java 2009/08/18 18:22:07 1.24 @@ -675,7 +675,7 @@ return getServices(getMobyObjects(u)); } - public MobyDataObject[] getMobyObjects(String textData, MobyDataType targetDataType){ + public MobyDataObject[] getMobyObjects(CharSequence textData, MobyDataType targetDataType){ return getMobyObjects(textData, targetDataType, null); } /** @@ -683,7 +683,7 @@ * maps a string using rules producing moby objects of the given type. * @param targetDataType matches any data type if null, otherwise restricts returned items to those that are of (or inherit from) the given type */ - public MobyDataObject[] getMobyObjects(String textData, MobyDataType targetDataType, MobyNamespace targetNS){ + public MobyDataObject[] getMobyObjects(CharSequence textData, MobyDataType targetDataType, MobyNamespace targetNS){ Vector objectVector = new Vector(); if(textData == null){ @@ -1024,7 +1024,7 @@ * Using the regular expression mappings that have been set up, * maps a string to moby objects. */ - public MobyDataObject[] getMobyObjects(String textData){ + public MobyDataObject[] getMobyObjects(CharSequence textData){ return getMobyObjects(textData, (byte[]) null); } @@ -1033,11 +1033,11 @@ * are derived from URN-addressable rules (which are the keys), mostly for provenance * and reproducibility purposes. */ - public Map getMobyObjectsURNMap(String textData){ + public Map getMobyObjectsURNMap(CharSequence textData){ return getMobyObjectsURNMap(textData, (byte[]) null); } - public Map getMobyObjectsURNMap(String textData, byte[] bytes){ + public Map getMobyObjectsURNMap(CharSequence textData, byte[] bytes){ Map results = new HashMap(); if(regexMap.isEmpty()){ System.out.println("The MOBY Client has not been provided any regex->moby data mappings!"); @@ -1074,7 +1074,7 @@ return results; } - public MobyDataObject[] getMobyObjects(String textData, byte[] bytes){ + public MobyDataObject[] getMobyObjects(CharSequence textData, byte[] bytes){ if(regexMap.isEmpty()){ System.out.println("The MOBY Client has not been provided any regex->moby data mappings!"); return new MobyDataObject[0]; From kawas at dev.open-bio.org Wed Aug 19 11:35:34 2009 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 19 Aug 2009 11:35:34 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908191535.n7JFZY3B005538@dev.open-bio.org> kawas Wed Aug 19 11:35:33 EDT 2009 Update of /home/repository/moby/moby-live/Perl/MOBY-Server/t In directory dev.open-bio.org:/tmp/cvs-serv5503/t Modified Files: Client-Central.t Log Message: added a test for datatype registration with a '%' in the name moby-live/Perl/MOBY-Server/t Client-Central.t,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY-Server/t/Client-Central.t,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOBY-Server/t/Client-Central.t 2009/04/08 16:16:48 1.4 +++ /home/repository/moby/moby-live/Perl/MOBY-Server/t/Client-Central.t 2009/08/19 15:35:33 1.5 @@ -278,6 +278,35 @@ # confirm that we cannot register a datatype with odd characters in its name $r = $C->registerObjectClass( + ( + objectType => "Rubbish_\%Art", + description => "a human-readable description of the object", + contactEmail => 'your at email.address', + authURI => "test.suite.com", + Relationships => { + ISA => [ + { + object => 'Object', + articleName => 'article1' + } + ], + HASA => [ + { + object => 'Object', + articleName => 'articleName3' + }, + ] + } + ) +); +ok( !$r->success, "Object registration correctly failed" ) + or diag( + "Shouldn't be possible to register Object with an invalid character in its name!" + . $r->message ); +$r = $C->deregisterObjectClass( objectType => "Rubbish_\%Art" ); + +# confirm that we cannot register a datatype with odd characters in its name +$r = $C->registerObjectClass( ( objectType => "Rubbish_/Art", description => "a human-readable description of the object", From kawas at dev.open-bio.org Wed Aug 19 11:36:20 2009 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 19 Aug 2009 11:36:20 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908191536.n7JFaKH9005581@dev.open-bio.org> kawas Wed Aug 19 11:36:19 EDT 2009 Update of /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY In directory dev.open-bio.org:/tmp/cvs-serv5546/lib/MOBY Modified Files: Central.pm Log Message: added '%' to the blacklist of characters not allowed in the name of a datatype moby-live/Perl/MOBY-Server/lib/MOBY Central.pm,1.9,1.10 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/Central.pm,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/Central.pm 2009/04/08 14:51:50 1.9 +++ /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/Central.pm 2009/08/19 15:36:19 1.10 @@ -318,7 +318,7 @@ return &_error("Object name may not contain spaces or other characters invalid in a URN", "" ) - if $term =~ /[\/\'\\\s\"\&\<\>\[\]\^\`\{\|\}\~]/; + if $term =~ /[\/\'\\\s\"\&\<\>\[\]\^\`\{\|\}\~\%\+]/; if ( $term =~ m"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?" ) { # matches a URI return &_error( "Object name may not be an URN or URI", "" ) if $1; From kawas at dev.open-bio.org Wed Aug 19 11:38:39 2009 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 19 Aug 2009 11:38:39 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908191538.n7JFcdxV005624@dev.open-bio.org> kawas Wed Aug 19 11:38:39 EDT 2009 Update of /home/repository/moby/moby-live/Perl/MOBY-Server In directory dev.open-bio.org:/tmp/cvs-serv5589 Modified Files: Changes Log Message: updated to reflect commits moby-live/Perl/MOBY-Server Changes,1.28,1.29 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY-Server/Changes,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- /home/repository/moby/moby-live/Perl/MOBY-Server/Changes 2009/05/22 16:38:39 1.28 +++ /home/repository/moby/moby-live/Perl/MOBY-Server/Changes 2009/08/19 15:38:39 1.29 @@ -3,6 +3,8 @@ 1.11 - Updated the Makefile.PL to handle some missing dependencies. + - Added '%' to the list of characters not allowed in the name of + a datatype. 1.10 - Added a RESTful WSDL page to the installation. Basically, you do From kawas at dev.open-bio.org Wed Aug 19 13:05:21 2009 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 19 Aug 2009 13:05:21 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908191705.n7JH5LND005808@dev.open-bio.org> kawas Wed Aug 19 13:05:21 EDT 2009 Update of /home/repository/moby/moby-live/Docs/ProjectDocs In directory dev.open-bio.org:/tmp/cvs-serv5773/ProjectDocs Modified Files: index.html Log Message: updated the test registry URL information. moby-live/Docs/ProjectDocs index.html,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Docs/ProjectDocs/index.html,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Docs/ProjectDocs/index.html 2009/01/19 19:13:29 1.10 +++ /home/repository/moby/moby-live/Docs/ProjectDocs/index.html 2009/08/19 17:05:21 1.11 @@ -52,9 +52,9 @@
URI: http://moby.ucalgary.ca/MOBY/CentralYESA curated public registry hosted at the SUN Centre of Excellence, CalgaryPolicy: open, non-test registry. Test services may be deleted at any time. - Open TEST registryEndpoint: http://bioinfo.icapture.ubc.ca/cgi-bin/mobycentral/MOBY-Central.pl -
OntologyServer: http://bioinfo.icapture.ubc.ca/cgi-bin/mobycentral/OntologyServer.cgi -
URI: http://bioinfo.icapture.ubc.ca/MOBY/CentralYESA full-featured + Open TEST registryEndpoint: http://mobytest.biordf.net/MOBY-Central.pl +
OntologyServer: http://mobytest.biordf.net/OntologyServer.cgi +
URI: http://mobytest.biordf.net/MOBY/CentralYESA full-featured registry for testing your code or pre-registering a service or whatever you wish. The codebase is generally kept up-to-date relative to the "real" registry, but the ontologies are not, so ontology nodes that you need might not be there and you will have to register them.For testing purposes only. No guarantee of stability of any kind. From kawas at dev.open-bio.org Wed Aug 19 13:07:27 2009 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Wed, 19 Aug 2009 13:07:27 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908191707.n7JH7RCI005866@dev.open-bio.org> kawas Wed Aug 19 13:07:26 EDT 2009 Update of /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Cache In directory dev.open-bio.org:/tmp/cvs-serv5831/MOSES-MOBY/lib/MOSES/MOBY/Cache Modified Files: Registries.pm Log Message: updated the test registry information moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Cache Registries.pm,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Cache/Registries.pm,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Cache/Registries.pm 2008/11/06 18:32:33 1.5 +++ /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Cache/Registries.pm 2009/08/19 17:07:26 1.6 @@ -54,10 +54,10 @@ text => 'The MOBY registry at the International Rice Research Institute (IRRI) is intended mostly for Generation Challenge Program (GCP) developers. It allows the registration of experimental moby entities within GCP.', }, testing => { - endpoint => 'http://bioinfo.icapture.ubc.ca/cgi-bin/mobycentral/MOBY-Central.pl', - namespace => 'http://bioinfo.icapture.ubc.ca/MOBY/Central', + endpoint => 'http://mobytest.biordf.net/MOBY-Central.pl', + namespace => 'http://mobytest.biordf.net/MOBY/Central', name => 'Testing BioMoby registry', - contact => 'Edward Kawas (edward.kawas at gmail.com)', + contact => 'Edward Kawas (edward.kawas+testregistry at gmail.com)', public => 'yes', }, ); From gordonp at dev.open-bio.org Wed Aug 19 16:25:05 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 19 Aug 2009 16:25:05 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908192025.n7JKP56A006419@dev.open-bio.org> gordonp Wed Aug 19 16:25:05 EDT 2009 Update of /home/repository/moby/moby-live/Java/docs/images In directory dev.open-bio.org:/tmp/cvs-serv6373/images Added Files: ws_response.png wsdl_ask.png input_ask.png datarecorder_hooks.png Log Message: Documentation for the SoapServlet class/WAR moby-live/Java/docs/images ws_response.png,NONE,1.1 wsdl_ask.png,NONE,1.1 input_ask.png,NONE,1.1 datarecorder_hooks.png,NONE,1.1 From gordonp at dev.open-bio.org Wed Aug 19 16:25:05 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 19 Aug 2009 16:25:05 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908192025.n7JKP53k006405@dev.open-bio.org> gordonp Wed Aug 19 16:25:05 EDT 2009 Update of /home/repository/moby/moby-live/Java/docs In directory dev.open-bio.org:/tmp/cvs-serv6373 Added Files: soapServlet.html Log Message: Documentation for the SoapServlet class/WAR moby-live/Java/docs soapServlet.html,NONE,1.1 From gordonp at dev.open-bio.org Wed Aug 19 16:45:45 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 19 Aug 2009 16:45:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908192045.n7JKjjTn006784@dev.open-bio.org> gordonp Wed Aug 19 16:45:45 EDT 2009 Update of /home/repository/moby/moby-live/Java/docs/images In directory dev.open-bio.org:/tmp/cvs-serv6748/images Modified Files: datarecorder_hooks.png Log Message: Forgot getBody() call in first version, now present moby-live/Java/docs/images datarecorder_hooks.png,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/images/datarecorder_hooks.png,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 Binary files /home/repository/moby/moby-live/Java/docs/images/datarecorder_hooks.png 2009/08/19 20:25:05 1.1 and /home/repository/moby/moby-live/Java/docs/images/datarecorder_hooks.png 2009/08/19 20:45:45 1.2 differ rcsdiff: /home/repository/moby/moby-live/Java/docs/images/datarecorder_hooks.png: diff failed From gordonp at dev.open-bio.org Wed Aug 19 16:47:23 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 19 Aug 2009 16:47:23 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908192047.n7JKlNq3006828@dev.open-bio.org> gordonp Wed Aug 19 16:47:23 EDT 2009 Update of /home/repository/moby/moby-live/Java/docs/images In directory dev.open-bio.org:/tmp/cvs-serv6792/images Modified Files: datarecorder_hooks.png Log Message: Line fix moby-live/Java/docs/images datarecorder_hooks.png,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/images/datarecorder_hooks.png,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 Binary files /home/repository/moby/moby-live/Java/docs/images/datarecorder_hooks.png 2009/08/19 20:45:45 1.2 and /home/repository/moby/moby-live/Java/docs/images/datarecorder_hooks.png 2009/08/19 20:47:22 1.3 differ rcsdiff: /home/repository/moby/moby-live/Java/docs/images/datarecorder_hooks.png: diff failed From gordonp at dev.open-bio.org Wed Aug 19 16:54:32 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 19 Aug 2009 16:54:32 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908192054.n7JKsWRw006874@dev.open-bio.org> gordonp Wed Aug 19 16:54:32 EDT 2009 Update of /home/repository/moby/moby-live/Java/docs In directory dev.open-bio.org:/tmp/cvs-serv6837 Modified Files: soapServlet.html Log Message: Updated image size for datarecorder_hooks.png moby-live/Java/docs soapServlet.html,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/soapServlet.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Java/docs/soapServlet.html 2009/08/19 20:25:05 1.1 +++ /home/repository/moby/moby-live/Java/docs/soapServlet.html 2009/08/19 20:54:32 1.2 @@ -132,7 +132,7 @@

To help you in writing a DataRecorder, the diagram below shows where your DataRecorder can affect the servlet: -

+

From gordonp at dev.open-bio.org Wed Aug 19 19:45:55 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 19 Aug 2009 19:45:55 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908192345.n7JNjt5p007173@dev.open-bio.org> gordonp Wed Aug 19 19:45:55 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/webapps/WEB-INF In directory dev.open-bio.org:/tmp/cvs-serv7141 Added Files: README.txt acd-abiview-web.xml acd-banana-web.xml soapweb.xml wsdlweb.xml Log Message: New web.xml files for various BioMOBY servlets moby-live/Java/src/webapps/WEB-INF README.txt,NONE,1.1 acd-abiview-web.xml,NONE,1.1 acd-banana-web.xml,NONE,1.1 soapweb.xml,NONE,1.1 wsdlweb.xml,NONE,1.1 From gordonp at dev.open-bio.org Thu Aug 20 12:47:02 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 20 Aug 2009 12:47:02 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908201647.n7KGl2Lg009549@dev.open-bio.org> gordonp Thu Aug 20 12:47:01 EDT 2009 Update of /home/repository/moby/moby-live/Java/docs In directory dev.open-bio.org:/tmp/cvs-serv9513/docs Modified Files: soapServlet.html Log Message: Reminder of nullary c-tor necessity for autoloading DataRecorders moby-live/Java/docs soapServlet.html,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/soapServlet.html,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Java/docs/soapServlet.html 2009/08/19 20:54:32 1.2 +++ /home/repository/moby/moby-live/Java/docs/soapServlet.html 2009/08/20 16:47:01 1.3 @@ -118,14 +118,17 @@ the example screenshots shown above. All the browser interaction between 1:20 and the end of the video is controlled by the PBERecorder intercepting and messaging SoapServlet messages. This demonstrates - the nice separation of concerns between the WSDL parsing/calling, and the user interface. + the nice separation of concerns between the WSDL parsing/calling, and the user interface. + The yellow screens are solely under the control of the DataRecorder, using the passthrough mechanism.

To use SoapServlet for your own more complex WS-calling system, simply implement a DataRecorder and register it with the servlet. This can be done at the Java code level with the SoapServlet.setRecorder() method, or in the WAR's WEB-INF/web.xml file by uncommenting the context-param called dataRecorder, setting the param-value to - the fully qualified class name you wrote that implements DataRecorder. Make sure you + the fully qualified class name you wrote that implements DataRecorder. Make sure your + DataRecorder has a no-args constructor if your going to use this autoloading functionality. + Also make sure you include your new class in the WAR's WEB-INF/classes directory too!

From gordonp at dev.open-bio.org Thu Aug 20 12:59:36 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 20 Aug 2009 12:59:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908201659.n7KGxalf009653@dev.open-bio.org> gordonp Thu Aug 20 12:59:36 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/resources In directory dev.open-bio.org:/tmp/cvs-serv9603/src/main/ca/ucalgary/services/resources Added Files: common.css wsdl_ask.css wsdl_input.css wsdl_result.css Log Message: Added SoapServlet customization capabilities with DataRecorder and CSS moby-live/Java/src/main/ca/ucalgary/services/resources common.css,NONE,1.1 wsdl_ask.css,NONE,1.1 wsdl_input.css,NONE,1.1 wsdl_result.css,NONE,1.1 From gordonp at dev.open-bio.org Thu Aug 20 12:59:36 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 20 Aug 2009 12:59:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908201659.n7KGxabD009639@dev.open-bio.org> gordonp Thu Aug 20 12:59:36 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services In directory dev.open-bio.org:/tmp/cvs-serv9603/src/main/ca/ucalgary/services Modified Files: SoapServlet.java Log Message: Added SoapServlet customization capabilities with DataRecorder and CSS moby-live/Java/src/main/ca/ucalgary/services SoapServlet.java,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.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/SoapServlet.java 2009/08/17 21:16:01 1.3 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.java 2009/08/20 16:59:36 1.4 @@ -23,6 +23,8 @@ public class SoapServlet extends HttpServlet{ + 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"; @@ -82,6 +84,41 @@ "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 = getInitParameter(DATARECORDER_CONTEXTPARAM); + 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){ @@ -150,7 +187,9 @@ String wsdlLoc = request.getParameter(WSDL_HTTP_PARAM); if(wsdlLoc == null || wsdlLoc.trim().length() == 0){ response.setContentType("text/html"); - out.print("ErrorNo '"+WSDL_HTTP_PARAM+"' parameter (the location of the WSDL document)" + + 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") +""); @@ -160,7 +199,9 @@ try{ url = new URL(wsdlLoc); } catch(Exception e){ - out.print("Error

The URL specified (" + + out.print("Error\n"+ + "\n"+ + "

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


");
 	    e.printStackTrace(out);
 	    out.print("
\n"); @@ -169,13 +210,17 @@ String serviceSpec = request.getParameter(SERVICE_SPEC_PARAM); if(wsdlLoc == null || wsdlLoc.trim().length() == 0){ - out.print("ErrorNo '"+SERVICE_SPEC_PARAM+"' parameter (specifying " + + out.print("Error\n"+ + "\n"+ + "No '"+SERVICE_SPEC_PARAM+"' parameter (specifying " + "the service/port/operation/action/use) was specified in the POST request"); return; } String[] serviceSpecs = serviceSpec.split(" "); if(serviceSpecs.length != 10){ - out.print("ErrorThe '"+SERVICE_SPEC_PARAM+"' parameter (specifying " + + out.print("Error\n"+ + "\n"+ + "The '"+SERVICE_SPEC_PARAM+"' parameter (specifying " + "the service/port/operation/action/use) did not contain 10 space-separated values as expected"); return; } @@ -185,7 +230,9 @@ try{ service = Service.create(url, serviceQName); } catch(Exception e){ - out.print(e.getClass().getName() + " while using JAX-WS to create a handle for " + + out.print("Error\n"+ + "\n"+ + "" + e.getClass().getName() + " while using JAX-WS to create a handle for " + "the service " + serviceQName + ", either the WSDL or the expected service name is wrong
");
 	    e.printStackTrace(out);
@@ -200,7 +247,9 @@
 					      Source.class,
 					      Service.Mode.PAYLOAD);
 	} catch(Exception e){
-	    out.print("Error" +
+	    out.print("Error\n"+
+		      "\n"+
+		      "" +
 		      e.getClass().getName() + " while using JAX-WS to create a dispatch for a port on " +
 		      "the service " + serviceQName + ", either the WSDL or the WSDLConfig's " +
 		      "portQName parsed (" + portQName + ") is wrong:
");	    
@@ -250,22 +299,30 @@
 		if(delimiter.equals(DQUOTE_OPTION) || delimiter.equals(SQUOTE_OPTION)){
 		    value = value.trim();
 		    if(delimiter.equals(DQUOTE_OPTION) && !value.startsWith("\"")){
-			out.print("Error" +
+			out.print("Error\n"+
+				  "\n"+
+				  "" +
 				  "The delimiter for field " + paramName + " was double quotes" +
 				  " but the value does not start with a double quote");
 		    }
 		    if(delimiter.equals(SQUOTE_OPTION) && !value.startsWith("'")){
-			out.print("Error" +
+			out.print("Error\n"+
+				  "\n"+
+				  "" +
 				  "The delimiter for field " + paramName + " was single quotes" +
 				  " but the value does not start with a single quote");
 		    }
 		    if(delimiter.equals(DQUOTE_OPTION) && !value.endsWith("\"")){
-			out.print("Error" +
+			out.print("Error\n"+
+				  "\n"+
+				  "" +
 				  "The delimiter for field " + paramName + " was double quotes" +
 				  " but the value does not end with a double quote");
 		    }
 		    if(delimiter.equals(SQUOTE_OPTION) && !value.endsWith("'")){
-			out.print("Error" +
+			out.print("Error\n"+
+				  "\n"+
+				  "" +
 				  "The delimiter for field " + paramName + " was single quotes" +
 				  " but the value does not end with a single quote");
 		    }		    
@@ -358,7 +415,9 @@
 						     new javax.xml.transform.stream.StreamResult(stringResult));
 		}
 	    } catch(Exception e){
-		out.print("Error" +
+		out.print("Error\n"+
+			  "\n"+
+			  "" +
 			  e.getClass().getName() + " while transforming response from " +
 			  "the service " + serviceQName + " (probably an internal error):
");	    
 		e.printStackTrace(out);
@@ -370,7 +429,9 @@
 	    answer = "
"+stringResult.toString().replaceAll("<", "<")+"
"; } - out.print("Service Response"+answer+""); + out.print("Service Response\n"+ + "\n" + + ""+answer+""); } // Asks for the WSDL file @@ -387,7 +448,7 @@ } try{ - out.write("Generic SOAP Client\n".getBytes()); + out.write("Generic SOAP Client\n".getBytes()); out.write("Enter the URL of the WSDL file below:
").getBytes()); out.write("
".getBytes()); @@ -416,7 +477,9 @@ try{ url = new URL(endpoint); } catch(Exception e){ - out.print("

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


");
+	    out.print("Parsing Error\n"+
+		      "\n" +
+		      "

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


");
 	    e.printStackTrace(out);
 	    out.print("
\n"); return; @@ -424,7 +487,7 @@ try{ out.print("Input interface for WSDL Services at " + url + - ""); + "\n"); if(recorder != null){ out.print(recorder.getHead(request)); } From gordonp at dev.open-bio.org Thu Aug 20 13:04:36 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 20 Aug 2009 13:04:36 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908201704.n7KH4aq2009746@dev.open-bio.org> gordonp Thu Aug 20 13:04:36 EDT 2009 Update of /home/repository/moby/moby-live/Java/docs In directory dev.open-bio.org:/tmp/cvs-serv9710/docs Modified Files: index.html Log Message: Included link to SoapServlet documentation moby-live/Java/docs index.html,1.39,1.40 =================================================================== RCS file: /home/repository/moby/moby-live/Java/docs/index.html,v retrieving revision 1.39 retrieving revision 1.40 diff -u -r1.39 -r1.40 --- /home/repository/moby/moby-live/Java/docs/index.html 2009/01/06 09:41:48 1.39 +++ /home/repository/moby/moby-live/Java/docs/index.html 2009/08/20 17:04:36 1.40 @@ -188,13 +188,14 @@ Idiots, Dummies, etc. (a.k.a. "MobyServlet")
  • A note on using secondary articles with MobyServlet
  • How to wrap an EMBOSS/ACD program as a Moby service -
  • How to wrap an existing Web Service as a Moby service (using SAWSDL) +
  • How to wrap an existing Web Service as a Moby service (using SAWSDL) +
  • A generic, customizable HTML SOAP Client (used as a base for Daggoo) +
  • The org.biomoby.shared.data package "In Anger": creating data instances
  • -
  • How to setup and create secure BioMoby web services
  • +
  • How to setup and create secure BioMoby web services
  • From gordonp at dev.open-bio.org Thu Aug 20 15:52:09 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 20 Aug 2009 15:52:09 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908201952.n7KJq9eY010291@dev.open-bio.org> gordonp Thu Aug 20 15:52:09 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services In directory dev.open-bio.org:/tmp/cvs-serv10255/src/main/ca/ucalgary/services Modified Files: SoapServlet.java Log Message: Moved tests from SoapServlet to Test Case class, updated and expanded tests moby-live/Java/src/main/ca/ucalgary/services SoapServlet.java,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.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/services/SoapServlet.java 2009/08/20 16:59:36 1.4 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.java 2009/08/20 19:52:09 1.5 @@ -3,7 +3,6 @@ import org.w3c.dom.*; import ca.ucalgary.services.util.*; -import org.biomoby.service.test.*; import javax.servlet.http.*; import javax.servlet.ServletException; @@ -87,7 +86,7 @@ // See if the user has specified a DataRecorder to be used (customization and/or recording of // user interaction and Web Service response). - String dataRecorderClassName = getInitParameter(DATARECORDER_CONTEXTPARAM); + String dataRecorderClassName = null; javax.servlet.ServletContext context = getServletContext(); if(context != null){ if(context.getInitParameter(DATARECORDER_CONTEXTPARAM) != null){ @@ -1414,73 +1413,6 @@ } } - public static void main(String[] args) throws Exception{ - if(args.length != 1 && args.length != 2){ - System.err.println("Usage: java SoapServlet [run]\n"); - System.exit(0); - } - - SoapServlet servlet = new SoapServlet(); - - if(args.length == 1){ - TestHttpServletRequest request = new TestHttpServletRequest(); - TestHttpServletResponse response = new TestHttpServletResponse(); - StringBufferServletOutputStream out = new StringBufferServletOutputStream(); - request.setParameter(WSDL_HTTP_PARAM, args[0]); - response.setOutputStream(out); - - try{ - servlet.doGet(request, response); - } catch(Exception e){ - e.printStackTrace(); - } finally{ - System.out.print(out.getBuffer().toString()); - } - } - else{ -// TestHttpServletRequest request2 = new TestHttpServletRequest(); -// request2.setParameter("wsdl", "http://soap.genome.jp/KEGG.wsdl"); -// request2.setParameter("service", "SOAP/KEGG KEGG SOAP/KEGG KEGGPort " + -// "SOAP/KEGG get_compounds_by_enzyme SOAP/KEGG#get_compounds_by_enzyme encoded"); -// request2.setParameter("enzyme_id", "ec:1.1.1.1"); - -// TestHttpServletRequest request2 = new TestHttpServletRequest(); -// request2.setParameter("wsdl", "http://www.ebi.ac.uk/ontology-lookup/OntologyQuery.wsdl"); -// request2.setParameter("service", "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 " + -// "getTermsByName literal"); -// request2.setParameter("partialName", "seed"); -// request2.setParameter("ontologyName", "GO"); -// request2.setParameter("reverseKeyOrder", "false"); - - TestHttpServletRequest request2 = new TestHttpServletRequest(); - request2.setParameter(WSDL_HTTP_PARAM, "http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/eutils.wsdl"); - request2.setParameter(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 " + - "espell literal"); - request2.setParameter("db:opt", ""); - request2.setParameter("term:opt", "brest"); - request2.setParameter("tool:opt", ""); - request2.setParameter("email:opt", ""); - - TestHttpServletResponse response2 = new TestHttpServletResponse(); - StringBufferServletOutputStream out2 = new StringBufferServletOutputStream(); - response2.setOutputStream(out2); - - try{ - servlet.doPost(request2, response2); - } - catch(Exception e){ - e.printStackTrace(); - } - finally{ - System.err.println(out2.getBuffer().toString()); - } - } - } - public static class MyNodeList implements NodeList{ private Vector nodes; public MyNodeList(){nodes = new Vector();} From gordonp at dev.open-bio.org Thu Aug 20 15:52:09 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 20 Aug 2009 15:52:09 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908201952.n7KJq9oQ010311@dev.open-bio.org> gordonp Thu Aug 20 15:52:09 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test In directory dev.open-bio.org:/tmp/cvs-serv10255/src/main/ca/ucalgary/services/test Modified Files: SoapServletTestCase.java Log Message: Moved tests from SoapServlet to Test Case class, updated and expanded tests moby-live/Java/src/main/ca/ucalgary/services/test SoapServletTestCase.java,1.1,1.2 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/SoapServletTestCase.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/SoapServletTestCase.java 2009/06/09 19:39:53 1.1 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/test/SoapServletTestCase.java 2009/08/20 19:52:09 1.2 @@ -4,8 +4,7 @@ import ca.ucalgary.seahawk.gui.*; import ca.ucalgary.seahawk.util.*; -import org.biomoby.shared.MobyDataType; -import org.biomoby.shared.data.*; +import org.biomoby.service.test.*; import junit.framework.*; @@ -17,30 +16,117 @@ * */ public class SoapServletTestCase extends TestCase{ - private final static String TEST_WSDL = "http://www.ncbi.nlm.nih.gov/entrez/eutils/soap/v2.0/eutils.wsdl"; + // The class below should have a nullary c-tor + private final static String TEST_DATARECORDER = "ca.ucalgary.services.util.PBERecorder"; public SoapServletTestCase(String name){ super(name); } - public void testWSDLLoad(){ - URL testWSDL = null; + /** + * Checks against a KEGG service + */ + public void testWSDLRpcEncExecute(){ + SoapServlet servlet = new SoapServlet(); + try{ + servlet.init(new TestServletConfig("", new TestServletContext())); + }catch(Exception e){ + e.printStackTrace(); + fail("Could not initialize the SoapServlet"); + } + + TestHttpServletRequest request = new TestHttpServletRequest(); + request.setParameter(SoapServlet.WSDL_HTTP_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"); + request.setParameter("enzyme_id", "ec:1.1.1.1"); + + TestHttpServletResponse response = new TestHttpServletResponse(); + StringBufferServletOutputStream out = new StringBufferServletOutputStream(); + response.setOutputStream(out); + try{ + servlet.doPost(request, response); + } + catch(Exception e){ + e.printStackTrace(); + fail("Got exception while posting request for RPC/Encoded KEGG Web Service"); + } + assertTrue("Did not find the expected data in the reponse from KEGG", + out.getBuffer().indexOf("cpd:C00001") != -1); + } + + /** + * Checks against both NCBI and EBI services. + */ + public void testWSDLDocLitExecute(){ + SoapServlet servlet = new SoapServlet(); try{ - testWSDL = new URL(TEST_WSDL); - } catch(Exception e){ + servlet.init(new TestServletConfig("", new TestServletContext())); + }catch(Exception e){ e.printStackTrace(); - fail("Could not create URL from test document (" + TEST_WSDL + "): " + e); + fail("Could not initialize the SoapServlet"); } + + TestHttpServletRequest request = new TestHttpServletRequest(); + request.setParameter(SoapServlet.WSDL_HTTP_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 " + + "getTermsByName getTermsByName document literal"); + request.setParameter("partialName", "seed"); + request.setParameter("ontologyName", "GO"); + request.setParameter("reverseKeyOrder", "false"); + + TestHttpServletResponse response = new TestHttpServletResponse(); + StringBufferServletOutputStream out = new StringBufferServletOutputStream(); + response.setOutputStream(out); + try{ + servlet.doPost(request, response); + } + catch(Exception e){ + e.printStackTrace(); + fail("Got exception while posting request for Document/Literal EBI Web Service"); + } + if(out.getBuffer().indexOf("coat") == -1){ + fail("Did not find the expected data in the reponse from EBI. Response was:\n" + + 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.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 " + + "espell run_eSpell document literal"); + request2.setParameter("db:opt", ""); + request2.setParameter("term:opt", "brest"); + request2.setParameter("tool:opt", ""); + request2.setParameter("email:opt", ""); - javax.swing.JOptionPane.showMessageDialog(null, "information", - "information", javax.swing.JOptionPane.INFORMATION_MESSAGE); - System.err.println("About to load GUI"); - MobyContentGUI gui = MobyUtils.getMobyContentGUI(null); - System.err.println("About to load " + TEST_WSDL); - gui.loadPaneFromURL(testWSDL, true); + TestHttpServletResponse response2 = new TestHttpServletResponse(); + StringBufferServletOutputStream out2 = new StringBufferServletOutputStream(); + response2.setOutputStream(out2); try{ - Thread.sleep(100000); - } catch(Exception e){System.err.println("Sleep interrupted: " + e);} + servlet.doPost(request2, response2); + } + catch(Exception e){ + e.printStackTrace(); + fail("Got exception while posting request for Document/Literal NCBI Web Service"); + } + assertTrue("Did not find the expected data in the reponse from NCBI", + out2.getBuffer().indexOf("breast") != -1); + } + + public void testDataRecorderAutoLoad(){ + SoapServlet servlet = new SoapServlet(); + try{ + TestServletConfig config = new TestServletConfig("", new TestServletContext()); + config.addInitParameter(SoapServlet.DATARECORDER_CONTEXTPARAM, TEST_DATARECORDER); + servlet.init(config); + }catch(Exception e){ + e.printStackTrace(); + fail("Could not initialize the SoapServlet"); + } } /** @@ -52,7 +138,9 @@ public static Test suite() { TestSuite suite = new TestSuite(); - suite.addTest(new SoapServletTestCase("testWSDLLoad")); + suite.addTest(new SoapServletTestCase("testWSDLRpcEncExecute")); + suite.addTest(new SoapServletTestCase("testWSDLDocLitExecute")); + suite.addTest(new SoapServletTestCase("testDataRecorderAutoLoad")); return suite; } From gordonp at dev.open-bio.org Wed Aug 26 18:02:18 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Wed, 26 Aug 2009 18:02:18 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908262202.n7QM2IfR032508@dev.open-bio.org> gordonp Wed Aug 26 18:02:18 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services In directory dev.open-bio.org:/tmp/cvs-serv32472/src/main/ca/ucalgary/services Modified Files: SoapServlet.java Log Message: Fix to avoid namespace collision between XML scehma elements and XML schema types in the WSDL doc moby-live/Java/src/main/ca/ucalgary/services SoapServlet.java,1.5,1.6 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.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/services/SoapServlet.java 2009/08/20 19:52:09 1.5 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.java 2009/08/26 22:02:18 1.6 @@ -20,6 +20,11 @@ import java.util.*; import java.io.*; +/** + * Provides an HTML interface for invoking SOAP-based Web Services. The appearance and functionality of the class + * 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 static final String DATARECORDER_CONTEXTPARAM = "dataRecorder"; // how users spec a DataRecorder in the web.xml @@ -842,6 +847,8 @@ "types"); Map> element2Members = new LinkedHashMap>(); + Map> type2Members = + new LinkedHashMap>(); for(int m = 0; m < types.getLength(); m++){ Element typeTag = (Element) types.item(m); MyNodeList typeDefs = new MyNodeList(); @@ -870,8 +877,17 @@ // It could either be a basic type (handled right here), or a complex one with subfields String elementType = element.getAttribute("type"); if(elementType != null && elementType.trim().length() != 0){ - memberMap.put(BASIC_TYPE_SENTINEL, getQName(elementType, element)); - memberMap.put(BASIC_NAME_SENTINEL, new QName(null, elementName)); + QName eT = getQName(elementType, element); + if(eT.getNamespaceURI() == null || + eT.getNamespaceURI().equals("http://www.w3.org/2001/XMLSchema")){ + memberMap.put(BASIC_TYPE_SENTINEL, eT); + memberMap.put(BASIC_NAME_SENTINEL, new QName(null, elementName)); + } + else{ + // pointer to complex type elsewhere in the schema tag + memberMap.put(BASIC_TYPE_SENTINEL, getQName(getRef(eT), element)); + memberMap.put(BASIC_NAME_SENTINEL, new QName(null, elementName)); + } } NodeList subelements = element.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", @@ -884,22 +900,20 @@ if(restrictions.getLength() == 0){ restrictions = element.getElementsByTagNameNS("http://www.w3.org/2001/XMLSchema", "extension"); - if(restrictions.getLength() == 0){ - //out.print("Error: Could not find the restriction or extension " + - // "attribute for a simple type " + - // " schema element " + elementName); + if(restrictions.getLength() != 0){ + String baseAttr = restrictions.getLength() == 0 ? "xs:string" : + ((Element) restrictions.item(0)).getAttribute("base"); + QName baseType = getQName(baseAttr, element); + QName anonQName = getQName(baseAttr+"SubType"+anonCount++, element); + memberMap.put(BASIC_TYPE_SENTINEL, anonQName); + memberMap.put(BASIC_NAME_SENTINEL, new QName(null, elementName)); } + // else, some time you just get a blank type... } else{ + // TODO handle extension properly } - String baseAttr = restrictions.getLength() == 0 ? "xs:string" : - ((Element) restrictions.item(0)).getAttribute("base"); - QName baseType = getQName(baseAttr, element); - QName anonQName = getQName(baseAttr+"SubType"+anonCount++, element); - // TODO handle extension properly - memberMap.put(BASIC_TYPE_SENTINEL, anonQName); - memberMap.put(BASIC_NAME_SENTINEL, new QName(null, elementName)); } for(int p = 0; p < subelements.getLength(); p++){ Element subelement = (Element) subelements.item(p); @@ -973,7 +987,12 @@ } } - element2Members.put(getQName(elementName, element), memberMap); + if(element.getLocalName().equals("element")){ + element2Members.put(getQName(elementName, element), memberMap); + } + else{ //probably complexType def + type2Members.put(getQName(elementName, element), memberMap); + } } //end for ... } //for wsdl:types @@ -1013,21 +1032,31 @@ Map subpartsMap = element2Members.get(dataType); if(subpartsMap == null){ if(dataType.getNamespaceURI().equals("http://schemas.xmlsoap.org/soap/encoding/")){ - writeDataType(out, part.getKey(), part.getValue(), element2Members, ""); + writeDataType(out, part.getKey(), + part.getValue(), element2Members, type2Members, ""); + } + else{ + out.print("Error: cannot find definition for data type " + + dataType + "\nValid types are:"); + for(QName key: element2Members.keySet()){ + out.print(" "+key); + } } - out.print("Error: cannot find definition for data type " + - dataType + "\nValid types are:"); - for(QName key: element2Members.keySet()){ - out.print(" "+key); - } continue; } - for(Map.Entry subpart: subpartsMap.entrySet()){ - writeDataType(out, subpart.getKey(), subpart.getValue(), element2Members, ""); + if(subpartsMap.containsKey(BASIC_TYPE_SENTINEL)){ + writeDataType(out, messageQName.getLocalPart(), + subpartsMap.get(BASIC_TYPE_SENTINEL), + type2Members, type2Members, ""); + } + else{ + for(Map.Entry subpart: subpartsMap.entrySet()){ + writeDataType(out, subpart.getKey(), subpart.getValue(), type2Members, type2Members, ""); + } } } else{ // rpc style - writeDataType(out, part.getKey(), part.getValue(), element2Members, ""); + writeDataType(out, part.getKey(), part.getValue(), element2Members, type2Members, ""); } } // for parts // special condition for rpc calls, still need to give the op ns & name @@ -1154,7 +1183,8 @@ } private void writeDataType(java.io.PrintStream out, String memberName, QName dataType, - Map> msg2Parts, String prefix){ + Map> msg2Parts, + Map> type2Parts, String prefix){ String datatype = dataType.getLocalPart(); @@ -1268,11 +1298,14 @@ else{ // doc/lit or complex rpc type Map subparts = msg2Parts.get(dataType); if(subparts == null){ - out.print("Error: cannot find definition for data type " + dataType); //+"\nValid types are:"); - // for(QName key: msg2Parts.keySet()){ -// out.print(" "+key); -// } - return; + subparts = type2Parts.get(dataType); + if(subparts == null){ + out.print("Error: cannot find definition for data type " + dataType); //+"\nValid types are:"); + // for(QName key: msg2Parts.keySet()){ + // out.print(" "+key); + // } + return; + } } else if(subparts.containsKey(BASIC_TYPE_SENTINEL)){ QName typeName = subparts.get(BASIC_TYPE_SENTINEL); @@ -1282,14 +1315,14 @@ if(isOptional){ typeName = new QName(typeName.getNamespaceURI(), typeName.getLocalPart()+"~"); } - writeDataType(out, memberName, typeName, msg2Parts, prefix); + writeDataType(out, memberName, typeName, type2Parts, type2Parts, prefix); } else{ // currently we don't handle arrays of composites in the form... - out.print("
    Composite "+memberName+ + out.print("
    Composite "+ memberName + " ("+(isOptional?"optional, ":"")+ datatype + "):
    "); for(Map.Entry subpart: subparts.entrySet()){ - writeDataType(out, subpart.getKey(), subpart.getValue(), msg2Parts, prefix+memberName+":"); + writeDataType(out, subpart.getKey(), subpart.getValue(), type2Parts, type2Parts, prefix+memberName+":"); } out.print("
    \n"); } From kawas at dev.open-bio.org Thu Aug 27 15:37:37 2009 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Thu, 27 Aug 2009 15:37:37 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908271937.n7RJbbl6005812@dev.open-bio.org> kawas Thu Aug 27 15:37:37 EDT 2009 Update of /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Generators/templates In directory dev.open-bio.org:/tmp/cvs-serv5776/MOSES-MOBY/lib/MOSES/MOBY/Generators/templates Modified Files: service-base.tt Log Message: fix the warning 'unsuccesful stat on file containing newline' when sending raw data moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Generators/templates service-base.tt,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Generators/templates/service-base.tt,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Generators/templates/service-base.tt 2008/02/21 00:12:55 1.3 +++ /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Generators/templates/service-base.tt 2009/08/27 19:37:37 1.4 @@ -112,7 +112,9 @@ Log::Log4perl::NDC->push ($$); $LOG->info ('*** REQUEST START *** ' . $self->log_request); + no warnings 'newline'; my $in_testing_mode = (-f $data); + use warnings 'newline'; if ($LOG->is_debug) { if ($in_testing_mode) { open (RAWXML, "<$data") or $LOG->logdie ("Cannot open $data: $!\n"); From kawas at dev.open-bio.org Thu Aug 27 15:39:26 2009 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Thu, 27 Aug 2009 15:39:26 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908271939.n7RJdQCb005925@dev.open-bio.org> kawas Thu Aug 27 15:39:26 EDT 2009 Update of /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Def In directory dev.open-bio.org:/tmp/cvs-serv5890/MOSES-MOBY/lib/MOSES/MOBY/Def Modified Files: Service.pm Log Message: added missing categories moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Def Service.pm,1.4,1.5 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Def/Service.pm,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Def/Service.pm 2008/04/29 19:41:38 1.4 +++ /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Def/Service.pm 2009/08/27 19:39:26 1.5 @@ -260,7 +260,7 @@ sub _check_category { my ($self, $attr) = @_; $self->throw ('Invalid service category: ' . $self->category) - unless $self->category =~ /^cgi|wsdl|moby|moby\-async|post$/i; + unless $self->category =~ /^cgi|wsdl|moby|moby\-async|post|cgi\-async$/i; } 1; From kawas at dev.open-bio.org Thu Aug 27 15:40:50 2009 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Thu, 27 Aug 2009 15:40:50 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908271940.n7RJeoVe006003@dev.open-bio.org> kawas Thu Aug 27 15:40:50 EDT 2009 Update of /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Cache In directory dev.open-bio.org:/tmp/cvs-serv5968/MOSES-MOBY/lib/MOSES/MOBY/Cache Modified Files: Central.pm Log Message: made relationship regex check case insensitive and less stringent. moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Cache Central.pm,1.7,1.8 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Cache/Central.pm,v retrieving revision 1.7 retrieving revision 1.8 diff -u -r1.7 -r1.8 --- /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Cache/Central.pm 2008/06/04 16:14:31 1.7 +++ /home/repository/moby/moby-live/Perl/MOSES-MOBY/lib/MOSES/MOBY/Cache/Central.pm 2009/08/27 19:40:50 1.8 @@ -708,13 +708,13 @@ while ( $count > 0 ) { my $node = $nodes->get_node( $count-- ); my $relationship = $node->getAttribute('relationshipType'); - if ( $relationship =~ /.*:isa$/ ) { + if ( $relationship =~ /^.*isa$/i ) { my $parent = $node->getChildrenByTagName('objectType'); my $isa = $parent->get_node(1)->textContent if ( $parent and $parent->get_node(1) and $parent->get_node(1) ); $datatype->parent($isa); } - elsif ( $relationship =~ /.*:hasa$/ ) { + elsif ( $relationship =~ /^.*hasa$/i ) { my $pNode = $node->getChildrenByTagName('objectType'); for ( my $i = 1 ; $i <= $pNode->size() ; $i++ ) { my $article = $pNode->get_node($i)->getAttribute('articleName') @@ -735,7 +735,7 @@ ); } } - elsif ( $relationship =~ /.*:has$/ ) { + elsif ( $relationship =~ /^.*has$/i ) { my $pNode = $node->getChildrenByTagName('objectType'); for ( my $i = 1 ; $i <= $pNode->size() ; $i++ ) { my $article = $pNode->get_node($i)->getAttribute('articleName') From kawas at dev.open-bio.org Thu Aug 27 15:44:40 2009 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Thu, 27 Aug 2009 15:44:40 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908271944.n7RJidME006047@dev.open-bio.org> kawas Thu Aug 27 15:44:39 EDT 2009 Update of /home/repository/moby/moby-live/Perl/MOSES-MOBY In directory dev.open-bio.org:/tmp/cvs-serv6008/MOSES-MOBY Modified Files: Makefile.PL Changes Log Message: updated to reflect current status of the module. moby-live/Perl/MOSES-MOBY Makefile.PL,1.17,1.18 Changes,1.16,1.17 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOSES-MOBY/Makefile.PL,v retrieving revision 1.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- /home/repository/moby/moby-live/Perl/MOSES-MOBY/Makefile.PL 2009/05/22 16:38:39 1.17 +++ /home/repository/moby/moby-live/Perl/MOSES-MOBY/Makefile.PL 2009/08/27 19:44:39 1.18 @@ -6,7 +6,7 @@ # Define metadata name 'MOSES-MOBY'; - version '0.90'; + version '0.91'; license 'perl'; abstract 'This distribution aids in the creation of BioMOBY perl based web services.'; @@ -17,7 +17,7 @@ requires 'CGI' => 0; requires 'File::Spec' => 0.80; requires 'SOAP::Lite' => 0.69; - requires 'XML::LibXML::Common' => '0.13'; + requires 'XML::LibXML::Common' => 0.13; requires 'XML::LibXML' => 1.62; requires 'Log::Log4perl' => 1.12; requires 'Template' => 1.11; @@ -25,15 +25,15 @@ requires 'IO::String' => 1.08; requires 'Unicode::String' => 2.09; requires 'File::HomeDir' => 0.65; - requires 'File::ShareDir' => 0.05; + requires 'File::ShareDir' => 1.00; requires 'Class::Inspector' => 1.17; requires 'Params::Util' => 0.38; requires 'HTTP::Date' => 5.81; # windows doesn't need this if ( not MSWIN ) { - requires 'Want' => '0.18'; - requires 'IO::Prompt' => '0.99.2'; + requires 'Want' => 0.18; + requires 'IO::Prompt' => 0.99.2; } # for async services =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOSES-MOBY/Changes,v retrieving revision 1.16 retrieving revision 1.17 diff -u -r1.16 -r1.17 --- /home/repository/moby/moby-live/Perl/MOSES-MOBY/Changes 2009/05/22 16:38:39 1.16 +++ /home/repository/moby/moby-live/Perl/MOSES-MOBY/Changes 2009/08/27 19:44:39 1.17 @@ -3,6 +3,11 @@ 0.91 - Updated the Makefile.PL to handle some missing dependencies. + - bug fix: fixed the unsuccessful stat on filename + warning in service-base.tt + - updated the categories in Service.pm + - updated Makefile.PL to reflect dependency upgrades + and versioning .90 - bug fix: when sending data with newlines on a WinOS, \r was causing problems with the From gordonp at dev.open-bio.org Thu Aug 27 17:37:33 2009 From: gordonp at dev.open-bio.org (Paul Gordon) Date: Thu, 27 Aug 2009 17:37:33 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908272137.n7RLbX32006322@dev.open-bio.org> gordonp Thu Aug 27 17:37:32 EDT 2009 Update of /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services In directory dev.open-bio.org:/tmp/cvs-serv6286/src/main/ca/ucalgary/services Modified Files: SoapServlet.java Log Message: Further element reference fixes for WSDL XML schema definitions moby-live/Java/src/main/ca/ucalgary/services SoapServlet.java,1.6,1.7 =================================================================== RCS file: /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.java 2009/08/26 22:02:18 1.6 +++ /home/repository/moby/moby-live/Java/src/main/ca/ucalgary/services/SoapServlet.java 2009/08/27 21:37:32 1.7 @@ -1045,14 +1045,18 @@ continue; } if(subpartsMap.containsKey(BASIC_TYPE_SENTINEL)){ - writeDataType(out, messageQName.getLocalPart(), - subpartsMap.get(BASIC_TYPE_SENTINEL), - type2Members, type2Members, ""); - } - else{ - for(Map.Entry subpart: subpartsMap.entrySet()){ - writeDataType(out, subpart.getKey(), subpart.getValue(), type2Members, type2Members, ""); + QName t = subpartsMap.get(BASIC_TYPE_SENTINEL); + while(DEFERRED_NAMESPACE_URI.equals(t.getNamespaceURI())){ + String[] p = t.getLocalPart().split("_deferred_"); + t = new QName(decode(p[0]), p[1]); + } + if(t.getNamespaceURI().equals("http://www.w3.org/2001/XMLSchema")){ + throw new Exception("Got bare XSD type as contents of WSDL message"); } + subpartsMap = type2Members.get(t); + } + for(Map.Entry subpart: subpartsMap.entrySet()){ + writeDataType(out, subpart.getKey(), subpart.getValue(), type2Members, type2Members, ""); } } else{ // rpc style From kawas at dev.open-bio.org Fri Aug 28 10:15:58 2009 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Fri, 28 Aug 2009 10:15:58 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908281415.n7SEFv0S017683@dev.open-bio.org> kawas Fri Aug 28 10:15:57 EDT 2009 Update of /home/repository/moby/moby-live/Perl/MOBY-Server/share/cgi In directory dev.open-bio.org:/tmp/cvs-serv17648/MOBY-Server/share/cgi Modified Files: RESOURCES Log Message: bug fix: sometimes users hit the url with Objects/, or Namespaces/, etc and the trailing slash tripped up the script. moby-live/Perl/MOBY-Server/share/cgi RESOURCES,1.3,1.4 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY-Server/share/cgi/RESOURCES,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- /home/repository/moby/moby-live/Perl/MOBY-Server/share/cgi/RESOURCES 2008/06/19 17:02:25 1.3 +++ /home/repository/moby/moby-live/Perl/MOBY-Server/share/cgi/RESOURCES 2009/08/28 14:15:57 1.4 @@ -47,7 +47,8 @@ $url =~ s/%([\da-f][\da-f])/chr( hex($1) )/egi; my $form = new CGI; -if ( $url =~ m/^RESOURCES\/MOBY\-S\/Objects(\/[A-Za-z0-9_\-]*)?$/ ) { +if ( $url =~ m/^RESOURCES\/MOBY\-S\/Objects(\/[A-Za-z0-9_\-]+)?$/ ) { + my $byName = length( substr $1, 1) > 0 if $1; do { if ($useCache) { my $x = @@ -60,14 +61,15 @@ $x = $x->createAll(); print $form->header('text/xml'), $x if $x; } - } unless $1; + } unless $byName; do { my $x = MOBY::RDF::Ontologies::Objects->new; my $rdf = $x->createByName( { term => substr $1, 1 } ); print $form->header('text/xml'), $rdf if $rdf; - } if $1; + } if $byName; -} elsif ( $url =~ m/^RESOURCES\/MOBY\-S\/Services(\/[A-Za-z0-9_\-]*)?$/ ) { +} elsif ( $url =~ m/^RESOURCES\/MOBY\-S\/Services(\/[A-Za-z0-9_\-]+)?$/ ) { + my $byName = length( substr $1, 1) > 0 if $1; do { if ($useCache) { my $x = @@ -80,12 +82,12 @@ $x = $x->createAll(); print $form->header('text/xml'), $x if $x; } - } unless $1; + } unless $byName; do { my $x = MOBY::RDF::Ontologies::ServiceTypes->new; my $rdf = $x->createByName( { term => substr $1, 1 } ); print $form->header('text/xml'), $rdf if $rdf; - } if $1; + } if $byName; } elsif ( $url =~ m/^RESOURCES\/MOBY\-S\/ServiceInstances(\/[A-Za-z0-9_\-.]*,[A-Za-z0-9_\-]*){1}$/ ) @@ -117,7 +119,7 @@ } unless $string; } elsif ( $url =~ -m/^RESOURCES\/MOBY\-S\/ServiceInstances(\/[A-Za-z0-9_\-.]*\/[A-Za-z0-9_\-]*)?$/ +m/^RESOURCES\/MOBY\-S\/ServiceInstances(\/[A-Za-z0-9_\-.]+\/[A-Za-z0-9_\-]+)?$/ ) { my $string = $1 || ""; @@ -169,25 +171,28 @@ print $form->header('text/xml'), $x if $x; } if $string; -} elsif ( $url =~ m/^RESOURCES\/MOBY\-S\/Namespaces(\/[A-Za-z0-9_\-]*)?$/ ) { - do { - if ($useCache) { - my $x = - MOBY::RDF::Ontologies::Cache::NamespaceCache->new( - cache => "$dir", ); - $x = $x->get_rdf(); - print $form->header('text/xml'), $x if $x; - } else { - my $x = MOBY::RDF::Ontologies::Namespaces->new; - $x = $x->createAll(); - print $form->header('text/xml'), $x if $x; - } - } unless $1; +} elsif ( $url =~ m/^RESOURCES\/MOBY\-S\/Namespaces(\/[A-Za-z0-9_\-]+)?$/ ) { + my $byName = length( substr $1, 1) > 0 if $1; do { my $x = MOBY::RDF::Ontologies::Namespaces->new; my $rdf = $x->createByName( { term => substr $1, 1 } ); print $form->header('text/xml'), $rdf if $rdf; - } if $1; + } if $byName; + + do { + if ($useCache) { + my $x = + MOBY::RDF::Ontologies::Cache::NamespaceCache->new( + cache => "$dir", ); + $x = $x->get_rdf(); + print $form->header('text/xml'), $x if $x; + } else { + my $x = MOBY::RDF::Ontologies::Namespaces->new; + $x = $x->createAll(); + print $form->header('text/xml'), $x if $x; + } + } unless $byName; + } elsif ( $url =~ m/^RESOURCES\/MOBY\-S\/FULL$/ ) { my $dom = undef; my $parser = XML::LibXML->new(); From kawas at dev.open-bio.org Fri Aug 28 10:19:38 2009 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Fri, 28 Aug 2009 10:19:38 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908281419.n7SEJcgp017777@dev.open-bio.org> kawas Fri Aug 28 10:19:38 EDT 2009 Update of /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY In directory dev.open-bio.org:/tmp/cvs-serv17742/MOBY-Server/lib/MOBY Modified Files: Central.pm Log Message: updated the regex expressions that checks the term names when registering new nodes in the ontology. moby-live/Perl/MOBY-Server/lib/MOBY Central.pm,1.10,1.11 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/Central.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/Central.pm 2009/08/19 15:36:19 1.10 +++ /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/Central.pm 2009/08/28 14:19:38 1.11 @@ -318,7 +318,7 @@ return &_error("Object name may not contain spaces or other characters invalid in a URN", "" ) - if $term =~ /[\/\'\\\s\"\&\<\>\[\]\^\`\{\|\}\~\%\+]/; + if $term =~ /[\/\'\\\s\"\&\<\>\[\]\^\`\{\|\}\~\%\!\@\#\$\%\*\+\=]/; if ( $term =~ m"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?" ) { # matches a URI return &_error( "Object name may not be an URN or URI", "" ) if $1; @@ -739,6 +739,10 @@ "" ) unless $email =~ /\S\@\S+\.\S+/; + return &_error("serviceType name may not contain spaces or other characters invalid in a URN", + "" + ) + if $term =~ /[\/\'\\\s\"\&\<\>\[\]\^\`\{\|\}\~\%\!\@\#\$\%\*\+\=]/; # validate that the final ontology will be valid my ( $exists, $exists_message, $existingURI ) = @@ -999,6 +1003,10 @@ ); } + return &_error("Namespace name may not contain spaces or other characters invalid in a URN", + "" + ) + if $term =~ /[\/\'\\\s\"\&\<\>\[\]\^\`\{\|\}\~\%\!\@\#\$\%\*\+\=]/; return &_error( "Malformed authURI - must not have an http:// prefix", "" ) if $auth =~ '[/:]'; return &_error( "Malformed authURI - must take the form NNN.NNN.NNN", "" ) @@ -1396,6 +1404,7 @@ $error .= "missing serviceType \n" unless defined $serviceType; $error .= "invalid character string for serviceName. Must start with a letter followed by [A-Za-z0-9_]\n" if ($serviceName =~ /^[^A-Za-z]/); $error .= "invalid character string for serviceName. Must start with a letter followed by [A-Za-z0-9_]\n" if ($serviceName =~ /^.+?[^A-Za-z0-9_]/); + $error .= "service name may not contain spaces or other characters invalid in a URN" if $serviceName =~ /[\/\'\\\s\"\&\<\>\[\]\^\`\{\|\}\~\%\!\@\#\$\%\*\+\=]/; # $error .="missing signatureURL \n" unless defined $signatureURL; $error .= "missing authURI \n" unless defined $AuthURI; @@ -2946,6 +2955,7 @@ if ( $def{description} =~ /[^\]]+))\]\]>/ ) { $def{description} = $1; } + my $response; $response = " $def{objectType} From kawas at dev.open-bio.org Fri Aug 28 10:40:45 2009 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Fri, 28 Aug 2009 10:40:45 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908281440.n7SEejaD017919@dev.open-bio.org> kawas Fri Aug 28 10:40:44 EDT 2009 Update of /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY In directory dev.open-bio.org:/tmp/cvs-serv17884/MOBY-Server/lib/MOBY Modified Files: Central.pm Log Message: updated the regex expressions that checks the term names when registering new nodes in the ontology. moby-live/Perl/MOBY-Server/lib/MOBY Central.pm,1.11,1.12 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/Central.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/Central.pm 2009/08/28 14:19:38 1.11 +++ /home/repository/moby/moby-live/Perl/MOBY-Server/lib/MOBY/Central.pm 2009/08/28 14:40:44 1.12 @@ -318,7 +318,7 @@ return &_error("Object name may not contain spaces or other characters invalid in a URN", "" ) - if $term =~ /[\/\'\\\s\"\&\<\>\[\]\^\`\{\|\}\~\%\!\@\#\$\%\*\+\=]/; + if $term =~ /[\/\'\\\s"\&\<\>\[\]\^\`\{\|\}\~%\!\@#\$\*\+=]/; if ( $term =~ m"^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?" ) { # matches a URI return &_error( "Object name may not be an URN or URI", "" ) if $1; @@ -742,7 +742,7 @@ return &_error("serviceType name may not contain spaces or other characters invalid in a URN", "" ) - if $term =~ /[\/\'\\\s\"\&\<\>\[\]\^\`\{\|\}\~\%\!\@\#\$\%\*\+\=]/; + if $term =~ /[\/\'\\\s"\&\<\>\[\]\^\`\{\|\}\~%\!\@#\$\*\+=]/; # validate that the final ontology will be valid my ( $exists, $exists_message, $existingURI ) = @@ -1006,7 +1006,7 @@ return &_error("Namespace name may not contain spaces or other characters invalid in a URN", "" ) - if $term =~ /[\/\'\\\s\"\&\<\>\[\]\^\`\{\|\}\~\%\!\@\#\$\%\*\+\=]/; + if $term =~ /[\/\'\\\s"\&\<\>\[\]\^\`\{\|\}\~%\!\@#\$\*\+=]/; return &_error( "Malformed authURI - must not have an http:// prefix", "" ) if $auth =~ '[/:]'; return &_error( "Malformed authURI - must take the form NNN.NNN.NNN", "" ) @@ -1404,7 +1404,7 @@ $error .= "missing serviceType \n" unless defined $serviceType; $error .= "invalid character string for serviceName. Must start with a letter followed by [A-Za-z0-9_]\n" if ($serviceName =~ /^[^A-Za-z]/); $error .= "invalid character string for serviceName. Must start with a letter followed by [A-Za-z0-9_]\n" if ($serviceName =~ /^.+?[^A-Za-z0-9_]/); - $error .= "service name may not contain spaces or other characters invalid in a URN" if $serviceName =~ /[\/\'\\\s\"\&\<\>\[\]\^\`\{\|\}\~\%\!\@\#\$\%\*\+\=]/; + $error .= "service name may not contain spaces or other characters invalid in a URN" if $serviceName =~ /[\/\'\\\s"\&\<\>\[\]\^\`\{\|\}\~%\!\@#\$\*\+=]/; # $error .="missing signatureURL \n" unless defined $signatureURL; $error .= "missing authURI \n" unless defined $AuthURI; @@ -2963,9 +2963,9 @@ $def{authURI} $def{contactEmail}\n"; my %relationships = %{ $def{Relationships} }; - - while ( my ( $rel, $objdefs ) = each %relationships ) { - $response .= "\n"; + + while ( my ( $rel, $objdefs ) = each %relationships ) { + $response .= "\n"; foreach my $def ( @{$objdefs} ) { my ( $lsid, $articlename,$type, $def, $auth, $contac ) = @{$def}; $articlename = "" unless defined $articlename; From kawas at dev.open-bio.org Fri Aug 28 11:03:33 2009 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Fri, 28 Aug 2009 11:03:33 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908281503.n7SF3Xf6018095@dev.open-bio.org> kawas Fri Aug 28 11:03:33 EDT 2009 Update of /home/repository/moby/moby-live/Perl/MOBY-Server In directory dev.open-bio.org:/tmp/cvs-serv18060/MOBY-Server Modified Files: Changes Log Message: moby-live/Perl/MOBY-Server Changes,1.29,1.30 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY-Server/Changes,v retrieving revision 1.29 retrieving revision 1.30 diff -u -r1.29 -r1.30 --- /home/repository/moby/moby-live/Perl/MOBY-Server/Changes 2009/08/19 15:38:39 1.29 +++ /home/repository/moby/moby-live/Perl/MOBY-Server/Changes 2009/08/28 15:03:33 1.30 @@ -3,8 +3,11 @@ 1.11 - Updated the Makefile.PL to handle some missing dependencies. - - Added '%' to the list of characters not allowed in the name of - a datatype. + Changes + * Updated the RESOURCES script to better handle trailing slashes + on Objects/, Namespaces, Services/ + * Updated the regex expressions that are applied against terms + when registering new nodes in the biomoby ontologies. 1.10 - Added a RESTful WSDL page to the installation. Basically, you do From kawas at dev.open-bio.org Fri Aug 28 11:07:18 2009 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Fri, 28 Aug 2009 11:07:18 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908281507.n7SF7IFN018280@dev.open-bio.org> kawas Fri Aug 28 11:07:18 EDT 2009 Update of /home/repository/moby/moby-live/Perl/MOBY-Server In directory dev.open-bio.org:/tmp/cvs-serv18245/MOBY-Server Modified Files: Makefile.PL Log Message: updated version for new cpan release. moby-live/Perl/MOBY-Server Makefile.PL,1.19,1.20 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY-Server/Makefile.PL,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- /home/repository/moby/moby-live/Perl/MOBY-Server/Makefile.PL 2009/05/22 16:38:39 1.19 +++ /home/repository/moby/moby-live/Perl/MOBY-Server/Makefile.PL 2009/08/28 15:07:18 1.20 @@ -3,7 +3,7 @@ # Define metadata name 'MOBY'; - version '1.10'; + version '1.11'; license 'perl'; abstract 'This distribution is for communicating with or creating your own MOBY Central registry'; From kawas at dev.open-bio.org Fri Aug 28 11:15:16 2009 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Fri, 28 Aug 2009 11:15:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908281515.n7SFFGJ4018496@dev.open-bio.org> kawas Fri Aug 28 11:15:16 EDT 2009 Update of /home/repository/moby/moby-live/Perl/MOBY-Client/inc/Module In directory dev.open-bio.org:/tmp/cvs-serv18457/MOBY-Client/inc/Module Modified Files: AutoInstall.pm Install.pm Log Message: updated the module::install inc modules. moby-live/Perl/MOBY-Client/inc/Module AutoInstall.pm,1.1,1.2 Install.pm,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY-Client/inc/Module/AutoInstall.pm,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- /home/repository/moby/moby-live/Perl/MOBY-Client/inc/Module/AutoInstall.pm 2008/02/21 00:14:33 1.1 +++ /home/repository/moby/moby-live/Perl/MOBY-Client/inc/Module/AutoInstall.pm 2009/08/28 15:15:15 1.2 @@ -18,7 +18,9 @@ # various lexical flags my ( @Missing, @Existing, %DisabledTests, $UnderCPAN, $HasCPANPLUS ); -my ( $Config, $CheckOnly, $SkipInstall, $AcceptDefault, $TestOnly ); +my ( + $Config, $CheckOnly, $SkipInstall, $AcceptDefault, $TestOnly, $AllDeps +); my ( $PostambleActions, $PostambleUsed ); # See if it's a testing or non-interactive session @@ -73,6 +75,9 @@ elsif ( $arg =~ /^--test(?:only)?$/ ) { $TestOnly = 1; } + elsif ( $arg =~ /^--all(?:deps)?$/ ) { + $AllDeps = 1; + } } } @@ -115,6 +120,13 @@ )[0] ); + # We want to know if we're under CPAN early to avoid prompting, but + # if we aren't going to try and install anything anyway then skip the + # check entirely since we don't want to have to load (and configure) + # an old CPAN just for a cosmetic message + + $UnderCPAN = _check_lock(1) unless $SkipInstall; + while ( my ( $feature, $modules ) = splice( @args, 0, 2 ) ) { my ( @required, @tests, @skiptests ); my $default = 1; @@ -163,15 +175,24 @@ } # XXX: check for conflicts and uninstalls(!) them. - if ( - defined( my $cur = _version_check( _load($mod), $arg ||= 0 ) ) ) + my $cur = _load($mod); + if (_version_cmp ($cur, $arg) >= 0) { print "loaded. ($cur" . ( $arg ? " >= $arg" : '' ) . ")\n"; push @Existing, $mod => $arg; $DisabledTests{$_} = 1 for map { glob($_) } @skiptests; } else { - print "missing." . ( $arg ? " (would need $arg)" : '' ) . "\n"; + if (not defined $cur) # indeed missing + { + print "missing." . ( $arg ? " (would need $arg)" : '' ) . "\n"; + } + else + { + # no need to check $arg as _version_cmp ($cur, undef) would satisfy >= above + print "too old. ($cur < $arg)\n"; + } + push @required, $mod => $arg; } } @@ -184,6 +205,8 @@ !$SkipInstall and ( $CheckOnly + or ($mandatory and $UnderCPAN) + or $AllDeps or _prompt( qq{==> Auto-install the } . ( @required / 2 ) @@ -214,8 +237,6 @@ } } - $UnderCPAN = _check_lock(); # check for $UnderCPAN - if ( @Missing and not( $CheckOnly or $UnderCPAN ) ) { require Config; print @@ -234,21 +255,38 @@ *{'main::WriteMakefile'} = \&Write if caller(0) eq 'main'; } +sub _running_under { + my $thing = shift; + print <<"END_MESSAGE"; +*** Since we're running under ${thing}, I'll just let it take care + of the dependency's installation later. +END_MESSAGE + return 1; +} + # Check to see if we are currently running under CPAN.pm and/or CPANPLUS; # if we are, then we simply let it taking care of our dependencies sub _check_lock { - return unless @Missing; + return unless @Missing or @_; + + my $cpan_env = $ENV{PERL5_CPAN_IS_RUNNING}; if ($ENV{PERL5_CPANPLUS_IS_RUNNING}) { - print <<'END_MESSAGE'; + return _running_under($cpan_env ? 'CPAN' : 'CPANPLUS'); + } -*** Since we're running under CPANPLUS, I'll just let it take care - of the dependency's installation later. -END_MESSAGE - return 1; + require CPAN; + + if ($CPAN::VERSION > '1.89') { + if ($cpan_env) { + return _running_under('CPAN'); + } + return; # CPAN.pm new enough, don't need to check further } - _load_cpan(); + # last ditch attempt, this -will- configure CPAN, very sorry + + _load_cpan(1); # force initialize even though it's already loaded # Find the CPAN lock-file my $lock = MM->catfile( $CPAN::Config->{cpan_home}, ".lock" ); @@ -284,7 +322,7 @@ while ( my ( $pkg, $ver ) = splice( @_, 0, 2 ) ) { # grep out those already installed - if ( defined( _version_check( _load($pkg), $ver ) ) ) { + if ( _version_cmp( _load($pkg), $ver ) >= 0 ) { push @installed, $pkg; } else { @@ -313,7 +351,7 @@ @modules = @newmod; } - if ( _has_cpanplus() ) { + if ( _has_cpanplus() and not $ENV{PERL_AUTOINSTALL_PREFER_CPAN} ) { _install_cpanplus( \@modules, \@config ); } else { _install_cpan( \@modules, \@config ); @@ -323,7 +361,7 @@ # see if we have successfully installed them while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) { - if ( defined( _version_check( _load($pkg), $ver ) ) ) { + if ( _version_cmp( _load($pkg), $ver ) >= 0 ) { push @installed, $pkg; } elsif ( $args{do_once} and open( FAILED, '>> .#autoinstall.failed' ) ) { @@ -378,7 +416,7 @@ my $success; my $obj = $modtree->{$pkg}; - if ( $obj and defined( _version_check( $obj->{version}, $ver ) ) ) { + if ( $obj and _version_cmp( $obj->{version}, $ver ) >= 0 ) { my $pathname = $pkg; $pathname =~ s/::/\\W/; @@ -471,7 +509,7 @@ my $obj = CPAN::Shell->expand( Module => $pkg ); my $success = 0; - if ( $obj and defined( _version_check( $obj->cpan_version, $ver ) ) ) { + if ( $obj and _version_cmp( $obj->cpan_version, $ver ) >= 0 ) { my $pathname = $pkg; $pathname =~ s/::/\\W/; @@ -535,7 +573,7 @@ my $ver = shift; return - if defined( _version_check( _load($class), $ver ) ); # no need to upgrade + if _version_cmp( _load($class), $ver ) >= 0; # no need to upgrade if ( _prompt( "==> A newer version of $class ($ver) is required. Install?", @@ -632,7 +670,7 @@ # Load CPAN.pm and it's configuration sub _load_cpan { - return if $CPAN::VERSION; + return if $CPAN::VERSION and $CPAN::Config and not @_; require CPAN; if ( $CPAN::HandleConfig::VERSION ) { # Newer versions of CPAN have a HandleConfig module @@ -644,9 +682,11 @@ } # compare two versions, either use Sort::Versions or plain comparison -sub _version_check { +# return values same as <=> +sub _version_cmp { my ( $cur, $min ) = @_; - return unless defined $cur; + return -1 unless defined $cur; # if 0 keep comparing + return 1 unless $min; $cur =~ s/\s+$//; @@ -657,16 +697,13 @@ ) { # use version.pm if it is installed. - return ( - ( version->new($cur) >= version->new($min) ) ? $cur : undef ); + return version->new($cur) <=> version->new($min); } elsif ( $Sort::Versions::VERSION or defined( _load('Sort::Versions') ) ) { # use Sort::Versions as the sorting algorithm for a.b.c versions - return ( ( Sort::Versions::versioncmp( $cur, $min ) != -1 ) - ? $cur - : undef ); + return Sort::Versions::versioncmp( $cur, $min ); } warn "Cannot reliably compare non-decimal formatted versions.\n" @@ -675,7 +712,7 @@ # plain comparison local $^W = 0; # shuts off 'not numeric' bugs - return ( $cur >= $min ? $cur : undef ); + return $cur <=> $min; } # nothing; this usage is deprecated. @@ -706,7 +743,7 @@ if $Config; $PostambleActions = ( - $missing + ($missing and not $UnderCPAN) ? "\$(PERL) $0 --config=$config --installdeps=$missing" : "\$(NOECHO) \$(NOOP)" ); @@ -746,7 +783,7 @@ sub postamble { $PostambleUsed = 1; - return << "."; + return <<"END_MAKE"; config :: installdeps \t\$(NOECHO) \$(NOOP) @@ -757,7 +794,7 @@ installdeps :: \t$PostambleActions -. +END_MAKE } @@ -765,4 +802,4 @@ __END__ -#line 1003 +#line 1056 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY-Client/inc/Module/Install.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Perl/MOBY-Client/inc/Module/Install.pm 2008/05/07 18:15:19 1.2 +++ /home/repository/moby/moby-live/Perl/MOBY-Client/inc/Module/Install.pm 2009/08/28 15:15:16 1.3 @@ -17,12 +17,10 @@ # 3. The ./inc/ version of Module::Install loads # } -BEGIN { - require 5.004; -} +use 5.005; use strict 'vars'; -use vars qw{$VERSION}; +use vars qw{$VERSION $MAIN}; BEGIN { # All Module::Install core packages now require synchronised versions. # This will be used to ensure we don't accidentally load old or @@ -30,7 +28,10 @@ # This is not enforced yet, but will be some time in the next few # releases once we can make sure it won't clash with custom # Module::Install extensions. - $VERSION = '0.72'; + $VERSION = '0.91'; + + # Storage for the pseudo-singleton + $MAIN = undef; *inc::Module::Install::VERSION = *VERSION; @inc::Module::Install::ISA = __PACKAGE__; @@ -69,15 +70,26 @@ # again. This is bad. Rather than taking action to touch it (which # is unreliable on some platforms and requires write permissions) # for now we should catch this and refuse to run. -if ( -f $0 and (stat($0))[9] > time ) { die <<"END_DIE" } +if ( -f $0 ) { + my $s = (stat($0))[9]; -Your installer $0 has a modification time in the future. + # If the modification time is only slightly in the future, + # sleep briefly to remove the problem. + my $a = $s - time; + if ( $a > 0 and $a < 5 ) { sleep 5 } + + # Too far in the future, throw an error. + my $t = time; + if ( $s > $t ) { die <<"END_DIE" } + +Your installer $0 has a modification time in the future ($s > $t). This is known to create infinite loops in make. Please correct this, then run $0 again. END_DIE +} @@ -85,7 +97,7 @@ # Build.PL was formerly supported, but no longer is due to excessive # difficulty in implementing every single feature twice. -if ( $0 =~ /Build.PL$/i or -f 'Build.PL' ) { die <<"END_DIE" } +if ( $0 =~ /Build.PL$/i ) { die <<"END_DIE" } Module::Install no longer supports Build.PL. @@ -121,12 +133,22 @@ $sym->{$cwd} = sub { my $pwd = Cwd::cwd(); if ( my $code = $sym->{$pwd} ) { - # delegate back to parent dirs + # Delegate back to parent dirs goto &$code unless $cwd eq $pwd; } $$sym =~ /([^:]+)$/ or die "Cannot autoload $who - $sym"; + my $method = $1; + if ( uc($method) eq $method ) { + # Do nothing + return; + } elsif ( $method =~ /^_/ and $self->can($method) ) { + # Dispatch to the root M:I class + return $self->$method(@_); + } + + # Dispatch to the appropriate plugin unshift @_, ( $self, $1 ); - goto &{$self->can('call')} unless uc($1) eq $1; + goto &{$self->can('call')}; }; } @@ -151,6 +173,9 @@ delete $INC{"$self->{file}"}; delete $INC{"$self->{path}.pm"}; + # Save to the singleton + $MAIN = $self; + return 1; } @@ -164,8 +189,7 @@ my @exts = @{$self->{extensions}}; unless ( @exts ) { - my $admin = $self->{admin}; - @exts = $admin->load_all_extensions; + @exts = $self->{admin}->load_all_extensions; } my %seen; @@ -248,7 +272,7 @@ sub load_extensions { my ($self, $path, $top) = @_; - unless ( grep { lc $_ eq lc $self->{prefix} } @INC ) { + unless ( grep { ! ref $_ and lc $_ eq lc $self->{prefix} } @INC ) { unshift @INC, $self->{prefix}; } @@ -312,7 +336,7 @@ ##################################################################### -# Utility Functions +# Common Utility Functions sub _caller { my $depth = 0; @@ -326,28 +350,81 @@ sub _read { local *FH; - open FH, "< $_[0]" or die "open($_[0]): $!"; - my $str = do { local $/; }; + if ( $] >= 5.006 ) { + open( FH, '<', $_[0] ) or die "open($_[0]): $!"; + } else { + open( FH, "< $_[0]" ) or die "open($_[0]): $!"; + } + my $string = do { local $/; }; close FH or die "close($_[0]): $!"; - return $str; + return $string; +} + +sub _readperl { + my $string = Module::Install::_read($_[0]); + $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; + $string =~ s/(\n)\n*__(?:DATA|END)__\b.*\z/$1/s; + $string =~ s/\n\n=\w+.+?\n\n=cut\b.+?\n+/\n\n/sg; + return $string; +} + +sub _readpod { + my $string = Module::Install::_read($_[0]); + $string =~ s/(?:\015{1,2}\012|\015|\012)/\n/sg; + return $string if $_[0] =~ /\.pod\z/; + $string =~ s/(^|\n=cut\b.+?\n+)[^=\s].+?\n(\n=\w+|\z)/$1$2/sg; + $string =~ s/\n*=pod\b[^\n]*\n+/\n\n/sg; + $string =~ s/\n*=cut\b[^\n]*\n+/\n\n/sg; + $string =~ s/^\n+//s; + return $string; } sub _write { local *FH; - open FH, "> $_[0]" or die "open($_[0]): $!"; - foreach ( 1 .. $#_ ) { print FH $_[$_] or die "print($_[0]): $!" } + if ( $] >= 5.006 ) { + open( FH, '>', $_[0] ) or die "open($_[0]): $!"; + } else { + open( FH, "> $_[0]" ) or die "open($_[0]): $!"; + } + foreach ( 1 .. $#_ ) { + print FH $_[$_] or die "print($_[0]): $!"; + } close FH or die "close($_[0]): $!"; } -sub _version { +# _version is for processing module versions (eg, 1.03_05) not +# Perl versions (eg, 5.8.1). +sub _version ($) { my $s = shift || 0; - $s =~ s/^(\d+)\.?//; + my $d =()= $s =~ /(\.)/g; + if ( $d >= 2 ) { + # Normalise multipart versions + $s =~ s/(\.)(\d{1,3})/sprintf("$1%03d",$2)/eg; + } + $s =~ s/^(\d+)\.?//; my $l = $1 || 0; - my @v = map { $_ . '0' x (3 - length $_) } $s =~ /(\d{1,3})\D?/g; - $l = $l . '.' . join '', @v if @v; + my @v = map { + $_ . '0' x (3 - length $_) + } $s =~ /(\d{1,3})\D?/g; + $l = $l . '.' . join '', @v if @v; return $l + 0; } +sub _cmp ($$) { + _version($_[0]) <=> _version($_[1]); +} + +# Cloned from Params::Util::_CLASS +sub _CLASS ($) { + ( + defined $_[0] + and + ! ref $_[0] + and + $_[0] =~ m/^[^\W\d]\w*(?:::\w+)*\z/s + ) ? $_[0] : undef; +} + 1; -# Copyright 2008 Adam Kennedy. +# Copyright 2008 - 2009 Adam Kennedy. From kawas at dev.open-bio.org Fri Aug 28 11:15:16 2009 From: kawas at dev.open-bio.org (Eddie Kawas) Date: Fri, 28 Aug 2009 11:15:16 -0400 Subject: [MOBY-guts] biomoby commit Message-ID: <200908281515.n7SFFGeG018558@dev.open-bio.org> kawas Fri Aug 28 11:15:16 EDT 2009 Update of /home/repository/moby/moby-live/Perl/MOBY-Client/inc/Module/Install In directory dev.open-bio.org:/tmp/cvs-serv18457/MOBY-Client/inc/Module/Install Modified Files: AutoInstall.pm Share.pm Include.pm Makefile.pm WriteAll.pm Base.pm Win32.pm Metadata.pm Fetch.pm Can.pm Added Files: Scripts.pm Log Message: updated the module::install inc modules. moby-live/Perl/MOBY-Client/inc/Module/Install Scripts.pm,1.2,1.3 AutoInstall.pm,1.2,1.3 Share.pm,1.2,1.3 Include.pm,1.2,1.3 Makefile.pm,1.2,1.3 WriteAll.pm,1.2,1.3 Base.pm,1.2,1.3 Win32.pm,1.2,1.3 Metadata.pm,1.2,1.3 Fetch.pm,1.2,1.3 Can.pm,1.2,1.3 =================================================================== RCS file: /home/repository/moby/moby-live/Perl/MOBY-Client/inc/Module/Install/Scripts.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- /home/repository/moby/moby-live/Perl/MOBY-Client/inc/Module/Install/Scripts.pm 2008/05/07 18:15:19 1.2 +++ /home/repository/moby/moby-live/Perl/MOBY-Client/inc/Module/Install/Scripts.pm 2009/08/28 15:15:16 1.3 @@ -1,50 +1,29 @@ #line 1 package Module::Install::Scripts; -use strict; -use Module::Install::Base; -use File::Basename (); +use strict 'vars'; +use Module::Install::Base (); -use vars qw{$VERSION $ISCORE @ISA}; +use vars qw{$VERSION @ISA $ISCORE}; BEGIN { - $VERSION = '0.67'; + $VERSION = '0.91'; + @ISA = 'Module::Install::Base'; $ISCORE = 1; - @ISA = qw{Module::Install::Base}; -} - -sub prompt_script { - my ($self, $script_file) = @_; - - my ($prompt, $abstract, $default); - foreach my $line ( $self->_read_script($script_file) ) { - last unless $line =~ /^#/; - $prompt = $1 if $line =~ /^#\s*prompt:\s+(.*)/; - $default = $1 if $line =~ /^#\s*default:\s+(.*)/; - $abstract = $1 if $line =~ /^#\s*abstract:\s+(.*)/; - } - unless (defined $prompt) { - my $script_name = File::Basename::basename($script_file); - $prompt = "Do you want to install '$script_name'"; - $prompt .= " ($abstract)" if defined $abstract; - $prompt .= '?'; - } - return unless $self->prompt($prompt, ($default || 'n')) =~ /^[Yy]/; - $self->install_script($script_file); } sub install_script { - my $self = shift; - my $args = $self->makemaker_args; - my $exe_files = $args->{EXE_FILES} ||= []; - push @$exe_files, @_; -} - -sub _read_script { - my ($self, $script_file) = @_; - local *SCRIPT; - open SCRIPT, $script_file - or die "Can't open '$script_file' for input: $!\n"; - return