From 3ef86f9e5ce61c5c3a8a8e426fe7ebf6a69a6326 Mon Sep 17 00:00:00 2001 From: Laurie Montant Date: Tue, 5 Mar 2024 17:03:32 +0100 Subject: [PATCH] modifs --- RFXtoRP_PlatformLogCreate.ftl | 8 +- RFXtoRP_RestResponse.ftl | 112 ++++++++++++++---------- RFXtoRP_RestResponseAllocationError.ftl | 21 +++++ 3 files changed, 93 insertions(+), 48 deletions(-) create mode 100644 RFXtoRP_RestResponseAllocationError.ftl diff --git a/RFXtoRP_PlatformLogCreate.ftl b/RFXtoRP_PlatformLogCreate.ftl index 7806150..9e657f1 100644 --- a/RFXtoRP_PlatformLogCreate.ftl +++ b/RFXtoRP_PlatformLogCreate.ftl @@ -2,9 +2,9 @@ [ <#assign UUID = UUID.randomUUID()> <#assign strJsonBody = JsonUtil.espaceQuoteInJsonString(restResponseBody)> - { + { "Header": { - "ProjectID": "${projectRP}" + "ProjectID": "${projectRP}" }, "ID": { "RefID": "${UUID}", @@ -12,7 +12,7 @@ "DateTime": "${aDateTime?iso_utc}", "AuthorTimeZone": "${time_zone_rfx}" } - }, + }, "Payload": { <#assign severity = SeverityLevel.ERROR> "Severity": "${severity}", @@ -35,7 +35,7 @@ "ContextPayload": "rfxresponse", "Type": "RP_EXECUTIONFLOW_EVENT", "Task": "${id.apiRestReflexID}", - "OriginalID": "${id.refid}", + "OriginalID": "${id.refid?trim?json_string}", "StackTrace": "" } } diff --git a/RFXtoRP_RestResponse.ftl b/RFXtoRP_RestResponse.ftl index 2b62793..01a3c9b 100644 --- a/RFXtoRP_RestResponse.ftl +++ b/RFXtoRP_RestResponse.ftl @@ -3,8 +3,8 @@ <#-- project : projectId in ReflexPlatform --> <#-- organisation : organisationtId in ReflexPlatform --> -<#assign restResponsetMsg = JsonUtil.jsonToMap(input)> -<#assign id = JsonUtil.jsonToMap(restResponsetMsg.id)> +<#assign restResponsetMsg = JsonUtil.jsonToMap(input)> +<#assign id = JsonUtil.jsonToMap(restResponsetMsg.id)> <#assign projectRP = project> <#assign organisationRP = organisation> @@ -18,91 +18,115 @@ <#case 201> <#-- *********************************************** ApiRestID = preparation_orders_post ******************** --> <#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) /> - <#assign preparationOrderPostResponse = JsonUtil.jsonToMap(restResponseBody)> - <#if preparationOrderPostResponse.status?? && preparationOrderPostResponse.status == "SUCCESS" > - [ + <#assign preparationOrderPostResponse = JsonUtil.jsonToMap(restResponseBody)> + <#if preparationOrderPostResponse.status?? && preparationOrderPostResponse.status == "SUCCESS" > + [ { - <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowShipFromAcked> + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowShipFromAcked> "apiReflexPlatformID" : "${apiReflexPlatformID}", - "datas" : - <#include "RFXtoRP_PrepOrder_ShipFromAcked.ftl"> + "datas" : + <#include "RFXtoRP_PrepOrder_ShipFromAcked.ftl"> } ] - <#else> - [ + <#else> + [ { <#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) /> - <#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate> + <#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate> "apiReflexPlatformID" : "${apiReflexPlatformID}", - "datas" : - <#include "RFXtoRP_PlatformLogCreate.ftl"> + "datas" : + <#include "RFXtoRP_PlatformLogCreate.ftl"> + }, + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowAllocationError> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_RestResponseAllocationError.ftl"> } - ] + ] - <#break> + <#break> <#default> - [ + [ { <#if restResponsetMsg.body?? > <#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) /> <#else> <#assign restResponseBody = "{}" /> - <#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate> + <#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate> "apiReflexPlatformID" : "${apiReflexPlatformID}", - "datas" : - <#include "RFXtoRP_PlatformLogCreate.ftl"> + "datas" : + <#include "RFXtoRP_PlatformLogCreate.ftl"> + }, + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowAllocationError> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_RestResponseAllocationError.ftl"> } - ] - + ] + <#break> - + <#case "receipts_post"> <#switch restResponsetMsg.status> <#case 200> <#case 201> <#-- *********************************************** ApiRestID = receipts_post ******************** --> <#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) /> - <#assign preparationOrderPostResponse = JsonUtil.jsonToMap(restResponseBody)> - <#if preparationOrderPostResponse.status?? && preparationOrderPostResponse.status == "SUCCESS" > - [ + <#assign preparationOrderPostResponse = JsonUtil.jsonToMap(restResponseBody)> + <#if preparationOrderPostResponse.status?? && preparationOrderPostResponse.status == "SUCCESS" > + [ { - <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowShipToAcked> + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowShipToAcked> "apiReflexPlatformID" : "${apiReflexPlatformID}", - "datas" : - <#include "RFXtoRP_Receipt_ShipToAcked.ftl"> + "datas" : + <#include "RFXtoRP_Receipt_ShipToAcked.ftl"> } - ] - <#else> - [ + ] + <#else> + [ { <#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) /> - <#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate> + <#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate> "apiReflexPlatformID" : "${apiReflexPlatformID}", - "datas" : - <#include "RFXtoRP_PlatformLogCreate.ftl"> - } - ] - + "datas" : + <#include "RFXtoRP_PlatformLogCreate.ftl"> + }, + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowAllocationError> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_RestResponseAllocationError.ftl"> + } + ] + <#break> <#default> - [ + [ { <#if restResponsetMsg.body?? > <#assign restResponseBody = JsonUtil.decodeBase64(restResponsetMsg.body) /> <#else> <#assign restResponseBody = "{}" /> - <#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate> + <#assign apiReflexPlatformID = ApiReflexPlatformID.PlatformLogCreate> "apiReflexPlatformID" : "${apiReflexPlatformID}", - "datas" : - <#include "RFXtoRP_PlatformLogCreate.ftl"> + "datas" : + <#include "RFXtoRP_PlatformLogCreate.ftl"> + }, + { + <#assign apiReflexPlatformID = ApiReflexPlatformID.ExecutionflowAllocationError> + "apiReflexPlatformID" : "${apiReflexPlatformID}", + "datas" : + <#include "RFXtoRP_RestResponseAllocationError.ftl"> } - ] - + ] + <#break> - + <#default> <#stop> diff --git a/RFXtoRP_RestResponseAllocationError.ftl b/RFXtoRP_RestResponseAllocationError.ftl new file mode 100644 index 0000000..f42c1d2 --- /dev/null +++ b/RFXtoRP_RestResponseAllocationError.ftl @@ -0,0 +1,21 @@ +<#include "HfRpConfig.ftl"> +<#include "ReflexUtils.ftl"> +<#assign receipt_status_datetime = RfxDateTimetoUTC(receipt.creation_datetime,time_zone_offset_rfx) /> + +[ + { + "Header": { + "ProjectID": "${projectRP}" + }, + "ID": { + "RefID": "${id.refid?trim?json_string}", + "RefDate": { + "DateTime": "${aDateTime?iso_utc}", + "AuthorTimeZone": "${time_zone_rfx}" + } + }, + + "Payload": {} + + } +]