Payload attributes are not displayed in operational policy
[clamp.git] / src / main / java / org / onap / clamp / clds / client / CdsServices.java
index f25e8b8..b8eb419 100644 (file)
@@ -34,6 +34,7 @@ import java.util.Map;
 import org.apache.camel.CamelContext;\r
 import org.apache.camel.Exchange;\r
 import org.apache.camel.builder.ExchangeBuilder;\r
+import org.onap.clamp.clds.exception.cds.CdsParametersException;\r
 import org.onap.clamp.clds.model.cds.CdsBpWorkFlowListResponse;\r
 import org.onap.clamp.clds.util.JsonUtils;\r
 import org.onap.clamp.clds.util.LoggingUtils;\r
@@ -117,7 +118,7 @@ public class CdsServices {
         return null;\r
     }\r
 \r
-    private JsonObject parseCdsResponse(String response) {\r
+    protected JsonObject parseCdsResponse(String response) {\r
         JsonObject root = JsonParser.parseString(response).getAsJsonObject();\r
         JsonObject inputs = root.getAsJsonObject("workFlowData").getAsJsonObject("inputs");\r
         JsonObject dataTypes = root.getAsJsonObject("dataTypes");\r
@@ -135,6 +136,9 @@ public class CdsServices {
             String type = inputProperty.get("type").getAsString();\r
             if (isComplexType(type, dataTypes)) {\r
                 inputObject.add(key, handleComplexType(type, dataTypes));\r
+            } else if (type.equalsIgnoreCase("list")) {\r
+                inputObject.add(key, handleListType(key, inputProperty,\r
+                                                    dataTypes));\r
             } else {\r
                 inputObject.add(key, entry.getValue());\r
             }\r
@@ -142,6 +146,24 @@ public class CdsServices {
         return inputObject;\r
     }\r
 \r
+    private JsonObject handleListType(String propertyName,\r
+                                      JsonObject inputProperty,\r
+                                      JsonObject dataTypes) {\r
+        if (inputProperty.get("entry_schema") != null) {\r
+            String type = inputProperty.get("entry_schema").getAsJsonObject().get(\r
+                            "type").getAsString();\r
+            if (dataTypes.get(type) != null) {\r
+                JsonObject jsonObject = new JsonObject();\r
+                jsonObject.addProperty("type", "list");\r
+                jsonObject.add("properties", handleComplexType(type, dataTypes));\r
+                return jsonObject;\r
+            } else {\r
+                return inputProperty;\r
+            }\r
+        }\r
+        throw new CdsParametersException("Entry schema is null for " + propertyName);\r
+    }\r
+\r
     private JsonObject handleComplexType(String key, JsonObject dataTypes) {\r
         JsonObject properties = dataTypes.get(key).getAsJsonObject().get("properties").getAsJsonObject();\r
         return getInputProperties(properties, dataTypes);\r