org.eclipse.rdf4j.repository.manager

## 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 `Repository`s.
  Author:
    Arjohn Kampman
  See Also:
    `RepositoryProvider`

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected Map<String,Repository>` | `initializedRepositories`
    `protected org.slf4j.Logger` | `logger`
    `static String` | `NAMESPACE` The `ProxyRepository` schema namespace ( `http://www.openrdf.org/config/repository/proxy#`).
    `static IRI` | `PROXIED_ID` `http://www.openrdf.org/config/repository/proxy#proxiedID`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `RepositoryManager()` Creates a new RepositoryManager.
    `protected` | `RepositoryManager(Map<String,Repository> initializedRepositories)` Create a new RepositoryManager using the given map to store repository information.

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods
    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 void` | `cleanUpRepository(String repositoryID)` Deprecated.
    `protected abstract Repository` | `createRepository(String id)` Creates and initializes the repository with the specified ID.
    `protected Repository` | `createSystemRepository()` Deprecated.
    `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.
    `ModelFactory` | `getModelFactory()` Get the `ModelFactory` used for creating new `Model` objects in the manager.
    `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()`
    `RepositoryInfo` | `getRepositoryInfo(String id)` Gets the repository that is known by the specified ID from this manager.
    `Repository` | `getSystemRepository()` Deprecated. Repository configuration is no longer stored in a centralized system repository, instead using a file `config.ttl` per repository, stored in that repository's datadir.
    `boolean` | `hasRepositoryConfig(String repositoryID)`
    `void` | `init()` Initializes the repository manager.
    `void` | `initialize()` Deprecated. since 2.0. Use `init()` instead.
    `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.0. Use `removeRepository(String repositoryID)` instead.
    `abstract void` | `setHttpClient(org.apache.http.client.HttpClient httpClient)` Should be called before `init()`.
    `protected void` | `setInitializedRepositories(Map<String,Repository> nextInitializedRepositories)`
    `void` | `setModelFactory(ModelFactory modelFactory)` Set the `ModelFactory` to use for creating new `Model` objects in the manager.
    `void` | `shutDown()` Shuts down all initialized repositories, including the SYSTEM repository.
    `protected void` | `updateInitializedRepositories()`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### logger

          protected final org.slf4j.Logger logger

    - #### NAMESPACE

          public static final String NAMESPACE

      The `ProxyRepository` schema namespace ( `http://www.openrdf.org/config/repository/proxy#`).
      See Also:
        Constant Field Values

    - #### PROXIED_ID

          public static final IRI PROXIED_ID

      `http://www.openrdf.org/config/repository/proxy#proxiedID`

    - #### initializedRepositories

          protected Map<String,Repository> initializedRepositories

  - ### Constructor Detail

    - #### RepositoryManager

          protected RepositoryManager()

      Creates a new RepositoryManager.

    - #### RepositoryManager

          protected RepositoryManager(Map<String,Repository> initializedRepositories)

      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 Detail

    - #### 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: `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.
      Specified by:
        `getHttpClient` in interface `HttpClientDependent`
      Returns:
        Returns the httpClient passed to `Repository` construction.

    - #### setHttpClient

          public abstract void setHttpClient(org.apache.http.client.HttpClient httpClient)

      Should be called before `init()`.
      Specified by:
        `setHttpClient` in interface `HttpClientDependent`
      Parameters:
        `httpClient` - The httpClient to use for remote/service calls.

    - #### getModelFactory

          public ModelFactory getModelFactory()

      Get the `ModelFactory` used for creating new `Model` objects in the manager.
      Returns:
        the modelFactory
      Since:
        3.0

    - #### setModelFactory

          public void setModelFactory(ModelFactory modelFactory)

      Set the `ModelFactory` to use for creating new `Model` objects in the manager.
      Parameters:
        `modelFactory` - the modelFactory to set. May not be `null`.
      Since:
        3.0

    - #### initialize

          @Deprecated
          public void initialize()
                                      throws RepositoryException

      Deprecated. since 2.0. Use `init()` instead.
      Initializes the repository manager.
      Throws:
        `RepositoryException` - If the manager failed to initialize

    - #### init

          public void init()
                    throws RepositoryException

      Initializes the repository manager.
      Throws:
        `RepositoryException` - If the manager failed to initialize.
      Since:
        2.5

    - #### createSystemRepository

          @Deprecated
          protected Repository createSystemRepository()
                                                           throws RepositoryException

      Deprecated.
      Throws:
        `RepositoryException`

    - #### getSystemRepository

          @Deprecated
          public Repository getSystemRepository()

      Deprecated. Repository configuration is no longer stored in a centralized system repository, instead using a file `config.ttl` per repository, stored in that repository's datadir.
      Gets the SYSTEM repository.

    - #### 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:
        `RepositoryException`
        `RepositoryConfigException`

    - #### getRepositoryIDs

          public Set<String> getRepositoryIDs()
                                       throws RepositoryException

      Throws:
        `RepositoryException`

    - #### hasRepositoryConfig

          public boolean hasRepositoryConfig(String repositoryID)
                                      throws RepositoryException,
                                             RepositoryConfigException

      Throws:
        `RepositoryException`
        `RepositoryConfigException`

    - #### getRepositoryConfig

          public RepositoryConfig getRepositoryConfig(String repositoryID)
                                               throws RepositoryConfigException,
                                                      RepositoryException

      Throws:
        `RepositoryConfigException`
        `RepositoryException`

    - #### addRepositoryConfig

          public void addRepositoryConfig(RepositoryConfig config)
                                   throws RepositoryException,
                                          RepositoryConfigException

      Adds 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.
      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.

    - #### removeRepositoryConfig

          @Deprecated
          public boolean removeRepositoryConfig(String repositoryID)
                                                     throws RepositoryException,
                                                            RepositoryConfigException

      Deprecated. since 2.0. Use `removeRepository(String repositoryID)` instead.
      Removes the configuration for the specified repository from the manager's system repository if such a configuration is present. Returns `true` if the system repository actually contained the specified repository configuration.
      Parameters:
        `repositoryID` - The ID of the repository whose configuration needs to be removed.
      Throws:
        `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.

    - #### isSafeToRemove

          public boolean isSafeToRemove(String repositoryID)
                                 throws RepositoryException

      Checks on whether the given repository is referred to by a `ProxyRepository` configuration.
      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 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!
      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.

    - #### getRepository

          public Repository getRepository(String identity)
                                   throws RepositoryConfigException,
                                          RepositoryException

      Gets the repository that is known by the specified ID from this manager.
      Specified by:
        `getRepository` in interface `RepositoryResolver`
      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

          public Set<String> 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:
        `getRepositoryIDs()`

    - #### getInitializedRepositories

          public Collection<Repository> 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:
        `getAllRepositories()`

    - #### setInitializedRepositories

          protected void setInitializedRepositories(Map<String,Repository> nextInitializedRepositories)

    - #### updateInitializedRepositories

          protected void updateInitializedRepositories()

    - #### getAllRepositories

          public Collection<Repository> getAllRepositories()
                                                    throws RepositoryConfigException,
                                                           RepositoryException

      Returns all configured repositories. This may be an expensive operation as it initializes repositories that have not been initialized yet.
      Returns:
        The Set of all Repositories defined in the SystemRepository.
      Throws:
        `RepositoryConfigException`
        `RepositoryException`
      See Also:
        `getInitializedRepositories()`

    - #### 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

          public RepositoryInfo getRepositoryInfo(String id)
                                           throws RepositoryException

      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

          public Collection<RepositoryInfo> getAllRepositoryInfos()
                                                           throws RepositoryException

      Throws:
        `RepositoryException`

    - #### getAllUserRepositoryInfos

          public Collection<RepositoryInfo> getAllUserRepositoryInfos()
                                                               throws RepositoryException

      Throws:
        `RepositoryException`

    - #### getAllRepositoryInfos

          public abstract Collection<RepositoryInfo> getAllRepositoryInfos(boolean skipSystemRepo)
                                                                    throws RepositoryException

      Parameters:
        `skipSystemRepo` -
      Throws:
        `RepositoryException` - When not able to retrieve existing configurations

    - #### refresh

          public void refresh()

      Shuts down all initialized user repositories.
      See Also:
        `shutDown()`

    - #### shutDown

          public void shutDown()

      Shuts down all initialized repositories, including the SYSTEM repository.
      See Also:
        `refresh()`

    - #### cleanUpRepository

          @Deprecated
          protected void cleanUpRepository(String repositoryID)
                                                throws IOException

      Deprecated.
      Clean up a removed repository. Note that the configuration for this repository is no longer present in the system repository.
      Parameters:
        `repositoryID` - the ID of the repository to clean up
      Throws:
        `IOException`

    - #### getLocation

          public abstract URL getLocation()
                                   throws MalformedURLException

      Gets the URL of the server or directory.
      Throws:
        `MalformedURLException` - If the location cannot be represented as a URL.

Copyright © 2015-2022 Eclipse Foundation. All Rights Reserved.