aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Daugherty <rd472p@att.com>2018-10-17 13:14:04 +0000
committerGerrit Code Review <gerrit@onap.org>2018-10-17 13:14:04 +0000
commitdae0218b5134920ddbbc76be657aebcb3314e1bd (patch)
tree4f1630a0f38221663d7b05b530cfabd2df7a8403
parent15af810c48631a9dfe24ec6b39186e3797c0143b (diff)
parent3d32d2b9df968ac7a39440226065ab76d7326eef (diff)
Merge "correlationId is now read from userParams"
-rw-r--r--common/src/main/java/org/onap/so/serviceinstancebeans/RequestParameters.java2
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/ServiceInstances.java33
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){