doQuery(req, resp);
}
public void doQuery(HttpServletRequest req, HttpServletResponse resp)
{
QueryEngine qe = null;
try
{
String theQuery = req.getParameter("query");
String stylesheet = tryParameter(req, "stylesheet", "xsl", "xslt",
"xslt-uri");
log.info("Query is:\n" + theQuery);
log.info("Stylesheet: " + stylesheet);
Query query = QueryFactory.create(theQuery);
if (type == LDAP)
qe = new LdapQueryEngine(query, config);
else
qe = new SQLQueryEngine(query, config);
qe.setDataset(DatasetFactory.create());
ResultSet results = qe.execSelect();
resp.setHeader("Content-Type", "application/xml");
ResultSetFormatter.outputAsXML(resp.getOutputStream(), results,
stylesheet);
}
catch (Throwable e)
{
log.error("Error: ", e);
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
finally
{
if (qe != null)
qe.close();
}
}