}
protected SPARQLResult executeQuery(HttpActionQuery action, Query query, String queryStringLog)
{
Dataset dataset = decideDataset(action, query, queryStringLog) ;
QueryExecution qexec = createQueryExecution(query, dataset) ;
setAnyTimeouts(qexec, action);
if ( query.isSelectType() )
{
ResultSet rs = qexec.execSelect() ;
// Force some query execution now.
// Do this to force the query to do something that should touch any underlying database,
// and hence ensure the communications layer is working.
// MySQL can time out after 8 hours of an idle connection
rs.hasNext() ;
// // Not necessary if we are inside a read lock until the end of sending results.
// rs = ResultSetFactory.copyResults(rs) ;
log.info(format("[%d] OK/select", action.id)) ;
return new SPARQLResult(rs) ;
}
if ( query.isConstructType() )
{
Model model = qexec.execConstruct() ;
log.info(format("[%d] OK/construct", action.id)) ;
return new SPARQLResult(model) ;
}
if ( query.isDescribeType() )
{
Model model = qexec.execDescribe() ;
log.info(format("[%d] OK/describe",action.id)) ;
return new SPARQLResult(model) ;
}
if ( query.isAskType() )
{
boolean b = qexec.execAsk() ;
log.info(format("[%d] OK/ask",action.id)) ;
return new SPARQLResult(b) ;
}
errorBadRequest("Unknown query type - "+queryStringLog) ;