Package org.eclipse.rdf4j.http.client
Class RDF4JProtocolSession
- java.lang.Object
-
- org.eclipse.rdf4j.http.client.SPARQLProtocolSession
-
- org.eclipse.rdf4j.http.client.RDF4JProtocolSession
-
- All Implemented Interfaces:
java.lang.AutoCloseable
,HttpClientDependent
public class RDF4JProtocolSession extends SPARQLProtocolSession
ASPARQLProtocolSession
subclass which extends the standard SPARQL 1.1 Protocol with additional functionality, as documented in the RDF4J REST API.- See Also:
- RDF4J REST API
-
-
Field Summary
Fields Modifier and Type Field Description private org.slf4j.Logger
logger
private java.util.concurrent.ScheduledFuture<?>
ping
private long
pingDelay
private static long
PINGDELAY
How long the client should wait before sending another PING to the serverprivate java.util.concurrent.ScheduledExecutorService
pingScheduler
private java.lang.String
serverURL
private java.lang.String
transactionURL
-
Fields inherited from class org.eclipse.rdf4j.http.client.SPARQLProtocolSession
DEFAULT_MAXIMUM_URL_LENGTH, MAXIMUM_URL_LENGTH, MAXIMUM_URL_LENGTH_PARAM, UTF8
-
-
Constructor Summary
Constructors Constructor Description RDF4JProtocolSession(org.apache.http.client.HttpClient client, java.util.concurrent.ExecutorService executor)
RDF4JProtocolSession(org.apache.http.client.HttpClient client, java.util.concurrent.ScheduledExecutorService executor)
Deprecated.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addData(java.io.InputStream contents, java.lang.String baseURI, RDFFormat dataFormat, Resource... contexts)
private java.lang.String
appendAction(java.lang.String url, Protocol.Action action)
Appends the action as a parameter to the supplied urlprivate <T extends org.apache.http.client.methods.HttpUriRequest>
TapplyAdditionalHeaders(T method)
void
beginTransaction(IsolationLevel isolationLevel)
void
beginTransaction(TransactionSetting... transactionSettings)
protected void
checkRepositoryURL()
protected void
checkServerURL()
void
clearNamespaces()
void
close()
void
commitTransaction()
void
createRepository(RepositoryConfig config)
Create a new repository.void
deleteRepository(java.lang.String repositoryID)
(package private) void
executeTransactionPing()
TupleQueryResult
getContextIDs()
void
getContextIDs(TupleQueryResultHandler handler)
java.lang.String
getNamespace(java.lang.String prefix)
TupleQueryResult
getNamespaces()
void
getNamespaces(TupleQueryResultHandler handler)
protected org.apache.http.client.methods.HttpUriRequest
getQueryMethod(QueryLanguage ql, java.lang.String query, java.lang.String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings)
protected java.util.List<org.apache.http.NameValuePair>
getQueryMethodParameters(QueryLanguage ql, java.lang.String query, java.lang.String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings)
void
getRepositoryConfig(StatementCollector statementCollector)
Retrieve configuration of the current repository and send it to the suppliedStatementCollector
TupleQueryResult
getRepositoryList()
void
getRepositoryList(TupleQueryResultHandler handler)
java.lang.String
getRepositoryURL()
java.lang.String
getServerProtocol()
java.lang.String
getServerURL()
void
getStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, RDFHandler handler, Resource... contexts)
private java.lang.String
getTransactionURL()
protected org.apache.http.client.methods.HttpUriRequest
getUpdateMethod(QueryLanguage ql, java.lang.String update, java.lang.String baseURI, Dataset dataset, boolean includeInferred, int maxExecutionTime, Binding... bindings)
protected java.util.List<org.apache.http.NameValuePair>
getUpdateMethodParameters(QueryLanguage ql, java.lang.String update, java.lang.String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings)
java.lang.String
getUpdateURL()
private void
pingTransaction()
void
prepareTransaction()
void
removeData(java.io.InputStream contents, java.lang.String baseURI, RDFFormat dataFormat, Resource... contexts)
void
removeNamespacePrefix(java.lang.String prefix)
void
rollbackTransaction()
void
sendTransaction(java.lang.Iterable<? extends TransactionOperation> txn)
Deprecated.since 2.8.0void
setNamespacePrefix(java.lang.String prefix, java.lang.String name)
void
setRepository(java.lang.String repositoryURL)
void
setServerURL(java.lang.String serverURL)
void
setUsernameAndPassword(java.lang.String username, java.lang.String password)
Set the username and password for authentication with the remote server.long
size(Resource... contexts)
void
updateRepository(RepositoryConfig config)
Update the config of an existing repository.protected void
upload(java.io.InputStream contents, java.lang.String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Protocol.Action action, Resource... contexts)
void
upload(java.io.InputStream contents, java.lang.String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Resource... contexts)
protected void
upload(java.io.Reader contents, java.lang.String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Protocol.Action action, Resource... contexts)
void
upload(java.io.Reader contents, java.lang.String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Resource... contexts)
protected void
upload(org.apache.http.HttpEntity reqEntity, java.lang.String baseURI, boolean overwrite, boolean preserveNodeIds, Protocol.Action action, Resource... contexts)
-
Methods inherited from class org.eclipse.rdf4j.http.client.SPARQLProtocolSession
execute, executeNoContent, executeOK, getAdditionalHttpHeaders, getBackgroundTupleQueryResult, getBoolean, getConnectionTimeout, getContentTypeSerialisation, getErrorInfo, getHttpClient, getHttpContext, getParserConfig, getPreferredBooleanQueryResultFormat, getPreferredRDFFormat, getPreferredTupleQueryResultFormat, getQueryURL, getRDF, getRDFBackground, getResponseCharset, getResponseMIMEType, getTupleQueryResult, getUpdateMethod, getUpdateMethodParameters, getValueFactory, isPassThroughEnabled, sendBooleanQuery, sendBooleanQuery, sendGraphQuery, sendGraphQuery, sendGraphQuery, sendGraphQuery, sendTupleQuery, sendTupleQuery, sendTupleQuery, sendUpdate, sendUpdate, setAdditionalHttpHeaders, setConnectionTimeout, setHttpClient, setParserConfig, setPassThroughEnabled, setPreferredBooleanQueryResultFormat, setPreferredRDFFormat, setPreferredTupleQueryResultFormat, setQueryURL, setUpdateURL, setUsernameAndPasswordForUrl, setValueFactory, shouldUsePost
-
-
-
-
Field Detail
-
PINGDELAY
private static final long PINGDELAY
How long the client should wait before sending another PING to the server
-
logger
private final org.slf4j.Logger logger
-
serverURL
private java.lang.String serverURL
-
transactionURL
private java.lang.String transactionURL
-
pingScheduler
private final java.util.concurrent.ScheduledExecutorService pingScheduler
-
ping
private java.util.concurrent.ScheduledFuture<?> ping
-
pingDelay
private long pingDelay
-
-
Constructor Detail
-
RDF4JProtocolSession
@Deprecated(since="3.6.2") public RDF4JProtocolSession(org.apache.http.client.HttpClient client, java.util.concurrent.ScheduledExecutorService executor)
Deprecated.
-
RDF4JProtocolSession
public RDF4JProtocolSession(org.apache.http.client.HttpClient client, java.util.concurrent.ExecutorService executor)
-
-
Method Detail
-
setServerURL
public void setServerURL(java.lang.String serverURL)
-
getServerURL
public java.lang.String getServerURL()
-
getRepositoryURL
public java.lang.String getRepositoryURL()
-
setRepository
public void setRepository(java.lang.String repositoryURL)
-
checkRepositoryURL
protected void checkRepositoryURL()
-
checkServerURL
protected void checkServerURL()
-
getUpdateURL
public java.lang.String getUpdateURL()
- Overrides:
getUpdateURL
in classSPARQLProtocolSession
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Overrides:
close
in classSPARQLProtocolSession
-
getTransactionURL
private java.lang.String getTransactionURL()
-
getRepositoryList
public TupleQueryResult getRepositoryList() throws java.io.IOException, RepositoryException, UnauthorizedException, QueryInterruptedException
- Throws:
java.io.IOException
RepositoryException
UnauthorizedException
QueryInterruptedException
-
getRepositoryList
public void getRepositoryList(TupleQueryResultHandler handler) throws java.io.IOException, TupleQueryResultHandlerException, RepositoryException, UnauthorizedException, QueryInterruptedException
- Throws:
java.io.IOException
TupleQueryResultHandlerException
RepositoryException
UnauthorizedException
QueryInterruptedException
-
getServerProtocol
public java.lang.String getServerProtocol() throws java.io.IOException, RepositoryException, UnauthorizedException
- Throws:
java.io.IOException
RepositoryException
UnauthorizedException
-
size
public long size(Resource... contexts) throws java.io.IOException, RepositoryException, UnauthorizedException
- Throws:
java.io.IOException
RepositoryException
UnauthorizedException
-
createRepository
public void createRepository(RepositoryConfig config) throws java.io.IOException, RepositoryException
Create a new repository.- Parameters:
config
- the repository configuration- Throws:
java.io.IOException
RepositoryException
-
updateRepository
public void updateRepository(RepositoryConfig config) throws java.io.IOException, RepositoryException
Update the config of an existing repository.- Parameters:
config
- the repository configuration- Throws:
java.io.IOException
RepositoryException
-
deleteRepository
public void deleteRepository(java.lang.String repositoryID) throws java.io.IOException, RepositoryException
- Throws:
java.io.IOException
RepositoryException
-
getRepositoryConfig
public void getRepositoryConfig(StatementCollector statementCollector) throws UnauthorizedException, QueryInterruptedException, RDFHandlerException, RepositoryException, java.io.IOException
Retrieve configuration of the current repository and send it to the suppliedStatementCollector
- Parameters:
statementCollector
- receiver of the repository config information- Throws:
java.io.IOException
RepositoryException
RDFHandlerException
QueryInterruptedException
UnauthorizedException
- Since:
- 3.1.0
-
getNamespaces
public TupleQueryResult getNamespaces() throws java.io.IOException, RepositoryException, UnauthorizedException, QueryInterruptedException
- Throws:
java.io.IOException
RepositoryException
UnauthorizedException
QueryInterruptedException
-
getNamespaces
public void getNamespaces(TupleQueryResultHandler handler) throws java.io.IOException, TupleQueryResultHandlerException, RepositoryException, UnauthorizedException, QueryInterruptedException
- Throws:
java.io.IOException
TupleQueryResultHandlerException
RepositoryException
UnauthorizedException
QueryInterruptedException
-
getNamespace
public java.lang.String getNamespace(java.lang.String prefix) throws java.io.IOException, RepositoryException, UnauthorizedException
- Throws:
java.io.IOException
RepositoryException
UnauthorizedException
-
setNamespacePrefix
public void setNamespacePrefix(java.lang.String prefix, java.lang.String name) throws java.io.IOException, RepositoryException, UnauthorizedException
- Throws:
java.io.IOException
RepositoryException
UnauthorizedException
-
removeNamespacePrefix
public void removeNamespacePrefix(java.lang.String prefix) throws java.io.IOException, RepositoryException, UnauthorizedException
- Throws:
java.io.IOException
RepositoryException
UnauthorizedException
-
clearNamespaces
public void clearNamespaces() throws java.io.IOException, RepositoryException, UnauthorizedException
- Throws:
java.io.IOException
RepositoryException
UnauthorizedException
-
getContextIDs
public TupleQueryResult getContextIDs() throws java.io.IOException, RepositoryException, UnauthorizedException, QueryInterruptedException
- Throws:
java.io.IOException
RepositoryException
UnauthorizedException
QueryInterruptedException
-
getContextIDs
public void getContextIDs(TupleQueryResultHandler handler) throws java.io.IOException, TupleQueryResultHandlerException, RepositoryException, UnauthorizedException, QueryInterruptedException
- Throws:
java.io.IOException
TupleQueryResultHandlerException
RepositoryException
UnauthorizedException
QueryInterruptedException
-
getStatements
public void getStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, RDFHandler handler, Resource... contexts) throws java.io.IOException, RDFHandlerException, RepositoryException, UnauthorizedException, QueryInterruptedException
- Throws:
java.io.IOException
RDFHandlerException
RepositoryException
UnauthorizedException
QueryInterruptedException
-
beginTransaction
public void beginTransaction(IsolationLevel isolationLevel) throws RDF4JException, java.io.IOException, UnauthorizedException
- Throws:
RDF4JException
java.io.IOException
UnauthorizedException
-
beginTransaction
public void beginTransaction(TransactionSetting... transactionSettings) throws RDF4JException, java.io.IOException, UnauthorizedException
- Throws:
RDF4JException
java.io.IOException
UnauthorizedException
-
prepareTransaction
public void prepareTransaction() throws RDF4JException, java.io.IOException, UnauthorizedException
- Throws:
RDF4JException
java.io.IOException
UnauthorizedException
-
commitTransaction
public void commitTransaction() throws RDF4JException, java.io.IOException, UnauthorizedException
- Throws:
RDF4JException
java.io.IOException
UnauthorizedException
-
rollbackTransaction
public void rollbackTransaction() throws RDF4JException, java.io.IOException, UnauthorizedException
- Throws:
RDF4JException
java.io.IOException
UnauthorizedException
-
pingTransaction
private void pingTransaction()
-
executeTransactionPing
void executeTransactionPing()
-
appendAction
private java.lang.String appendAction(java.lang.String url, Protocol.Action action)
Appends the action as a parameter to the supplied url- Parameters:
url
- a url on which to append the parameter. it is assumed the url has no parameters.action
- the action to add as a parameter- Returns:
- the url parametrized with the supplied action
-
sendTransaction
@Deprecated(since="2.8.0") public void sendTransaction(java.lang.Iterable<? extends TransactionOperation> txn) throws java.io.IOException, RepositoryException, UnauthorizedException
Deprecated.since 2.8.0Sends a transaction list as serialized XML to the server.- Parameters:
txn
-- Throws:
java.io.IOException
RepositoryException
UnauthorizedException
-
addData
public void addData(java.io.InputStream contents, java.lang.String baseURI, RDFFormat dataFormat, Resource... contexts) throws UnauthorizedException, RDFParseException, RepositoryException, java.io.IOException
- Throws:
UnauthorizedException
RDFParseException
RepositoryException
java.io.IOException
-
removeData
public void removeData(java.io.InputStream contents, java.lang.String baseURI, RDFFormat dataFormat, Resource... contexts) throws UnauthorizedException, RDFParseException, RepositoryException, java.io.IOException
- Throws:
UnauthorizedException
RDFParseException
RepositoryException
java.io.IOException
-
upload
public void upload(java.io.InputStream contents, java.lang.String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Resource... contexts) throws java.io.IOException, RDFParseException, RepositoryException, UnauthorizedException
- Throws:
java.io.IOException
RDFParseException
RepositoryException
UnauthorizedException
-
upload
protected void upload(java.io.InputStream contents, java.lang.String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Protocol.Action action, Resource... contexts) throws java.io.IOException, RDFParseException, RepositoryException, UnauthorizedException
- Throws:
java.io.IOException
RDFParseException
RepositoryException
UnauthorizedException
-
upload
public void upload(java.io.Reader contents, java.lang.String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Resource... contexts) throws UnauthorizedException, RDFParseException, RepositoryException, java.io.IOException
- Throws:
UnauthorizedException
RDFParseException
RepositoryException
java.io.IOException
-
getQueryMethod
protected org.apache.http.client.methods.HttpUriRequest getQueryMethod(QueryLanguage ql, java.lang.String query, java.lang.String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings)
- Overrides:
getQueryMethod
in classSPARQLProtocolSession
-
getUpdateMethod
protected org.apache.http.client.methods.HttpUriRequest getUpdateMethod(QueryLanguage ql, java.lang.String update, java.lang.String baseURI, Dataset dataset, boolean includeInferred, int maxExecutionTime, Binding... bindings)
- Overrides:
getUpdateMethod
in classSPARQLProtocolSession
-
upload
protected void upload(java.io.Reader contents, java.lang.String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Protocol.Action action, Resource... contexts) throws java.io.IOException, RDFParseException, RepositoryException, UnauthorizedException
- Throws:
java.io.IOException
RDFParseException
RepositoryException
UnauthorizedException
-
upload
protected void upload(org.apache.http.HttpEntity reqEntity, java.lang.String baseURI, boolean overwrite, boolean preserveNodeIds, Protocol.Action action, Resource... contexts) throws java.io.IOException, RDFParseException, RepositoryException, UnauthorizedException
- Throws:
java.io.IOException
RDFParseException
RepositoryException
UnauthorizedException
-
setUsernameAndPassword
public void setUsernameAndPassword(java.lang.String username, java.lang.String password)
Description copied from class:SPARQLProtocolSession
Set the username and password for authentication with the remote server.- Overrides:
setUsernameAndPassword
in classSPARQLProtocolSession
- Parameters:
username
- the usernamepassword
- the password
-
getQueryMethodParameters
protected java.util.List<org.apache.http.NameValuePair> getQueryMethodParameters(QueryLanguage ql, java.lang.String query, java.lang.String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings)
- Overrides:
getQueryMethodParameters
in classSPARQLProtocolSession
-
getUpdateMethodParameters
protected java.util.List<org.apache.http.NameValuePair> getUpdateMethodParameters(QueryLanguage ql, java.lang.String update, java.lang.String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings)
- Overrides:
getUpdateMethodParameters
in classSPARQLProtocolSession
-
applyAdditionalHeaders
private <T extends org.apache.http.client.methods.HttpUriRequest> T applyAdditionalHeaders(T method)
-
-