aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForService.java4
-rw-r--r--bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsUtil.java8
-rw-r--r--common/src/main/java/org/onap/so/serviceinstancebeans/Service.java6
-rw-r--r--mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/RequestHandlerUtils.java9
4 files changed, 21 insertions, 6 deletions
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForService.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForService.java
index e8c88e00d7..4148a60433 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForService.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsForService.java
@@ -20,7 +20,7 @@
package org.onap.so.client.cds;
-import static org.onap.so.client.cds.ConfigureInstanceParamsUtil.applyParamsToObject;
+import static org.onap.so.client.cds.ConfigureInstanceParamsUtil.applyJsonParamsToObject;
import com.google.gson.JsonObject;
import java.util.List;
import java.util.Map;
@@ -49,7 +49,7 @@ public class ConfigureInstanceParamsForService {
Optional<Service> service =
extractServiceFromUserParameters.getServiceFromRequestUserParams(userParamsFromRequest);
- service.map(Service::getInstanceParams).ifPresent(p -> applyParamsToObject(p, jsonObject));
+ service.map(Service::getInstanceParams).ifPresent(p -> applyJsonParamsToObject(p, jsonObject));
} catch (Exception e) {
throw new PayloadGenerationException("Failed to resolve instance parameters", e);
}
diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsUtil.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsUtil.java
index 117fd74498..7e9c885496 100644
--- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsUtil.java
+++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/client/cds/ConfigureInstanceParamsUtil.java
@@ -20,15 +20,23 @@
package org.onap.so.client.cds;
+import com.google.gson.Gson;
import com.google.gson.JsonObject;
import java.util.List;
import java.util.Map;
public final class ConfigureInstanceParamsUtil {
+ private static final Gson gson = new Gson();
+
public static void applyParamsToObject(List<Map<String, String>> instanceParamsList, JsonObject jsonObject) {
instanceParamsList.stream().flatMap(instanceParamsMap -> instanceParamsMap.entrySet().stream())
.forEachOrdered(entry -> jsonObject.addProperty(entry.getKey(), entry.getValue()));
}
+ public static void applyJsonParamsToObject(List<Map<String, Object>> instanceParamsList, JsonObject jsonObject) {
+ instanceParamsList.stream().flatMap(instanceParamsMap -> instanceParamsMap.entrySet().stream())
+ .forEachOrdered(entry -> jsonObject.add(entry.getKey(), gson.toJsonTree(entry.getValue())));
+ }
+
}
diff --git a/common/src/main/java/org/onap/so/serviceinstancebeans/Service.java b/common/src/main/java/org/onap/so/serviceinstancebeans/Service.java
index c368f67907..3c3e10c483 100644
--- a/common/src/main/java/org/onap/so/serviceinstancebeans/Service.java
+++ b/common/src/main/java/org/onap/so/serviceinstancebeans/Service.java
@@ -42,7 +42,7 @@ public class Service implements Serializable {
@JsonProperty("instanceName")
protected String instanceName;
@JsonProperty("instanceParams")
- private List<Map<String, String>> instanceParams = new ArrayList<>();
+ private List<Map<String, Object>> instanceParams = new ArrayList<>();
@JsonProperty("resources")
protected Resources resources;
@@ -70,11 +70,11 @@ public class Service implements Serializable {
this.instanceName = instanceName;
}
- public List<Map<String, String>> getInstanceParams() {
+ public List<Map<String, Object>> getInstanceParams() {
return instanceParams;
}
- public void setInstanceParams(List<Map<String, String>> instanceParams) {
+ public void setInstanceParams(List<Map<String, Object>> instanceParams) {
this.instanceParams = instanceParams;
}
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 cddb1ada31..531d87c229 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
@@ -33,7 +33,10 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Optional;
+import java.util.Set;
+import java.util.stream.Collectors;
import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
@@ -841,7 +844,11 @@ public class RequestHandlerUtils extends AbstractRestHandler {
if (params.containsKey("service")) {
Service service = serviceMapper(params);
- addUserParams(userParams, service.getInstanceParams());
+ // Filter out non-string params for backward compatibility
+ Map<String, String> svcStrParams = service.getInstanceParams().stream().map(Map::entrySet)
+ .flatMap(Set::stream).filter(e -> e.getValue() instanceof String)
+ .collect(Collectors.toMap(Entry::getKey, e -> (String) e.getValue()));
+ userParams.putAll(svcStrParams);
for (Networks network : service.getResources().getNetworks()) {
addUserParams(userParams, network.getInstanceParams());