Class RemoteRepositoryManager
- java.lang.Object
-
- org.eclipse.rdf4j.repository.manager.RepositoryManager
-
- org.eclipse.rdf4j.repository.manager.RemoteRepositoryManager
-
- All Implemented Interfaces:
HttpClientDependent,RepositoryResolver
public class RemoteRepositoryManager extends RepositoryManager
A manager forRepositorys that reside on a remote server. This repository manager allows one to access repositories over HTTP similar to how local repositories are accessed using theLocalRepositoryManager.- Author:
- Arjohn Kampman
-
-
Field Summary
-
Fields inherited from class org.eclipse.rdf4j.repository.manager.RepositoryManager
initializedRepositories, logger, NAMESPACE, PROXIED_ID
-
-
Constructor Summary
Constructors Constructor Description RemoteRepositoryManager(String serverURL)Creates a new RepositoryManager that operates on the specified base directory.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description voidaddRepositoryConfig(RepositoryConfig config)Adds or updates the configuration of a repository to the manager's system repository.protected RepositorycreateRepository(String id)Creates and initializes the repository with the specified ID.protected RepositorycreateSystemRepository()Deprecated.Collection<RepositoryInfo>getAllRepositoryInfos(boolean skipSystemRepo)org.apache.http.client.HttpClientgetHttpClient()HttpClientthat has been assigned or has been used by this object.static RemoteRepositoryManagergetInstance(String serverURL)Creates an initializedRemoteRepositoryManagerwith the specified server URL.static RemoteRepositoryManagergetInstance(String serverURL, String username, String password)Creates an initializedRemoteRepositoryManagerwith the specified server URL and credentials.URLgetLocation()Gets the URL of the remote server, e.g.RepositoryConfiggetRepositoryConfig(String id)StringgetServerURL()Gets the URL of the remote server, e.g.protected SharedHttpClientSessionManagergetSharedHttpClientSessionManager()booleanremoveRepository(String repositoryID)Removes the specified repository by deleting its configuration from the manager's system repository if such a configuration is present, and removing any persistent data associated with the repository.voidsetHttpClient(org.apache.http.client.HttpClient protocolSession)Should be called beforeRepositoryManager.init().voidsetUsernameAndPassword(String username, String password)Set the username and password for authenication with the remote server.voidshutDown()Shuts down all initialized repositories, including the SYSTEM repository.-
Methods inherited from class org.eclipse.rdf4j.repository.manager.RepositoryManager
cleanUpRepository, getAllRepositories, getAllRepositoryInfos, getAllUserRepositoryInfos, getInitializedRepositories, getInitializedRepositoryIDs, getModelFactory, getNewRepositoryID, getRepository, getRepositoryIDs, getRepositoryInfo, getSystemRepository, hasRepositoryConfig, init, initialize, isInitialized, isSafeToRemove, refresh, removeRepositoryConfig, setInitializedRepositories, setModelFactory, updateInitializedRepositories
-
-
-
-
Constructor Detail
-
RemoteRepositoryManager
public RemoteRepositoryManager(String serverURL)
Creates a new RepositoryManager that operates on the specified base directory.- Parameters:
serverURL- The URL of the server.
-
-
Method Detail
-
getInstance
public static RemoteRepositoryManager getInstance(String serverURL) throws RepositoryException
Creates an initializedRemoteRepositoryManagerwith the specified server URL.- Throws:
RepositoryException
-
getInstance
public static RemoteRepositoryManager getInstance(String serverURL, String username, String password) throws RepositoryException
Creates an initializedRemoteRepositoryManagerwith the specified server URL and credentials.- Throws:
RepositoryException
-
getSharedHttpClientSessionManager
protected SharedHttpClientSessionManager getSharedHttpClientSessionManager()
- Returns:
- Returns the
SharedHttpClientSessionManager
-
getHttpClient
public org.apache.http.client.HttpClient getHttpClient()
Description copied from interface:HttpClientDependentHttpClientthat has been assigned or has been used by this object. The life cycle might not be or might be tied to this object, depending on whetherHttpClientwas passed to or created by this object respectively.- Specified by:
getHttpClientin interfaceHttpClientDependent- Specified by:
getHttpClientin classRepositoryManager- Returns:
- Returns the httpClient passed to
Repositoryconstruction.
-
setHttpClient
public void setHttpClient(org.apache.http.client.HttpClient protocolSession)
Description copied from class:RepositoryManagerShould be called beforeRepositoryManager.init().- Specified by:
setHttpClientin interfaceHttpClientDependent- Specified by:
setHttpClientin classRepositoryManager- Parameters:
protocolSession- The httpClient to use for remote/service calls.
-
shutDown
public void shutDown()
Description copied from class:RepositoryManagerShuts down all initialized repositories, including the SYSTEM repository.- Overrides:
shutDownin classRepositoryManager- See Also:
RepositoryManager.refresh()
-
setUsernameAndPassword
public void setUsernameAndPassword(String username, String password)
Set the username and password for authenication with the remote server.- Parameters:
username- the usernamepassword- the password
-
createSystemRepository
@Deprecated protected Repository createSystemRepository() throws RepositoryException
Deprecated.- Overrides:
createSystemRepositoryin classRepositoryManager- Throws:
RepositoryException
-
getLocation
public URL getLocation() throws MalformedURLException
Gets the URL of the remote server, e.g. "http://localhost:8080/rdf4j-server/".- Specified by:
getLocationin classRepositoryManager- Throws:
MalformedURLException- If serverURL cannot be parsed
-
getServerURL
public String getServerURL()
Gets the URL of the remote server, e.g. "http://localhost:8080/rdf4j-server/".
-
createRepository
protected Repository createRepository(String id) throws RepositoryConfigException, RepositoryException
Creates and initializes the repository with the specified ID.- Specified by:
createRepositoryin classRepositoryManager- Parameters:
id- A repository ID.- Returns:
- The created repository, or null if no such repository exists.
- Throws:
RepositoryConfigException- If no repository could be created due to invalid or incomplete configuration data.RepositoryException- If the repository could not be initialized.
-
getRepositoryConfig
public RepositoryConfig getRepositoryConfig(String id) throws RepositoryException
- Overrides:
getRepositoryConfigin classRepositoryManager- Throws:
RepositoryException
-
getAllRepositoryInfos
public Collection<RepositoryInfo> getAllRepositoryInfos(boolean skipSystemRepo) throws RepositoryException
- Specified by:
getAllRepositoryInfosin classRepositoryManager- Throws:
RepositoryException- When not able to retrieve existing configurations
-
addRepositoryConfig
public void addRepositoryConfig(RepositoryConfig config) throws RepositoryException, RepositoryConfigException
Description copied from class:RepositoryManagerAdds or updates the configuration of a repository to the manager's system repository. The system repository may already contain a configuration for a repository with the same ID as specified by config, in which case all previous configuration data for that repository will be cleared before the new configuration is added.- Overrides:
addRepositoryConfigin classRepositoryManager- Parameters:
config- The repository configuration that should be added to or updated in the system repository.- Throws:
RepositoryException- If the manager failed to update it's system repository.RepositoryConfigException- If the manager doesn't know how to update a configuration due to inconsistent configuration data in the system repository. For example, this happens when there are multiple existing configurations with the concerning ID.
-
removeRepository
public boolean removeRepository(String repositoryID) throws RepositoryException, RepositoryConfigException
Description copied from class:RepositoryManagerRemoves the specified repository by deleting its configuration from the manager's system repository if such a configuration is present, and removing any persistent data associated with the repository. Returns true if the system repository actually contained the specified repository configuration. NB this operation can not be undone!- Overrides:
removeRepositoryin classRepositoryManager- Parameters:
repositoryID- The ID of the repository that needs to be removed.- Throws:
RepositoryException- If the manager failed to update its system repository.RepositoryConfigException- If the manager doesn't know how to remove a repository due to inconsistent configuration data in the system repository. For example, this happens when there are multiple existing configurations with the concerning ID.
-
-