Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into ab_PI-2378
Browse files Browse the repository at this point in the history
  • Loading branch information
anthony-britton-moj committed Dec 13, 2024
2 parents f8c65ff + cad8f10 commit e17a601
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package uk.gov.justice.digital.hmpps.hmppsintegrationapi.controllers.v1.prison

import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.Parameter
import io.swagger.v3.oas.annotations.media.Content
import io.swagger.v3.oas.annotations.media.Schema
import io.swagger.v3.oas.annotations.responses.ApiResponse
Expand All @@ -12,7 +11,6 @@ import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.exception.EntityNotFoundException
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.extensions.decodeUrlCharacters
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.DataResponse
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.Person
import uk.gov.justice.digital.hmpps.hmppsintegrationapi.models.hmpps.UpstreamApi
Expand All @@ -37,17 +35,15 @@ class PrisonController(
],
)
fun getPerson(
@Parameter(description = "A HMPPS identifier", example = "2008%2F0545166T", required = true) @PathVariable hmppsId: String,
@PathVariable hmppsId: String,
): DataResponse<Person?> {
val decodedHmppsId = hmppsId.decodeUrlCharacters()

val response = getPersonService.getPrisoner(decodedHmppsId)
val response = getPersonService.getPrisoner(hmppsId)

if (response.hasErrorCausedBy(ENTITY_NOT_FOUND, causedBy = UpstreamApi.PRISONER_OFFENDER_SEARCH)) {
throw EntityNotFoundException("Could not find person with hmppsId: $decodedHmppsId")
throw EntityNotFoundException("Could not find person with hmppsId: $hmppsId")
}

auditService.createEvent("GET_PERSON_DETAILS", mapOf("hmppsId" to decodedHmppsId))
auditService.createEvent("GET_PERSON_DETAILS", mapOf("hmppsId" to hmppsId))
val data = response.data
return DataResponse(data)
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,8 @@ authorisation:
- "/v1/persons/.*/plp-review-schedule"
- "/v1/hmpps/id/by-nomis-number/[^/]*$"
- "/v1/hmpps/id/nomis-number/by-hmpps-id/[^/]*$"
bmadley:
include:
- "/v1/persons"
- "/v1/persons/[^/]*$"
- "/v1/prison/prisoners/[^/]*$"

0 comments on commit e17a601

Please sign in to comment.