From 67cdcede699fa541495557db32a6cb5a6f091570 Mon Sep 17 00:00:00 2001 From: rajitha Date: Wed, 5 Jul 2023 20:01:06 +0530 Subject: [PATCH] Fix realm service unbinding issues --- .../APIApplicationManagerExtensionDataHolder.java | 13 +++++++------ .../publisher/internal/APIPublisherDataHolder.java | 13 +++++++------ .../internal/JWTClientExtensionDataHolder.java | 13 +++++++------ 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java index 8a4cf4f1a67..299184c946c 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.application.extension/src/main/java/io/entgra/device/mgt/core/apimgt/application/extension/internal/APIApplicationManagerExtensionDataHolder.java @@ -62,17 +62,18 @@ public class APIApplicationManagerExtensionDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - this.setTenantManager(realmService); + setTenantManager(realmService != null ? + realmService.getTenantManager() : null); } - private void setTenantManager(RealmService realmService) { - if (realmService == null) { - throw new IllegalStateException("Realm service is not initialized properly"); - } - this.tenantManager = realmService.getTenantManager(); + private void setTenantManager(TenantManager tenantManager) { + this.tenantManager = tenantManager; } public TenantManager getTenantManager() { + if (tenantManager == null) { + throw new IllegalStateException("Tenant manager is not initialized properly"); + } return tenantManager; } diff --git a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java index baff1848ed9..bc7b8af32cc 100644 --- a/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java +++ b/components/apimgt-extensions/io.entgra.device.mgt.core.apimgt.webapp.publisher/src/main/java/io/entgra/device/mgt/core/apimgt/webapp/publisher/internal/APIPublisherDataHolder.java @@ -75,17 +75,18 @@ public class APIPublisherDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - this.setTenantManager(realmService); + setTenantManager(realmService != null ? + realmService.getTenantManager() : null); } - private void setTenantManager(RealmService realmService) { - if (realmService == null) { - throw new IllegalStateException("Realm service is not initialized properly"); - } - this.tenantManager = realmService.getTenantManager(); + private void setTenantManager(TenantManager tenantManager) { + this.tenantManager = tenantManager; } public TenantManager getTenantManager() { + if (tenantManager == null) { + throw new IllegalStateException("Tenant manager is not initialized properly"); + } return tenantManager; } diff --git a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java index 7d253b2333e..cd3999c9bf7 100644 --- a/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java +++ b/components/identity-extensions/io.entgra.device.mgt.core.identity.jwt.client.extension/src/main/java/io/entgra/device/mgt/core/identity/jwt/client/extension/internal/JWTClientExtensionDataHolder.java @@ -74,17 +74,18 @@ public class JWTClientExtensionDataHolder { public void setRealmService(RealmService realmService) { this.realmService = realmService; - this.setTenantManager(realmService); + setTenantManager(realmService != null ? + realmService.getTenantManager() : null); } - private void setTenantManager(RealmService realmService) { - if (realmService == null) { - throw new IllegalStateException("Realm service is not initialized properly"); - } - this.tenantManager = realmService.getTenantManager(); + private void setTenantManager(TenantManager tenantManager) { + this.tenantManager = tenantManager; } public TenantManager getTenantManager() { + if (tenantManager == null) { + throw new IllegalStateException("Tenant manager is not initialized properly"); + } return tenantManager; } }