generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4da32c
commit b935f9d
Showing
16 changed files
with
241 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
projects/manage-pom-cases-and-delius/src/dev/resources/messages/deallocation.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"Type": "Notification", | ||
"MessageId": "63ba0b4b-340e-4853-b343-6429965a3961", | ||
"TopicArn": "arn:aws:sns:eu-west-2:000000000000:domain-event", | ||
"Message": "{\"eventType\":\"offender-management.allocation.changed\",\"detailUrl\":\"http://localhost:{wiremock.port}/api/pom-allocation/A0123BY/3\",\"occurredAt\":\"2023-10-10T14:25:19.102Z\",\"personReference\":{\"identifiers\":[{\"type\":\"NOMS\",\"value\":\"A0123BY\"}]}}", | ||
"Timestamp": "2023-10-10T14:25:20.000Z", | ||
"MessageAttributes": { | ||
"eventType": { | ||
"Type": "String", | ||
"Value": "offender-management.allocation.changed" | ||
} | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
projects/manage-pom-cases-and-delius/src/dev/resources/messages/not-yet-allocation.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"Type": "Notification", | ||
"MessageId": "63ba0b4b-340e-4853-b343-6429965a3961", | ||
"TopicArn": "arn:aws:sns:eu-west-2:000000000000:domain-event", | ||
"Message": "{\"eventType\":\"offender-management.allocation.changed\",\"detailUrl\":\"http://localhost:{wiremock.port}/api/pom-allocation/A0123BY/0\",\"occurredAt\":\"2023-05-09T13:25:19.102Z\",\"personReference\":{\"identifiers\":[{\"type\":\"NOMS\",\"value\":\"A0123BY\"}]}}", | ||
"Timestamp": "2023-05-09T13:25:20.000Z", | ||
"MessageAttributes": { | ||
"eventType": { | ||
"Type": "String", | ||
"Value": "offender-management.allocation.changed" | ||
} | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
projects/manage-pom-cases-and-delius/src/dev/resources/simulations/__files/deallocation.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"status": "error", | ||
"message": "Not allocated" | ||
} |
4 changes: 4 additions & 0 deletions
4
...manage-pom-cases-and-delius/src/dev/resources/simulations/__files/not-yet-allocation.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"status": "error", | ||
"message": "Not ready for allocation" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
...ases-and-delius/src/main/kotlin/uk/gov/justice/digital/hmpps/exception/Feign404Decoder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package uk.gov.justice.digital.hmpps.exception | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import com.fasterxml.jackson.module.kotlin.readValue | ||
import feign.FeignException.errorStatus | ||
import feign.Response | ||
import feign.codec.ErrorDecoder | ||
import org.springframework.stereotype.Component | ||
import java.lang.Exception | ||
|
||
@Component | ||
class Feign404Decoder(private val objectMapper: ObjectMapper) : ErrorDecoder { | ||
override fun decode(methodKey: String?, response: Response): Exception? { | ||
return response.body().asInputStream()?.use { ins -> | ||
objectMapper.readValue<ErrorResponse>(ins).message?.let { | ||
NotAllocatedException( | ||
when (it) { | ||
"Not allocated" -> NotAllocatedException.Reason.DEALLOCATED | ||
else -> NotAllocatedException.Reason.PRE_ALLOCATION | ||
} | ||
) | ||
} ?: errorStatus(methodKey, response) | ||
} | ||
} | ||
} | ||
|
||
data class ErrorResponse(val message: String?) | ||
class NotAllocatedException(val reason: Reason) : Exception("POM Not Allocated: $reason") { | ||
enum class Reason { | ||
DEALLOCATED, PRE_ALLOCATION | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ class Team( | |
) { | ||
companion object { | ||
val POM_SUFFIX = "POM" | ||
val UNALLOCATED_SUFFIX = "ALL" | ||
} | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.