Merge pull request #10714 from YevhenBondarenko/fix/tenant-creation-order

fixed events ordering during tenant creation
This commit is contained in:
Viacheslav Klimov 2024-05-06 11:39:02 +03:00 committed by GitHub
commit 0a3c92d448
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -136,18 +136,20 @@ public class TenantServiceImpl extends AbstractCachedEntityService<TenantId, Ten
TenantId tenantId = savedTenant.getId();
publishEvictEvent(new TenantEvictEvent(tenantId, create));
if (create && defaultEntitiesCreator != null) {
defaultEntitiesCreator.accept(tenantId);
}
eventPublisher.publishEvent(SaveEntityEvent.builder().tenantId(tenantId)
.entityId(tenantId).entity(savedTenant).created(create).build());
if (create) {
deviceProfileService.createDefaultDeviceProfile(tenantId);
assetProfileService.createDefaultAssetProfile(tenantId);
apiUsageStateService.createDefaultApiUsageState(tenantId, null);
notificationSettingsService.createDefaultNotificationConfigs(tenantId);
if (defaultEntitiesCreator != null) {
defaultEntitiesCreator.accept(tenantId);
}
}
eventPublisher.publishEvent(SaveEntityEvent.builder().tenantId(tenantId)
.entityId(tenantId).entity(savedTenant).created(create).build());
return savedTenant;
}