diff options
2 files changed, 21 insertions, 14 deletions
diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java index e89c5c7e6a..87cb481dec 100644 --- a/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java +++ b/common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java @@ -120,7 +120,7 @@ public class RequestParameters implements Serializable { public String getUserParamValue(String name){ if(userParams!=null){ for(Map<String, Object> param:userParams){ - if(param.get("name").equals(name)){ + if(param.containsKey("name") && param.get("name").equals(name) && param.containsKey("value")){ return param.get("value").toString(); } } 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){ |