Class HTTPRepository
- java.lang.Object
-
- org.eclipse.rdf4j.repository.base.AbstractRepository
-
- org.eclipse.rdf4j.repository.http.HTTPRepository
-
- All Implemented Interfaces:
HttpClientDependent,SessionManagerDependent,Repository
public class HTTPRepository extends AbstractRepository implements HttpClientDependent, SessionManagerDependent
A repository that serves as a client for a remote repository on an RDF4J Server. Methods in this class may throw the specificRepositoryExceptionsubclassUnauthorizedException, the semantics of which is defined by the HTTP protocol.This repository client uses a RDF4J-specific extension of the SPARQL 1.1 Protocol to communicate with the server. For communicating with a SPARQL endpoint that is not based on RDF4J, it is recommended to use
SPARQLRepositoryinstead.- Author:
- Arjohn Kampman, Jeen Broekstra, Herko ter Horst
- See Also:
UnauthorizedException
-
-
Field Summary
-
Fields inherited from class org.eclipse.rdf4j.repository.base.AbstractRepository
logger
-
-
Constructor Summary
Constructors Constructor Description HTTPRepository(String repositoryURL)HTTPRepository(String serverURL, String repositoryID)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected RDF4JProtocolSessioncreateHTTPClient()Creates a newRDF4JProtocolSessionobject.Map<String,String>getAdditionalHttpHeaders()Get the additional HTTP headers which will be usedRepositoryConnectiongetConnection()FilegetDataDir()org.apache.http.client.HttpClientgetHttpClient()HttpClientSessionManagergetHttpClientSessionManager()RDFFormatgetPreferredRDFFormat()Indicates the current preferredRDFFormat.TupleQueryResultFormatgetPreferredTupleQueryResultFormat()Indicates the current preferredTupleQueryResultFormat.StringgetRepositoryURL()org.eclipse.rdf4j.model.ValueFactorygetValueFactory()protected voidinitializeInternal()booleanisWritable()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.voidsetDataDir(File dataDir)voidsetHttpClient(org.apache.http.client.HttpClient httpClient)voidsetHttpClientSessionManager(HttpClientSessionManager client)voidsetPreferredRDFFormat(RDFFormat format)Sets the preferred serialization format for RDF to the suppliedRDFFormat, overriding theSPARQLProtocolSession's default preference.voidsetPreferredTupleQueryResultFormat(TupleQueryResultFormat format)Sets the preferred serialization format for tuple query results to the suppliedTupleQueryResultFormat, overriding theSPARQLProtocolSession's default preference.voidsetUsernameAndPassword(String username, String password)Set the username and password to use for authenticating with the remote repository.protected voidshutDownInternal()-
Methods inherited from class org.eclipse.rdf4j.repository.base.AbstractRepository
init, isInitialized, shutDown
-
-
-
-
Method Detail
-
setDataDir
public void setDataDir(File dataDir)
- Specified by:
setDataDirin interfaceRepository
-
getDataDir
public File getDataDir()
- Specified by:
getDataDirin interfaceRepository
-
getHttpClientSessionManager
public HttpClientSessionManager getHttpClientSessionManager()
- Specified by:
getHttpClientSessionManagerin interfaceSessionManagerDependent
-
setHttpClientSessionManager
public void setHttpClientSessionManager(HttpClientSessionManager client)
- Specified by:
setHttpClientSessionManagerin interfaceSessionManagerDependent
-
getAdditionalHttpHeaders
public Map<String,String> getAdditionalHttpHeaders()
Get the additional HTTP headers which will be used- Returns:
- a read-only view of the additional HTTP headers which will be included in every request to the server.
-
setAdditionalHttpHeaders
public void setAdditionalHttpHeaders(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. This will only take effect on connections subsequently returned bygetConnection().- Parameters:
additionalHttpHeaders- a map containing pairs of header names and values. May be null
-
getHttpClient
public final org.apache.http.client.HttpClient getHttpClient()
- Specified by:
getHttpClientin interfaceHttpClientDependent
-
setHttpClient
public void setHttpClient(org.apache.http.client.HttpClient httpClient)
- Specified by:
setHttpClientin interfaceHttpClientDependent
-
getValueFactory
public org.eclipse.rdf4j.model.ValueFactory getValueFactory()
- Specified by:
getValueFactoryin interfaceRepository
-
getConnection
public RepositoryConnection getConnection() throws RepositoryException
- Specified by:
getConnectionin interfaceRepository- Throws:
RepositoryException
-
isWritable
public boolean isWritable() throws RepositoryException- Specified by:
isWritablein interfaceRepository- Throws:
RepositoryException
-
setPreferredTupleQueryResultFormat
public void setPreferredTupleQueryResultFormat(TupleQueryResultFormat format)
Sets the preferred serialization format for tuple query results to the suppliedTupleQueryResultFormat, overriding theSPARQLProtocolSession's default preference. Setting this parameter is not necessary in most cases as theSPARQLProtocolSessionby default indicates a preference for the most compact and efficient format available.- Parameters:
format- the preferredTupleQueryResultFormat. If set to 'null' no explicit preference will be stated.
-
getPreferredTupleQueryResultFormat
public TupleQueryResultFormat getPreferredTupleQueryResultFormat()
Indicates the current preferredTupleQueryResultFormat.- Returns:
- The preferred format, of 'null' if no explicit preference is defined.
-
setPreferredRDFFormat
public void setPreferredRDFFormat(RDFFormat format)
Sets the preferred serialization format for RDF to the suppliedRDFFormat, overriding theSPARQLProtocolSession's default preference. Setting this parameter is not necessary in most cases as theSPARQLProtocolSessionby default indicates a preference for the most compact and efficient format available.Use with caution: if set to a format that does not support context serialization any context info contained in the query result will be lost.
- Parameters:
format- the preferredRDFFormat. If set to 'null' no explicit preference will be stated.
-
getPreferredRDFFormat
public RDFFormat getPreferredRDFFormat()
Indicates the current preferredRDFFormat.- Returns:
- The preferred format, of 'null' if no explicit preference is defined.
-
setUsernameAndPassword
public void setUsernameAndPassword(String username, String password)
Set the username and password to use for authenticating with the remote repository.- Parameters:
username- the username. Setting this to null will disable authentication.password- the password. Setting this to null will disable authentication.
-
getRepositoryURL
public String getRepositoryURL()
-
initializeInternal
protected void initializeInternal() throws RepositoryException- Specified by:
initializeInternalin classAbstractRepository- Throws:
RepositoryException
-
shutDownInternal
protected void shutDownInternal() throws RepositoryException- Specified by:
shutDownInternalin classAbstractRepository- Throws:
RepositoryException
-
createHTTPClient
protected RDF4JProtocolSession createHTTPClient()
Creates a newRDF4JProtocolSessionobject.- Returns:
- a
RDF4JProtocolSessionobject.
-
-