From 65ca9cb2cc392dcd9793f7758d9d1fd0dd592fb7 Mon Sep 17 00:00:00 2001 From: "Plummer, Brittany" Date: Thu, 6 Jun 2019 16:02:00 -0400 Subject: resume request support copy request body rewrite requestorid added missing curly brace case to regex Updated how we are updating requestorId in requestBody Removed unused imports from RequestHandlerUtils Replaced requestorId in requestBody string Began updating requestorId in requestBody Change-Id: I54bd8097b196899b271956f03395bb98d295e1e0 Issue-ID: SO-1990 Signed-off-by: Benjamin, Max (mb388a) --- .../java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'mso-api-handlers/mso-api-handler-infra/src/main') diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java index 4e910e5382..f88d244a88 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java @@ -52,6 +52,7 @@ import org.onap.so.apihandler.common.RequestClientFactory; import org.onap.so.apihandler.common.RequestClientParameter; import org.onap.so.apihandler.common.ResponseBuilder; import org.onap.so.apihandler.common.ResponseHandler; +import org.onap.so.apihandlerinfra.TestApi; import org.onap.so.apihandlerinfra.exceptions.ApiException; import org.onap.so.apihandlerinfra.exceptions.BPMNFailureException; import org.onap.so.apihandlerinfra.exceptions.ClientConnectionException; @@ -638,7 +639,7 @@ public class RequestHandlerUtils { request.setLastModifiedBy(Constants.MODIFIED_BY_APIHANDLER); if (infraActiveRequest != null) { request.setTenantId(infraActiveRequest.getTenantId()); - request.setRequestBody(infraActiveRequest.getRequestBody()); + request.setRequestBody(updateRequestorIdInRequestBody(infraActiveRequest, requestorId)); request.setAicCloudRegion(infraActiveRequest.getAicCloudRegion()); request.setRequestScope(infraActiveRequest.getRequestScope()); request.setRequestAction(infraActiveRequest.getRequestAction()); @@ -707,4 +708,10 @@ public class RequestHandlerUtils { } } + protected String updateRequestorIdInRequestBody(InfraActiveRequests infraActiveRequest, String newRequestorId) { + String requestBody = infraActiveRequest.getRequestBody(); + return requestBody.replaceAll( + "(?s)(\"requestInfo\"\\s*?:\\s*?\\{.*?\"requestorId\"\\s*?:\\s*?\")(.*?)(\"[ ]*(?:,|\\R|\\}))", + "$1" + newRequestorId + "$3"); + } } -- cgit 1.2.3-korg