Java Code Examples for org.wso2.carbon.core.multitenancy.utils.TenantAxisUtils#getTenantAxisConfiguration()

The following examples show how to use org.wso2.carbon.core.multitenancy.utils.TenantAxisUtils#getTenantAxisConfiguration() . 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: APISynchronizer.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * Method to load the configurations of a tenant
 */
private void loadTenant(String username) {
    String tenantDomain = MultitenantUtils.getTenantDomain(username);
    PrivilegedCarbonContext.startTenantFlow();
    PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true);
    PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username);
    if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
        ConfigurationContext context = ServiceDataHolder.getInstance().getConfigurationContextService()
                .getServerConfigContext();
        TenantAxisUtils.getTenantAxisConfiguration(tenantDomain, context);
        if (log.isDebugEnabled()) {
            log.debug("Tenant was loaded into Carbon Context. Tenant : " + tenantDomain
                    + ", Username : " + username);
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Skipping loading super tenant space since execution is currently in super tenant flow.");
        }
    }
}
 
Example 2
Source File: ServerStartupListener.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
/**
 * Method to load the configurations of a tenant
 */
private static void loadTenant(String username) throws IOException {
    String tenantDomain;
    APIManagerConfiguration config = ServiceDataHolder.getInstance().
            getAPIManagerConfigurationService().getAPIManagerConfiguration();
    tenantDomain = MultitenantUtils.getTenantDomain(username);
    if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
        try {
            PrivilegedCarbonContext.startTenantFlow();
            PrivilegedCarbonContext carbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
            carbonContext.setTenantDomain(tenantDomain);
            carbonContext.setUsername(MultitenantUtils.getTenantAwareUsername(username));
            ConfigurationContext context =
                    ServiceDataHolder.getInstance().getConfigurationContextService().getServerConfigContext();
            // load tenant configuration
            TenantAxisUtils.getTenantAxisConfiguration(tenantDomain, context);
            log.info("Successfully loaded tenant with tenant domain : " + tenantDomain);
        } finally {
            PrivilegedCarbonContext.endTenantFlow();
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Skipping loading super tenant space since execution is currently in super tenant flow.");
        }
    }
}
 
Example 3
Source File: ThrottlingSynchronizer.java    From carbon-apimgt with Apache License 2.0 6 votes vote down vote up
private void loadTenant(String username) {
    String tenantDomain = MultitenantUtils.getTenantDomain(username);
    PrivilegedCarbonContext.startTenantFlow();
    PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(tenantDomain, true);
    PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(username);
    if (!MultitenantConstants.SUPER_TENANT_DOMAIN_NAME.equals(tenantDomain)) {
        ConfigurationContext context = ServiceReferenceHolder.getInstance()
                .getConfigContextService().getServerConfigContext();
        TenantAxisUtils.getTenantAxisConfiguration(tenantDomain, context);
        if (log.isDebugEnabled()) {
            log.debug("Tenant was loaded into Carbon Context. Tenant : " + tenantDomain
                    + ", Username : " + username);
        }
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Skipping loading super tenant space since execution is currently in super tenant flow.");
        }
    }
}
 
Example 4
Source File: WSDL2FormGenerator.java    From carbon-commons with Apache License 2.0 6 votes vote down vote up
private AxisService getAxisService(String url, String serviceContextRoot,
                                   ConfigurationContext configCtx) throws AxisFault {
    String service =
            url.substring(url.indexOf(serviceContextRoot) + serviceContextRoot.length(),
                    url.indexOf("?"));
    AxisConfiguration axisConfig = configCtx.getAxisConfiguration();
    AxisService axisService = axisConfig.getServiceForActivation(service);
    if (axisService == null) {
        // Try to see whether the service is available in a tenant
        axisService = TenantAxisUtils.getAxisService(url, configCtx);
        axisConfig = TenantAxisUtils.getTenantAxisConfiguration(TenantAxisUtils
                .getTenantDomain(url), configCtx);
    }
    if (GhostDeployerUtils.isGhostService(axisService) && axisConfig != null) {
        // if the existing service is a ghost service, deploy the actual one
        axisService = GhostDeployerUtils.deployActualService(axisConfig, axisService);
    }
    return axisService;
}