Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do not decode variable #537

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.PROBATION_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
Loading