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
ASPARQLProtocolSessionsubclass 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.Loggerloggerprivate java.util.concurrent.ScheduledFuture<?>pingprivate longpingDelayprivate static longPINGDELAYHow long the client should wait before sending another PING to the serverprivate java.util.concurrent.ScheduledExecutorServicepingSchedulerprivate java.lang.StringserverURLprivate java.lang.StringtransactionURL-
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 voidaddData(java.io.InputStream contents, java.lang.String baseURI, RDFFormat dataFormat, Resource... contexts)private java.lang.StringappendAction(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)voidbeginTransaction(IsolationLevel isolationLevel)voidbeginTransaction(TransactionSetting... transactionSettings)protected voidcheckRepositoryURL()protected voidcheckServerURL()voidclearNamespaces()voidclose()voidcommitTransaction()voidcreateRepository(RepositoryConfig config)Create a new repository.voiddeleteRepository(java.lang.String repositoryID)(package private) voidexecuteTransactionPing()TupleQueryResultgetContextIDs()voidgetContextIDs(TupleQueryResultHandler handler)java.lang.StringgetNamespace(java.lang.String prefix)TupleQueryResultgetNamespaces()voidgetNamespaces(TupleQueryResultHandler handler)protected org.apache.http.client.methods.HttpUriRequestgetQueryMethod(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)voidgetRepositoryConfig(StatementCollector statementCollector)Retrieve configuration of the current repository and send it to the suppliedStatementCollectorTupleQueryResultgetRepositoryList()voidgetRepositoryList(TupleQueryResultHandler handler)java.lang.StringgetRepositoryURL()java.lang.StringgetServerProtocol()java.lang.StringgetServerURL()voidgetStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, RDFHandler handler, Resource... contexts)private java.lang.StringgetTransactionURL()protected org.apache.http.client.methods.HttpUriRequestgetUpdateMethod(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.StringgetUpdateURL()private voidpingTransaction()voidprepareTransaction()voidremoveData(java.io.InputStream contents, java.lang.String baseURI, RDFFormat dataFormat, Resource... contexts)voidremoveNamespacePrefix(java.lang.String prefix)voidrollbackTransaction()voidsendTransaction(java.lang.Iterable<? extends TransactionOperation> txn)Deprecated.since 2.8.0voidsetNamespacePrefix(java.lang.String prefix, java.lang.String name)voidsetRepository(java.lang.String repositoryURL)voidsetServerURL(java.lang.String serverURL)voidsetUsernameAndPassword(java.lang.String username, java.lang.String password)Set the username and password for authentication with the remote server.longsize(Resource... contexts)voidupdateRepository(RepositoryConfig config)Update the config of an existing repository.protected voidupload(java.io.InputStream contents, java.lang.String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Protocol.Action action, Resource... contexts)voidupload(java.io.InputStream contents, java.lang.String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Resource... contexts)protected voidupload(java.io.Reader contents, java.lang.String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Protocol.Action action, Resource... contexts)voidupload(java.io.Reader contents, java.lang.String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Resource... contexts)protected voidupload(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:
getUpdateURLin classSPARQLProtocolSession
-
close
public void close()
- Specified by:
closein interfacejava.lang.AutoCloseable- Overrides:
closein classSPARQLProtocolSession
-
getTransactionURL
private java.lang.String getTransactionURL()
-
getRepositoryList
public TupleQueryResult getRepositoryList() throws java.io.IOException, RepositoryException, UnauthorizedException, QueryInterruptedException
- Throws:
java.io.IOExceptionRepositoryExceptionUnauthorizedExceptionQueryInterruptedException
-
getRepositoryList
public void getRepositoryList(TupleQueryResultHandler handler) throws java.io.IOException, TupleQueryResultHandlerException, RepositoryException, UnauthorizedException, QueryInterruptedException
- Throws:
java.io.IOExceptionTupleQueryResultHandlerExceptionRepositoryExceptionUnauthorizedExceptionQueryInterruptedException
-
getServerProtocol
public java.lang.String getServerProtocol() throws java.io.IOException, RepositoryException, UnauthorizedException- Throws:
java.io.IOExceptionRepositoryExceptionUnauthorizedException
-
size
public long size(Resource... contexts) throws java.io.IOException, RepositoryException, UnauthorizedException
- Throws:
java.io.IOExceptionRepositoryExceptionUnauthorizedException
-
createRepository
public void createRepository(RepositoryConfig config) throws java.io.IOException, RepositoryException
Create a new repository.- Parameters:
config- the repository configuration- Throws:
java.io.IOExceptionRepositoryException
-
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.IOExceptionRepositoryException
-
deleteRepository
public void deleteRepository(java.lang.String repositoryID) throws java.io.IOException, RepositoryException- Throws:
java.io.IOExceptionRepositoryException
-
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.IOExceptionRepositoryExceptionRDFHandlerExceptionQueryInterruptedExceptionUnauthorizedException- Since:
- 3.1.0
-
getNamespaces
public TupleQueryResult getNamespaces() throws java.io.IOException, RepositoryException, UnauthorizedException, QueryInterruptedException
- Throws:
java.io.IOExceptionRepositoryExceptionUnauthorizedExceptionQueryInterruptedException
-
getNamespaces
public void getNamespaces(TupleQueryResultHandler handler) throws java.io.IOException, TupleQueryResultHandlerException, RepositoryException, UnauthorizedException, QueryInterruptedException
- Throws:
java.io.IOExceptionTupleQueryResultHandlerExceptionRepositoryExceptionUnauthorizedExceptionQueryInterruptedException
-
getNamespace
public java.lang.String getNamespace(java.lang.String prefix) throws java.io.IOException, RepositoryException, UnauthorizedException- Throws:
java.io.IOExceptionRepositoryExceptionUnauthorizedException
-
setNamespacePrefix
public void setNamespacePrefix(java.lang.String prefix, java.lang.String name) throws java.io.IOException, RepositoryException, UnauthorizedException- Throws:
java.io.IOExceptionRepositoryExceptionUnauthorizedException
-
removeNamespacePrefix
public void removeNamespacePrefix(java.lang.String prefix) throws java.io.IOException, RepositoryException, UnauthorizedException- Throws:
java.io.IOExceptionRepositoryExceptionUnauthorizedException
-
clearNamespaces
public void clearNamespaces() throws java.io.IOException, RepositoryException, UnauthorizedException- Throws:
java.io.IOExceptionRepositoryExceptionUnauthorizedException
-
getContextIDs
public TupleQueryResult getContextIDs() throws java.io.IOException, RepositoryException, UnauthorizedException, QueryInterruptedException
- Throws:
java.io.IOExceptionRepositoryExceptionUnauthorizedExceptionQueryInterruptedException
-
getContextIDs
public void getContextIDs(TupleQueryResultHandler handler) throws java.io.IOException, TupleQueryResultHandlerException, RepositoryException, UnauthorizedException, QueryInterruptedException
- Throws:
java.io.IOExceptionTupleQueryResultHandlerExceptionRepositoryExceptionUnauthorizedExceptionQueryInterruptedException
-
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.IOExceptionRDFHandlerExceptionRepositoryExceptionUnauthorizedExceptionQueryInterruptedException
-
beginTransaction
public void beginTransaction(IsolationLevel isolationLevel) throws RDF4JException, java.io.IOException, UnauthorizedException
- Throws:
RDF4JExceptionjava.io.IOExceptionUnauthorizedException
-
beginTransaction
public void beginTransaction(TransactionSetting... transactionSettings) throws RDF4JException, java.io.IOException, UnauthorizedException
- Throws:
RDF4JExceptionjava.io.IOExceptionUnauthorizedException
-
prepareTransaction
public void prepareTransaction() throws RDF4JException, java.io.IOException, UnauthorizedException- Throws:
RDF4JExceptionjava.io.IOExceptionUnauthorizedException
-
commitTransaction
public void commitTransaction() throws RDF4JException, java.io.IOException, UnauthorizedException- Throws:
RDF4JExceptionjava.io.IOExceptionUnauthorizedException
-
rollbackTransaction
public void rollbackTransaction() throws RDF4JException, java.io.IOException, UnauthorizedException- Throws:
RDF4JExceptionjava.io.IOExceptionUnauthorizedException
-
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.IOExceptionRepositoryExceptionUnauthorizedException
-
addData
public void addData(java.io.InputStream contents, java.lang.String baseURI, RDFFormat dataFormat, Resource... contexts) throws UnauthorizedException, RDFParseException, RepositoryException, java.io.IOException- Throws:
UnauthorizedExceptionRDFParseExceptionRepositoryExceptionjava.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:
UnauthorizedExceptionRDFParseExceptionRepositoryExceptionjava.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.IOExceptionRDFParseExceptionRepositoryExceptionUnauthorizedException
-
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.IOExceptionRDFParseExceptionRepositoryExceptionUnauthorizedException
-
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:
UnauthorizedExceptionRDFParseExceptionRepositoryExceptionjava.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:
getQueryMethodin 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:
getUpdateMethodin 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.IOExceptionRDFParseExceptionRepositoryExceptionUnauthorizedException
-
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.IOExceptionRDFParseExceptionRepositoryExceptionUnauthorizedException
-
setUsernameAndPassword
public void setUsernameAndPassword(java.lang.String username, java.lang.String password)Description copied from class:SPARQLProtocolSessionSet the username and password for authentication with the remote server.- Overrides:
setUsernameAndPasswordin 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:
getQueryMethodParametersin 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:
getUpdateMethodParametersin classSPARQLProtocolSession
-
applyAdditionalHeaders
private <T extends org.apache.http.client.methods.HttpUriRequest> T applyAdditionalHeaders(T method)
-
-