Search in sources :

Example 41 with RepositoryException

use of org.eclipse.rdf4j.repository.RepositoryException in project rdf4j by eclipse.

the class RDF4JProtocolSession method getRepositoryList.

public void getRepositoryList(TupleQueryResultHandler handler) throws IOException, TupleQueryResultHandlerException, RepositoryException, UnauthorizedException, QueryInterruptedException {
    checkServerURL();
    HttpGet method = new HttpGet(Protocol.getRepositoriesLocation(serverURL));
    try {
        getTupleQueryResult(method, handler);
    } catch (MalformedQueryException e) {
        // This shouldn't happen as no queries are involved
        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 42 with RepositoryException

use of org.eclipse.rdf4j.repository.RepositoryException 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 43 with RepositoryException

use of org.eclipse.rdf4j.repository.RepositoryException in project rdf4j by eclipse.

the class RDF4JProtocolSession method removeNamespacePrefix.

public void removeNamespacePrefix(String prefix) throws IOException, RepositoryException, UnauthorizedException {
    checkRepositoryURL();
    HttpDelete method = new HttpDelete(Protocol.getNamespacePrefixLocation(getQueryURL(), prefix));
    try {
        executeNoContent(method);
    } catch (RepositoryException e) {
        throw e;
    } catch (RDF4JException e) {
        throw new RepositoryException(e);
    } finally {
        method.reset();
    }
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) RDF4JException(org.eclipse.rdf4j.RDF4JException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException)

Example 44 with RepositoryException

use of org.eclipse.rdf4j.repository.RepositoryException in project rdf4j by eclipse.

the class RDF4JProtocolSession method getNamespace.

public String getNamespace(String prefix) throws IOException, RepositoryException, UnauthorizedException {
    checkRepositoryURL();
    HttpGet method = new HttpGet(Protocol.getNamespacePrefixLocation(getQueryURL(), prefix));
    try {
        HttpResponse response = execute(method);
        int code = response.getStatusLine().getStatusCode();
        if (code == HttpURLConnection.HTTP_OK || code == HttpURLConnection.HTTP_NOT_AUTHORITATIVE) {
            return EntityUtils.toString(response.getEntity());
        } else {
            EntityUtils.consume(response.getEntity());
            return null;
        }
    } catch (RepositoryException e) {
        throw e;
    } catch (RDF4JException e) {
        throw new RepositoryException(e);
    } finally {
        method.reset();
    }
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) HttpResponse(org.apache.http.HttpResponse) RDF4JException(org.eclipse.rdf4j.RDF4JException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException)

Example 45 with RepositoryException

use of org.eclipse.rdf4j.repository.RepositoryException in project rdf4j by eclipse.

the class RDF4JProtocolSession method clearNamespaces.

public void clearNamespaces() throws IOException, RepositoryException, UnauthorizedException {
    checkRepositoryURL();
    HttpDelete method = new HttpDelete(Protocol.getNamespacesLocation(getQueryURL()));
    try {
        executeNoContent(method);
    } catch (RepositoryException e) {
        throw e;
    } catch (RDF4JException e) {
        throw new RepositoryException(e);
    } finally {
        method.reset();
    }
}
Also used : HttpDelete(org.apache.http.client.methods.HttpDelete) RDF4JException(org.eclipse.rdf4j.RDF4JException) RepositoryException(org.eclipse.rdf4j.repository.RepositoryException)

Aggregations

RepositoryException (org.eclipse.rdf4j.repository.RepositoryException)67 IOException (java.io.IOException)24 MalformedQueryException (org.eclipse.rdf4j.query.MalformedQueryException)20 QueryEvaluationException (org.eclipse.rdf4j.query.QueryEvaluationException)15 RDF4JException (org.eclipse.rdf4j.RDF4JException)13 HttpResponse (org.apache.http.HttpResponse)11 TupleQueryResult (org.eclipse.rdf4j.query.TupleQueryResult)10 RDFParseException (org.eclipse.rdf4j.rio.RDFParseException)8 HttpGet (org.apache.http.client.methods.HttpGet)7 Resource (org.eclipse.rdf4j.model.Resource)7 Statement (org.eclipse.rdf4j.model.Statement)6 ArrayList (java.util.ArrayList)5 HttpPut (org.apache.http.client.methods.HttpPut)5 RDF4JProtocolSession (org.eclipse.rdf4j.http.client.RDF4JProtocolSession)5 UnauthorizedException (org.eclipse.rdf4j.http.protocol.UnauthorizedException)5 BindingSet (org.eclipse.rdf4j.query.BindingSet)5 TupleQuery (org.eclipse.rdf4j.query.TupleQuery)5 RDFHandlerException (org.eclipse.rdf4j.rio.RDFHandlerException)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4