diff --git a/RFXtoRP_PlatformLogCreate.ftl b/RFXtoRP_PlatformLogCreate.ftl index 9e657f1..f48b2b9 100644 --- a/RFXtoRP_PlatformLogCreate.ftl +++ b/RFXtoRP_PlatformLogCreate.ftl @@ -22,22 +22,21 @@ "AuthorTimeZone": "${time_zone_rfx}" }, "TechMessage": { - "Code": "${restResponsetMsg.status}", + "Code": "${restResponsetMsg.status!"no Code"}", "Label": ${strJsonBody} }, "UserMessage": { - "Code": "${restResponsetMsg.status}", + "Code": "${restResponsetMsg.status!"no Code"}", "Label": ${strJsonBody}, "Params": [] }, "DetailElements": [], - "CorrelationID": "${id.correlationid}", - "ContextPayload": "rfxresponse", + "CorrelationID": "${id.correlationid!"no Correlationid"}", + "ContextPayload": ${strJsonBody}, "Type": "RP_EXECUTIONFLOW_EVENT", - "Task": "${id.apiRestReflexID}", - "OriginalID": "${id.refid?trim?json_string}", + "Task": "${id.apiRestReflexID!"no Task"}", + "OriginalID": "${id.refid!"no OriginalID"?trim?json_string}", "StackTrace": "" } } -] - +] \ No newline at end of file diff --git a/RFXtoRP_RestResponse.ftl b/RFXtoRP_RestResponse.ftl index 69983ef..489cedb 100644 --- a/RFXtoRP_RestResponse.ftl +++ b/RFXtoRP_RestResponse.ftl @@ -4,16 +4,57 @@ <#-- organisation : organisationtId in ReflexPlatform --> <#assign restResponsetMsg = JsonUtil.jsonToMap(input)> -<#assign id = JsonUtil.jsonToMap(restResponsetMsg.id)> +<#assign id = JsonUtil.jsonToMap(restResponsetMsg.id!"{}")> <#assign projectRP = project> <#assign organisationRP = organisation> <#assign aDateTime = .now> +<#assign no_apiRestReflexID = "no apiRestReflexID"> +<#assign no_status = -99999> -<#switch id.apiRestReflexID> + +<#switch id.apiRestReflexID!no_apiRestReflexID> + <#case no_apiRestReflexID> + [ + { + <#if restResponsetMsg.body?? > + <#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) /> + <#else> + <#assign restResponseBody = "${restResponsetMsg?trim?json_string}" /> + + <#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_PlatformLogCreate.ftl"> + } + ] + <#break> + <#case "preparation_orders_post"> - <#switch restResponsetMsg.status> + <#switch restResponsetMsg.status!no_status> + <#case no_status> + [ + { + <#if restResponsetMsg.body?? > + <#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) /> + <#else> + <#assign restResponseBody = "${restResponsetMsg?trim?json_string}" /> + + <#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_PlatformLogCreate.ftl"> + }, + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowAllocationError> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_RestResponseAllocationError.ftl"> + } + ] + <#break> + <#case 200> <#case 201> <#-- *********************************************** ApiRestID = preparation_orders_post ******************** --> @@ -63,7 +104,7 @@ <#if restResponsetMsg.body?? > <#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) /> <#else> - <#assign restResponseBody = "{}" /> + <#assign restResponseBody = "${restResponsetMsg?trim?json_string}}" /> <#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate> "apiReflexPlatformID" : "${apiReflexPlatformID}", @@ -81,7 +122,29 @@ <#break> <#case "receipts_post"> - <#switch restResponsetMsg.status> + <#switch restResponsetMsg.status!no_status> + <#case no_status> + [ + { + <#if restResponsetMsg.body?? > + <#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) /> + <#else> + <#assign restResponseBody = "${restResponsetMsg?trim?json_string}" /> + + <#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_PlatformLogCreate.ftl"> + }, + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowAllocationError> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_RestResponseAllocationError.ftl"> + } + ] + <#break> + <#case 200> <#case 201> <#-- *********************************************** ApiRestID = receipts_post ******************** --> @@ -121,7 +184,7 @@ <#if restResponsetMsg.body?? > <#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) /> <#else> - <#assign restResponseBody = "{}" /> + <#assign restResponseBody = "${restResponsetMsg?trim?json_string}" /> <#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate> "apiReflexPlatformID" : "${apiReflexPlatformID}", @@ -137,7 +200,6 @@ ] <#break> - <#default> <#stop> diff --git a/RFXtoRP_RestResponseAllocationError.ftl b/RFXtoRP_RestResponseAllocationError.ftl index 56626f1..1a31357 100644 --- a/RFXtoRP_RestResponseAllocationError.ftl +++ b/RFXtoRP_RestResponseAllocationError.ftl @@ -7,7 +7,7 @@ "ProjectID": "${projectRP}" }, "ID": { - "RefID": "${id.refid?trim?json_string}", + "RefID": "${id.refid!"no RefID"?trim?json_string}", "RefDate": { "DateTime": "${aDateTime?iso_utc}", "AuthorTimeZone": "${time_zone_rfx}"