@SuppressWarnings("unchecked") private void removeBootstrapOnlyAccount(Providers providers, String deploymentName, String bootstrapAccountName) { Account bootstrapAccount = accountService.getAnyProviderAccount(deploymentName, bootstrapAccountName); Provider bootstrapProvider = ((Provider) bootstrapAccount.getParent()); bootstrapProvider.getAccounts().remove(bootstrapAccount); if (bootstrapProvider.getAccounts().isEmpty()) { bootstrapProvider.setEnabled(false); if (bootstrapAccount instanceof ContainerAccount) { ContainerAccount containerAccount = (ContainerAccount) bootstrapAccount; DockerRegistryAccountReverseIndex revIndex = new DockerRegistryAccountReverseIndex(providers); containerAccount.getDockerRegistries().forEach(reg -> { Set<Account> dependentAccounts = revIndex.get(reg.getAccountName()); if (dependentAccounts == null || dependentAccounts.isEmpty()) { DockerRegistryAccount regAcct = (DockerRegistryAccount) accountService.getAnyProviderAccount(deploymentName, reg.getAccountName()); ((DockerRegistryProvider) regAcct.getParent()).getAccounts().remove(regAcct); } }); if (providers.getDockerRegistry().getAccounts().isEmpty()) { providers.getDockerRegistry().setEnabled(false); } } } }
@SuppressWarnings("unchecked") private void removeBootstrapOnlyAccount(Providers providers, String deploymentName, String bootstrapAccountName) { Account bootstrapAccount = accountService.getAnyProviderAccount(deploymentName, bootstrapAccountName); Provider bootstrapProvider = ((Provider) bootstrapAccount.getParent()); bootstrapProvider.getAccounts().remove(bootstrapAccount); if (bootstrapProvider.getAccounts().isEmpty()) { bootstrapProvider.setEnabled(false); if (bootstrapAccount instanceof ContainerAccount) { ContainerAccount containerAccount = (ContainerAccount) bootstrapAccount; DockerRegistryAccountReverseIndex revIndex = new DockerRegistryAccountReverseIndex(providers); containerAccount.getDockerRegistries().forEach(reg -> { Set<Account> dependentAccounts = revIndex.get(reg.getAccountName()); if (dependentAccounts == null || dependentAccounts.isEmpty()) { DockerRegistryAccount regAcct = (DockerRegistryAccount) accountService.getAnyProviderAccount(deploymentName, reg.getAccountName()); ((DockerRegistryProvider) regAcct.getParent()).getAccounts().remove(regAcct); } }); if (providers.getDockerRegistry().getAccounts().isEmpty()) { providers.getDockerRegistry().setEnabled(false); } } } }