org.openrdf.sesame.repository.remote
Class HTTPRepository

java.lang.Object
  extended byorg.openrdf.sesame.repository.remote.HTTPRepository
All Implemented Interfaces:
SesameRepository

public class HTTPRepository
extends Object
implements SesameRepository

A proxy for a single remote Sesame repository that can be reached over HTTP. Create this object using an HTTPService.

Author:
Jeen Broekstra, Arjohn Kampman
See Also:
HTTPService

Method Summary
 void addData(File dataFile, String baseURI, RDFFormat dataFormat, boolean verifyData, AdminListener listener)
          Adds RDF data from the specified file to the repository.
 void addData(InputStream data, String baseURI, RDFFormat dataFormat, boolean verifyData, AdminListener listener)
          Adds RDF data from an InputStream to the repository.
 void addData(Reader data, String baseURI, RDFFormat dataFormat, boolean verifyData, AdminListener listener)
          Adds RDF data from a Reader to the repository.
 void addData(SesameRepository repository, AdminListener listener)
          Adds the contents of the supplied SesameRepository to this repository.
 void addData(String data, String baseURI, RDFFormat dataFormat, boolean verifyData, AdminListener listener)
          Adds an RDF document to the repository.
 void addData(URL dataURL, String baseURI, RDFFormat dataFormat, boolean verifyData, AdminListener listener)
          Adds the RDF data that can be found at the specified URL to the repository.
 void addGraph(Graph graph)
          Adds the contents of the supplied graph to the repository.
 void addGraph(Graph graph, boolean joinBlankNodes)
          Adds the contents of the supplied graph to the repository.
 void addGraph(QueryLanguage language, String query)
          Adds the contents of the graph specified by the supplied graph query to the repository.
 void addGraph(QueryLanguage language, String query, boolean joinBlankNodes)
          Adds the contents of the graph specified by the supplied graph query to the repository.
 void clear(AdminListener listener)
          Clears the repository.
 InputStream extractRDF(RDFFormat serialization, boolean schema, boolean data, boolean explicitOnly, boolean niceOutput)
          Extracts data from the repository and returns it in the requested format.
 String getRepositoryId()
          retrieves the repository id string for this repository.
 Graph performGraphQuery(QueryLanguage language, String query)
          Evaluates a graph query and reports the resulting statements to the specified listener.
 void performGraphQuery(QueryLanguage language, String query, GraphQueryResultListener listener)
          Evaluates a graph query and reports the resulting statements to the specified listener.
 QueryResultsTable performTableQuery(QueryLanguage language, String query)
          Evaluates a query and returns the results in a QueryResultsTable.
 void performTableQuery(QueryLanguage language, String query, TableQueryResultListener listener)
          Evaluates a query and reports the results as rows in a table to the supplied listener.
 void removeGraph(Graph graph)
          Removes the contents of the supplied graph from the repository.
 void removeGraph(QueryLanguage language, String query)
          Removes the contents of the graph specified by the supplied graph query from the repository.
 void removeStatements(Resource subject, URI predicate, Value object, AdminListener listener)
          Removes statements from the repository.
 void setGraphQueryResultFormat(RDFFormat format)
          Sets the response format for graph query results.
 void setTableQueryResultFormat(QueryResultFormat format)
          Sets the response format for table query results.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

setTableQueryResultFormat

public void setTableQueryResultFormat(QueryResultFormat format)
Sets the response format for table query results. The default format is QueryResultFormat.XML. Setting another format may result in better performance and/or a more compact result requiring less bandwidth.

Parameters:
format - A table query result format. Allowed values are XML and BINARY.

performTableQuery

public void performTableQuery(QueryLanguage language,
                              String query,
                              TableQueryResultListener listener)
                       throws IOException,
                              MalformedQueryException,
                              QueryEvaluationException,
                              AccessDeniedException
Description copied from interface: SesameRepository
Evaluates a query and reports the results as rows in a table to the supplied listener.

Specified by:
performTableQuery in interface SesameRepository
Parameters:
language - the query language in which the query is formulated.
query - the query.
listener - the result listener
Throws:
AccessDeniedException - In case the current user does not have read access on this repository.
QueryEvaluationException - If a problem occurs during evaluation of the query.
MalformedQueryException - If the supplied query is malformed.
IOException - In case an I/O error occurs while sending the query to, or retrieving the result from a Sesame server.
See Also:
QueryLanguage

performTableQuery

public QueryResultsTable performTableQuery(QueryLanguage language,
                                           String query)
                                    throws IOException,
                                           MalformedQueryException,
                                           QueryEvaluationException,
                                           AccessDeniedException
Description copied from interface: SesameRepository
Evaluates a query and returns the results in a QueryResultsTable.

