use of org.eclipse.rdf4j.http.client.SPARQLProtocolSession in project rdf4j by eclipse.
the class HTTPUpdate method execute.
@Override
public void execute() throws UpdateExecutionException {
try {
if (httpCon.getRepository().useCompatibleMode()) {
if (httpCon.isAutoCommit()) {
// execute update immediately
SPARQLProtocolSession client = getHttpClient();
try {
client.sendUpdate(getQueryLanguage(), getQueryString(), getBaseURI(), dataset, includeInferred, getMaxExecutionTime(), getBindingsArray());
} catch (UnauthorizedException e) {
throw new HTTPUpdateExecutionException(e.getMessage(), e);
} catch (QueryInterruptedException e) {
throw new HTTPUpdateExecutionException(e.getMessage(), e);
} catch (MalformedQueryException e) {
throw new HTTPUpdateExecutionException(e.getMessage(), e);
} catch (IOException e) {
throw new HTTPUpdateExecutionException(e.getMessage(), e);
}
} else {
// defer execution as part of transaction.
httpCon.scheduleUpdate(this);
}
return;
}
SPARQLProtocolSession client = getHttpClient();
try {
httpCon.flushTransactionState(Action.UPDATE);
client.sendUpdate(getQueryLanguage(), getQueryString(), getBaseURI(), dataset, includeInferred, getMaxExecutionTime(), getBindingsArray());
} catch (UnauthorizedException e) {
throw new HTTPUpdateExecutionException(e.getMessage(), e);
} catch (QueryInterruptedException e) {
throw new HTTPUpdateExecutionException(e.getMessage(), e);
} catch (MalformedQueryException e) {
throw new HTTPUpdateExecutionException(e.getMessage(), e);
} catch (IOException e) {
throw new HTTPUpdateExecutionException(e.getMessage(), e);
}
} catch (RepositoryException e) {
throw new HTTPUpdateExecutionException(e.getMessage(), e);
}
}
use of org.eclipse.rdf4j.http.client.SPARQLProtocolSession in project rdf4j by eclipse.
the class SPARQLRepository method createHTTPClient.
/**
* Creates a new HTTPClient object. Subclasses may override to return a more specific HTTPClient subtype.
*
* @return a HTTPClient object.
*/
protected SPARQLProtocolSession createHTTPClient() {
// initialize HTTP client
SPARQLProtocolSession httpClient = getHttpClientSessionManager().createSPARQLProtocolSession(queryEndpointUrl, updateEndpointUrl);
httpClient.setValueFactory(SimpleValueFactory.getInstance());
httpClient.setPreferredTupleQueryResultFormat(TupleQueryResultFormat.SPARQL);
httpClient.setAdditionalHttpHeaders(additionalHttpHeaders);
if (username != null) {
httpClient.setUsernameAndPassword(username, password);
}
return httpClient;
}
use of org.eclipse.rdf4j.http.client.SPARQLProtocolSession 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.http.client.SPARQLProtocolSession in project rdf4j by eclipse.
the class HTTPGraphQuery method evaluate.
/*
* public GraphQueryResult evaluate() throws QueryEvaluationException { HTTPClient client =
* httpCon.getRepository().getHTTPClient(); try { return client.sendGraphQuery(queryLanguage, queryString,
* baseURI, dataset, includeInferred, maxQueryTime, 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); } }
*/
public void evaluate(RDFHandler handler) throws QueryEvaluationException, RDFHandlerException {
SPARQLProtocolSession client = getHttpClient();
try {
conn.flushTransactionState(Protocol.Action.QUERY);
client.sendGraphQuery(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);
}
}
Aggregations