Repository: stratos Updated Branches: refs/heads/4.0.0-grouping bc7f7b249 -> aadd589f3
Unable to trigger TenantCreatedEvent when the tenant is not there in TenantManager Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/9f0c67e7 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/9f0c67e7 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/9f0c67e7 Branch: refs/heads/4.0.0-grouping Commit: 9f0c67e72b8ddc460851a11204d011b8c8123ddf Parents: 2555cb2 Author: Udara Liyanage <[email protected]> Authored: Mon Aug 18 12:24:53 2014 +0530 Committer: Udara Liyanage <[email protected]> Committed: Mon Aug 18 12:24:53 2014 +0530 ---------------------------------------------------------------------- components/org.apache.stratos.manager/pom.xml | 6 ++++++ .../manager/publisher/TenantSynzhronizerTask.java | 16 ++++++++++++++++ 2 files changed, 22 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/9f0c67e7/components/org.apache.stratos.manager/pom.xml ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager/pom.xml b/components/org.apache.stratos.manager/pom.xml index 3c24303..7481745 100644 --- a/components/org.apache.stratos.manager/pom.xml +++ b/components/org.apache.stratos.manager/pom.xml @@ -114,6 +114,12 @@ <artifactId>org.apache.stratos.messaging</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.apache.stratos</groupId> + <artifactId>org.apache.stratos.tenant.mgt</artifactId> + <version>${project.version}</version> + <scope>provided</scope> + </dependency> </dependencies> <build> http://git-wip-us.apache.org/repos/asf/stratos/blob/9f0c67e7/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/TenantSynzhronizerTask.java ---------------------------------------------------------------------- diff --git a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/TenantSynzhronizerTask.java b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/TenantSynzhronizerTask.java index 47911d6..81ec432 100644 --- a/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/TenantSynzhronizerTask.java +++ b/components/org.apache.stratos.manager/src/main/java/org/apache/stratos/manager/publisher/TenantSynzhronizerTask.java @@ -21,6 +21,7 @@ package org.apache.stratos.manager.publisher; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.stratos.common.beans.TenantInfoBean; import org.apache.stratos.manager.internal.DataHolder; import org.apache.stratos.manager.retriever.DataInsertionAndRetrievalManager; import org.apache.stratos.manager.subscription.CartridgeSubscription; @@ -31,6 +32,7 @@ import org.apache.stratos.messaging.domain.tenant.Subscription; import org.apache.stratos.messaging.domain.tenant.Tenant; import org.apache.stratos.messaging.event.tenant.CompleteTenantEvent; import org.apache.stratos.messaging.util.Constants; +import org.apache.stratos.tenant.mgt.util.TenantMgtUtil; import org.wso2.carbon.ntask.core.Task; import org.wso2.carbon.user.core.tenant.TenantManager; @@ -64,6 +66,20 @@ public class TenantSynzhronizerTask implements Task { log.debug(String.format("Tenant found: [tenant-id] %d [tenant-domain] %s", carbonTenant.getId(), carbonTenant.getDomain())); } tenant = new Tenant(carbonTenant.getId(), carbonTenant.getDomain()); + + if (!org.apache.stratos.messaging.message.receiver.tenant.TenantManager + .getInstance().tenantExists(carbonTenant.getId())) { + // if the tenant is not already there in TenantManager, + // trigger TenantCreatedEvent + TenantInfoBean tenantBean = new TenantInfoBean(); + tenantBean.setTenantId(carbonTenant.getId()); + tenantBean.setTenantDomain(carbonTenant.getDomain()); + TenantMgtUtil.triggerAddTenant(tenantBean); + // add tenant to Tenant Manager + org.apache.stratos.messaging.message.receiver.tenant.TenantManager + .getInstance().addTenant(tenant); + } + // Add subscriptions ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //List<CartridgeSubscriptionInfo> cartridgeSubscriptions = PersistenceManager.getSubscriptionsForTenant(tenant.getTenantId());