Specified by:
performTableQuery in interface SesameRepository
Parameters:
language - The query language in which the query is formulated.
query - The query.
Returns:
A QueryResultsTable object that contains the query result. Note: if the query returned no results, an empty QueryResultsTable will be returned.
Throws:
MalformedQueryException - If the supplied query is malformed.
QueryEvaluationException - If a problem occurs during evaluation of the query.
AccessDeniedException - In case the current user does not have read access on this repository.
IOException - In case an I/O error occurs while sending the query to, or retrieving the result from a Sesame server.
See Also:
QueryLanguage

setGraphQueryResultFormat

public void setGraphQueryResultFormat(RDFFormat format)
Sets the response format for graph query results. The default format is RDFFormat.RDFXML. Setting another format may result in better performance and/or a more compact result requiring less bandwidth.

Parameters:
format - An RDF serialization format. Allowed values are RDFXML, NTRIPLES and TURTLE.

performGraphQuery

public void performGraphQuery(QueryLanguage language,
                              String query,
                              GraphQueryResultListener listener)
                       throws IOException,
                              MalformedQueryException,
                              QueryEvaluationException,
                              AccessDeniedException
Description copied from interface: SesameRepository
Evaluates a graph query and reports the resulting statements to the specified listener.

Specified by:
performGraphQuery in interface SesameRepository
Parameters:
language - The query language in which the query is formulated. Currently, only SeRQL supports graph queries and QueryLanguage.SERQL is the only legal value.
query - The query.
listener - A listener for the query result.
Throws:
QueryEvaluationException - If a problem occurs during evaluation of the query.
IOException - In case an I/O error occurs while sending the query to, or retrieving the result from a Sesame server.
MalformedQueryException - If the supplied query is malformed.
AccessDeniedException - In case the current user does not have read access on this repository.
See Also:
QueryLanguage

performGraphQuery

public Graph performGraphQuery(QueryLanguage language,
                               String query)
                        throws IOException,
                               MalformedQueryException,
                               QueryEvaluationException,
                               AccessDeniedException
Description copied from interface: SesameRepository
Evaluates a graph query and reports the resulting statements to the specified listener.

Specified by:
performGraphQuery in interface SesameRepository
Parameters:
language - The query language in which the query is formulated. Currently, only SeRQL supports graph queries and QueryLanguage.SERQL is the only legal value.
query - The query.
Returns:
A Graph object that contains the query result.
Throws:
MalformedQueryException - If the supplied query is malformed.
IOException - In case an I/O error occurs while sending the query to, or retrieving the result from a Sesame server.
AccessDeniedException - In case the current user does not have read access on this repository.
QueryEvaluationException - If a problem occurs during evaluation of the query.
See Also:
QueryLanguage

addData

public void addData(URL dataURL,
                    String baseURI,
                    RDFFormat dataFormat,
                    boolean verifyData,
                    AdminListener listener)
             throws IOException,
                    AccessDeniedException
Description copied from interface: SesameRepository
Adds the RDF data that can be found at the specified URL to the repository.

Specified by:
addData in interface SesameRepository
Parameters:
dataURL - the URL of the RDF data.
baseURI - the base URI to resolve any relative URIs against. This defaults to the value of dataURL if the value is set to null.
dataFormat - the serialization format of the data (one of RDFFormat.RDFXML, RDFFormat.NTRIPLES).
verifyData - if set to 'true', the RDF parser will verify the data before adding it to the repository.
listener - an AdminListener that will receive error- and progress messages.
Throws:
AccessDeniedException - In case the current user does not have write access on this repository.
IOException - In case an I/O error occurs.
See Also:
RDFFormat

addData

public void addData(File dataFile,
                    String baseURI,
                    RDFFormat dataFormat,
                    boolean verifyData,
                    AdminListener listener)
             throws FileNotFoundException,
                    IOException,
                    AccessDeniedException
Description copied from interface: SesameRepository
Adds RDF data from the specified file to the repository.

Specified by:
addData in interface SesameRepository
Parameters:
dataFile - a file containing RDF data.
baseURI - the base URI to resolve any relative URIs against.
dataFormat - the serialization format of the data (one of RDFFormat.RDFXML, RDFFormat.NTRIPLES).
verifyData - if set to 'true', the RDF parser will verify the data before adding it to the repository.
listener - an AdminListener that will receive error- and progress messages.
Throws:
IOException - In case an I/O error occurs.
AccessDeniedException - In case the current user does not have write access on this repository.
FileNotFoundException - In case the file could not be found.
See Also:
RDFFormat

addData

public void addData(InputStream data,
                    String baseURI,
                    RDFFormat dataFormat,
                    boolean verifyData,
                    AdminListener listener)
             throws IOException,
                    AccessDeniedException
