From 3d32d2b9df968ac7a39440226065ab76d7326eef Mon Sep 17 00:00:00 2001 From: biniek Date: Tue, 9 Oct 2018 15:05:08 +0200 Subject: correlationId is now read from userParams Change-Id: I92c6caad1370fde7daf067addbf39e45469e08aa Issue-ID: SO-1116 Signed-off-by: biniek --- .../onap/so/apihandlerinfra/ServiceInstances.java | 33 +++++++++++++--------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'mso-api-handlers') diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java index fb6076e1a4..8047893bb4 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java @@ -111,7 +111,7 @@ public class ServiceInstances { private static String NAME = "name"; private static String VALUE = "value"; private static final String SAVE_TO_DB = "save instance to db"; - + @Autowired private Environment env; @@ -738,17 +738,16 @@ public class ServiceInstances { if(sir.getNetworkInstanceId () != null){ networkId = sir.getNetworkInstanceId (); } - - if (sir.getCorrelationId() != null) { - correlationId = sir.getCorrelationId(); - } - try{ - infraActiveRequestsClient.save(currentActiveReq); - }catch(Exception e){ - ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); + + correlationId = getCorrelationId(sir); + + try{ + infraActiveRequestsClient.save(currentActiveReq); + }catch(Exception e){ + ErrorLoggerInfo errorLoggerInfo = new ErrorLoggerInfo.Builder(MessageEnum.APIH_DB_ACCESS_EXC, MsoLogger.ErrorCode.DataError).errorSource(Constants.MSO_PROP_APIHANDLER_INFRA).build(); throw new RequestDbFailureException.Builder(SAVE_TO_DB, e.toString(), HttpStatus.SC_INTERNAL_SERVER_ERROR, ErrorNumbers.SVC_DETAILED_SERVICE_ERROR).cause(e) .errorInfo(errorLoggerInfo).build(); - } + } if(!requestScope.equalsIgnoreCase(ModelType.service.name())){ aLaCarte = true; @@ -761,6 +760,14 @@ public class ServiceInstances { serviceInstanceType,vnfType, vfModuleType,networkType, apiVersion, aLaCarte, requestUri, null, requestScope, sir); } + private String getCorrelationId(ServiceInstancesRequest sir) { + return Optional.of(sir) + .map(ServiceInstancesRequest::getRequestDetails) + .map(RequestDetails::getRequestParameters) + .map(parameters -> parameters.getUserParamValue("pnfId")) + .orElse(""); + } + private String deriveRequestScope(Actions action, ServiceInstancesRequest sir, String requestUri) { if(action == Action.inPlaceSoftwareUpdate || action == Action.applyUpdatedConfig){ return (ModelType.vnf.name()); @@ -1641,9 +1648,9 @@ public class ServiceInstances { if(sir.getConfigurationId() != null){ configurationId = sir.getConfigurationId(); } - if (sir.getCorrelationId() != null) { - correlationId = sir.getCorrelationId(); - } + + correlationId = getCorrelationId(sir); + try{ infraActiveRequestsClient.save(currentActiveReq); }catch(Exception e){ -- cgit 1.2.3-korg