Search in sources :

Example 1 with SPARQLProtocolSession

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);
    }
}
Also used : SPARQLProtocolSession(org.eclipse.rdf4j.http.client.SPARQLProtocolSession) UnauthorizedException(org.eclipse.rdf4j.http.protocol.UnauthorizedException) MalformedQueryException(org.eclipse.rdf4j.query.MalformedQueryException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException) IOException(java.io.IOException) QueryInterruptedException(org.eclipse.rdf4j.query.QueryInterruptedException)

Example 2 with SPARQLProtocolSession

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;
}
Also used : SPARQLProtocolSession(org.eclipse.rdf4j.http.client.SPARQLProtocolSession)

Example 3 with SPARQLProtocolSession

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);
    }
}
Also used : SPARQLProtocolSession(org.eclipse.rdf4j.http.client.SPARQLProtocolSession) MalformedQueryException(org.eclipse.rdf4j.query.MalformedQueryException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException) IOException(java.io.IOException)

Example 4 with SPARQLProtocolSession

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);
    }
}
Also used : SPARQLProtocolSession(org.eclipse.rdf4j.http.client.SPARQLProtocolSession) MalformedQueryException(org.eclipse.rdf4j.query.MalformedQueryException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException) IOException(java.io.IOException)

Aggregations

SPARQLProtocolSession (org.eclipse.rdf4j.http.client.SPARQLProtocolSession)4 IOException (java.io.IOException)3 MalformedQueryException (org.eclipse.rdf4j.query.MalformedQueryException)3 RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)3 UnauthorizedException (org.eclipse.rdf4j.http.protocol.UnauthorizedException)1 QueryInterruptedException (org.eclipse.rdf4j.query.QueryInterruptedException)1