From 115663a32db3b5574fc54efc9850503322621287 Mon Sep 17 00:00:00 2001 From: girirajsharma Date: Sat, 10 Oct 2015 00:55:03 +0530 Subject: [PATCH] [KEYCLOAK-1932] Unable to create flow named exactly the same as removed NON-top level flow --- .../resources/admin/AuthenticationManagementResource.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/services/src/main/java/org/keycloak/services/resources/admin/AuthenticationManagementResource.java b/services/src/main/java/org/keycloak/services/resources/admin/AuthenticationManagementResource.java index ede2e278a7..4b523a16c9 100755 --- a/services/src/main/java/org/keycloak/services/resources/admin/AuthenticationManagementResource.java +++ b/services/src/main/java/org/keycloak/services/resources/admin/AuthenticationManagementResource.java @@ -323,6 +323,14 @@ public class AuthenticationManagementResource { if (flow.isBuiltIn()) { throw new BadRequestException("Can't delete built in flow"); } + List executions = realm.getAuthenticationExecutions(id); + for (AuthenticationExecutionModel execution : executions) { + if(execution.getFlowId() != null) { + AuthenticationFlowModel nonTopLevelFlow = realm.getAuthenticationFlowById(execution.getFlowId()); + realm.removeAuthenticationFlow(nonTopLevelFlow); + } + realm.removeAuthenticatorExecution(execution); + } realm.removeAuthenticationFlow(flow); }