use of org.eclipse.rdf4j.query.MalformedQueryException in project rdf4j by eclipse.
the class RDF4JProtocolSession method getContextIDs.
public void getContextIDs(TupleQueryResultHandler handler) throws IOException, TupleQueryResultHandlerException, RepositoryException, UnauthorizedException, QueryInterruptedException {
checkRepositoryURL();
HttpGet method = new HttpGet(Protocol.getContextsLocation(getQueryURL()));
try {
getTupleQueryResult(method, handler);
} catch (MalformedQueryException e) {
logger.warn("Server reported unexpected malfored query error", e);
throw new RepositoryException(e.getMessage(), e);
} finally {
method.reset();
}
}
use of org.eclipse.rdf4j.query.MalformedQueryException in project rdf4j by eclipse.
the class RDF4JProtocolSession method getNamespaces.
public void getNamespaces(TupleQueryResultHandler handler) throws IOException, TupleQueryResultHandlerException, RepositoryException, UnauthorizedException, QueryInterruptedException {
checkRepositoryURL();
HttpGet method = new HttpGet(Protocol.getNamespacesLocation(getQueryURL()));
try {
getTupleQueryResult(method, handler);
} catch (MalformedQueryException e) {
logger.warn("Server reported unexpected malfored query error", e);
throw new RepositoryException(e.getMessage(), e);
} finally {
method.reset();
}
}
use of org.eclipse.rdf4j.query.MalformedQueryException in project rdf4j by eclipse.
the class SPARQLProtocolSession method sendGraphQueryViaHttp.
private HttpResponse sendGraphQueryViaHttp(HttpUriRequest method, boolean requireContext, Set<RDFFormat> rdfFormats) throws RepositoryException, IOException, QueryInterruptedException, MalformedQueryException {
List<String> acceptParams = RDFFormat.getAcceptParams(rdfFormats, requireContext, getPreferredRDFFormat());
method.addHeader(ACCEPT_PARAM_NAME, String.join(", ", acceptParams));
try {
return executeOK(method);
} catch (RepositoryException | MalformedQueryException | QueryInterruptedException e) {
throw e;
} catch (RDF4JException e) {
throw new RepositoryException(e);
}
}
use of org.eclipse.rdf4j.query.MalformedQueryException in project rdf4j by eclipse.
the class SPARQLConnection method hasStatement.
public boolean hasStatement(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws RepositoryException {
try {
BooleanQuery query = prepareBooleanQuery(SPARQL, SOMETHING, "");
setBindings(query, subj, pred, obj, contexts);
return query.evaluate();
} catch (MalformedQueryException e) {
throw new RepositoryException(e);
} catch (QueryEvaluationException e) {
throw new RepositoryException(e);
}
}
use of org.eclipse.rdf4j.query.MalformedQueryException in project rdf4j by eclipse.
the class SPARQLConnection method getStatementGeneral.
private RepositoryResult<Statement> getStatementGeneral(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws RepositoryException, MalformedQueryException, QueryEvaluationException {
GraphQueryResult gRes = null;
RepositoryResult<Statement> result = null;
boolean allGood = false;
try {
GraphQuery query = prepareGraphQuery(SPARQL, EVERYTHING, "");
query.setIncludeInferred(includeInferred);
setBindings(query, subj, pred, obj, contexts);
gRes = query.evaluate();
result = new RepositoryResult<Statement>(new ExceptionConvertingIteration<Statement, RepositoryException>(gRes) {
@Override
protected RepositoryException convert(Exception e) {
return new RepositoryException(e);
}
});
allGood = true;
return result;
} finally {
if (!allGood) {
try {
if (result != null) {
result.close();
}
} finally {
if (gRes != null) {
gRes.close();
}
}
}
}
}
Aggregations