Skip to content

Commit

Permalink
[SELC-6228] feat: using NumberOfAdminsExceededException
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetano-miglionico committed Jan 3, 2025
1 parent f61703c commit 30639d2
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import it.pagopa.selfcare.user.entity.filter.OnboardedProductFilter;
import it.pagopa.selfcare.user.entity.filter.UserInstitutionFilter;
import it.pagopa.selfcare.user.exception.InvalidRequestException;
import it.pagopa.selfcare.user.exception.NumberOfAdminsExceededException;
import it.pagopa.selfcare.user.exception.ResourceNotFoundException;
import it.pagopa.selfcare.user.exception.UserRoleAlreadyPresentException;
import it.pagopa.selfcare.user.mapper.OnboardedProductMapper;
Expand Down Expand Up @@ -363,9 +364,9 @@ public Uni<CreateOrUpdateUserByFiscalCodeResponse> createOrUpdateUserByFiscalCod
}

private Uni<Void> checkNumberOfAdminsExceeded(String institutionId, String productId, List<String> productRoles) {
if (productId.equalsIgnoreCase(ProductId.PROD_PAGOPA.getValue()) && productRoles.contains("admin-psp")) {
if (ProductId.PROD_PAGOPA.getValue().equalsIgnoreCase(productId) && productRoles.contains("admin-psp")) {
return userInstitutionService.countInstitutionProductRoles(institutionId, ProductId.PROD_PAGOPA, "admin-psp")
.flatMap(n -> n >= 3 ? Uni.createFrom().failure(new InvalidRequestException("Maximum number of 3 admin-psp reached for prod-pagopa")) : Uni.createFrom().voidItem());
.flatMap(n -> n >= 3 ? Uni.createFrom().failure(new NumberOfAdminsExceededException("Maximum number of 3 admin-psp reached for prod-pagopa")) : Uni.createFrom().voidItem());
}
return Uni.createFrom().voidItem();
}
Expand Down

0 comments on commit 30639d2

Please sign in to comment.