Skip to content

Commit

Permalink
Fix for displaying tenant created user as null when organization crea…
Browse files Browse the repository at this point in the history
…tion
  • Loading branch information
sadilchamishka committed Aug 1, 2022
1 parent 6cf1467 commit 2cb3337
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 2cb3337

Please sign in to comment.