@@ -70,26 +70,37 @@ fun main() {
70
70
} catch (e: Exception ) {
71
71
// Deal with invalid json in request
72
72
sikkerlogg.info(" Parsing incoming json request failed with exception (responding 4xx): $e " )
73
- e.printStackTrace()
74
73
SensuMetrics ().feilVedMeldingFraOebs()
75
74
call.respond(HttpStatusCode .BadRequest , " bad request: json not valid" )
76
75
return @post
77
76
}
78
77
79
- val uid = UUID .randomUUID()
80
- val opprettet = LocalDateTime .now()
78
+ if (validJson!! .incidentType != " Vedtak Infotrygd" ) {
79
+ log.info(" Mottok melding fra oebs av incidentType: ${validJson.incidentType} . Avbryter prosesseringen og returnerer" )
80
+ call.respond(HttpStatusCode .OK )
81
+ return @post
82
+ }
81
83
82
- // Publish the received json to our rapid
83
- rapidApp!! .publish(
84
- UUID .randomUUID().toString(),
85
- " {\" @id\" : \" $uid \" , \" @event_name\" : \" oebs-listener-testevent\" , \" @opprettet\" : \" $opprettet \" , \" fnrBruker\" : ${validJson?.accountNumber} \" data\" : ${
86
- Klaxon ().toJsonString(
87
- validJson
88
- )
89
- } }"
84
+ val melding = Message (
85
+ UUID .randomUUID(),
86
+ " hm-ordrelinje" ,
87
+ LocalDateTime .now(),
88
+ validJson.accountNumber,
89
+ validJson
90
90
)
91
91
92
- call.respond(HttpStatusCode .OK , " ok" )
92
+ // Publish the received json to our rapid
93
+ try {
94
+ rapidApp!! .publish(validJson.accountNumber, Klaxon ().toJsonString(melding))
95
+ SensuMetrics ().meldingTilRapidSuksess()
96
+ } catch (e: Exception ) {
97
+ SensuMetrics ().meldingTilRapidFeilet()
98
+ sikkerlogg.error(" Sending til rapid feilet, exception: $e " )
99
+ call.respond(HttpStatusCode .InternalServerError , " Feil under prosessering" )
100
+ return @post
101
+ }
102
+
103
+ call.respond(HttpStatusCode .OK )
93
104
}
94
105
}
95
106
}.build().apply {
@@ -102,6 +113,14 @@ fun main() {
102
113
logg.info(" Application ending." )
103
114
}
104
115
116
+ data class Message (
117
+ val eventId : UUID ,
118
+ val eventName : String ,
119
+ val opprettet : LocalDateTime ,
120
+ val fnrBruker : String ,
121
+ val data : Statusinfo ,
122
+ )
123
+
105
124
data class Statusinfo (
106
125
val system : String ,
107
126
@Json(name = " IncidentNummer" )
0 commit comments