package org.kepler.web.service; import com.google.gwt.user.client.rpc.*; import com.google.gwt.user.server.rpc.*; import org.kepler.web.client.*; import edu.ucsb.nceas.metacat.client.*; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.apache.xpath.XPathAPI; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import org.xml.sax.InputSource; import java.io.*; import java.util.*; public class KeplerServiceServlet extends RemoteServiceServlet implements KeplerService { private String url = "http://library.kepler-project.org/kepler/metacat"; /** * takes in a query string and a sessionid and returns a resultset */ public MetacatQueryResult[] query(String query, String sessionid) { try { //query metacat MetacatClient client = (MetacatClient)MetacatFactory.createMetacatConnection(url); String queryDoc = createQueryDocument(query); Reader queryResultReader = client.query(new StringReader(queryDoc)); //now we have the result document, parse it and return it as MQR[] InputSource is = new InputSource(queryResultReader); DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder builder = factory.newDocumentBuilder(); Document doc = builder.parse(is); NodeList docs = XPathAPI.selectNodeList(doc, "/resultset/document"); MetacatQueryResult[] mqr = new MetacatQueryResult[docs.getLength()]; for(int i=0; i" + "" + "Untitled-Search-1" + "entity" + "eml://ecoinformatics.org//eml-2.0.0" + "-//ecoinformatics.org//eml-dataset-2.0.0beta4//EN" + "-//ecoinformatics.org//eml-dataset-2.0.0beta6//EN" + "-//NCEAS//eml-dataset-2.0//EN" + "-//NCEAS//resource//EN" + "/entity/@name" + "" + "" + "" + "" + queryString + "" + "" + "" + "" + ""; return query; } }