Class SparqlHttpProtocolConnector
Class for connecting to any store that implements the SPARQL Graph Store HTTP Protocol for Managing Graphs.
Inheritance
Implements
Inherited Members
Namespace: VDS.RDF.Storage
Assembly: dotNetRdf.dll
Syntax
public class SparqlHttpProtocolConnector : BaseAsyncHttpConnector, IConfigurationSerializable, IAsyncStorageProvider, IStorageProvider, IStorageCapabilities, IDisposable
Remarks
The SPARQL Graph Store HTTP Protocol is defined as part of SPARQL 1.1 and is currently a working draft so implementations are not guaranteed to be fully compliant with the draft and the protocol may change in the future.
Note: While this connector supports the update of a Graph the Graph Store HTTP Protocol only allows for the addition of data to an existing Graph and not the removal of data, therefore any calls to UpdateGraph() that would require the removal of Triple(s) will result in an error.
Constructors
| Edit this page View SourceSparqlHttpProtocolConnector(string, IWebProxy)
Creates a new SPARQL Graph Store HTTP Protocol Connector.
Declaration
public SparqlHttpProtocolConnector(string serviceUri, IWebProxy proxy)
Parameters
| Type | Name | Description |
|---|---|---|
| string | serviceUri | URI of the Protocol Server. |
| IWebProxy | proxy | Proxy Server. |
SparqlHttpProtocolConnector(string, MimeTypeDefinition)
Creates a new SPARQL Graph Store HTTP Protocol Connector.
Declaration
public SparqlHttpProtocolConnector(string serviceUri, MimeTypeDefinition writerMimeTypeDefinition = null)
Parameters
| Type | Name | Description |
|---|---|---|
| string | serviceUri | URI of the Protocol Server. |
| MimeTypeDefinition | writerMimeTypeDefinition | The MIME type specifying the syntax to use when sending RDF data to the server. Defaults to "application/rdf+xml". |
SparqlHttpProtocolConnector(Uri)
Creates a new SPARQL Graph Store HTTP Protocol Connector.
Declaration
public SparqlHttpProtocolConnector(Uri serviceUri)
Parameters
| Type | Name | Description |
|---|---|---|
| Uri | serviceUri | URI of the Protocol Server. |
SparqlHttpProtocolConnector(Uri, IWebProxy)
Creates a new SPARQL Graph Store HTTP Protocol Connector.
Declaration
public SparqlHttpProtocolConnector(Uri serviceUri, IWebProxy proxy)
Parameters
| Type | Name | Description |
|---|---|---|
| Uri | serviceUri | URI of the Protocol Server. |
| IWebProxy | proxy | Proxy Server. |
Fields
| Edit this page View Source_serviceUri
URI of the Protocol Server.
Declaration
protected string _serviceUri
Field Value
| Type | Description |
|---|---|
| string |
_writerMimeTypeDefinition
The MIME type of the syntax to use when sending RDF data to the server.
Declaration
protected MimeTypeDefinition _writerMimeTypeDefinition
Field Value
| Type | Description |
|---|---|
| MimeTypeDefinition |
Properties
| Edit this page View SourceDeleteSupported
Returns that deleting Graphs is supported.
Declaration
public override bool DeleteSupported { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
| Edit this page View SourceIOBehaviour
Gets the IO Behaviour of SPARQL Graph Store protocol based stores.
Declaration
public override IOBehaviour IOBehaviour { get; }
Property Value
| Type | Description |
|---|---|
| IOBehaviour |
Overrides
| Edit this page View SourceIsReadOnly
Gets that the Store is not read-only.
Declaration
public override bool IsReadOnly { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
| Edit this page View SourceIsReady
Gets that the Store is ready.
Declaration
public override bool IsReady { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
| Edit this page View SourceListGraphsSupported
Returns that listing Graphs is not supported.
Declaration
public override bool ListGraphsSupported { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
| Edit this page View SourceUpdateSupported
Gets that Updates are supported.
Declaration
public override bool UpdateSupported { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
Methods
| Edit this page View SourceDeleteGraph(string)
Deletes a Graph from the store.
Declaration
public virtual void DeleteGraph(string graphUri)
Parameters
| Type | Name | Description |
|---|---|---|
| string | graphUri | URI of the Graph to delete. |
DeleteGraph(string, AsyncStorageCallback, object)
Deletes a Graph from the store asynchronously.
Declaration
public override void DeleteGraph(string graphUri, AsyncStorageCallback callback, object state)
Parameters
| Type | Name | Description |
|---|---|---|
| string | graphUri | URI of the graph to delete. |
| AsyncStorageCallback | callback | Callback. |
| object | state | State to pass to the callback. |
Overrides
| Edit this page View SourceDeleteGraph(Uri)
Deletes a Graph from the store.
Declaration
public virtual void DeleteGraph(Uri graphUri)
Parameters
| Type | Name | Description |
|---|---|---|
| Uri | graphUri | URI of the Graph to delete. |
DeleteGraphAsync(string, CancellationToken)
Deletes a graph from the store asynchronously.
Declaration
public override Task DeleteGraphAsync(string graphName, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | graphName | Name of the graph to delete. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
Overrides
| Edit this page View SourceHasGraph(string)
Sends a HEAD Command to the Protocol Server to determine whether a given Graph exists.
Declaration
public virtual bool HasGraph(string graphUri)
Parameters
| Type | Name | Description |
|---|---|---|
| string | graphUri | URI of the Graph to check for. |
Returns
| Type | Description |
|---|---|
| bool |
HasGraph(Uri)
Sends a HEAD Command to the Protocol Server to determine whether a given Graph exists.
Declaration
public virtual bool HasGraph(Uri graphUri)
Parameters
| Type | Name | Description |
|---|---|---|
| Uri | graphUri | URI of the Graph to check for. |
Returns
| Type | Description |
|---|---|
| bool |
ListGraphNames()
Gets an enumeration of the names of the graphs in the store.
Declaration
public virtual IEnumerable<string> ListGraphNames()
Returns
| Type | Description |
|---|---|
| IEnumerable<string> |
Remarks
Implementations should implement this method only if they need to provide a custom way of listing Graphs. If the Store for which you are providing a manager can efficiently return the Graphs using a SELECT DISTINCT ?g WHERE { GRAPH ?g { ?s ?p ?o } } query then there should be no need to implement this function.
ListGraphs()
Throws an exception as listing graphs in a SPARQL Graph Store HTTP Protocol does not support listing graphs.
Declaration
[Obsolete("Replaced by ListGraphNames")]
public virtual IEnumerable<Uri> ListGraphs()
Returns
| Type | Description |
|---|---|
| IEnumerable<Uri> |
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | Thrown since SPARQL Graph Store HTTP Protocol does not support listing graphs. |
ListGraphs(AsyncStorageCallback, object)
Lists the Graphs in the Store asynchronously.
Declaration
[Obsolete("Replaced with ListGraphsAsync(CancellationToken)")]
public override void ListGraphs(AsyncStorageCallback callback, object state)
Parameters
| Type | Name | Description |
|---|---|---|
| AsyncStorageCallback | callback | Callback. |
| object | state | State to pass to the callback. |
Overrides
| Edit this page View SourceListGraphsAsync(CancellationToken)
List the names of the graph on the remote server asynchronously.
Declaration
public override Task<IEnumerable<string>> ListGraphsAsync(CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<IEnumerable<string>> | Task that returns the list of graph names. |
Overrides
Remarks
This implementation uses a SPARQL query to list the names of the graphs in the store. Many stores support more efficient means of listing graphs and so this method SHOULD be overridden. If the store does not implement the IAsyncQueryableStorage interface, then this method MUST be overridden.
Exceptions
| Type | Condition |
|---|---|
| RdfStorageException | Raised if the store does not support the asynchronous SPARQL query required to retrieve a list of graph names. |
LoadGraph(IGraph, string)
Loads a Graph from the Protocol Server.
Declaration
public virtual void LoadGraph(IGraph g, string graphUri)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph | g | Graph to load into. |
| string | graphUri | URI of the Graph to load. |
LoadGraph(IGraph, string, AsyncStorageCallback, object)
Loads a Graph from the Protocol Server.
Declaration
public override void LoadGraph(IGraph g, string graphUri, AsyncStorageCallback callback, object state)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph | g | Graph to load into. |
| string | graphUri | URI of the Graph to load. |
| AsyncStorageCallback | callback | Callback. |
| object | state | State to pass to the callback. |
Overrides
| Edit this page View SourceLoadGraph(IGraph, Uri)
Loads a Graph from the Protocol Server.
Declaration
public virtual void LoadGraph(IGraph g, Uri graphUri)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph | g | Graph to load into. |
| Uri | graphUri | URI of the Graph to load. |
LoadGraph(IRdfHandler, string)
Loads a Graph from the Protocol Server.
Declaration
public virtual void LoadGraph(IRdfHandler handler, string graphUri)
Parameters
| Type | Name | Description |
|---|---|---|
| IRdfHandler | handler | RDF Handler. |
| string | graphUri | URI of the Graph to load. |
LoadGraph(IRdfHandler, string, AsyncStorageCallback, object)
Loads a Graph from the Protocol Server.
Declaration
public override void LoadGraph(IRdfHandler handler, string graphUri, AsyncStorageCallback callback, object state)
Parameters
| Type | Name | Description |
|---|---|---|
| IRdfHandler | handler | RDF Handler. |
| string | graphUri | URI of the Graph to load. |
| AsyncStorageCallback | callback | Callback. |
| object | state | State to pass to the callback. |
Overrides
| Edit this page View SourceLoadGraph(IRdfHandler, Uri)
Loads a Graph from the Protocol Server.
Declaration
public virtual void LoadGraph(IRdfHandler handler, Uri graphUri)
Parameters
| Type | Name | Description |
|---|---|---|
| IRdfHandler | handler | RDF Handler. |
| Uri | graphUri | URI of the Graph to load. |
LoadGraphAsync(IRdfHandler, string, CancellationToken)
Loads a graph from the store asynchronously.
Declaration
public override Task LoadGraphAsync(IRdfHandler handler, string graphName, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| IRdfHandler | handler | The handler to receive the loaded triples. |
| string | graphName | Name of the graph to load. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
Overrides
| Edit this page View SourceSaveGraph(IGraph)
Saves a Graph to the Protocol Server.
Declaration
public virtual void SaveGraph(IGraph g)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph | g | Graph to save. |
SaveGraph(IGraph, AsyncStorageCallback, object)
Saves a Graph to the Protocol Server.
Declaration
public override void SaveGraph(IGraph g, AsyncStorageCallback callback, object state)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph | g | Graph to save. |
| AsyncStorageCallback | callback | Callback. |
| object | state | State to pass to the callback. |
Overrides
| Edit this page View SourceSaveGraphAsync(IGraph, CancellationToken)
Saves a Graph to the Store asynchronously.
Declaration
public override Task SaveGraphAsync(IGraph g, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| IGraph | g | Graph to save. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |
Overrides
| Edit this page View SourceSerializeConfiguration(ConfigurationSerializationContext)
Serializes the connection's configuration.
Declaration
public virtual void SerializeConfiguration(ConfigurationSerializationContext context)
Parameters
| Type | Name | Description |
|---|---|---|
| ConfigurationSerializationContext | context | Configuration Serialization Context. |
ToString()
Gets a String representation of the connection.
Declaration
public override string ToString()
Returns
| Type | Description |
|---|---|
| string |
Overrides
| Edit this page View SourceUpdateGraph(string, IEnumerable<Triple>, IEnumerable<Triple>)
Updates a Graph on the Protocol Server.
Declaration
public virtual void UpdateGraph(string graphUri, IEnumerable<Triple> additions, IEnumerable<Triple> removals)
Parameters
| Type | Name | Description |
|---|---|---|
| string | graphUri | URI of the Graph to update. |
| IEnumerable<Triple> | additions | Triples to be added. |
| IEnumerable<Triple> | removals | Triples to be removed. |
Remarks
Note: The SPARQL Graph Store HTTP Protocol for Graph Management only supports the addition of Triples to a Graph and does not support removal of Triples from a Graph. If you attempt to remove Triples then an RdfStorageException will be thrown.
UpdateGraph(string, IEnumerable<Triple>, IEnumerable<Triple>, AsyncStorageCallback, object)
Updates a Graph on the Protocol Server.
Declaration
public override void UpdateGraph(string graphUri, IEnumerable<Triple> additions, IEnumerable<Triple> removals, AsyncStorageCallback callback, object state)
Parameters
| Type | Name | Description |
|---|---|---|
| string | graphUri | URI of the Graph to update. |
| IEnumerable<Triple> | additions | Triples to be added. |
| IEnumerable<Triple> | removals | Triples to be removed. |
| AsyncStorageCallback | callback | Callback. |
| object | state | State to pass to the callback. |
Overrides
Remarks
Note: The SPARQL Graph Store HTTP Protocol for Graph Management only supports the addition of Triples to a Graph and does not support removal of Triples from a Graph. If you attempt to remove Triples then an RdfStorageException will be thrown.
UpdateGraph(Uri, IEnumerable<Triple>, IEnumerable<Triple>)
Updates a Graph on the Protocol Server.
Declaration
public virtual void UpdateGraph(Uri graphUri, IEnumerable<Triple> additions, IEnumerable<Triple> removals)
Parameters
| Type | Name | Description |
|---|---|---|
| Uri | graphUri | URI of the Graph to update. |
| IEnumerable<Triple> | additions | Triples to be added. |
| IEnumerable<Triple> | removals | Triples to be removed. |
Remarks
Note: The SPARQL Graph Store HTTP Protocol for Graph Management only supports the addition of Triples to a Graph and does not support removal of Triples from a Graph. If you attempt to remove Triples then an RdfStorageException will be thrown.
UpdateGraph(IRefNode, IEnumerable<Triple>, IEnumerable<Triple>)
Updates a Graph in the Store.
Declaration
public virtual void UpdateGraph(IRefNode graphName, IEnumerable<Triple> additions, IEnumerable<Triple> removals)
Parameters
| Type | Name | Description |
|---|---|---|
| IRefNode | graphName | Name of the Graph to update. |
| IEnumerable<Triple> | additions | Triples to add to the Graph. |
| IEnumerable<Triple> | removals | Triples to remove from the Graph. |
Remarks
Note: Not all Stores are capable of supporting update at the individual Triple level and as such it is acceptable for such a Store to throw a NotSupportedException or an RdfStorageException if the Store cannot provide this functionality.
Behaviour of this method with regards to non-existent Graph is up to the implementor, it may create a new empty Graph and apply the updates to that or it may throw an error. Implementors should state in the XML comments for their implementation what behaviour is implemented.
Implementers MUST allow for either the additions or removals argument to be null.
Exceptions
| Type | Condition |
|---|---|
| NotSupportedException | May be thrown if the underlying Store is not capable of doing Updates at the Triple level. |
| RdfStorageException | May be thrown if the underlying Store is not capable of doing Updates at the Triple level or if some error occurs while attempting the Update. |
UpdateGraphAsync(string, IEnumerable<Triple>, IEnumerable<Triple>, CancellationToken)
Updates a graph in the store asynchronously.
Declaration
public override Task UpdateGraphAsync(string graphUri, IEnumerable<Triple> additions, IEnumerable<Triple> removals, CancellationToken cancellationToken)
Parameters
| Type | Name | Description |
|---|---|---|
| string | graphUri | |
| IEnumerable<Triple> | additions | Triples to be added. |
| IEnumerable<Triple> | removals | Triples to be removed. |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task |