Skip to content

Commit

Permalink
Merge pull request wso2-extensions#121 from sadilchamishka/org-mgt-pa…
Browse files Browse the repository at this point in the history
…cth-1

Fix for displaying tenant created user as null when organization creation
  • Loading branch information
AnuradhaSK authored Aug 7, 2022
2 parents a9ba151 + 2cb3337 commit 9ec73b1
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 @@ -797,13 +798,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 9ec73b1

Please sign in to comment.