Class RDF4JProtocolSession
java.lang.Object
org.eclipse.rdf4j.http.client.SPARQLProtocolSession
org.eclipse.rdf4j.http.client.RDF4JProtocolSession
- All Implemented Interfaces:
AutoCloseable, HttpClientDependent
A
SPARQLProtocolSession subclass which extends the standard SPARQL 1.1 Protocol with additional
functionality, as documented in the RDF4J REST API.- Author:
- Andreas Schwarte, Jeen Broekstra
- See Also:
-
Field Summary
Fields inherited from class SPARQLProtocolSession
DEFAULT_MAXIMUM_URL_LENGTH, MAXIMUM_URL_LENGTH, MAXIMUM_URL_LENGTH_PARAM, UTF8Modifier and TypeFieldDescriptionstatic final intThe default value of the threshold for URL length, beyond which we use the POST method for SPARQL query requests.static final intDeprecated.static final StringSystem property for configuration of URL length threshold:rdf4j.sparql.url.maxlength.protected static final Charset -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddData(InputStream contents, String baseURI, RDFFormat dataFormat, Resource... contexts) protected HttpRequest.BuilderApplies additional HTTP headers (fromSPARQLProtocolSession.getAdditionalHttpHeaders()) and the authorization header to the supplied request builder.voidbeginTransaction(IsolationLevel isolationLevel) voidbeginTransaction(TransactionSetting... transactionSettings) voidcancelQueryExplanation(String explainRequestId) protected voidprotected voidvoidvoidclose()voidvoidcreateRepository(RepositoryConfig config) Create a new repository.voiddeleteRepository(String repositoryID) voidgetContextIDs(TupleQueryResultHandler handler) getNamespace(String prefix) voidgetNamespaces(TupleQueryResultHandler handler) protected HttpRequestgetQueryMethod(QueryLanguage ql, String query, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings) protected List<NameValuePair> getQueryMethodParameters(QueryLanguage ql, String query, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings) voidgetRepositoryConfig(StatementCollector statementCollector) Retrieve configuration of the current repository and send it to the suppliedStatementCollectorvoidgetRepositoryList(TupleQueryResultHandler handler) voidgetStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, RDFHandler handler, Resource... contexts) protected HttpRequestgetUpdateMethod(QueryLanguage ql, String update, String baseURI, Dataset dataset, boolean includeInferred, int maxExecutionTime, Binding... bindings) protected List<NameValuePair> getUpdateMethodParameters(QueryLanguage ql, String update, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings) voidvoidremoveData(InputStream contents, String baseURI, RDFFormat dataFormat, Resource... contexts) voidremoveNamespacePrefix(String prefix) voidsendQueryExplanation(QueryLanguage ql, String query, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Explanation.Level level, Binding... bindings) voidsendTransaction(Iterable<? extends TransactionOperation> txn) Deprecated.since 2.8.0voidsetNamespacePrefix(String prefix, String name) voidsetRepository(String repositoryURL) voidsetServerURL(String serverURL) voidsetUsernameAndPassword(String username, String password) Set the username and password for authentication with the remote server.longvoidupdateRepository(RepositoryConfig config) Update the config of an existing repository.protected voidupload(InputStream contents, String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Protocol.Action action, Resource... contexts) voidupload(InputStream contents, String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Resource... contexts) protected voidupload(Reader contents, String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Protocol.Action action, Resource... contexts) voidupload(Reader contents, String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Resource... contexts) protected voidupload(HttpRequestBody reqBody, String baseURI, boolean overwrite, boolean preserveNodeIds, Protocol.Action action, Resource... contexts) Methods inherited from class SPARQLProtocolSession
execute, executeNoContent, executeOK, getAdditionalHttpHeaders, getAuthenticationHandler, getBackgroundTupleQueryResult, getBoolean, getErrorInfo, getHttpClient, getParserConfig, getPreferredBooleanQueryResultFormat, getPreferredRDFFormat, getPreferredTupleQueryResultFormat, getQueryURL, getRDF, getRDFBackground, getResponseMIMEType, getTupleQueryResult, getUpdateMethod, getUpdateMethodParameters, getValueFactory, isPassThroughEnabled, sendBooleanQuery, sendBooleanQuery, sendGraphQuery, sendGraphQuery, sendGraphQuery, sendGraphQuery, sendTupleQuery, sendTupleQuery, sendTupleQuery, sendUpdate, sendUpdate, setAdditionalHttpHeaders, setAuthenticationHandler, setHttpClient, setParserConfig, setPassThroughEnabled, setPreferredBooleanQueryResultFormat, setPreferredRDFFormat, setPreferredTupleQueryResultFormat, setQueryURL, setUpdateURL, setUsernameAndPasswordForUrl, setValueFactory, shouldUsePostModifier and TypeMethodDescriptionprotected HttpResponseexecute(HttpRequest request) Executes the given HTTP request and returns the response on success (2xx or 404).protected voidexecuteNoContent(HttpRequest method) protected HttpResponseexecuteOK(HttpRequest method) Convenience method to deal with HTTP level errors of tuple, graph and boolean queries in the same way.Get the additional HTTP headers which will be usedReturns the currentAuthenticationHandler, ornullif none has been set.protected TupleQueryResultgetBackgroundTupleQueryResult(HttpRequest method, WeakReference<?> callerRef) Deprecated.WeakReferenceinvalid input: '<'?protected booleangetBoolean(HttpRequest method) Parse the response in this thread using a suitableBooleanQueryResultParser.protected ErrorInfogetErrorInfo(HttpResponse response) final RDF4JHttpClientRDF4JHttpClientthat has been assigned or has been used by this object.Gets the preferredBooleanQueryResultFormatfor encoding boolean query results.Gets the preferredRDFFormatfor encoding RDF documents.Gets the preferredTupleQueryResultFormatfor encoding tuple query results.protected voidgetRDF(HttpRequest method, RDFHandler handler, boolean requireContext) Parse the response in this thread using the providedRDFHandler.protected GraphQueryResultgetRDFBackground(HttpRequest method, boolean requireContext, WeakReference<?> callerRef) Deprecated.WeakReferenceinvalid input: '<'?protected StringgetResponseMIMEType(HttpResponse response) Gets the MIME type specified in the response headers of the supplied method, if any.protected voidgetTupleQueryResult(HttpRequest method, TupleQueryResultHandler handler) Parse the response in this thread using the providedTupleQueryResultHandler.protected HttpRequestgetUpdateMethod(QueryLanguage ql, String update, String baseURI, Dataset dataset, boolean includeInferred, Binding... bindings) protected List<NameValuePair> getUpdateMethodParameters(QueryLanguage ql, String update, String baseURI, Dataset dataset, boolean includeInferred, Binding... bindings) booleanIndicates if direct pass-through of the endpoint result to the suppliedSinkis enabled.booleansendBooleanQuery(QueryLanguage ql, String query, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings) booleansendBooleanQuery(QueryLanguage ql, String query, Dataset dataset, boolean includeInferred, Binding... bindings) sendGraphQuery(QueryLanguage ql, String query, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, WeakReference<?> callerRef, Binding... bindings) Deprecated.WeakReferenceinvalid input: '<'?voidsendGraphQuery(QueryLanguage ql, String query, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, RDFHandler handler, Binding... bindings) sendGraphQuery(QueryLanguage ql, String query, Dataset dataset, boolean includeInferred, WeakReference<?> callerRef, Binding... bindings) Deprecated.WeakReferenceinvalid input: '<'?voidsendGraphQuery(QueryLanguage ql, String query, Dataset dataset, boolean includeInferred, RDFHandler handler, Binding... bindings) sendTupleQuery(QueryLanguage ql, String query, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, WeakReference<?> callerRef, Binding... bindings) Deprecated.WeakReferenceinvalid input: '<'?voidsendTupleQuery(QueryLanguage ql, String query, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, TupleQueryResultHandler handler, Binding... bindings) sendTupleQuery(QueryLanguage ql, String query, Dataset dataset, boolean includeInferred, WeakReference<?> callerRef, Binding... bindings) Deprecated.WeakReferenceinvalid input: '<'?voidsendUpdate(QueryLanguage ql, String update, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings) voidsendUpdate(QueryLanguage ql, String update, String baseURI, Dataset dataset, boolean includeInferred, Binding... bindings) voidsetAdditionalHttpHeaders(Map<String, String> additionalHttpHeaders) Set additional HTTP headers to be included in every request to the server, which may be required for certain unusual server configurations.voidSets anAuthenticationHandlerthat will be applied to every outgoing request.voidsetHttpClient(RDF4JHttpClient httpClient) Assign anRDF4JHttpClientthat this object should use.voidsetParserConfig(ParserConfig parserConfig) Sets the parser configuration used to process HTTP response data.voidsetPassThroughEnabled(boolean passThroughEnabled) Configure direct pass-through of the endpoint result to the suppliedSink.voidSets the preferred format for encoding boolean query results.voidsetPreferredRDFFormat(RDFFormat format) Sets the preferred format for encoding RDF documents.voidSets the preferred format for encoding tuple query results.protected voidsetQueryURL(String queryURL) protected voidsetUpdateURL(String updateURL) protected voidsetUsernameAndPasswordForUrl(String username, String password, String url) voidsetValueFactory(ValueFactory valueFactory) protected booleanshouldUsePost(String fullQueryUrl) Return whether the provided query should use POST (otherwise use GET)
-
Constructor Details
-
RDF4JProtocolSession
-
-
Method Details
-
setServerURL
-
getServerURL
-
getRepositoryURL
-
setRepository
-
checkRepositoryURL
protected void checkRepositoryURL() -
checkServerURL
protected void checkServerURL() -
getUpdateURL
- Overrides:
getUpdateURLin classSPARQLProtocolSession
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classSPARQLProtocolSession
-
getRepositoryList
public TupleQueryResult getRepositoryList() throws IOException, RepositoryException, UnauthorizedException, QueryInterruptedException -
getRepositoryList
public void getRepositoryList(TupleQueryResultHandler handler) throws IOException, TupleQueryResultHandlerException, RepositoryException, UnauthorizedException, QueryInterruptedException -
getServerProtocol
-
size
public long size(Resource... contexts) throws IOException, RepositoryException, UnauthorizedException -
createRepository
Create a new repository.- Parameters:
config- the repository configuration- Throws:
IOExceptionRepositoryException
-
updateRepository
Update the config of an existing repository.- Parameters:
config- the repository configuration- Throws:
IOExceptionRepositoryException
-
deleteRepository
- Throws:
IOExceptionRepositoryException
-
getRepositoryConfig
public void getRepositoryConfig(StatementCollector statementCollector) throws UnauthorizedException, QueryInterruptedException, RDFHandlerException, RepositoryException, IOException Retrieve configuration of the current repository and send it to the suppliedStatementCollector- Parameters:
statementCollector- receiver of the repository config information- Throws:
IOExceptionRepositoryExceptionRDFHandlerExceptionQueryInterruptedExceptionUnauthorizedException- Since:
- 3.1.0
-
getNamespaces
public TupleQueryResult getNamespaces() throws IOException, RepositoryException, UnauthorizedException, QueryInterruptedException -
getNamespaces
public void getNamespaces(TupleQueryResultHandler handler) throws IOException, TupleQueryResultHandlerException, RepositoryException, UnauthorizedException, QueryInterruptedException -
getNamespace
public String getNamespace(String prefix) throws IOException, RepositoryException, UnauthorizedException -
setNamespacePrefix
public void setNamespacePrefix(String prefix, String name) throws IOException, RepositoryException, UnauthorizedException -
removeNamespacePrefix
public void removeNamespacePrefix(String prefix) throws IOException, RepositoryException, UnauthorizedException -
clearNamespaces
-
getContextIDs
public TupleQueryResult getContextIDs() throws IOException, RepositoryException, UnauthorizedException, QueryInterruptedException -
getContextIDs
public void getContextIDs(TupleQueryResultHandler handler) throws IOException, TupleQueryResultHandlerException, RepositoryException, UnauthorizedException, QueryInterruptedException -
getStatements
public void getStatements(Resource subj, IRI pred, Value obj, boolean includeInferred, RDFHandler handler, Resource... contexts) throws IOException, RDFHandlerException, RepositoryException, UnauthorizedException, QueryInterruptedException -
beginTransaction
public void beginTransaction(IsolationLevel isolationLevel) throws RDF4JException, IOException, UnauthorizedException -
beginTransaction
public void beginTransaction(TransactionSetting... transactionSettings) throws RDF4JException, IOException, UnauthorizedException -
prepareTransaction
-
commitTransaction
-
rollbackTransaction
-
sendTransaction
@Deprecated(since="2.8.0") public void sendTransaction(Iterable<? extends TransactionOperation> txn) throws IOException, RepositoryException, UnauthorizedException Deprecated.since 2.8.0Sends a transaction list as serialized XML to the server.- Parameters:
txn-- Throws:
IOExceptionRepositoryExceptionUnauthorizedException
-
addData
public void addData(InputStream contents, String baseURI, RDFFormat dataFormat, Resource... contexts) throws UnauthorizedException, RDFParseException, RepositoryException, IOException -
removeData
public void removeData(InputStream contents, String baseURI, RDFFormat dataFormat, Resource... contexts) throws UnauthorizedException, RDFParseException, RepositoryException, IOException -
upload
public void upload(InputStream contents, String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Resource... contexts) throws IOException, RDFParseException, RepositoryException, UnauthorizedException -
upload
protected void upload(InputStream contents, String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Protocol.Action action, Resource... contexts) throws IOException, RDFParseException, RepositoryException, UnauthorizedException -
upload
public void upload(Reader contents, String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Resource... contexts) throws UnauthorizedException, RDFParseException, RepositoryException, IOException -
getQueryMethod
protected HttpRequest getQueryMethod(QueryLanguage ql, String query, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings) - Overrides:
getQueryMethodin classSPARQLProtocolSession
-
sendQueryExplanation
public Explanation sendQueryExplanation(QueryLanguage ql, String query, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Explanation.Level level, Binding... bindings) throws IOException, RepositoryException, MalformedQueryException, UnauthorizedException, QueryInterruptedException -
cancelQueryExplanation
public void cancelQueryExplanation(String explainRequestId) throws IOException, RepositoryException, UnauthorizedException -
getUpdateMethod
protected HttpRequest getUpdateMethod(QueryLanguage ql, String update, String baseURI, Dataset dataset, boolean includeInferred, int maxExecutionTime, Binding... bindings) - Overrides:
getUpdateMethodin classSPARQLProtocolSession
-
upload
protected void upload(Reader contents, String baseURI, RDFFormat dataFormat, boolean overwrite, boolean preserveNodeIds, Protocol.Action action, Resource... contexts) throws IOException, RDFParseException, RepositoryException, UnauthorizedException -
upload
protected void upload(HttpRequestBody reqBody, String baseURI, boolean overwrite, boolean preserveNodeIds, Protocol.Action action, Resource... contexts) throws IOException, RDFParseException, RepositoryException, UnauthorizedException -
setUsernameAndPassword
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 List<NameValuePair> getQueryMethodParameters(QueryLanguage ql, String query, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings) - Overrides:
getQueryMethodParametersin classSPARQLProtocolSession
-
getUpdateMethodParameters
protected List<NameValuePair> getUpdateMethodParameters(QueryLanguage ql, String update, String baseURI, Dataset dataset, boolean includeInferred, int maxQueryTime, Binding... bindings) - Overrides:
getUpdateMethodParametersin classSPARQLProtocolSession
-
applyAdditionalHeaders
Applies additional HTTP headers (fromSPARQLProtocolSession.getAdditionalHttpHeaders()) and the authorization header to the supplied request builder.- Parameters:
builder- the request builder to add headers to- Returns:
- the same builder, with headers added
-
SPARQLProtocolSession.DEFAULT_MAXIMUM_URL_LENGTHinstead.