Java Code Examples for org.wso2.carbon.utils.multitenancy.MultitenantUtils#getTenantId()

The following examples show how to use org.wso2.carbon.utils.multitenancy.MultitenantUtils#getTenantId() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeploymentSynchronizerAdmin.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
public void disableSynchronizerForCarbonRepository() throws DeploymentSynchronizerException {

        int tenantId = MultitenantUtils.getTenantId(getConfigContext());
        try {
            DeploymentSynchronizerConfiguration config =
                    CarbonRepositoryUtils.getActiveSynchronizerConfiguration(tenantId);
            if (config == null || !config.isEnabled()) {
                log.warn("Attempted to disable an already disabled deployment synchronizer");
                return;
            }
            config.setEnabled(false);
            CarbonRepositoryUtils.persistConfiguration(config, tenantId);
        } catch (RegistryException e) {
            handleException("Error while persisting the deployment synchronizer configuration", e);
        }

        String filePath = CarbonRepositoryUtils.getCarbonRepositoryFilePath(getConfigContext());
        DeploymentSynchronizer synchronizer =  DeploymentSynchronizationManager.getInstance().
                deleteSynchronizer(filePath);
        if (synchronizer != null) {
            synchronizer.stop();
        }
    }
 
Example 2
Source File: ApplicationManagementUtil.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
public static int getTenantId(ConfigurationContext configurationContext) {
    int tenantId = MultitenantUtils.getTenantId(configurationContext);
    if (log.isDebugEnabled()) {
        log.debug("Returning tenant ID : " + tenantId);
    }
    return tenantId;
}
 
Example 3
Source File: DeploymentSynchronizerAdmin.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
public DeploymentSynchronizerConfiguration getSynchronizerConfigurationForCarbonRepository()
        throws DeploymentSynchronizerException {

    int tenantId = MultitenantUtils.getTenantId(getConfigContext());
    return CarbonRepositoryUtils.getActiveSynchronizerConfiguration(tenantId);
}
 
Example 4
Source File: DeploymentSyncAxis2ConfigurationContextObserver.java    From carbon-commons with Apache License 2.0 4 votes vote down vote up
@Override
public void terminatingConfigurationContext(ConfigurationContext configCtx) {
    int tenantId = MultitenantUtils.getTenantId(configCtx);
    DeploymentSynchronizationManager.getInstance().deleteSynchronizer(tenantId);
}
 
Example 5
Source File: CarbonRepositoryUtils.java    From carbon-commons with Apache License 2.0 2 votes vote down vote up
/**
 * Returns the Carbon/Axis2 repository path for the given ConfigurationContext
 *
 * @param cfgCtx A ConfigurationContext instance owned by super tenant or some other tenant
 * @return Axis2 repository path from which the configuration is read
 */
public static String getCarbonRepositoryFilePath(ConfigurationContext cfgCtx) {
    int tenantId = MultitenantUtils.getTenantId(cfgCtx);
    return MultitenantUtils.getAxis2RepositoryPath(tenantId);
}