public void execute() {
try {
if (log.isDebugEnabled()) {
log.debug(String.format("Publishing complete tenant event"));
}
Tenant tenant;
List<Tenant> tenants = new ArrayList<Tenant>();
TenantManager tenantManager = DataHolder.getRealmService().getTenantManager();
org.wso2.carbon.user.api.Tenant[] carbonTenants = tenantManager.getAllTenants();
for (org.wso2.carbon.user.api.Tenant carbonTenant : carbonTenants) {
// Create tenant
if(log.isDebugEnabled()) {
log.debug(String.format("Tenant found: [tenant-id] %d [tenant-domain] %s", carbonTenant.getId(), carbonTenant.getDomain()));
}
tenant = new Tenant(carbonTenant.getId(), carbonTenant.getDomain());
// Add subscriptions
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//List<CartridgeSubscriptionInfo> cartridgeSubscriptions = PersistenceManager.getSubscriptionsForTenant(tenant.getTenantId());
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Collection<CartridgeSubscription> cartridgeSubscriptions = new DataInsertionAndRetrievalManager().getCartridgeSubscriptions(tenant.getTenantId());
if (cartridgeSubscriptions != null && !cartridgeSubscriptions.isEmpty()) {
for (CartridgeSubscription subscription : cartridgeSubscriptions) {
if(log.isDebugEnabled()) {
log.debug(String.format("Tenant subscription found: [tenant-id] %d [tenant-domain] %s [service] %s",
carbonTenant.getId(), carbonTenant.getDomain(), subscription.getType()));
}
tenant.addServiceSubscription(subscription.getType());
}
}
tenants.add(tenant);
}
CompleteTenantEvent event = new CompleteTenantEvent(tenants);