Description copied from interface: SesameRepository
Adds RDF data from an InputStream to the repository.

Specified by:
addData in interface SesameRepository
Parameters:
data - an InputStream from which RDF data can be read.
baseURI - the base URI to resolve any relative URIs against.
dataFormat - the serialization format of the data (one of RDFFormat.RDFXML, RDFFormat.NTRIPLES).
verifyData - if set to 'true', the RDF parser will verify the data before adding it to the repository.
listener - an AdminListener that will receive error- and progress messages.
Throws:
IOException - In case an I/O error occurs.
AccessDeniedException - In case the current user does not have write access on this repository.
See Also:
RDFFormat

addData

public void addData(Reader data,
                    String baseURI,
                    RDFFormat dataFormat,
                    boolean verifyData,
                    AdminListener listener)
             throws IOException,
                    AccessDeniedException
Description copied from interface: SesameRepository
Adds RDF data from a Reader to the repository. Note: uploading XML-encoded RDF using a Reader can destroy the character encoding of the data. Using an InputStream can prevent this.

Specified by:
addData in interface SesameRepository
Parameters:
data - a Reader from which RDF data can be read.
baseURI - the base URI to resolve any relative URIs against.
dataFormat - the serialization format of the data (one of RDFFormat.RDFXML, RDFFormat.NTRIPLES).
verifyData - if set to 'true', the RDF parser will verify the data before adding it to the repository.
listener - an AdminListener that will receive error- and progress messages.
Throws:
IOException - In case an I/O error occurs.
AccessDeniedException - In case the current user does not have write access on this repository.
See Also:
RDFFormat

addData

public void addData(String data,
                    String baseURI,
                    RDFFormat dataFormat,
                    boolean verifyData,
                    AdminListener listener)
             throws IOException,
                    AccessDeniedException
Description copied from interface: SesameRepository
Adds an RDF document to the repository.

Specified by:
addData in interface SesameRepository
Parameters:
data - an RDF document.
baseURI - the base URI to resolve any relative URIs against.
dataFormat - the serialization format of the data (one of RDFFormat.RDFXML, RDFFormat.NTRIPLES).
verifyData - if set to 'true', the RDF parser will verify the data before adding it to the repository.
listener - an AdminListener that will receive error- and progress messages.
Throws:
IOException - In case an I/O error occurs.
AccessDeniedException - In case the current user does not have write access on this repository.
See Also:
RDFFormat

addData

public void addData(SesameRepository repository,
                    AdminListener listener)
             throws IOException,
                    AccessDeniedException
Description copied from interface: SesameRepository
Adds the contents of the supplied SesameRepository to this repository.

Specified by:
addData in interface SesameRepository
Parameters:
repository - a SesameRepository.
listener - an AdminListener that will receive error- and progress messages.
Throws:
IOException - In case an I/O error occurs.
AccessDeniedException - In case the current user does not have write access on this repository.
See Also:
RDFFormat

addGraph

public void addGraph(Graph graph)
              throws IOException,
                     AccessDeniedException
Description copied from interface: SesameRepository
Adds the contents of the supplied graph to the repository. Blank nodes in the supplied graph that originate from this repository are reused.

Specified by:
addGraph in interface SesameRepository
Parameters:
graph - a Graph containing the RDF statements to be added.
Throws:
IOException - in case an I/O error occurs.
AccessDeniedException - In case the current user does not have write access on this repository.
See Also:
Graph

addGraph

public void addGraph(QueryLanguage language,
                     String query)
              throws IOException,
                     AccessDeniedException
Description copied from interface: SesameRepository
Adds the contents of the graph specified by the supplied graph query to the repository. Blank nodes in the supplied graph that originate from this repository are reused.

Specified by:
addGraph in interface SesameRepository
Parameters:
language - the query language in which the query is formulated.
query - the query. Note that the query must be of a form that has an RDF graph as its result (e.g. a SeRQL CONSTRUCT query)
Throws:
IOException - in case an I/O error occurs
AccessDeniedException - in case the current user does not have write access on this repository.

addGraph

public void addGraph(Graph graph,
                     boolean joinBlankNodes)
              throws IOException,
                     AccessDeniedException
Description copied from interface: SesameRepository
Adds the contents of the supplied graph to the repository.

Specified by:
addGraph in interface SesameRepository
Parameters:
graph - a Graph containing the RDF statements to be added.
joinBlankNodes - indicates adding behavior. If set to true, blank nodes in the supplied graph that originate from this repository are reused. If set to false, new blank nodes are created for each blank node in the supplied graph.
Throws:
AccessDeniedException - In case the current user does not have write access on this repository.
IOException - in case an I/O error occurs.
See Also:
Graph

addGraph

