// Reader reader = new StringReader(writer.toString());
// UserRegistry tenantConfigSystemRegistry =
// TenantMgtCoreServiceComponent.getConfigSystemRegistry(tenantId);
// tenantConfigSystemRegistry.restore(CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION, reader);
try {
UserRealm realm =
(UserRealm) TenantMgtCoreServiceComponent.getRealmService().
getTenantUserRealm(tenantId);
String adminRole = realm.getRealmConfiguration().getAdminRoleName();
AuthorizationManager authMan = realm.getAuthorizationManager();
// Authorize the admin role, if not authorized yet.
if (!authMan.isRoleAuthorized(adminRole,
CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION,
UserMgtConstants.EXECUTE_ACTION)) {
authMan.authorizeRole(adminRole, CarbonConstants.UI_ADMIN_PERMISSION_COLLECTION,