Merge branch 'RED-8008' into 'main'
RED-8008: Ensure that new roles are added to existing tenants during upgrade See merge request fforesight/tenant-user-management-service!54
This commit is contained in:
commit
2692a7b1a9
@ -1,5 +1,6 @@
|
||||
package com.knecon.fforesight.tenantusermanagement.initializer;
|
||||
|
||||
import com.knecon.fforesight.tenantusermanagement.service.TenantManagementService;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@ -24,10 +25,19 @@ public class MigrateOnlyHook {
|
||||
|
||||
private final ApplicationContext ctx;
|
||||
|
||||
private final TenantManagementService tenantManagementService;
|
||||
|
||||
private final KeyCloakRoleManagerService keyCloakRoleManagerService;
|
||||
|
||||
|
||||
@SuppressWarnings("PMD.DoNotTerminateVM")
|
||||
@EventListener(ApplicationReadyEvent.class)
|
||||
public void migrate() {
|
||||
|
||||
tenantManagementService.getTenants().forEach(tenant -> {
|
||||
keyCloakRoleManagerService.updateRoles(tenant.getTenantId());
|
||||
});
|
||||
|
||||
// This should only run in post upgrade hook
|
||||
if (isMigrateOnly) {
|
||||
System.exit(SpringApplication.exit(ctx, () -> 0));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user