From fd6271c4d77df4a63d3f78562927129d74789cb0 Mon Sep 17 00:00:00 2001 From: Mathias Brunkow Moser Date: Tue, 4 Jul 2023 16:03:19 +0200 Subject: [PATCH] fix: refixed the bug related to the infinite loop --- .../productpass/http/controllers/api/ApiController.java | 5 ----- src/services/BackendService.js | 6 +++--- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/http/controllers/api/ApiController.java b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/http/controllers/api/ApiController.java index 135e34c0c..9ce588e3e 100644 --- a/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/http/controllers/api/ApiController.java +++ b/consumer-backend/productpass/src/main/java/org/eclipse/tractusx/productpass/http/controllers/api/ApiController.java @@ -161,11 +161,6 @@ public Response getPassport(@Valid @RequestBody TokenRequest tokenRequestBody) { return httpUtil.buildResponse(response, httpResponse); } - if (!status.historyExists("transfer-completed")) { - response = httpUtil.getNotFound("The passport transfer was not completed!"); - return httpUtil.buildResponse(response, httpResponse); - } - if (!status.historyExists("passport-received")) { response = httpUtil.getNotFound("The passport is not available!"); return httpUtil.buildResponse(response, httpResponse); diff --git a/src/services/BackendService.js b/src/services/BackendService.js index d09a850f2..c69b3b1be 100644 --- a/src/services/BackendService.js +++ b/src/services/BackendService.js @@ -82,7 +82,7 @@ export default class BackendService { ) } - let loopBreakStatus = ["COMPLETED", "FAILED", "DECLINED"] + let loopBreakStatus = ["COMPLETED", "FAILED", "DECLINED", "RECEIVED"] let maxRetries = API_MAX_RETRIES; let waitingTime = API_DELAY; let retries = 0; @@ -91,14 +91,14 @@ export default class BackendService { while (retries < maxRetries) { statusResponse = await this.getStatus(processId, authentication) status = jsonUtil.get("data.status", statusResponse); - if (loopBreakStatus.includes(status) || status == null || (jsonUtil.exists("history", status) && jsonUtil.exists("transfer-completed",status["history"]))) { + if (loopBreakStatus.includes(status) || status == null) { break; } await threadUtil.sleep(waitingTime); retries++; } - if (status == "COMPLETED" || (jsonUtil.exists("history", status) && jsonUtil.exists("transfer-completed",status["history"]))) { + if (status === "COMPLETED" || status === "RECEIVED" ) { return await this.retrievePassport(negotiation, authentication); }