From 2cb3337fcd905e130048b8e7ff56a8a051a996fb Mon Sep 17 00:00:00 2001 From: sadilchamishka Date: Mon, 1 Aug 2022 22:23:49 +0530 Subject: [PATCH] Fix for displaying tenant created user as null when organization creation --- .../management/service/OrganizationManagerImpl.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/OrganizationManagerImpl.java b/components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/OrganizationManagerImpl.java index 1178ca92e..535c4010a 100644 --- a/components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/OrganizationManagerImpl.java +++ b/components/org.wso2.carbon.identity.organization.management.service/src/main/java/org/wso2/carbon/identity/organization/management/service/OrganizationManagerImpl.java @@ -153,8 +153,9 @@ public Organization addOrganization(Organization organization) throws Organizati setCreatedAndLastModifiedTime(organization); organizationManagementDAO.addOrganization(organization); String orgCreatorID = getUserId(); + String orgCreatorName = getAuthenticatedUsername(); if (StringUtils.equals(TENANT.toString(), organization.getType())) { - createTenant(organization.getId(), orgCreatorID); + createTenant(organization.getId(), orgCreatorID, orgCreatorName); } return organization; } @@ -782,13 +783,15 @@ private boolean isFilteringAttributeNotSupported(String attributeValue) { !attributeValue.equalsIgnoreCase(PAGINATION_BEFORE); } - private void createTenant(String domain, String orgCreatorID) throws OrganizationManagementException { + private void createTenant(String domain, String orgCreatorID, String orgCreatorName) + throws OrganizationManagementException { try { PrivilegedCarbonContext.startTenantFlow(); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantDomain(MultitenantConstants .SUPER_TENANT_DOMAIN_NAME); PrivilegedCarbonContext.getThreadLocalCarbonContext().setTenantId(MultitenantConstants.SUPER_TENANT_ID); + PrivilegedCarbonContext.getThreadLocalCarbonContext().setUsername(orgCreatorName); getTenantMgtService().addTenant(createTenantInfoBean(domain, orgCreatorID)); } catch (TenantMgtException e) { // Rollback created organization.