Source:
public void deleteTenant(String tenantDomain) throws StratosException, org.wso2.carbon.user.api.UserStoreException { TenantManager tenantManager = TenantMgtServiceComponent.getTenantManager(); if (tenantManager != null) { int tenantId = tenantManager.getTenantId(tenantDomain); try { log.debug(String.format("Starting tenant deletion for domain: %s and tenant id: %d from the system", tenantDomain, tenantId)); ServerConfigurationService serverConfigurationService = TenantMgtServiceComponent.getServerConfigurationService(); if (Boolean.parseBoolean(serverConfigurationService.getFirstProperty("Tenant.TenantDelete"))) { if (Boolean.parseBoolean(serverConfigurationService.getFirstProperty("Tenant.ListenerInvocationPolicy.InvokeOnDelete"))) { notifyTenantDeletion(tenantId); } else { log.debug("Tenant.ListenerInvocationPolicy.InvokeOnDelete flag is not set to true in carbon.xml. Listener invocation ignored."); } TenantMgtUtil.deleteWorkernodesTenant(tenantId); if (TenantMgtServiceComponent.getBillingService() != null) { TenantMgtServiceComponent.getBillingService().deleteBillingData(tenantId); } TenantMgtUtil.unloadTenantConfigurations(tenantDomain, tenantId); TenantMgtUtil.deleteTenantRegistryData(tenantId); tenantManager.deleteTenant(tenantId); log.info(String.format("Deleted tenant with domain: %s and tenant id: %d from the system.", tenantDomain, tenantId)); } else { log.debug("Tenant.TenantDelete flag is not set to true in carbon.xml. Tenant will not be deleted."); } } catch (Exception e) { String msg = String.format("Deleted tenant with domain: %s and tenant id: %d from the system.", tenantDomain, tenantId); log.error(msg, e); throw new StratosException(msg, e); } } }

Target:
public void deleteTenant(String tenantDomain) throws StratosException, org.wso2.carbon.user.api.UserStoreException { TenantManager tenantManager = TenantMgtServiceComponent.getTenantManager(); if (tenantManager != null) { int tenantId = tenantManager.getTenantId(tenantDomain); try { if (log.isDebugEnabled()) { log.debug(String.format("Starting tenant deletion for domain: %s and tenant id: %d from the system", tenantDomain, tenantId)); } ServerConfigurationService serverConfigurationService = TenantMgtServiceComponent.getServerConfigurationService(); if (Boolean.parseBoolean(serverConfigurationService.getFirstProperty("Tenant.TenantDelete"))) { if (Boolean.parseBoolean(serverConfigurationService.getFirstProperty("Tenant.ListenerInvocationPolicy.InvokeOnDelete"))) { notifyTenantDeletion(tenantId); } else { if (log.isDebugEnabled()) { log.debug("Tenant.ListenerInvocationPolicy.InvokeOnDelete flag is not set to true in carbon.xml. Listener invocation ignored."); } } TenantMgtUtil.deleteWorkernodesTenant(tenantId); if (TenantMgtServiceComponent.getBillingService() != null) { TenantMgtServiceComponent.getBillingService().deleteBillingData(tenantId); } TenantMgtUtil.unloadTenantConfigurations(tenantDomain, tenantId); TenantMgtUtil.deleteTenantRegistryData(tenantId); tenantManager.deleteTenant(tenantId); log.info(String.format("Deleted tenant with domain: %s and tenant id: %d from the system.", tenantDomain, tenantId)); } else { if (log.isDebugEnabled()) { log.debug("Tenant.TenantDelete flag is not set to true in carbon.xml. Tenant will not be deleted."); } } } catch (Exception e) { String msg = String.format("Deleted tenant with domain: %s and tenant id: %d from the system.", tenantDomain, tenantId); log.error(msg, e); throw new StratosException(msg, e); } } }