Class RepositoryManager
java.lang.Object
org.eclipse.rdf4j.repository.manager.RepositoryManager
- All Implemented Interfaces:
HttpClientDependent,RepositoryResolver
- Direct Known Subclasses:
LocalRepositoryManager,RemoteRepositoryManager,TypeFilteringRepositoryManager
public abstract class RepositoryManager
extends Object
implements RepositoryResolver, HttpClientDependent
A manager for
Repositorys.- Author:
- Arjohn Kampman
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Map<String,Repository> protected final org.slf4j.Loggerstatic final StringDeprecated.static final IRIDeprecated, for removal: This API element is subject to removal in a future version.useCONFIG.Proxy.proxiedIDinstead. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new RepositoryManager.protectedRepositoryManager(Map<String, Repository> initializedRepositories) Create a new RepositoryManager using the given map to store repository information. -
Method Summary
Modifier and TypeMethodDescriptionabstract voidaddRepositoryConfig(RepositoryConfig config) Adds or updates the configuration of a repository to the manager.protected abstract RepositoryCreates and initializes the repository with the specified ID.Returns all configured repositories.abstract Collection<RepositoryInfo>Retrieve meta information of all configured repositories.getAllRepositoryInfos(boolean skipSystemRepo) Deprecated.UsegetAllRepositoryInfos()instead.Deprecated.UsegetAllRepositoryInfos()instead.abstract org.apache.http.client.HttpClientHttpClientthat has been assigned or has been used by this object.Returns all initialized repositories.Returns all initialized repositories.abstract URLGets the URL of the server or directory.Get theModelFactoryused for creating newModelobjects in the manager.getNewRepositoryID(String baseName) Generates an ID for a new repository based on the specified base name.getRepository(String identity) Gets the repository that is known by the specified ID from this manager.abstract RepositoryConfiggetRepositoryConfig(String repositoryID) Get the IDs of all available repositories.Gets the repository that is known by the specified ID from this manager.booleanhasRepositoryConfig(String repositoryID) voidinit()Initializes the repository manager.booleanIndicates if this RepositoryManager has been initialized.booleanisSafeToRemove(String repositoryID) Checks on whether the given repository is referred to by aProxyRepositoryconfiguration.voidrefresh()Shuts down all initialized user repositories.booleanremoveRepository(String repositoryID) Removes the specified repository by deleting its configuration if such a configuration is present, and removing any persistent data associated with the repository.abstract voidsetHttpClient(org.apache.http.client.HttpClient httpClient) Should be called beforeinit().protected voidsetInitializedRepositories(Map<String, Repository> nextInitializedRepositories) voidsetModelFactory(ModelFactory modelFactory) Set theModelFactoryto use for creating newModelobjects in the manager.voidshutDown()Shuts down all initialized repositories.protected void
-
Field Details
-
logger
protected final org.slf4j.Logger logger -
NAMESPACE
Deprecated.useCONFIG.Proxyinstead.TheProxyRepositoryschema namespace ( http://www.openrdf.org/config/repository/proxy#).- See Also:
-
PROXIED_ID
Deprecated, for removal: This API element is subject to removal in a future version.useCONFIG.Proxy.proxiedIDinstead.http://www.openrdf.org/config/repository/proxy#proxiedID -
initializedRepositories
-
-
Constructor Details
-
RepositoryManager
protected RepositoryManager()Creates a new RepositoryManager. -
RepositoryManager
Create a new RepositoryManager using the given map to store repository information.- Parameters:
initializedRepositories- A map that will be used to store repository information.
-
-
Method Details
-
isInitialized
public boolean isInitialized()Indicates if this RepositoryManager has been initialized. Note that the initialization status may change if the Repository is shut down.- Returns:
- true iff the repository manager has been initialized.
-
getHttpClient
public abstract 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- Returns:
- Returns the httpClient passed to
Repositoryconstruction.
-
setHttpClient
public abstract void setHttpClient(org.apache.http.client.HttpClient httpClient) Should be called beforeinit().- Specified by:
setHttpClientin interfaceHttpClientDependent- Parameters:
httpClient- The httpClient to use for remote/service calls.
-
getModelFactory
Get theModelFactoryused for creating newModelobjects in the manager.- Returns:
- the modelFactory
- Since:
- 3.0
-
setModelFactory
Set theModelFactoryto use for creating newModelobjects in the manager.- Parameters:
modelFactory- the modelFactory to set. May not benull.- Since:
- 3.0
-
init
Initializes the repository manager.- Throws:
RepositoryException- If the manager failed to initialize.- Since:
- 2.5
-
getNewRepositoryID
public String getNewRepositoryID(String baseName) throws RepositoryException, RepositoryConfigException Generates an ID for a new repository based on the specified base name. The base name may for example be a repository name entered by the user. The generated ID will contain a variant of this name that does not occur as a repository ID in this manager yet and is suitable for use as a file name (e.g. for the repository's data directory).- Parameters:
baseName- The String on which the returned ID should be based, must not be null.- Returns:
- A new repository ID derived from the specified base name.
- Throws:
RepositoryExceptionRepositoryConfigException
-
getRepositoryIDs
Get the IDs of all available repositories. Note that this is potentially slow as it may initialize all available repository configurations.- Returns:
- a list of repository ID strings.
- Throws:
RepositoryException
-
hasRepositoryConfig
public boolean hasRepositoryConfig(String repositoryID) throws RepositoryException, RepositoryConfigException -
getRepositoryConfig
public abstract RepositoryConfig getRepositoryConfig(String repositoryID) throws RepositoryConfigException, RepositoryException -
addRepositoryConfig
public abstract void addRepositoryConfig(RepositoryConfig config) throws RepositoryException, RepositoryConfigException Adds or updates the configuration of a repository to the manager. The manager 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.- Parameters:
config- The repository configuration that should be added to or updated in the manager.- Throws:
RepositoryException- If the manager failed to update.RepositoryConfigException- If the manager doesn't know how to update a configuration due to inconsistent configuration data. For example, this happens when there are multiple existing configurations with the concerning ID.
-
isSafeToRemove
Checks on whether the given repository is referred to by aProxyRepositoryconfiguration.- Parameters:
repositoryID- id to check- Returns:
- true if there is no existing proxy reference to the given id, false otherwise
- Throws:
RepositoryException
-
removeRepository
public boolean removeRepository(String repositoryID) throws RepositoryException, RepositoryConfigException Removes the specified repository by deleting its configuration if such a configuration is present, and removing any persistent data associated with the repository. Returns true if the specified repository configuration was actually present. NB this operation can not be undone!- Parameters:
repositoryID- The ID of the repository that needs to be removed.- Throws:
RepositoryException- If the manager failed to update the configuration.RepositoryConfigException- If the manager doesn't know how to remove a repository due to inconsistent configuration data. For example, this can happen when there are multiple existing configurations with the concerning ID.
-
getRepository
public Repository getRepository(String identity) throws RepositoryConfigException, RepositoryException Gets the repository that is known by the specified ID from this manager.- Specified by:
getRepositoryin interfaceRepositoryResolver- Parameters:
identity- A repository ID.- Returns:
- An initialized Repository object, or null if no repository was known for the specified ID.
- Throws:
RepositoryConfigException- If no repository could be created due to invalid or incomplete configuration data.RepositoryException
-
getInitializedRepositoryIDs
Returns all initialized repositories. This method returns fast as no lazy creation of repositories takes place.- Returns:
- a collection containing the IDs of all initialized repositories.
- See Also:
-
getInitializedRepositories
Returns all initialized repositories. This method returns fast as no lazy creation of repositories takes place.- Returns:
- a set containing the initialized repositories.
- See Also:
-
setInitializedRepositories
-
updateInitializedRepositories
protected void updateInitializedRepositories() -
getAllRepositories
public Collection<Repository> getAllRepositories() throws RepositoryConfigException, RepositoryExceptionReturns all configured repositories. This may be an expensive operation as it initializes repositories that have not been initialized yet.- Returns:
- The Set of all configured Repositories.
- Throws:
RepositoryConfigExceptionRepositoryException- See Also:
-
createRepository
protected abstract Repository createRepository(String id) throws RepositoryConfigException, RepositoryException Creates and initializes the repository with the specified ID.- Parameters:
id- A repository ID.- Returns:
- The created and initialized 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.
-
getRepositoryInfo
Gets the repository that is known by the specified ID from this manager.- Parameters:
id- A repository ID.- Returns:
- A Repository object, or null if no repository was known for the specified ID.
- Throws:
RepositoryException- When not able to retrieve existing configurations
-
getAllRepositoryInfos
Retrieve meta information of all configured repositories.- Returns:
- a collection of
RepositoryInfoobjects - Throws:
RepositoryException- if the repository meta information could not be retrieved.
-
getAllUserRepositoryInfos
@Deprecated(since="4.0") public Collection<RepositoryInfo> getAllUserRepositoryInfos() throws RepositoryExceptionDeprecated.UsegetAllRepositoryInfos()instead.- Throws:
RepositoryException
-
getAllRepositoryInfos
@Deprecated(since="4.0") public Collection<RepositoryInfo> getAllRepositoryInfos(boolean skipSystemRepo) throws RepositoryException Deprecated.UsegetAllRepositoryInfos()instead.- Throws:
RepositoryException
-
refresh
public void refresh()Shuts down all initialized user repositories.- See Also:
-
shutDown
public void shutDown()Shuts down all initialized repositories.- See Also:
-
getLocation
Gets the URL of the server or directory.- Throws:
MalformedURLException- If the location cannot be represented as a URL.
-
CONFIG.Proxyinstead.