Search in sources :

Example 16 with MalformedQueryException

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();
    }
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) MalformedQueryException(org.eclipse.rdf4j.query.MalformedQueryException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException)

Example 17 with MalformedQueryException

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();
    }
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) MalformedQueryException(org.eclipse.rdf4j.query.MalformedQueryException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException)

Example 18 with MalformedQueryException

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);
    }
}
Also used : MalformedQueryException(org.eclipse.rdf4j.query.MalformedQueryException) RDF4JException(org.eclipse.rdf4j.RDF4JException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException) QueryInterruptedException(org.eclipse.rdf4j.query.QueryInterruptedException)

Example 19 with MalformedQueryException

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);
    }
}
Also used : BooleanQuery(org.eclipse.rdf4j.query.BooleanQuery) SPARQLBooleanQuery(org.eclipse.rdf4j.repository.sparql.query.SPARQLBooleanQuery) QueryEvaluationException(org.eclipse.rdf4j.query.QueryEvaluationException) MalformedQueryException(org.eclipse.rdf4j.query.MalformedQueryException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException)

Example 20 with MalformedQueryException

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();
                }
            }
        }
    }
}
Also used : Statement(org.eclipse.rdf4j.model.Statement) ExceptionConvertingIteration(org.eclipse.rdf4j.common.iteration.ExceptionConvertingIteration) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException) SPARQLGraphQuery(org.eclipse.rdf4j.repository.sparql.query.SPARQLGraphQuery) GraphQuery(org.eclipse.rdf4j.query.GraphQuery) GraphQueryResult(org.eclipse.rdf4j.query.GraphQueryResult) QueryEvaluationException(org.eclipse.rdf4j.query.QueryEvaluationException) RDFParseException(org.eclipse.rdf4j.rio.RDFParseException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException) UpdateExecutionException(org.eclipse.rdf4j.query.UpdateExecutionException) MalformedQueryException(org.eclipse.rdf4j.query.MalformedQueryException) UnknownTransactionStateException(org.eclipse.rdf4j.repository.UnknownTransactionStateException) UnsupportedQueryLanguageException(org.eclipse.rdf4j.query.UnsupportedQueryLanguageException) RDFHandlerException(org.eclipse.rdf4j.rio.RDFHandlerException) IOException(java.io.IOException)

Aggregations

MalformedQueryException (org.eclipse.rdf4j.query.MalformedQueryException)33 RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)20 QueryEvaluationException (org.eclipse.rdf4j.query.QueryEvaluationException)9 IOException (java.io.IOException)6 TupleQuery (org.eclipse.rdf4j.query.TupleQuery)5 TupleQueryResult (org.eclipse.rdf4j.query.TupleQueryResult)5 VisitorException (org.eclipse.rdf4j.query.parser.sparql.ast.VisitorException)5 HttpGet (org.apache.http.client.methods.HttpGet)4 QueryInterruptedException (org.eclipse.rdf4j.query.QueryInterruptedException)4 UnsupportedQueryLanguageException (org.eclipse.rdf4j.query.UnsupportedQueryLanguageException)4 UpdateExecutionException (org.eclipse.rdf4j.query.UpdateExecutionException)4 ExceptionConvertingIteration (org.eclipse.rdf4j.common.iteration.ExceptionConvertingIteration)3 SPARQLProtocolSession (org.eclipse.rdf4j.http.client.SPARQLProtocolSession)3 Binding (org.eclipse.rdf4j.query.Binding)3 TupleExpr (org.eclipse.rdf4j.query.algebra.TupleExpr)3 ParsedUpdate (org.eclipse.rdf4j.query.parser.ParsedUpdate)3 ASTInsertData (org.eclipse.rdf4j.query.parser.sparql.ast.ASTInsertData)3 UnknownTransactionStateException (org.eclipse.rdf4j.repository.UnknownTransactionStateException)3 RDFHandlerException (org.eclipse.rdf4j.rio.RDFHandlerException)3 RDFParseException (org.eclipse.rdf4j.rio.RDFParseException)3