From 4aff388a9aa56832ceb7277e55c6e8d5fc8322b6 Mon Sep 17 00:00:00 2001 From: sadilchamishka Date: Fri, 27 Oct 2023 17:15:55 +0530 Subject: [PATCH] Improve the organization resolving logic --- .../organization/v1/core/UserOrganizationService.java | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/components/org.wso2.carbon.identity.api.user.organization/org.wso2.carbon.identity.rest.api.user.organization.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/organization/v1/core/UserOrganizationService.java b/components/org.wso2.carbon.identity.api.user.organization/org.wso2.carbon.identity.rest.api.user.organization.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/organization/v1/core/UserOrganizationService.java index b46873e21..0fee6c466 100644 --- a/components/org.wso2.carbon.identity.api.user.organization/org.wso2.carbon.identity.rest.api.user.organization.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/organization/v1/core/UserOrganizationService.java +++ b/components/org.wso2.carbon.identity.api.user.organization/org.wso2.carbon.identity.rest.api.user.organization.v1/src/main/java/org/wso2/carbon/identity/rest/api/user/organization/v1/core/UserOrganizationService.java @@ -52,7 +52,6 @@ import static org.wso2.carbon.identity.api.user.common.Constants.USER_API_PATH_COMPONENT; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_ERROR_BUILDING_PAGINATED_RESPONSE_URL; import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.ErrorMessages.ERROR_CODE_USER_ROOT_ORGANIZATION_NOT_FOUND; -import static org.wso2.carbon.identity.organization.management.service.constant.OrganizationManagementConstants.SUPER_ORG_ID; import static org.wso2.carbon.identity.organization.management.service.util.Utils.buildURIForBody; import static org.wso2.carbon.identity.organization.management.service.util.Utils.getOrganizationId; import static org.wso2.carbon.identity.rest.api.user.organization.v1.Constants.ASC_SORT_ORDER; @@ -77,10 +76,7 @@ public class UserOrganizationService { public RootOrganizationResponse getUserOrganizationRoot() { String userId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserId(); - String accessedOrgId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getOrganizationId(); - if (StringUtils.isBlank(accessedOrgId)) { - accessedOrgId = SUPER_ORG_ID; - } + String accessedOrgId = getOrganizationId(); try { String rootOrgId = getOrganizationUserResidentResolverService() .resolveResidentOrganization(userId, accessedOrgId) @@ -102,10 +98,7 @@ public RootOrganizationResponse getUserOrganizationRoot() { public List getUserOrganizationHierarchyUptoResidentOrganization() { String userId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserId(); - String accessedOrgId = PrivilegedCarbonContext.getThreadLocalCarbonContext().getOrganizationId(); - if (StringUtils.isBlank(accessedOrgId)) { - accessedOrgId = SUPER_ORG_ID; - } + String accessedOrgId = getOrganizationId(); try { List rootDescendantsOrganizationResponseList = new ArrayList<>(); List basicOrganizationList = getOrganizationUserResidentResolverService()