Skip to content

Commit a2a8ef5

Browse files
prison search fix
1 parent ab4c1c3 commit a2a8ef5

File tree

3 files changed

+12
-23
lines changed

3 files changed

+12
-23
lines changed

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/gateways/PrisonerOffenderSearchGateway.kt

-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.gateways
22

3-
import org.slf4j.LoggerFactory
43
import org.springframework.beans.factory.annotation.Autowired
54
import org.springframework.beans.factory.annotation.Value
65
import org.springframework.http.HttpMethod
@@ -19,8 +18,6 @@ class PrisonerOffenderSearchGateway(
1918
) {
2019
private val webClient = WebClientWrapper(baseUrl)
2120

22-
private val log: org.slf4j.Logger = LoggerFactory.getLogger(this::class.java)
23-
2421
@Autowired
2522
lateinit var hmppsAuthGateway: HmppsAuthGateway
2623

@@ -59,7 +56,6 @@ class PrisonerOffenderSearchGateway(
5956
}
6057

6158
fun getPrisonOffender(nomsNumber: String): Response<POSPrisoner?> {
62-
log.info("looking up the person via prison search $nomsNumber")
6359
val result =
6460
webClient.request<POSPrisoner>(
6561
HttpMethod.GET,
@@ -70,12 +66,10 @@ class PrisonerOffenderSearchGateway(
7066

7167
return when (result) {
7268
is WebClientWrapperResponse.Success -> {
73-
log.info("found a match via prison search $nomsNumber")
7469
Response(data = result.data)
7570
}
7671

7772
is WebClientWrapperResponse.Error -> {
78-
log.error("An error occurred getting person from prion search: ${result.errors}")
7973
Response(
8074
data = null,
8175
errors = result.errors,

src/main/kotlin/uk/gov/justice/digital/hmpps/hmppsintegrationapi/services/GetHmppsIdService.kt

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.services
22

3-
import org.slf4j.LoggerFactory
43
import org.springframework.beans.factory.annotation.Autowired
54
import org.springframework.stereotype.Service
65
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.HmppsId
@@ -11,23 +10,23 @@ import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Response
1110
class GetHmppsIdService(
1211
@Autowired val getPersonService: GetPersonService,
1312
) {
14-
private val log: org.slf4j.Logger = LoggerFactory.getLogger(this::class.java)
15-
1613
fun execute(hmppsId: String): Response<HmppsId?> {
1714
val personResponse = getPersonService.execute(hmppsId.uppercase())
18-
1915
var hmppsIdToReturn =
2016
personResponse.data?.hmppsId
21-
log.info("hmppsId from probation: $hmppsIdToReturn")
22-
if (hmppsIdToReturn == null) {
23-
hmppsIdToReturn = getPersonService.getPersonFromNomis(hmppsId.uppercase()).data?.prisonerNumber
24-
log.info("hmppsId from prison: $hmppsIdToReturn")
17+
return if (hmppsIdToReturn != null) {
18+
Response(
19+
data = HmppsId(hmppsIdToReturn),
20+
errors = personResponse.errors,
21+
)
22+
} else {
23+
val prisonerResponse = getPersonService.getPersonFromNomis(hmppsId.uppercase())
24+
hmppsIdToReturn = prisonerResponse.data?.prisonerNumber
25+
Response(
26+
data = HmppsId(hmppsIdToReturn),
27+
errors = prisonerResponse.errors,
28+
)
2529
}
26-
27-
return Response(
28-
data = HmppsId(hmppsIdToReturn),
29-
errors = personResponse.errors,
30-
)
3130
}
3231

3332
fun getNomisNumber(hmppsId: String): Response<NomisNumber?> {

src/main/resources/application-dev.yml

-4
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,3 @@ authorisation:
115115
- "/v1/hmpps/id/by-nomis-number/[^/]*$"
116116
- "/v1/hmpps/id/nomis-number/by-hmpps-id/[^/]*$"
117117

118-
logging:
119-
level:
120-
root: INFO
121-
uk.gov.justice.digital.hmpps.hmppsintegrationapi: DEBUG

0 commit comments

Comments
 (0)