From 15edb7791ddb8cc75421274fab812558219ddaf7 Mon Sep 17 00:00:00 2001 From: Krzysztof Gajewski Date: Wed, 29 Jul 2020 12:54:01 +0200 Subject: Bug fix - SO GR Api sends wrong reposnse after service instantiation Issue-ID: SO-2836 Signed-off-by: Krzysztof Gajewski Change-Id: Ib37b7972a939cd353a6cbb0370aed126534315d4 --- .../infra/rest/handler/AbstractRestHandler.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap') diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java index c806e9fc1b..fec512ac44 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/infra/rest/handler/AbstractRestHandler.java @@ -163,12 +163,14 @@ public abstract class AbstractRestHandler { try { URL aUrl = new URL(url); String aPath = aUrl.getPath(); - if (aPath.indexOf("/v") == -1) { - version = aPath.substring(aPath.indexOf("/V"), aPath.indexOf("/V") + 4); - } else { - version = aPath.substring(aPath.indexOf("/v"), aPath.indexOf("/v") + 4); - } - String selfLinkPath = Constants.ORCHESTRATION_REQUESTS_PATH.concat(version).concat(requestId); + int indexOfVersion = Math.max(aPath.indexOf("/V"), aPath.indexOf("/v")); + version = aPath.substring(indexOfVersion, indexOfVersion + 4); + + String pathWithSOAction = aPath.substring(0, indexOfVersion); + String pathWithoutSOAction = pathWithSOAction.substring(0, pathWithSOAction.lastIndexOf("/")); + + String selfLinkPath = + pathWithoutSOAction.concat(Constants.ORCHESTRATION_REQUESTS_PATH).concat(version).concat(requestId); selfLinkUrl = Optional.of(new URL(aUrl.getProtocol(), aUrl.getHost(), aUrl.getPort(), selfLinkPath)); } catch (Exception e) { selfLinkUrl = Optional.empty(); // ignore -- cgit 1.2.3-korg