Package org.wso2.carbon.deployment.synchronizer.repository

## Class CarbonRepositoryUtils

- java.lang.Object
- - org.wso2.carbon.deployment.synchronizer.repository.CarbonRepositoryUtils

-     public class CarbonRepositoryUtils
      extends Object

  Utility methods for creating and managing DeploymentSynchronizer instances for Carbon repositories

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `CarbonRepositoryUtils()` |

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `static DeploymentSynchronizerConfiguration` | `getActiveSynchronizerConfiguration​(int tenantId)` | Loads the deployment synchronizer configuration.
    `static String` | `getCarbonRepositoryFilePath​(org.apache.axis2.context.ConfigurationContext cfgCtx)` | Returns the Carbon/Axis2 repository path for the given ConfigurationContext
    `static DeploymentSynchronizerConfiguration` | `getDefaultDeploymentSyncConfiguration()` |
    `static DeploymentSynchronizerConfiguration` | `getDeploymentSyncConfigurationFromConf()` | Load the deployment synchronizer configuration from the global ServerConfiguration of Carbon.
    `static DeploymentSynchronizerConfiguration` | `getDeploymentSyncConfigurationFromRegistry​(int tenantId)` | Loads the deployment synchronizer configuration from the configuration registry of the specified tenant.
    `static boolean` | `isSynchronizerEnabled​(int tenantId)` | Checks whether deployment synchronizer is enabled for the Carbon repository of the specified tenant.
    `static DeploymentSynchronizer` | `newCarbonRepositorySynchronizer​(int tenantId)` | Create and initialize a new DeploymentSynchronizer for the Carbon repository of the specified tenant.
    `static void` | `persistConfiguration​(DeploymentSynchronizerConfiguration config, int tenantId)` | Save the given DeploymentSynchronizerConfiguration to the registry.

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

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

- - ### Constructor Detail

    - #### CarbonRepositoryUtils

          public CarbonRepositoryUtils()

  - ### Method Detail

    - #### newCarbonRepositorySynchronizer

          public static DeploymentSynchronizer newCarbonRepositorySynchronizer​(int tenantId)
                                                                        throws DeploymentSynchronizerException

      Create and initialize a new DeploymentSynchronizer for the Carbon repository of the specified tenant. This method first attempts to load the synchronizer configuration from the registry. If a configuration does not exist in the registry, it will get the configuration from the global ServerConfiguration of Carbon. Note that this method does not start the created synchronizers. It only creates and initializes them using the available configuration settings.
      Parameters:
        `tenantId` - ID of the tenant
      Returns:
        a DeploymentSynchronizer instance or null if the synchronizer is disabled
      Throws:
        `DeploymentSynchronizerException` - If an error occurs while initializing the synchronizer

    - #### getActiveSynchronizerConfiguration

          public static DeploymentSynchronizerConfiguration getActiveSynchronizerConfiguration​(int tenantId)
                                                                                        throws DeploymentSynchronizerException

      Loads the deployment synchronizer configuration. It will attempt to get the configuration from the registry of the tenant. Failing that, it will get the configuration from the ServerConfiguration.
      Parameters:
        `tenantId` - Tenant ID
      Returns:
        a DeploymentSynchronizerConfiguration instance
      Throws:
        `DeploymentSynchronizerException` - if an error occurs while accessing the registry

    - #### getDeploymentSyncConfigurationFromConf

          public static DeploymentSynchronizerConfiguration getDeploymentSyncConfigurationFromConf()
                                                                                            throws DeploymentSynchronizerException

      Load the deployment synchronizer configuration from the global ServerConfiguration of Carbon.
      Returns:
        a DeploymentSynchronizerConfiguration instance
      Throws:
        `DeploymentSynchronizerException` - on error

    - #### getDefaultDeploymentSyncConfiguration

          public static DeploymentSynchronizerConfiguration getDefaultDeploymentSyncConfiguration()
                                                                                           throws DeploymentSynchronizerException

      Throws:
        `DeploymentSynchronizerException`

    - #### getCarbonRepositoryFilePath

          public static String getCarbonRepositoryFilePath​(org.apache.axis2.context.ConfigurationContext cfgCtx)

      Returns the Carbon/Axis2 repository path for the given ConfigurationContext
      Parameters:
        `cfgCtx` - A ConfigurationContext instance owned by super tenant or some other tenant
      Returns:
        Axis2 repository path from which the configuration is read

    - #### isSynchronizerEnabled

          public static boolean isSynchronizerEnabled​(int tenantId)
                                               throws DeploymentSynchronizerException

      Checks whether deployment synchronizer is enabled for the Carbon repository of the specified tenant. This method first checks whether a synchronizer configuration exists in the registry (created by an admin service). If not it will try to get the configuration from the Carbon ServerConfiguration.
      Parameters:
        `tenantId` - Tenant ID
      Returns:
        true if deployment synchronizer is enabled for the repository
      Throws:
        `DeploymentSynchronizerException` - if an error occurs while loading configuration from the registry

    - #### getDeploymentSyncConfigurationFromRegistry

          public static DeploymentSynchronizerConfiguration getDeploymentSyncConfigurationFromRegistry​(int tenantId)
                                                                                                throws org.wso2.carbon.registry.core.exceptions.RegistryException

      Loads the deployment synchronizer configuration from the configuration registry of the specified tenant.
      Parameters:
        `tenantId` - Tenant ID
      Returns:
        a DeploymentSynchronizerConfiguration object or null
      Throws:
        `org.wso2.carbon.registry.core.exceptions.RegistryException` - if the registry cannot be accessed

    - #### persistConfiguration

          public static void persistConfiguration​(DeploymentSynchronizerConfiguration config,
                                                  int tenantId)
                                           throws org.wso2.carbon.registry.core.exceptions.RegistryException

      Save the given DeploymentSynchronizerConfiguration to the registry. The target configuration registry space will be selected using the specified tenant ID. As a result the configuration will be stored in the configuration registry of the specified tenant.
      Parameters:
        `config` - The configuration to be saved
        `tenantId` - Tenant ID to select the configuration registry
      Throws:
        `org.wso2.carbon.registry.core.exceptions.RegistryException` - if an error occurs while accessing the registry