public abstract class RepositoryManager extends Object implements RepositoryResolver, HttpClientDependent
Repository
s. Every RepositoryManager has one
SYSTEM repository and zero or more "user repositories". The SYSTEM repository
contains data that describes the configuration of the other repositories
(their IDs, which implementations of the Repository API to use, access
rights, etc.). The other repositories are instantiated based on this
configuration data.RepositoryProvider
Modifier and Type | Field and Description |
---|---|
protected Map<String,Repository> |
initializedRepositories |
protected org.slf4j.Logger |
logger |
Constructor and Description |
---|
RepositoryManager()
Creates a new RepositoryManager.
|
RepositoryManager(Map<String,Repository> initializedRepositories)
Create a new RepositoryManager using the given map to store repository
information.
|
Modifier and Type | Method and Description |
---|---|
void |
addRepositoryConfig(RepositoryConfig config)
Adds or updates the configuration of a repository to the manager's system
repository.
|
protected abstract void |
cleanUpRepository(String repositoryID)
Clean up a removed repository.
|
protected abstract Repository |
createRepository(String id)
Creates and initializes the repository with the specified ID.
|
protected abstract Repository |
createSystemRepository() |
Collection<Repository> |
getAllRepositories()
Returns all configured repositories.
|
Collection<RepositoryInfo> |
getAllRepositoryInfos() |
abstract Collection<RepositoryInfo> |
getAllRepositoryInfos(boolean skipSystemRepo) |
Collection<RepositoryInfo> |
getAllUserRepositoryInfos() |
abstract org.apache.http.client.HttpClient |
getHttpClient()
HttpClient that has been assigned or has been used by this object. |
Collection<Repository> |
getInitializedRepositories()
Returns all initialized repositories.
|
Set<String> |
getInitializedRepositoryIDs()
Returns all initialized repositories.
|
abstract URL |
getLocation()
Gets the URL of the server or directory.
|
String |
getNewRepositoryID(String baseName)
Generates an ID for a new repository based on the specified base name.
|
Repository |
getRepository(String identity)
Gets the repository that is known by the specified ID from this manager.
|
RepositoryConfig |
getRepositoryConfig(String repositoryID) |
Set<String> |
getRepositoryIDs() |
abstract RepositoryInfo |
getRepositoryInfo(String id)
Gets the repository that is known by the specified ID from this manager.
|
Repository |
getSystemRepository()
Gets the SYSTEM repository.
|
boolean |
hasRepositoryConfig(String repositoryID) |
void |
initialize()
Initializes the repository manager.
|
boolean |
isInitialized()
Indicates if this RepositoryManager has been initialized.
|
boolean |
isSafeToRemove(String repositoryID)
Checks on whether the given repository is referred to by a
ProxyRepository configuration. |
void |
refresh()
Shuts down all initialized user repositories.
|
boolean |
removeRepository(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.
|
boolean |
removeRepositoryConfig(String repositoryID)
Deprecated.
since 2.6.7. Use
removeRepository(String repositoryID)
instead. |
abstract void |
setHttpClient(org.apache.http.client.HttpClient httpClient)
Should be called before
initialize() . |
protected void |
setInitializedRepositories(Map<String,Repository> nextInitializedRepositories) |
void |
shutDown()
Shuts down all initialized repositories, including the SYSTEM repository.
|
protected void |
updateInitializedRepositories() |
protected final org.slf4j.Logger logger
protected Map<String,Repository> initializedRepositories
public RepositoryManager()
public RepositoryManager(Map<String,Repository> initializedRepositories)
initializedRepositories
- A map that will be used to store repository information.public boolean isInitialized()
public abstract org.apache.http.client.HttpClient getHttpClient()
HttpClientDependent
HttpClient
that 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
whether HttpClient
was passed to or created by this object
respectively.getHttpClient
in interface HttpClientDependent
Repository
construction.public abstract void setHttpClient(org.apache.http.client.HttpClient httpClient)
initialize()
.setHttpClient
in interface HttpClientDependent
httpClient
- The httpClient to use for remote/service calls.public void initialize() throws RepositoryException
RepositoryException
- If the manager failed to initialize the SYSTEM repository.protected abstract Repository createSystemRepository() throws RepositoryException
RepositoryException
public Repository getSystemRepository()
public String getNewRepositoryID(String baseName) throws RepositoryException, RepositoryConfigException
baseName
- The String on which the returned ID should be based, must not be
null.RepositoryException
RepositoryConfigException
public Set<String> getRepositoryIDs() throws RepositoryException
RepositoryException
public boolean hasRepositoryConfig(String repositoryID) throws RepositoryException, RepositoryConfigException
public RepositoryConfig getRepositoryConfig(String repositoryID) throws RepositoryConfigException, RepositoryException
public void addRepositoryConfig(RepositoryConfig config) throws RepositoryException, RepositoryConfigException
config
- The repository configuration that should be added to or updated in
the system repository.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.@Deprecated public boolean removeRepositoryConfig(String repositoryID) throws RepositoryException, RepositoryConfigException
removeRepository(String repositoryID)
instead.repositoryID
- The ID of the repository whose configuration needs to be removed.RepositoryException
- If the manager failed to update it's system repository.RepositoryConfigException
- If the manager doesn't know how to remove 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.public boolean isSafeToRemove(String repositoryID) throws RepositoryException
ProxyRepository
configuration.repositoryID
- id to checkRepositoryException
public boolean removeRepository(String repositoryID) throws RepositoryException, RepositoryConfigException
repositoryID
- The ID of the repository that needs to be removed.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.public Repository getRepository(String identity) throws RepositoryConfigException, RepositoryException
getRepository
in interface RepositoryResolver
identity
- A repository ID.RepositoryConfigException
- If no repository could be created due to invalid or incomplete
configuration data.RepositoryException
public Set<String> getInitializedRepositoryIDs()
getRepositoryIDs()
public Collection<Repository> getInitializedRepositories()
getAllRepositories()
protected void setInitializedRepositories(Map<String,Repository> nextInitializedRepositories)
protected void updateInitializedRepositories()
public Collection<Repository> getAllRepositories() throws RepositoryConfigException, RepositoryException
RepositoryConfigException
RepositoryException
getInitializedRepositories()
protected abstract Repository createRepository(String id) throws RepositoryConfigException, RepositoryException
id
- A repository ID.RepositoryConfigException
- If no repository could be created due to invalid or incomplete
configuration data.RepositoryException
- If the repository could not be initialized.public abstract RepositoryInfo getRepositoryInfo(String id) throws RepositoryException
id
- A repository ID.RepositoryException
- When not able to retrieve existing configurationspublic Collection<RepositoryInfo> getAllRepositoryInfos() throws RepositoryException
RepositoryException
public Collection<RepositoryInfo> getAllUserRepositoryInfos() throws RepositoryException
RepositoryException
public abstract Collection<RepositoryInfo> getAllRepositoryInfos(boolean skipSystemRepo) throws RepositoryException
skipSystemRepo
- RepositoryException
- When not able to retrieve existing configurationspublic void refresh()
shutDown()
public void shutDown()
refresh()
protected abstract void cleanUpRepository(String repositoryID) throws IOException
repositoryID
- the ID of the repository to clean upIOException
public abstract URL getLocation() throws MalformedURLException
MalformedURLException
- If the location cannot be represented as a URL.Copyright © 2001-2016 Aduna. All Rights Reserved.