diff --git a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java index 5b1c41238b462ad003ca5cea9716cb43d578dbfc..b541a36dd5a4b04af9ac1bd19b24b1c4801dd79f 100644 --- a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java +++ b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java @@ -582,6 +582,10 @@ public class AccountRepositoryAdditionalImpl implements AccountRepositoryAdditio for (AccountByProfileId accountByProfileId : existingAccountsForProfile) { Account existingAccount = accountRepository.findByAccountId(accountByProfileId.getAccountId()); deleteAccountData(batchOperations, existingAccount); + if (!accessPointService.deleteAccessPointsForAccount(accountByProfileId.getAccountId())) { + logger.error("Error deleting accesspoints from the DB for account {}.", accountByProfileId.getAccountId()); + } + } } diff --git a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java index 191f704fce6d75cd48cf37973a2a409169290b1e..e988a605a2a0a7e8c353f40cb6d588db42cc3bb9 100644 --- a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java +++ b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java @@ -18,6 +18,7 @@ import org.lognet.springboot.grpc.GRpcService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import biz.nynja.account.accesspoints.AccessPointService; import biz.nynja.account.configuration.ProfileDataConfiguration; import biz.nynja.account.grpc.AccountByAccountIdRequest; import biz.nynja.account.grpc.AccountResponse; @@ -103,6 +104,7 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas private final ProfileProvider profileProvider; private final PermissionsValidator permissionsValidator; private final ProfileDataConfiguration profileDataConfiguration; + private final AccessPointService accessPointService; public AccountServiceImpl(AccountRepositoryAdditional accountRepositoryAdditional, ProfileRepository profileRepository, @@ -111,7 +113,7 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas AccountByUsernameRepository accountByUsernameRepository, AccountProvider accountProvider, AccountByProfileIdRepository accountByProfileIdRepository, PhoneNumberNormalizer phoneNumberNormalizer, AccountCreator accountCreator, ProfileProvider profileProvider, PermissionsValidator permissionsValidator, - ProfileDataConfiguration profileDataConfiguration) { + ProfileDataConfiguration profileDataConfiguration, AccessPointService accessPointService) { this.accountRepositoryAdditional = accountRepositoryAdditional; this.profileRepository = profileRepository; this.profileByAutheticationProviderRepository = profileByAutheticationProviderRepository; @@ -124,6 +126,7 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas this.profileProvider = profileProvider; this.permissionsValidator = permissionsValidator; this.profileDataConfiguration = profileDataConfiguration; + this.accessPointService = accessPointService; } @Override @@ -584,6 +587,9 @@ public class AccountServiceImpl extends AccountServiceGrpc.AccountServiceImplBas "Failed to delete account"); return; } + if (!accessPointService.deleteAccessPointsForAccount(UUID.fromString(request.getAccountId()))) { + logger.error("Error deleting accesspoints from the DB for account {}.", request.getAccountId()); + } logger.info("SUCCESS: Account successfully deleted: {}", request.getAccountId()); responseObserver.onNext(StatusResponse.newBuilder().setStatus("SUCCESS").build()); responseObserver.onCompleted();