From 5235ed6fd8d5cda4eac9100bf2b28531115f1a38 Mon Sep 17 00:00:00 2001 From: Stoyan Tzenkov Date: Thu, 31 Jan 2019 09:41:05 +0200 Subject: [PATCH 1/2] Ny-6879: Accesspoints for account deleted whenever the account is deleted. Signed-off-by: Stoyan Tzenkov --- .../biz/nynja/account/services/AccountServiceImpl.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/biz/nynja/account/services/AccountServiceImpl.java b/src/main/java/biz/nynja/account/services/AccountServiceImpl.java index 191f704..e988a60 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(); -- GitLab From 01fa79ffda12adba20d5fa827b7f279511dbcceb Mon Sep 17 00:00:00 2001 From: Stoyan Tzenkov Date: Thu, 31 Jan 2019 12:15:21 +0200 Subject: [PATCH 2/2] NY-6879: Accesspoints deleted for account whenever profile deleted. Signed-off-by: Stoyan Tzenkov --- .../account/repositories/AccountRepositoryAdditionalImpl.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java b/src/main/java/biz/nynja/account/repositories/AccountRepositoryAdditionalImpl.java index 5b1c412..b541a36 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()); + } + } } -- GitLab