use of org.eclipse.rdf4j.repository.RepositoryException in project rdf4j by eclipse.
the class SPARQLConnection method getStatementsQuadMode.
private RepositoryResult<Statement> getStatementsQuadMode(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws MalformedQueryException, RepositoryException, QueryEvaluationException {
TupleQueryResult qRes = null;
RepositoryResult<Statement> result = null;
boolean allGood = false;
try {
TupleQuery tupleQuery = prepareTupleQuery(SPARQL, EVERYTHING_WITH_GRAPH);
setBindings(tupleQuery, subj, pred, obj, contexts);
tupleQuery.setIncludeInferred(includeInferred);
qRes = tupleQuery.evaluate();
result = new RepositoryResult<Statement>(new ExceptionConvertingIteration<Statement, RepositoryException>(toStatementIteration(qRes, subj, pred, obj)) {
@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 (qRes != null) {
qRes.close();
}
}
}
}
}
use of org.eclipse.rdf4j.repository.RepositoryException in project rdf4j by eclipse.
the class SPARQLConnection method getStatementsSingleTriple.
private RepositoryResult<Statement> getStatementsSingleTriple(Resource subj, IRI pred, Value obj, boolean includeInferred, Resource... contexts) throws RepositoryException {
if (hasStatement(subj, pred, obj, includeInferred, contexts)) {
Statement st = getValueFactory().createStatement(subj, pred, obj);
CloseableIteration<Statement, RepositoryException> cursor;
cursor = new SingletonIteration<Statement, RepositoryException>(st);
return new RepositoryResult<Statement>(cursor);
} else {
return new RepositoryResult<Statement>(new EmptyIteration<Statement, RepositoryException>());
}
}
use of org.eclipse.rdf4j.repository.RepositoryException in project rdf4j by eclipse.
the class SPARQLConnection method commit.
public void commit() throws RepositoryException {
synchronized (transactionLock) {
if (isActive()) {
synchronized (transactionLock) {
SPARQLUpdate transaction = new SPARQLUpdate(client, null, sparqlTransaction.toString());
try {
transaction.execute();
} catch (UpdateExecutionException e) {
throw new RepositoryException("error executing transaction", e);
}
sparqlTransaction = null;
}
} else {
throw new RepositoryException("no transaction active.");
}
}
}
use of org.eclipse.rdf4j.repository.RepositoryException in project rdf4j by eclipse.
the class HTTPTupleQuery method evaluate.
public void evaluate(TupleQueryResultHandler handler) throws QueryEvaluationException, TupleQueryResultHandlerException {
SPARQLProtocolSession client = getHttpClient();
try {
conn.flushTransactionState(Protocol.Action.QUERY);
client.sendTupleQuery(queryLanguage, queryString, baseURI, dataset, includeInferred, getMaxExecutionTime(), handler, getBindingsArray());
} catch (IOException e) {
throw new HTTPQueryEvaluationException(e.getMessage(), e);
} catch (RepositoryException e) {
throw new HTTPQueryEvaluationException(e.getMessage(), e);
} catch (MalformedQueryException e) {
throw new HTTPQueryEvaluationException(e.getMessage(), e);
}
}
use of org.eclipse.rdf4j.repository.RepositoryException in project rdf4j by eclipse.
the class HTTPRepositoryConnection method begin.
public void begin() throws RepositoryException {
verifyIsOpen();
verifyNotTxnActive("Connection already has an active transaction");
if (this.getRepository().useCompatibleMode()) {
active = true;
return;
}
try {
client.beginTransaction(this.getIsolationLevel());
active = true;
} catch (RepositoryException e) {
throw e;
} catch (RDF4JException e) {
throw new RepositoryException(e);
} catch (IllegalStateException e) {
throw new RepositoryException(e);
} catch (IOException e) {
throw new RepositoryException(e);
}
}
Aggregations