diff --git a/amrit/src/main/java/org/avni_integration_service/amrit/service/BaseAmritService.java b/amrit/src/main/java/org/avni_integration_service/amrit/service/BaseAmritService.java index da765147..052ee06f 100644 --- a/amrit/src/main/java/org/avni_integration_service/amrit/service/BaseAmritService.java +++ b/amrit/src/main/java/org/avni_integration_service/amrit/service/BaseAmritService.java @@ -1,7 +1,5 @@ package org.avni_integration_service.amrit.service; -import org.avni_integration_service.amrit.config.AmritEntityType; -import org.avni_integration_service.amrit.config.AmritErrorType; import org.avni_integration_service.amrit.config.AmritMappingDbConstants; import org.avni_integration_service.amrit.dto.AmritFetchIdentityResponse; import org.avni_integration_service.amrit.repository.BeneficiaryRepository; diff --git a/amrit/src/main/java/org/avni_integration_service/amrit/service/BornBirthService.java b/amrit/src/main/java/org/avni_integration_service/amrit/service/BornBirthService.java index 456ab98c..560ee768 100644 --- a/amrit/src/main/java/org/avni_integration_service/amrit/service/BornBirthService.java +++ b/amrit/src/main/java/org/avni_integration_service/amrit/service/BornBirthService.java @@ -9,6 +9,7 @@ import org.avni_integration_service.avni.domain.Subject; import org.avni_integration_service.integration_data.repository.IntegrationSystemRepository; import org.avni_integration_service.integration_data.repository.MappingMetaDataRepository; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.web.client.HttpClientErrorException; @@ -29,8 +30,10 @@ public void createOrUpdateBornBirth(Subject subject, Enrolment enrolment) { if (wasFetchOfAmritIdSuccessful(subject, true, true)) { bornBirthRepository.createEvent(subject, enrolment, AmritBaseResponse.class); } - } catch (HttpClientErrorException.NotFound e) { - beneficiaryRepository.createEvent(subject, null, AmritUpsertBeneficiaryResponse.class); + } catch (HttpClientErrorException e) { + if(e.getStatusCode().equals(HttpStatus.NOT_FOUND)) { + beneficiaryRepository.createEvent(subject, null, AmritUpsertBeneficiaryResponse.class); + } throw e; } } diff --git a/amrit/src/main/java/org/avni_integration_service/amrit/service/CBACService.java b/amrit/src/main/java/org/avni_integration_service/amrit/service/CBACService.java index ca934806..f12f45ef 100644 --- a/amrit/src/main/java/org/avni_integration_service/amrit/service/CBACService.java +++ b/amrit/src/main/java/org/avni_integration_service/amrit/service/CBACService.java @@ -9,6 +9,7 @@ import org.avni_integration_service.avni.domain.Subject; import org.avni_integration_service.integration_data.repository.IntegrationSystemRepository; import org.avni_integration_service.integration_data.repository.MappingMetaDataRepository; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.web.client.HttpClientErrorException; @@ -29,8 +30,10 @@ public void createOrUpdateCBAC(Subject subject, GeneralEncounter encounter) { if (wasFetchOfAmritIdSuccessful(subject, true, true)) { cBACRepository.createEvent(subject, encounter, AmritBaseResponse.class); } - } catch (HttpClientErrorException.NotFound e) { - beneficiaryRepository.createEvent(subject, null, AmritUpsertBeneficiaryResponse.class); + } catch (HttpClientErrorException e) { + if(e.getStatusCode().equals(HttpStatus.NOT_FOUND)) { + beneficiaryRepository.createEvent(subject, null, AmritUpsertBeneficiaryResponse.class); + } throw e; } } diff --git a/amrit/src/main/java/org/avni_integration_service/amrit/service/HouseholdService.java b/amrit/src/main/java/org/avni_integration_service/amrit/service/HouseholdService.java index 93f96369..4675e810 100644 --- a/amrit/src/main/java/org/avni_integration_service/amrit/service/HouseholdService.java +++ b/amrit/src/main/java/org/avni_integration_service/amrit/service/HouseholdService.java @@ -8,6 +8,7 @@ import org.avni_integration_service.avni.domain.Household; import org.avni_integration_service.integration_data.repository.IntegrationSystemRepository; import org.avni_integration_service.integration_data.repository.MappingMetaDataRepository; +import org.springframework.http.HttpStatus; import org.springframework.stereotype.Service; import org.springframework.web.client.HttpClientErrorException; @@ -28,8 +29,10 @@ public void createOrUpdateHousehold(Household household) { if (wasFetchOfAmritIdSuccessful(household.getMemberSubject(), true, true)) { householdRepository.createEvent(household, AmritBaseResponse.class); } - } catch (HttpClientErrorException.NotFound e) { - beneficiaryRepository.createEvent(household.getMemberSubject(), null, AmritUpsertBeneficiaryResponse.class); + } catch (HttpClientErrorException e) { + if(e.getStatusCode().equals(HttpStatus.NOT_FOUND)) { + beneficiaryRepository.createEvent(household.getMemberSubject(), null, AmritUpsertBeneficiaryResponse.class); + } throw e; } }