From ebf57b53a01188b69d32be308d068f93f3ddf039 Mon Sep 17 00:00:00 2001 From: NipuniBhagya Date: Mon, 14 Oct 2024 12:27:57 +0530 Subject: [PATCH 1/3] Remove Spring dependencies in the organization roles API --- .../pom.xml | 7 +-- ...ganizationRoleManagementServiceHolder.java | 51 +++++----------- ...ationRoleManagementOSGIServiceFactory.java | 53 ----------------- ...serResidentResolverOSGIServiceFactory.java | 56 ------------------ .../pom.xml | 7 +-- .../role/management/v1/OrganizationsApi.java | 13 +++-- .../OrganizationsApiServiceFactory.java | 14 ++++- .../RoleManagementServiceFactory.java | 58 +++++++++++++++++++ .../v1/impl/OrganizationsApiServiceImpl.java | 15 +++-- .../v1/service/RoleManagementService.java | 34 ++++++----- .../v1/util/RoleManagementEndpointUtils.java | 6 +- .../cxf/org-role-mgt-server-v1-cxf.xml | 34 ----------- 12 files changed, 128 insertions(+), 220 deletions(-) delete mode 100644 components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.common/src/main/java/org/wso2/carbon/identity/api/server/organization/role/management/common/factory/OrganizationRoleManagementOSGIServiceFactory.java delete mode 100644 components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.common/src/main/java/org/wso2/carbon/identity/api/server/organization/role/management/common/factory/OrganizationUserResidentResolverOSGIServiceFactory.java create mode 100644 components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/role/management/v1/factories/RoleManagementServiceFactory.java delete mode 100644 components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.v1/src/main/resources/META-INF/cxf/org-role-mgt-server-v1-cxf.xml diff --git a/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.common/pom.xml b/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.common/pom.xml index 57ce9c0881..647192d669 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.common/pom.xml +++ b/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.common/pom.xml @@ -1,6 +1,6 @@ - - - - - - - - - - - - From 6e0eeb8c72bf3ee59dd60965ba7f296ec5a7ca84 Mon Sep 17 00:00:00 2001 From: NipuniBhagya Date: Tue, 15 Oct 2024 19:51:30 +0530 Subject: [PATCH 2/3] Resolve PR comments --- .../management/v1/factories/RoleManagementServiceFactory.java | 1 + 1 file changed, 1 insertion(+) diff --git a/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/role/management/v1/factories/RoleManagementServiceFactory.java b/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/role/management/v1/factories/RoleManagementServiceFactory.java index f7b2d12086..8bca9652df 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/role/management/v1/factories/RoleManagementServiceFactory.java +++ b/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/role/management/v1/factories/RoleManagementServiceFactory.java @@ -53,6 +53,7 @@ public class RoleManagementServiceFactory { * @return RoleManagementService. */ public static RoleManagementService getRoleManagementService() { + return SERVICE; } } From b46450ff303ce68a456226a30bb935149aa1f948 Mon Sep 17 00:00:00 2001 From: NipuniBhagya Date: Wed, 16 Oct 2024 15:43:22 +0530 Subject: [PATCH 3/3] Refactor RoleManagementServiceFactory class --- .../RoleManagementServiceFactory.java | 49 +++++++++++++------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/role/management/v1/factories/RoleManagementServiceFactory.java b/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/role/management/v1/factories/RoleManagementServiceFactory.java index 8bca9652df..5a2597b8ab 100644 --- a/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/role/management/v1/factories/RoleManagementServiceFactory.java +++ b/components/org.wso2.carbon.identity.api.server.organization.role.management/org.wso2.carbon.identity.api.server.organization.role.management.v1/src/main/java/org/wso2/carbon/identity/api/server/organization/role/management/v1/factories/RoleManagementServiceFactory.java @@ -28,23 +28,22 @@ */ public class RoleManagementServiceFactory { - private static final RoleManagementService SERVICE; + private RoleManagementServiceFactory() { - static { - RoleManager roleManager = OrganizationRoleManagementServiceHolder.getRoleManager(); - OrganizationUserResidentResolverService organizationUserResidentResolverService = - OrganizationRoleManagementServiceHolder.getOrganizationUserResidentResolverService(); + } - if (roleManager == null) { - throw new IllegalStateException("RoleManager service is not available from OSGi context."); - } + private static class RoleManagementServiceHolder { - if (organizationUserResidentResolverService == null) { - throw new IllegalStateException("OrganizationUserResidentResolverService is not available " + - "from OSGi context."); - } + private static final RoleManagementService SERVICE = createServiceInstance(); + } + + private static RoleManagementService createServiceInstance() { - SERVICE = new RoleManagementService(roleManager, organizationUserResidentResolverService); + RoleManager roleManager = getRoleManagerService(); + OrganizationUserResidentResolverService organizationUserResidentResolverService = + getOrganizationUserResidentResolverService(); + + return new RoleManagementService(roleManager, organizationUserResidentResolverService); } /** @@ -54,6 +53,28 @@ public class RoleManagementServiceFactory { */ public static RoleManagementService getRoleManagementService() { - return SERVICE; + return RoleManagementServiceHolder.SERVICE; + } + + private static RoleManager getRoleManagerService() { + + RoleManager service = OrganizationRoleManagementServiceHolder.getRoleManager(); + if (service == null) { + throw new IllegalStateException("RoleManager service is not available from OSGi context."); + } + + return service; + } + + private static OrganizationUserResidentResolverService getOrganizationUserResidentResolverService() { + + OrganizationUserResidentResolverService service = OrganizationRoleManagementServiceHolder + .getOrganizationUserResidentResolverService(); + if (service == null) { + throw new IllegalStateException("OrganizationUserResidentResolverService is not available " + + "from OSGi context."); + } + + return service; } }