Class LocalRepositoryManager
- java.lang.Object
-
- org.eclipse.rdf4j.repository.manager.RepositoryManager
-
- org.eclipse.rdf4j.repository.manager.LocalRepositoryManager
-
- All Implemented Interfaces:
HttpClientDependent,RepositoryResolver
- Direct Known Subclasses:
NotifyingLocalRepositoryManager
public class LocalRepositoryManager extends RepositoryManager
An implementation of theRepositoryManagerinterface that operates directly on the repository data files in the local file system.
-
-
Field Summary
Fields Modifier and Type Field Description private java.io.FilebaseDirThe base dir to resolve any relative paths against.private static WriterConfigCFG_CONFIGprivate static java.lang.StringCFG_FILEprivate SharedHttpClientSessionManagerclientdependent life cycleprivate static RDFFormatCONFIG_FORMATstatic java.lang.StringREPOSITORIES_DIRprivate SPARQLServiceResolverserviceResolverdependent life cycle-
Fields inherited from class org.eclipse.rdf4j.repository.manager.RepositoryManager
initializedRepositories, logger, NAMESPACE, PROXIED_ID
-
-
Constructor Summary
Constructors Constructor Description LocalRepositoryManager(java.io.File baseDir)Creates a new RepositoryManager that operates on the specfified base directory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddRepositoryConfig(RepositoryConfig config)Adds or updates the configuration of a repository to the manager.protected RepositorycreateRepository(java.lang.String id)Creates and initializes the repository with the specified ID.private RepositorycreateRepositoryStack(RepositoryImplConfig config)Creates the stack of Repository objects for the repository represented by the specifiedRepositoryImplConfig.java.util.List<RepositoryInfo>getAllRepositoryInfos()Retrieve meta information of all configured repositories.java.io.FilegetBaseDir()Gets the base dir against which to resolve relative paths.protected FederatedServiceResolvergetFederatedServiceResolver()org.apache.http.client.HttpClientgetHttpClient()HttpClientthat has been assigned or has been used by this object.java.net.URLgetLocation()Gets the base dir against which to resolve relative paths.RepositoryConfiggetRepositoryConfig(java.lang.String id)java.io.FilegetRepositoryDir(java.lang.String repositoryID)RepositoryInfogetRepositoryInfo(java.lang.String id)Gets the repository that is known by the specified ID from this manager.protected SharedHttpClientSessionManagergetSesameClient()booleanremoveRepository(java.lang.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.java.io.FileresolvePath(java.lang.String path)Resolves the specified path against the manager's base directory.voidsetHttpClient(org.apache.http.client.HttpClient httpClient)Should be called beforeRepositoryManager.init().voidshutDown()Shuts down all initialized repositories.-
Methods inherited from class org.eclipse.rdf4j.repository.manager.RepositoryManager
getAllRepositories, getAllRepositoryInfos, getAllUserRepositoryInfos, getInitializedRepositories, getInitializedRepository, getInitializedRepositoryIDs, getModelFactory, getNewRepositoryID, getRepository, getRepositoryIDs, hasRepositoryConfig, init, isInitialized, isSafeToRemove, refresh, refreshRepository, removeInitializedRepository, setInitializedRepositories, setModelFactory, updateInitializedRepositories
-
-
-
-
Field Detail
-
REPOSITORIES_DIR
public static final java.lang.String REPOSITORIES_DIR
- See Also:
- Constant Field Values
-
CONFIG_FORMAT
private static final RDFFormat CONFIG_FORMAT
-
CFG_FILE
private static final java.lang.String CFG_FILE
-
CFG_CONFIG
private static final WriterConfig CFG_CONFIG
-
baseDir
private final java.io.File baseDir
The base dir to resolve any relative paths against.
-
client
private volatile SharedHttpClientSessionManager client
dependent life cycle
-
serviceResolver
private volatile SPARQLServiceResolver serviceResolver
dependent life cycle
-
-
Method Detail
-
getBaseDir
public java.io.File getBaseDir()
Gets the base dir against which to resolve relative paths.
-
getLocation
public java.net.URL getLocation() throws java.net.MalformedURLExceptionGets the base dir against which to resolve relative paths.- Specified by:
getLocationin classRepositoryManager- Throws:
java.net.MalformedURLException- If the path cannot be parsed as a URL
-
getSesameClient
protected SharedHttpClientSessionManager getSesameClient()
- Returns:
- Returns the httpClient.
-
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 httpClient)
Description copied from class:RepositoryManagerShould be called beforeRepositoryManager.init().- Specified by:
setHttpClientin interfaceHttpClientDependent- Specified by:
setHttpClientin classRepositoryManager- Parameters:
httpClient- The httpClient to use for remote/service calls.
-
getFederatedServiceResolver
protected FederatedServiceResolver getFederatedServiceResolver()
- Returns:
- Returns the serviceResolver.
-
shutDown
public void shutDown()
Description copied from class:RepositoryManagerShuts down all initialized repositories.- Overrides:
shutDownin classRepositoryManager- See Also:
RepositoryManager.refresh()
-
resolvePath
public java.io.File resolvePath(java.lang.String path)
Resolves the specified path against the manager's base directory.- See Also:
getBaseDir()
-
getRepositoryDir
public java.io.File getRepositoryDir(java.lang.String repositoryID)
-
createRepository
protected Repository createRepository(java.lang.String id) throws RepositoryConfigException, RepositoryException
Description copied from class:RepositoryManagerCreates and initializes the repository with the specified ID.- Specified by:
createRepositoryin classRepositoryManager- 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.
-
createRepositoryStack
private Repository createRepositoryStack(RepositoryImplConfig config) throws RepositoryConfigException
Creates the stack of Repository objects for the repository represented by the specifiedRepositoryImplConfig. Uses aRepositoryFactoryto create the repository and initialize it.- Parameters:
config- The node representing the to-be-created repository in the configuration.- 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.
-
getRepositoryConfig
public RepositoryConfig getRepositoryConfig(java.lang.String id)
- Specified by:
getRepositoryConfigin classRepositoryManager
-
getRepositoryInfo
public RepositoryInfo getRepositoryInfo(java.lang.String id)
Description copied from class:RepositoryManagerGets the repository that is known by the specified ID from this manager.- Overrides:
getRepositoryInfoin classRepositoryManager- Parameters:
id- A repository ID.- Returns:
- A Repository object, or null if no repository was known for the specified ID.
-
getAllRepositoryInfos
public java.util.List<RepositoryInfo> getAllRepositoryInfos() throws RepositoryException
Description copied from class:RepositoryManagerRetrieve meta information of all configured repositories.- Specified by:
getAllRepositoryInfosin classRepositoryManager- Returns:
- a collection of
RepositoryInfoobjects - Throws:
RepositoryException- if the repository meta information could not be retrieved.
-
addRepositoryConfig
public void addRepositoryConfig(RepositoryConfig config) throws RepositoryException, RepositoryConfigException
Description copied from class:RepositoryManagerAdds 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.- Specified by:
addRepositoryConfigin classRepositoryManager- 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.
-
removeRepository
public boolean removeRepository(java.lang.String repositoryID) throws RepositoryException, RepositoryConfigExceptionDescription copied from class:RepositoryManagerRemoves 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!- Overrides:
removeRepositoryin classRepositoryManager- 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.
-
-