public void addGraph(QueryLanguage language,
                     String query,
                     boolean joinBlankNodes)
              throws IOException,
                     AccessDeniedException
Description copied from interface: SesameRepository
Adds the contents of the graph specified by the supplied graph query to the repository.

Specified by:
addGraph in interface SesameRepository
Parameters:
language - the query language in which the query is formulated.
query - the query. Note that the query must be of a form that has an RDF graph as its result (e.g. a SeRQL CONSTRUCT query)
joinBlankNodes - indicates adding behavior. If set to true, blank nodes in the supplied graph that originate from this repository are reused. If set to false, new blank nodes are created for each blank node in the supplied graph.
Throws:
AccessDeniedException - in case the current user does not have write access on this repository.
IOException - in case an I/O error occurs

extractRDF

public InputStream extractRDF(RDFFormat serialization,
                              boolean schema,
                              boolean data,
                              boolean explicitOnly,
                              boolean niceOutput)
                       throws IOException,
                              AccessDeniedException
Description copied from interface: SesameRepository
Extracts data from the repository and returns it in the requested format. You can either extract the ontological data, the instance data, or both. For any of these, you can specify whether you want to extract all statements, or only the ones that were explicitly added.

Specified by:
extractRDF in interface SesameRepository
Parameters:
serialization - The serialization format that should be used (one of RDFFormat.RDFXML, RDFFormat.NTRIPLES, RDFFormat.N3).
schema - If true, the ontological part of the data will be extracted.
data - If true, the instances part of the data will be extracted.
explicitOnly - If true, only explicitely added statements will be extracted, i.e. the inferred statements will be skipped.
niceOutput - If true, the server will try its best to make the data as much readable for humans as possible. Note that this will cost extra processing time, and it should be set to 'false' if not necessary.
Throws:
IOException - In case an I/O error occurs.
AccessDeniedException - In case the current user does not have read access on this repository.
See Also:
RDFFormat

removeStatements

public void removeStatements(Resource subject,
                             URI predicate,
                             Value object,
                             AdminListener listener)
                      throws IOException,
                             AccessDeniedException
Description copied from interface: SesameRepository
Removes statements from the repository. Statements that match the pattern specified by the parameters subject, predicate and object will be removed from the repository. null values for these parameters indicate wildcards. So calling removeStatements(mySubject, null, null, l) will remove all statements with a subject equal to mySubject.

Specified by:
removeStatements in interface SesameRepository
Parameters:
subject - The subject of the statements that should be removed, or null if the subject is allowed to be anything.
predicate - The predicate of the statements that should be removed, or null if the predicate is allowed to be anything.
object - The object of the statements that should be removed, or null if the object is allowed to be anything.
listener - An AdminListener that will receive error- and progress messages.
Throws:
IOException - In case an I/O error occurs.
AccessDeniedException - In case the current user does not have write access on this repository.

removeGraph

public void removeGraph(Graph graph)
                 throws IOException,
                        AccessDeniedException
Description copied from interface: SesameRepository
Removes the contents of the supplied graph from the repository. All statements in the graph are removed from the repository. Blank nodes in the supplied graph that originate from this repository are reused.

Specified by:
removeGraph in interface SesameRepository
Parameters:
graph - a Graph containing RDF statements that are to be removed.
Throws:
IOException - in case an I/O error occurs.
AccessDeniedException - In case the current user does not have write access on this repository.
See Also:
Graph

removeGraph

public void removeGraph(QueryLanguage language,
                        String query)
                 throws IOException,
                        AccessDeniedException
Description copied from interface: SesameRepository
Removes the contents of the graph specified by the supplied graph query from the repository. Blank nodes in the supplied graph that originate from this repository are reused.

Specified by:
removeGraph in interface SesameRepository
Parameters:
language - the query language in which the query is formulated.
query - the query. Note that the query must be of a form that has an RDF graph as its result (e.g. a SeRQL CONSTRUCT query)
Throws:
AccessDeniedException - in case the current user does not have write access on this repository.
IOException - in case an I/O error occurs

clear

public void clear(AdminListener listener)
           throws IOException,
                  AccessDeniedException
Description copied from interface: SesameRepository
Clears the repository. All statements will be removed.

Specified by:
clear in interface SesameRepository
Parameters:
listener - An AdminListener that will receive error- and progress messages.
Throws:
AccessDeniedException - In case the current user does not have write access on this repository.
IOException - In case an I/O error occurs.

getRepositoryId

public String getRepositoryId()
Description copied from interface: SesameRepository
retrieves the repository id string for this repository.

Specified by:
getRepositoryId in interface SesameRepository
Returns:
the id of the repository.


Copyright © 2002-2006 Aduna BV, GNU LGPL License applies.