Replace jackson usages with GSON 17/77517/10
authorKrysiak Adam <adam.krysiak@nokia.com>
Tue, 29 Jan 2019 14:59:00 +0000 (15:59 +0100)
committerKrysiak Adam <adam.krysiak@nokia.com>
Wed, 6 Feb 2019 10:55:09 +0000 (11:55 +0100)
Issue-ID: CLAMP-286
Change-Id: I3492811e248cbcf502656a992cea4f76deed46dc
Signed-off-by: Krysiak Adam <adam.krysiak@nokia.com>
51 files changed:
pom.xml
src/main/java/org/onap/clamp/clds/client/DcaeDispatcherServices.java
src/main/java/org/onap/clamp/clds/client/DcaeInventoryServices.java
src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java
src/main/java/org/onap/clamp/clds/client/req/sdc/SdcRequests.java
src/main/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatter.java
src/main/java/org/onap/clamp/clds/config/ClampProperties.java
src/main/java/org/onap/clamp/clds/config/CldsUserJsonDecoder.java
src/main/java/org/onap/clamp/clds/config/sdc/BlueprintParserMappingConfiguration.java
src/main/java/org/onap/clamp/clds/config/sdc/SdcControllersConfiguration.java
src/main/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfiguration.java
src/main/java/org/onap/clamp/clds/model/CldsModelInstance.java
src/main/java/org/onap/clamp/clds/model/actions/ActionsHandler.java
src/main/java/org/onap/clamp/clds/model/properties/AbstractModelElement.java
src/main/java/org/onap/clamp/clds/model/properties/Global.java
src/main/java/org/onap/clamp/clds/model/properties/Holmes.java
src/main/java/org/onap/clamp/clds/model/properties/ModelBpmn.java
src/main/java/org/onap/clamp/clds/model/properties/ModelProperties.java
src/main/java/org/onap/clamp/clds/model/properties/Policy.java
src/main/java/org/onap/clamp/clds/model/properties/PolicyChain.java
src/main/java/org/onap/clamp/clds/model/properties/PolicyItem.java
src/main/java/org/onap/clamp/clds/model/properties/Tca.java
src/main/java/org/onap/clamp/clds/model/properties/TcaItem.java
src/main/java/org/onap/clamp/clds/model/properties/TcaThreshold.java
src/main/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImpl.java
src/main/java/org/onap/clamp/clds/service/CldsService.java
src/main/java/org/onap/clamp/clds/service/CldsUser.java
src/main/java/org/onap/clamp/clds/service/SecureServicePermissionDeserializer.java [moved from src/main/java/org/onap/clamp/clds/service/JacksonObjectMapperProvider.java with 56% similarity]
src/main/java/org/onap/clamp/clds/util/JacksonUtils.java [deleted file]
src/main/java/org/onap/clamp/clds/util/JsonUtils.java [new file with mode: 0644]
src/main/resources/application.properties
src/test/java/org/onap/clamp/clds/client/DcaeDispatcherServicesTest.java
src/test/java/org/onap/clamp/clds/client/req/policy/GuardPolicyAttributesConstructorTest.java
src/test/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyAttributesConstructorTest.java
src/test/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatterTest.java [new file with mode: 0644]
src/test/java/org/onap/clamp/clds/config/CldsUserJsonDecoderTest.java
src/test/java/org/onap/clamp/clds/config/sdc/SdcSingleControllerConfigurationTest.java
src/test/java/org/onap/clamp/clds/it/CldsServiceItCase.java
src/test/java/org/onap/clamp/clds/it/DcaeHttpConnectionManagerItCase.java
src/test/java/org/onap/clamp/clds/it/PolicyClientItCase.java
src/test/java/org/onap/clamp/clds/it/config/CldsReferencePropertiesItCase.java
src/test/java/org/onap/clamp/clds/it/config/SdcControllersConfigurationItCase.java
src/test/java/org/onap/clamp/clds/it/sdc/controller/SdcSingleControllerItCase.java
src/test/java/org/onap/clamp/clds/model/prop/CustomModelElement.java
src/test/java/org/onap/clamp/clds/model/prop/ModelPropertiesTest.java
src/test/java/org/onap/clamp/clds/model/sdc/SdcResourceBasicInfoTest.java
src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImplTest.java [new file with mode: 0644]
src/test/java/org/onap/clamp/clds/util/JacksonUtilsTest.java [deleted file]
src/test/java/org/onap/clamp/clds/util/JsonUtilsTest.java [new file with mode: 0644]
src/test/resources/example/model-properties/custom/modelBpmnPropertiesMultiVF.json [new file with mode: 0644]
src/test/resources/tosca/dcea_blueprint.yml [new file with mode: 0644]

diff --git a/pom.xml b/pom.xml
index 297b0a1..6a2d273 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -66,7 +66,7 @@
                                <eelf.core.version>1.0.0</eelf.core.version>
                                <camel.version>2.22.1</camel.version>
                                <springboot.version>2.0.6.RELEASE</springboot.version>
-                               
+
                                <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
                                <sonar.surefire.reportsPath>${project.build.directory}/surefire-reports</sonar.surefire.reportsPath>
                                <sonar.jacoco.reportPath>${project.build.directory}/coverage-reports/jacoco.exec</sonar.jacoco.reportPath>
@@ -75,7 +75,7 @@
                                <sonar.projectVersion>${project.version}</sonar.projectVersion>
                                <!-- Enable language to disable javascript analysis -->
                                <sonar.language>java</sonar.language>
-                               <!-- Parameters for Javascript coverage 
+                               <!-- Parameters for Javascript coverage
                                        <sonar.sources>src/main,${project.build.directory}/clamp-ui/designer</sonar.sources>
                                        <sonar.javascript.lcov.reportPaths>${project.build.directory}/clamp-ui/coverage/lcov.info</sonar.javascript.lcov.reportPaths>
                                 -->
                                                <artifactId>camel-servlet-starter</artifactId>
                                </dependency>
                                <dependency>
-                                       <groupId>org.apache.camel</groupId> 
+                                       <groupId>org.apache.camel</groupId>
                                        <artifactId>camel-jackson-starter</artifactId>
                                </dependency>
                                <dependency>
                                <dependency>
                                                <groupId>org.springframework.boot</groupId>
                                                <artifactId>spring-boot-starter-web</artifactId>
+                                               <exclusions>
+                                                       <exclusion>
+                                                               <groupId>org.springframework.boot</groupId>
+                                                               <artifactId>spring-boot-starter-json</artifactId>
+                                                               </exclusion>
+                                               </exclusions>
                                </dependency>
                                <dependency>
                                                <groupId>org.springframework.boot</groupId>
                                                                                <groupId>org.onap.policy.common</groupId>
                                                                                <artifactId>integrity-audit</artifactId>
                                                                </exclusion>
+                                                               <exclusion>
+                                                                       <groupId>com.fasterxml.jackson.core</groupId>
+                                                                       <artifactId>jackson-databind</artifactId>
+                                                               </exclusion>
                                                                <exclusion>
                                                                                <groupId>org.onap.aaf.cadi</groupId>
                                                                                <artifactId>cadi-aaf</artifactId>
                                                <groupId>org.onap.sdc.sdc-tosca</groupId>
                                                <artifactId>sdc-tosca</artifactId>
                                                <version>1.4.1</version>
+                                               <exclusions>
+                                                       <exclusion>
+                                                               <groupId>com.fasterxml.jackson.core</groupId>
+                                                               <artifactId>jackson-databind</artifactId>
+                                                       </exclusion>
+                                               </exclusions>
                                </dependency>
                                <!-- TESTING -->
                                <dependency>
                                                </testResource>
                                </testResources>
                                <resources>
-                                               <!--  For AAF folder maven should not try to filter Keystores/Truststores ... 
+                                               <!--  For AAF folder maven should not try to filter Keystores/Truststores ...
                                                          Otherwise they will be broken and unreadable
                                                -->
                                                <resource>
                                                                </execution>
                                                        </executions>
                                                </plugin>
-                                               <!-- Read the swagger.json file and the definition from SwaggerConfig.java; 
-                                                       generate a list of .adoc files containing the APIs info in more structured 
+                                               <!-- Read the swagger.json file and the definition from SwaggerConfig.java;
+                                                       generate a list of .adoc files containing the APIs info in more structured
                                                        way -->
                                                <plugin>
                                                                <groupId>io.github.swagger2markup</groupId>
                                                                </executions>
                                                </plugin>
 
-                                               <!-- Run the generated asciidoc through Asciidoctor to generate other 
+                                               <!-- Run the generated asciidoc through Asciidoctor to generate other
                                                                documentation types, such as PDFs or HTML5 -->
                                                <plugin>
                                                                <groupId>org.asciidoctor</groupId>
                                                                                                                                                <tag>${project.docker.latesttagtimestamp.version}</tag>
                                                                                                                                                <tag>${project.docker.latesttag.version}</tag>
                                                                                                                                </tags>
-                                                                                                                               <!-- A relative path is looked up in ${project.basedir}/src/main/docker 
+                                                                                                                               <!-- A relative path is looked up in ${project.basedir}/src/main/docker
                                                                                                                                                by default -->
                                                                                                                                <dockerFile>Dockerfile</dockerFile>
                                                                                                                                <assembly>
index 4151c7a..6845452 100644 (file)
@@ -25,9 +25,8 @@ package org.onap.clamp.clds.client;
 \r
 import com.att.eelf.configuration.EELFLogger;\r
 import com.att.eelf.configuration.EELFManager;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
 \r
+import com.google.gson.JsonObject;\r
 import java.io.IOException;\r
 import java.util.Date;\r
 \r
@@ -122,16 +121,16 @@ public class DcaeDispatcherServices {
      *        The value for each blueprint parameters in a flat JSON\r
      * @return The status URL\r
      */\r
-    public String createNewDeployment(String deploymentId, String serviceTypeId, JsonNode blueprintInputJson) {\r
+    public String createNewDeployment(String deploymentId, String serviceTypeId, JsonObject blueprintInputJson) {\r
         Date startTime = new Date();\r
         LoggingUtils.setTargetContext("DCAE", "createNewDeployment");\r
         try {\r
-            ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("dcae.deployment.template");\r
-            rootNode.put("serviceTypeId", serviceTypeId);\r
+            JsonObject rootObject = refProp.getJsonTemplate("dcae.deployment.template").getAsJsonObject();\r
+            rootObject.addProperty("serviceTypeId", serviceTypeId);\r
             if (blueprintInputJson != null) {\r
-                rootNode.set("inputs", blueprintInputJson);\r
+                rootObject.add("inputs", blueprintInputJson);\r
             }\r
-            String apiBodyString = rootNode.toString();\r
+            String apiBodyString = rootObject.toString();\r
             logger.info("Dcae api Body String - " + apiBodyString);\r
             String url = refProp.getStringValue(DCAE_URL_PROPERTY_NAME) + DCAE_URL_PREFIX + deploymentId;\r
             String statusUrl = getDcaeResponse(url, "PUT", apiBodyString, "application/json", DCAE_LINK_FIELD,\r
index 327aff1..7702307 100644 (file)
@@ -44,7 +44,7 @@ import org.onap.clamp.clds.model.DcaeEvent;
 import org.onap.clamp.clds.model.dcae.DcaeInventoryResponse;\r
 import org.onap.clamp.clds.model.properties.Global;\r
 import org.onap.clamp.clds.model.properties.ModelProperties;\r
-import org.onap.clamp.clds.util.JacksonUtils;\r
+import org.onap.clamp.clds.util.JsonUtils;\r
 import org.onap.clamp.clds.util.LoggingUtils;\r
 import org.springframework.beans.factory.annotation.Autowired;\r
 import org.springframework.stereotype.Component;\r
@@ -155,14 +155,13 @@ public class DcaeInventoryServices {
     }\r
 \r
     private DcaeInventoryResponse getItemsFromDcaeInventoryResponse(String responseStr)\r
-        throws ParseException, IOException {\r
+        throws ParseException {\r
         JSONParser parser = new JSONParser();\r
         Object obj0 = parser.parse(responseStr);\r
         JSONObject jsonObj = (JSONObject) obj0;\r
         JSONArray itemsArray = (JSONArray) jsonObj.get("items");\r
         JSONObject dcaeServiceType0 = (JSONObject) itemsArray.get(0);\r
-        return JacksonUtils.getObjectMapperInstance().readValue(dcaeServiceType0.toString(),\r
-            DcaeInventoryResponse.class);\r
+        return JsonUtils.GSON.fromJson(dcaeServiceType0.toString(), DcaeInventoryResponse.class);\r
     }\r
 \r
     /**\r
index cd7d4f2..37c6257 100644 (file)
@@ -26,18 +26,19 @@ package org.onap.clamp.clds.client.req.sdc;
 \r
 import com.att.eelf.configuration.EELFLogger;\r
 import com.att.eelf.configuration.EELFManager;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-import com.fasterxml.jackson.databind.node.ArrayNode;\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-import com.fasterxml.jackson.databind.node.TextNode;\r
 \r
+import com.google.gson.JsonArray;\r
+import com.google.gson.JsonElement;\r
+import com.google.gson.JsonObject;\r
+import com.google.gson.JsonParseException;\r
+import com.google.gson.reflect.TypeToken;\r
 import java.io.BufferedReader;\r
 import java.io.IOException;\r
 import java.io.InputStream;\r
 import java.io.InputStreamReader;\r
 import java.io.Reader;\r
 import java.io.StringReader;\r
+import java.lang.reflect.Type;\r
 import java.net.HttpURLConnection;\r
 import java.net.URL;\r
 import java.nio.charset.StandardCharsets;\r
@@ -68,7 +69,7 @@ import org.onap.clamp.clds.model.sdc.SdcServiceDetail;
 import org.onap.clamp.clds.model.sdc.SdcServiceInfo;\r
 import org.onap.clamp.clds.service.CldsService;\r
 import org.onap.clamp.clds.util.CryptoUtils;\r
-import org.onap.clamp.clds.util.JacksonUtils;\r
+import org.onap.clamp.clds.util.JsonUtils;\r
 import org.onap.clamp.clds.util.LoggingUtils;\r
 import org.springframework.beans.factory.annotation.Autowired;\r
 import org.springframework.context.annotation.Primary;\r
@@ -80,17 +81,24 @@ public class SdcCatalogServices {
 \r
     private static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcCatalogServices.class);\r
     private static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();\r
-    public static final String RESOURCE_VF_TYPE = "VF";\r
-    public static final String RESOURCE_VFC_TYPE = "VFC";\r
-    public static final String RESOURCE_CVFC_TYPE = "CVFC";\r
-    public static final String SDC_REQUESTID_PROPERTY_NAME = "sdc.header.requestId";\r
-    public static final String SDC_METADATA_URL_PREFIX = "/metadata";\r
-    public static final String SDC_INSTANCE_ID_PROPERTY_NAME = "sdc.InstanceID";\r
-    public static final String SDC_CATALOG_URL_PROPERTY_NAME = "sdc.catalog.url";\r
-    public static final String SDC_SERVICE_URL_PROPERTY_NAME = "sdc.serviceUrl";\r
-    public static final String SDC_INSTANCE_ID_CLAMP = "CLAMP-Tool";\r
-    public static final String RESOURCE_URL_PREFIX = "resources";\r
+    private static final String RESOURCE_VF_TYPE = "VF";\r
+    private static final String RESOURCE_VFC_TYPE = "VFC";\r
+    private static final String RESOURCE_CVFC_TYPE = "CVFC";\r
+    private static final String SDC_REQUESTID_PROPERTY_NAME = "sdc.header.requestId";\r
+    private static final String SDC_METADATA_URL_PREFIX = "/metadata";\r
+    private static final String SDC_INSTANCE_ID_PROPERTY_NAME = "sdc.InstanceID";\r
+    private static final String SDC_CATALOG_URL_PROPERTY_NAME = "sdc.catalog.url";\r
+    private static final String SDC_SERVICE_URL_PROPERTY_NAME = "sdc.serviceUrl";\r
+    private static final String SDC_INSTANCE_ID_CLAMP = "CLAMP-Tool";\r
+    private static final String RESOURCE_URL_PREFIX = "resources";\r
     private static final LoggingUtils utils = new LoggingUtils(logger);\r
+\r
+    private static final Type LIST_SDC_SERVICE_INFO_TYPE = new TypeToken<List<SdcServiceInfo>>() {\r
+    }.getType();\r
+\r
+    private static final Type LIST_SDC_RESOURCE_BASIC_INFO_TYPE = new TypeToken<List<SdcResourceBasicInfo>>() {\r
+    }.getType();\r
+\r
     @Autowired\r
     private ClampProperties refProp;\r
 \r
@@ -285,9 +293,8 @@ public class SdcCatalogServices {
             return new ArrayList<>();\r
         }\r
         try {\r
-            return JacksonUtils.getObjectMapperInstance().readValue(jsonStr, JacksonUtils.getObjectMapperInstance()\r
-                .getTypeFactory().constructCollectionType(List.class, SdcServiceInfo.class));\r
-        } catch (IOException e) {\r
+            return JsonUtils.GSON.fromJson(jsonStr, LIST_SDC_SERVICE_INFO_TYPE);\r
+        } catch (JsonParseException e) {\r
             logger.error("Error when attempting to decode the JSON containing CldsSdcServiceInfo", e);\r
             return new ArrayList<>();\r
         }\r
@@ -305,9 +312,8 @@ public class SdcCatalogServices {
             return new ArrayList<>();\r
         }\r
         try {\r
-            return JacksonUtils.getObjectMapperInstance().readValue(jsonStr, JacksonUtils.getObjectMapperInstance()\r
-                .getTypeFactory().constructCollectionType(List.class, SdcResourceBasicInfo.class));\r
-        } catch (IOException e) {\r
+            return JsonUtils.GSON.fromJson(jsonStr, LIST_SDC_RESOURCE_BASIC_INFO_TYPE);\r
+        } catch (JsonParseException e) {\r
             logger.error("Exception occurred when attempting to decode the list of CldsSdcResourceBasicInfo JSON", e);\r
             return new ArrayList<>();\r
         }\r
@@ -321,8 +327,8 @@ public class SdcCatalogServices {
      */\r
     public SdcServiceDetail decodeCldsSdcServiceDetailFromJson(String jsonStr) {\r
         try {\r
-            return JacksonUtils.getObjectMapperInstance().readValue(jsonStr, SdcServiceDetail.class);\r
-        } catch (IOException e) {\r
+            return JsonUtils.GSON.fromJson(jsonStr, SdcServiceDetail.class);\r
+        } catch (JsonParseException e) {\r
             logger.error("Exception when attempting to decode the CldsSdcServiceDetail JSON", e);\r
             return null;\r
         }\r
@@ -402,9 +408,8 @@ public class SdcCatalogServices {
         if (responseStr != null) {\r
             SdcServiceDetail cldsSdcServiceDetail;\r
             try {\r
-                cldsSdcServiceDetail = JacksonUtils.getObjectMapperInstance().readValue(responseStr,\r
-                    SdcServiceDetail.class);\r
-            } catch (IOException e) {\r
+                cldsSdcServiceDetail = JsonUtils.GSON.fromJson(responseStr, SdcServiceDetail.class);\r
+            } catch (JsonParseException e) {\r
                 logger.error("Exception when decoding the CldsServiceData JSON from SDC", e);\r
                 throw new SdcCommunicationException("Exception when decoding the CldsServiceData JSON from SDC", e);\r
             }\r
@@ -497,41 +502,43 @@ public class SdcCatalogServices {
     }\r
 \r
     private List<CldsVfcData> getVfcDataListFromVfResponse(String vfResponse) {\r
-        ObjectNode vfResponseNode;\r
+        JsonObject vfResponseNode;\r
         try {\r
-            vfResponseNode = (ObjectNode) JacksonUtils.getObjectMapperInstance().readTree(vfResponse);\r
-        } catch (IOException e) {\r
+            vfResponseNode = JsonUtils.GSON.fromJson(vfResponse, JsonObject.class);\r
+        } catch (JsonParseException e) {\r
             logger.error("Exception when decoding the JSON list of CldsVfcData", e);\r
             return new ArrayList<>();\r
         }\r
-        ArrayNode vfcArrayNode = (ArrayNode) vfResponseNode.get("resources");\r
+        JsonArray vfcArrayNode = vfResponseNode.get("resources").getAsJsonArray();\r
         List<CldsVfcData> cldsVfcDataList = new ArrayList<>();\r
         if (vfcArrayNode != null) {\r
-            for (JsonNode vfcjsonNode : vfcArrayNode) {\r
-                ObjectNode currVfcNode = (ObjectNode) vfcjsonNode;\r
-                TextNode resourceTypeNode = (TextNode) currVfcNode.get("resoucreType");\r
-                if (resourceTypeNode != null && "VFC".equalsIgnoreCase(resourceTypeNode.textValue())) {\r
-                    handleVFCtypeNode(currVfcNode, cldsVfcDataList);\r
-                } else if (resourceTypeNode != null && "CVFC".equalsIgnoreCase(resourceTypeNode.textValue())) {\r
-                    handleCVFCtypeNode(currVfcNode, cldsVfcDataList);\r
+            for (JsonElement vfcjsonNode : vfcArrayNode) {\r
+                JsonObject currVfcNode = vfcjsonNode.getAsJsonObject();\r
+                JsonElement resourceTypeNode = currVfcNode.get("resoucreType");\r
+                if (resourceTypeNode != null && resourceTypeNode.isJsonPrimitive()) {\r
+                    if ("VFC".equalsIgnoreCase(resourceTypeNode.getAsString())) {\r
+                        handleVFCtypeNode(currVfcNode, cldsVfcDataList);\r
+                    } else if ("CVFC".equalsIgnoreCase(resourceTypeNode.getAsString())) {\r
+                        handleCVFCtypeNode(currVfcNode, cldsVfcDataList);\r
+                    }\r
                 }\r
             }\r
         }\r
         return cldsVfcDataList;\r
     }\r
 \r
-    private void handleVFCtypeNode(ObjectNode currVfcNode, List<CldsVfcData> cldsVfcDataList) {\r
+    private void handleVFCtypeNode(JsonObject currVfcNode, List<CldsVfcData> cldsVfcDataList) {\r
         CldsVfcData currCldsVfcData = new CldsVfcData();\r
-        TextNode vfcResourceName = (TextNode) currVfcNode.get("resourceInstanceName");\r
-        TextNode vfcInvariantResourceUuid = (TextNode) currVfcNode.get("resourceInvariantUUID");\r
-        currCldsVfcData.setVfcName(vfcResourceName.textValue());\r
-        currCldsVfcData.setVfcInvariantResourceUUID(vfcInvariantResourceUuid.textValue());\r
+        String vfcResourceName = currVfcNode.get("resourceInstanceName").getAsString();\r
+        String vfcInvariantResourceUuid = currVfcNode.get("resourceInvariantUUID").getAsString();\r
+        currCldsVfcData.setVfcName(vfcResourceName);\r
+        currCldsVfcData.setVfcInvariantResourceUUID(vfcInvariantResourceUuid);\r
         cldsVfcDataList.add(currCldsVfcData);\r
     }\r
 \r
-    private void handleCVFCtypeNode(ObjectNode currVfcNode, List<CldsVfcData> cldsVfcDataList) {\r
+    private void handleCVFCtypeNode(JsonObject currVfcNode, List<CldsVfcData> cldsVfcDataList) {\r
         handleVFCtypeNode(currVfcNode, cldsVfcDataList);\r
-        cldsVfcDataList.addAll(getVFCfromCVFC(currVfcNode.get("resourceUUID").textValue()));\r
+        cldsVfcDataList.addAll(getVFCfromCVFC(currVfcNode.get("resourceUUID").getAsString()));\r
     }\r
 \r
     private List<CldsVfcData> getVFCfromCVFC(String resourceUUID) {\r
@@ -541,18 +548,18 @@ public class SdcCatalogServices {
             String vfcResourceUUIDUrl = catalogUrl + RESOURCE_URL_PREFIX + "/" + resourceUUID + SDC_METADATA_URL_PREFIX;\r
             try {\r
                 String vfcResponse = getCldsServicesOrResourcesBasedOnURL(vfcResourceUUIDUrl);\r
-                ObjectNode vfResponseNode = (ObjectNode) JacksonUtils.getObjectMapperInstance().readTree(vfcResponse);\r
-                ArrayNode vfcArrayNode = (ArrayNode) vfResponseNode.get("resources");\r
+                JsonObject vfResponseNode = JsonUtils.GSON.fromJson(vfcResponse, JsonObject.class);\r
+                JsonArray vfcArrayNode = vfResponseNode.get("resources").getAsJsonArray();\r
                 if (vfcArrayNode != null) {\r
-                    for (JsonNode vfcjsonNode : vfcArrayNode) {\r
-                        ObjectNode currVfcNode = (ObjectNode) vfcjsonNode;\r
-                        TextNode resourceTypeNode = (TextNode) currVfcNode.get("resoucreType");\r
-                        if (resourceTypeNode != null && "VFC".equalsIgnoreCase(resourceTypeNode.textValue())) {\r
+                    for (JsonElement vfcjsonNode : vfcArrayNode) {\r
+                        JsonObject currVfcNode = vfcjsonNode.getAsJsonObject();\r
+                        JsonElement resourceTypeNode = currVfcNode.get("resoucreType");\r
+                        if (resourceTypeNode != null && resourceTypeNode.isJsonPrimitive() && "VFC".equalsIgnoreCase(resourceTypeNode.getAsString())) {\r
                             handleVFCtypeNode(currVfcNode, cldsVfcDataList);\r
                         }\r
                     }\r
                 }\r
-            } catch (IOException e) {\r
+            } catch (JsonParseException e) {\r
                 logger.error("Exception during JSON analyzis", e);\r
             }\r
         }\r
@@ -565,20 +572,21 @@ public class SdcCatalogServices {
 \r
     private List<CldsAlarmCondition> getAlarmCondtionsFromVfc(String vfcResponse) throws GeneralSecurityException {\r
         List<CldsAlarmCondition> cldsAlarmConditionList = new ArrayList<>();\r
-        ObjectNode vfcResponseNode;\r
+        JsonObject vfcResponseNode;\r
         try {\r
-            vfcResponseNode = (ObjectNode) JacksonUtils.getObjectMapperInstance().readTree(vfcResponse);\r
-        } catch (IOException e) {\r
+            vfcResponseNode = JsonUtils.GSON.fromJson(vfcResponse, JsonObject.class);\r
+        } catch (JsonParseException e) {\r
             logger.error("Exception when decoding the JSON list of CldsAlarmCondition", e);\r
             return cldsAlarmConditionList;\r
         }\r
-        ArrayNode artifactsArrayNode = (ArrayNode) vfcResponseNode.get("artifacts");\r
-        if (artifactsArrayNode != null && artifactsArrayNode.size() > 0) {\r
-            for (int index = 0; index < artifactsArrayNode.size(); index++) {\r
-                ObjectNode currArtifactNode = (ObjectNode) artifactsArrayNode.get(index);\r
-                TextNode artifactUrlNode = (TextNode) currArtifactNode.get("artifactURL");\r
-                if (artifactUrlNode != null) {\r
-                    String responsesFromArtifactUrl = getResponsesFromArtifactUrl(artifactUrlNode.textValue());\r
+        JsonElement artifactsNode = vfcResponseNode.get("artifacts");\r
+        if (artifactsNode != null && artifactsNode.isJsonArray() && artifactsNode.getAsJsonArray().size() > 0) {\r
+            JsonArray artifactsList = artifactsNode.getAsJsonArray();\r
+            for (int index = 0; index < artifactsList.size(); index++) {\r
+                JsonObject currArtifactNode = artifactsList.get(index).getAsJsonObject();\r
+                JsonElement artifactUrlNode = currArtifactNode.get("artifactURL");\r
+                if (artifactUrlNode != null && artifactUrlNode.isJsonPrimitive()) {\r
+                    String responsesFromArtifactUrl = getResponsesFromArtifactUrl(artifactUrlNode.getAsString());\r
                     cldsAlarmConditionList.addAll(parseCsvToGetAlarmConditions(responsesFromArtifactUrl));\r
                     logger.info(responsesFromArtifactUrl);\r
                 }\r
@@ -609,26 +617,26 @@ public class SdcCatalogServices {
     // Method to get the artifact for any particular VF\r
     private List<CldsVfKPIData> getFieldPathFromVF(String vfResponse) throws GeneralSecurityException {\r
         List<CldsVfKPIData> cldsVfKPIDataList = new ArrayList<>();\r
-        ObjectNode vfResponseNode;\r
+        JsonObject vfResponseNode;\r
         try {\r
-            vfResponseNode = (ObjectNode) JacksonUtils.getObjectMapperInstance().readTree(vfResponse);\r
-        } catch (IOException e) {\r
+            vfResponseNode = JsonUtils.GSON.fromJson(vfResponse, JsonObject.class);\r
+        } catch (JsonParseException e) {\r
             logger.error("Exception when decoding the JSON list of CldsVfKPIData", e);\r
             return cldsVfKPIDataList;\r
         }\r
-        ArrayNode artifactsArrayNode = (ArrayNode) vfResponseNode.get("artifacts");\r
+        JsonArray artifactsArrayNode = vfResponseNode.get("artifacts").getAsJsonArray();\r
         if (artifactsArrayNode != null && artifactsArrayNode.size() > 0) {\r
             for (int index = 0; index < artifactsArrayNode.size(); index++) {\r
-                ObjectNode currArtifactNode = (ObjectNode) artifactsArrayNode.get(index);\r
-                TextNode artifactUrlNode = (TextNode) currArtifactNode.get("artifactURL");\r
-                TextNode artifactNameNode = (TextNode) currArtifactNode.get("artifactName");\r
+                JsonObject currArtifactNode = artifactsArrayNode.get(index).getAsJsonObject();\r
+                JsonElement artifactUrlNode = currArtifactNode.get("artifactURL");\r
+                JsonElement artifactNameNode = currArtifactNode.get("artifactName");\r
                 String artifactName = "";\r
                 if (artifactNameNode != null) {\r
-                    artifactName = artifactNameNode.textValue();\r
+                    artifactName = artifactNameNode.getAsString();\r
                     artifactName = artifactName.substring(artifactName.lastIndexOf('.') + 1);\r
                 }\r
                 if (artifactUrlNode != null && "csv".equalsIgnoreCase(artifactName)) {\r
-                    String responsesFromArtifactUrl = getResponsesFromArtifactUrl(artifactUrlNode.textValue());\r
+                    String responsesFromArtifactUrl = getResponsesFromArtifactUrl(artifactUrlNode.getAsString());\r
                     cldsVfKPIDataList.addAll(parseCsvToGetFieldPath(responsesFromArtifactUrl));\r
                     logger.info(responsesFromArtifactUrl);\r
                 }\r
@@ -760,37 +768,32 @@ public class SdcCatalogServices {
     /**\r
      * To create properties object by using cldsServicedata.\r
      *\r
-     * @param globalProps\r
-     * @param cldsServiceData\r
-     * @return\r
-     * @throws IOException\r
-     *         In case of issues during the parsing of the Global Properties\r
+     * @throws IOException In case of issues during the parsing of the Global Properties\r
      */\r
     public String createPropertiesObjectByUUID(CldsServiceData cldsServiceData) throws IOException {\r
         String totalPropsStr;\r
-        ObjectMapper mapper = JacksonUtils.getObjectMapperInstance();\r
-        ObjectNode globalPropsJson = (ObjectNode) refProp.getJsonTemplate(CldsService.GLOBAL_PROPERTIES_KEY);\r
+        JsonObject globalPropsJson = refProp.getJsonTemplate(CldsService.GLOBAL_PROPERTIES_KEY).getAsJsonObject();\r
         if (cldsServiceData != null && cldsServiceData.getServiceUUID() != null) {\r
             // Objectnode to save all byservice, byvf , byvfc and byalarm nodes\r
-            ObjectNode byIdObjectNode = mapper.createObjectNode();\r
+            JsonObject byIdObjectNode = new JsonObject();\r
             // To create vf ResourceUUID node with serviceInvariantUUID\r
-            ObjectNode invariantUuidObjectNodeWithVf = createVfObjectNodeByServiceInvariantUuid(cldsServiceData);\r
-            byIdObjectNode.putPOJO("byService", invariantUuidObjectNodeWithVf);\r
+            JsonObject invariantUuidObjectNodeWithVf = createVfObjectNodeByServiceInvariantUuid(cldsServiceData);\r
+            byIdObjectNode.add("byService", invariantUuidObjectNodeWithVf);\r
             // To create byVf and vfcResourceNode with vfResourceUUID\r
-            ObjectNode vfcObjectNodeByVfUuid = createVfcObjectNodeByVfUuid(cldsServiceData.getCldsVfs());\r
-            byIdObjectNode.putPOJO("byVf", vfcObjectNodeByVfUuid);\r
+            JsonObject vfcObjectNodeByVfUuid = createVfcObjectNodeByVfUuid(cldsServiceData.getCldsVfs());\r
+            byIdObjectNode.add("byVf", vfcObjectNodeByVfUuid);\r
             // To create byKpi\r
-            ObjectNode kpiObjectNode = mapper.createObjectNode();\r
+            JsonObject kpiJsonObject = new JsonObject();\r
             if (cldsServiceData.getCldsVfs() != null && !cldsServiceData.getCldsVfs().isEmpty()) {\r
                 for (CldsVfData currCldsVfData : cldsServiceData.getCldsVfs()) {\r
                     if (currCldsVfData != null) {\r
-                        createKpiObjectNodeByVfUuid(kpiObjectNode, currCldsVfData.getCldsKPIList());\r
+                        createKpiObjectNodeByVfUuid(kpiJsonObject, currCldsVfData.getCldsKPIList());\r
                     }\r
                 }\r
             }\r
-            byIdObjectNode.putPOJO("byKpi", kpiObjectNode);\r
+            byIdObjectNode.add("byKpi", kpiJsonObject);\r
             // To create byVfc and alarmCondition with vfcResourceUUID\r
-            ObjectNode vfcResourceUuidObjectNode = mapper.createObjectNode();\r
+            JsonObject vfcResourceUuidObjectNode = new JsonObject();\r
             if (cldsServiceData.getCldsVfs() != null && !cldsServiceData.getCldsVfs().isEmpty()) {\r
                 for (CldsVfData currCldsVfData : cldsServiceData.getCldsVfs()) {\r
                     if (currCldsVfData != null) {\r
@@ -798,18 +801,18 @@ public class SdcCatalogServices {
                     }\r
                 }\r
             }\r
-            byIdObjectNode.putPOJO("byVfc", vfcResourceUuidObjectNode);\r
+            byIdObjectNode.add("byVfc", vfcResourceUuidObjectNode);\r
             // To create byAlarmCondition with alarmConditionKey\r
             List<CldsAlarmCondition> allAlarmConditions = getAllAlarmConditionsFromCldsServiceData(cldsServiceData,\r
                 "alarmCondition");\r
-            ObjectNode alarmCondObjectNodeByAlarmKey = createAlarmCondObjectNodeByAlarmKey(allAlarmConditions);\r
-            byIdObjectNode.putPOJO("byAlarmCondition", alarmCondObjectNodeByAlarmKey);\r
+            JsonObject alarmCondObjectNodeByAlarmKey = createAlarmCondObjectNodeByAlarmKey(allAlarmConditions);\r
+            byIdObjectNode.add("byAlarmCondition", alarmCondObjectNodeByAlarmKey);\r
             // To create byAlertDescription with AlertDescription\r
             List<CldsAlarmCondition> allAlertDescriptions = getAllAlarmConditionsFromCldsServiceData(cldsServiceData,\r
                 "alertDescription");\r
-            ObjectNode alertDescObjectNodeByAlert = createAlarmCondObjectNodeByAlarmKey(allAlertDescriptions);\r
-            byIdObjectNode.putPOJO("byAlertDescription", alertDescObjectNodeByAlert);\r
-            globalPropsJson.putPOJO("shared", byIdObjectNode);\r
+            JsonObject alertDescObjectNodeByAlert = createAlarmCondObjectNodeByAlarmKey(allAlertDescriptions);\r
+            byIdObjectNode.add("byAlertDescription", alertDescObjectNodeByAlert);\r
+            globalPropsJson.add("shared", byIdObjectNode);\r
             logger.info("Global properties JSON created with SDC info:" + globalPropsJson);\r
         }\r
         totalPropsStr = globalPropsJson.toString();\r
@@ -880,73 +883,69 @@ public class SdcCatalogServices {
         return alarmCondList;\r
     }\r
 \r
-    private ObjectNode createAlarmCondObjectNodeByAlarmKey(List<CldsAlarmCondition> cldsAlarmCondList) {\r
-        ObjectMapper mapper = JacksonUtils.getObjectMapperInstance();\r
-        ObjectNode alarmCondKeyNode = mapper.createObjectNode();\r
+    private JsonObject createAlarmCondObjectNodeByAlarmKey(List<CldsAlarmCondition> cldsAlarmCondList) {\r
+        JsonObject alarmCondKeyNode = new JsonObject();\r
         if (cldsAlarmCondList != null && !cldsAlarmCondList.isEmpty()) {\r
             for (CldsAlarmCondition currCldsAlarmCondition : cldsAlarmCondList) {\r
                 if (currCldsAlarmCondition != null) {\r
-                    ObjectNode alarmCondNode = mapper.createObjectNode();\r
-                    alarmCondNode.put("eventSourceType", currCldsAlarmCondition.getEventSourceType());\r
-                    alarmCondNode.put("eventSeverity", currCldsAlarmCondition.getSeverity());\r
-                    alarmCondKeyNode.putPOJO(currCldsAlarmCondition.getAlarmConditionKey(), alarmCondNode);\r
+                    JsonObject alarmCondNode = new JsonObject();\r
+                    alarmCondNode.addProperty("eventSourceType", currCldsAlarmCondition.getEventSourceType());\r
+                    alarmCondNode.addProperty("eventSeverity", currCldsAlarmCondition.getSeverity());\r
+                    alarmCondKeyNode.add(currCldsAlarmCondition.getAlarmConditionKey(), alarmCondNode);\r
                 }\r
             }\r
         } else {\r
-            ObjectNode alarmCondNode = mapper.createObjectNode();\r
-            alarmCondNode.put("eventSourceType", "");\r
-            alarmCondNode.put("eventSeverity", "");\r
-            alarmCondKeyNode.putPOJO("", alarmCondNode);\r
+            JsonObject alarmCondNode = new JsonObject();\r
+            alarmCondNode.addProperty("eventSourceType", "");\r
+            alarmCondNode.addProperty("eventSeverity", "");\r
+            alarmCondKeyNode.add("", alarmCondNode);\r
         }\r
         return alarmCondKeyNode;\r
     }\r
 \r
-    private ObjectNode createVfObjectNodeByServiceInvariantUuid(CldsServiceData cldsServiceData) {\r
-        ObjectMapper mapper = JacksonUtils.getObjectMapperInstance();\r
-        ObjectNode invariantUuidObjectNode = mapper.createObjectNode();\r
-        ObjectNode vfObjectNode = mapper.createObjectNode();\r
-        ObjectNode vfUuidNode = mapper.createObjectNode();\r
+    private JsonObject createVfObjectNodeByServiceInvariantUuid(CldsServiceData cldsServiceData) {\r
+        JsonObject invariantUuidObjectNode = new JsonObject();\r
+        JsonObject vfObjectNode = new JsonObject();\r
+        JsonObject vfUuidNode = new JsonObject();\r
         List<CldsVfData> cldsVfsList = cldsServiceData.getCldsVfs();\r
         if (cldsVfsList != null && !cldsVfsList.isEmpty()) {\r
             for (CldsVfData currCldsVfData : cldsVfsList) {\r
                 if (currCldsVfData != null) {\r
-                    vfUuidNode.put(currCldsVfData.getVfInvariantResourceUUID(), currCldsVfData.getVfName());\r
+                    vfUuidNode.addProperty(currCldsVfData.getVfInvariantResourceUUID(), currCldsVfData.getVfName());\r
                 }\r
             }\r
         } else {\r
-            vfUuidNode.put("", "");\r
+            vfUuidNode.addProperty("", "");\r
         }\r
-        vfObjectNode.putPOJO("vf", vfUuidNode);\r
-        invariantUuidObjectNode.putPOJO(cldsServiceData.getServiceInvariantUUID(), vfObjectNode);\r
+        vfObjectNode.add("vf", vfUuidNode);\r
+        invariantUuidObjectNode.add(cldsServiceData.getServiceInvariantUUID(), vfObjectNode);\r
         return invariantUuidObjectNode;\r
     }\r
 \r
-    private void createKpiObjectNodeByVfUuid(ObjectNode vfResourceUuidObjectNode,\r
+    private void createKpiObjectNodeByVfUuid(JsonObject vfResourceUuidObjectNode,\r
         List<CldsVfKPIData> cldsVfKpiDataList) {\r
-        ObjectMapper mapper = JacksonUtils.getObjectMapperInstance();\r
         if (cldsVfKpiDataList != null && !cldsVfKpiDataList.isEmpty()) {\r
             for (CldsVfKPIData currCldsVfKpiData : cldsVfKpiDataList) {\r
                 if (currCldsVfKpiData != null) {\r
-                    ObjectNode thresholdNameObjectNode = mapper.createObjectNode();\r
-                    ObjectNode fieldPathObjectNode = mapper.createObjectNode();\r
-                    ObjectNode nfNamingCodeNode = mapper.createObjectNode();\r
-                    fieldPathObjectNode.put(currCldsVfKpiData.getFieldPathValue(),\r
+                    JsonObject thresholdNameObjectNode = new JsonObject();\r
+                    JsonObject fieldPathObjectNode = new JsonObject();\r
+                    JsonObject nfNamingCodeNode = new JsonObject();\r
+                    fieldPathObjectNode.addProperty(currCldsVfKpiData.getFieldPathValue(),\r
                         currCldsVfKpiData.getFieldPathValue());\r
-                    nfNamingCodeNode.put(currCldsVfKpiData.getNfNamingValue(), currCldsVfKpiData.getNfNamingValue());\r
-                    thresholdNameObjectNode.putPOJO("fieldPath", fieldPathObjectNode);\r
-                    thresholdNameObjectNode.putPOJO("nfNamingCode", nfNamingCodeNode);\r
-                    vfResourceUuidObjectNode.putPOJO(currCldsVfKpiData.getThresholdValue(), thresholdNameObjectNode);\r
+                    nfNamingCodeNode.addProperty(currCldsVfKpiData.getNfNamingValue(), currCldsVfKpiData.getNfNamingValue());\r
+                    thresholdNameObjectNode.add("fieldPath", fieldPathObjectNode);\r
+                    thresholdNameObjectNode.add("nfNamingCode", nfNamingCodeNode);\r
+                    vfResourceUuidObjectNode.add(currCldsVfKpiData.getThresholdValue(), thresholdNameObjectNode);\r
                 }\r
             }\r
         }\r
     }\r
 \r
-    private void createAlarmCondObjectNodeByVfcUuid(ObjectNode vfcResourceUuidObjectNode,\r
+    private void createAlarmCondObjectNodeByVfcUuid(JsonObject vfcResourceUuidObjectNode,\r
         List<CldsVfcData> cldsVfcDataList) {\r
-        ObjectMapper mapper = JacksonUtils.getObjectMapperInstance();\r
-        ObjectNode vfcObjectNode = mapper.createObjectNode();\r
-        ObjectNode alarmCondNode = mapper.createObjectNode();\r
-        ObjectNode alertDescNode = mapper.createObjectNode();\r
+        JsonObject vfcObjectNode = new JsonObject();\r
+        JsonObject alarmCondNode = new JsonObject();\r
+        JsonObject alertDescNode = new JsonObject();\r
         if (cldsVfcDataList != null && !cldsVfcDataList.isEmpty()) {\r
             for (CldsVfcData currCldsVfcData : cldsVfcDataList) {\r
                 if (currCldsVfcData != null) {\r
@@ -954,25 +953,25 @@ public class SdcCatalogServices {
                         && !currCldsVfcData.getCldsAlarmConditions().isEmpty()) {\r
                         for (CldsAlarmCondition currCldsAlarmCondition : currCldsVfcData.getCldsAlarmConditions()) {\r
                             if ("alarmCondition".equalsIgnoreCase(currCldsAlarmCondition.getEventName())) {\r
-                                alarmCondNode.put(currCldsAlarmCondition.getAlarmConditionKey(),\r
+                                alarmCondNode.addProperty(currCldsAlarmCondition.getAlarmConditionKey(),\r
                                     currCldsAlarmCondition.getAlarmConditionKey());\r
                             } else {\r
-                                alertDescNode.put(currCldsAlarmCondition.getAlarmConditionKey(),\r
+                                alertDescNode.addProperty(currCldsAlarmCondition.getAlarmConditionKey(),\r
                                     currCldsAlarmCondition.getAlarmConditionKey());\r
                             }\r
                         }\r
                     }\r
-                    vfcObjectNode.putPOJO("alarmCondition", alarmCondNode);\r
-                    vfcObjectNode.putPOJO("alertDescription", alertDescNode);\r
-                    vfcResourceUuidObjectNode.putPOJO(currCldsVfcData.getVfcInvariantResourceUUID(), vfcObjectNode);\r
+                    vfcObjectNode.add("alarmCondition", alarmCondNode);\r
+                    vfcObjectNode.add("alertDescription", alertDescNode);\r
+                    vfcResourceUuidObjectNode.add(currCldsVfcData.getVfcInvariantResourceUUID(), vfcObjectNode);\r
                 }\r
             }\r
         } else {\r
-            alarmCondNode.put("", "");\r
-            vfcObjectNode.putPOJO("alarmCondition", alarmCondNode);\r
-            alertDescNode.put("", "");\r
-            vfcObjectNode.putPOJO("alertDescription", alarmCondNode);\r
-            vfcResourceUuidObjectNode.putPOJO("", vfcObjectNode);\r
+            alarmCondNode.addProperty("", "");\r
+            vfcObjectNode.add("alarmCondition", alarmCondNode);\r
+            alertDescNode.addProperty("", "");\r
+            vfcObjectNode.add("alertDescription", alarmCondNode);\r
+            vfcResourceUuidObjectNode.add("", vfcObjectNode);\r
         }\r
     }\r
 \r
@@ -983,45 +982,45 @@ public class SdcCatalogServices {
      * @param cldsVfDataList\r
      * @return\r
      */\r
-    private ObjectNode createVfcObjectNodeByVfUuid(List<CldsVfData> cldsVfDataList) {\r
-        ObjectMapper mapper = JacksonUtils.getObjectMapperInstance();\r
-        ObjectNode vfUuidObjectNode = mapper.createObjectNode();\r
+    private JsonObject createVfcObjectNodeByVfUuid(List<CldsVfData> cldsVfDataList) {\r
+        JsonObject vfUuidObjectNode = new JsonObject();\r
         if (cldsVfDataList != null && !cldsVfDataList.isEmpty()) {\r
             for (CldsVfData currCldsVfData : cldsVfDataList) {\r
                 if (currCldsVfData != null) {\r
-                    ObjectNode vfObjectNode = mapper.createObjectNode();\r
-                    ObjectNode vfcUuidNode = mapper.createObjectNode();\r
-                    ObjectNode kpiObjectNode = mapper.createObjectNode();\r
+                    JsonObject vfObjectNode = new JsonObject();\r
+                    JsonObject vfcUuidNode = new JsonObject();\r
+                    JsonObject kpiObjectNode = new JsonObject();\r
                     if (currCldsVfData.getCldsVfcs() != null && !currCldsVfData.getCldsVfcs().isEmpty()) {\r
                         for (CldsVfcData currCldsVfcData : currCldsVfData.getCldsVfcs()) {\r
                             if (currCldsVfcData.getCldsAlarmConditions() != null\r
                                 && !currCldsVfcData.getCldsAlarmConditions().isEmpty()) {\r
-                                vfcUuidNode.put(currCldsVfcData.getVfcInvariantResourceUUID(),\r
+                                vfcUuidNode.addProperty(currCldsVfcData.getVfcInvariantResourceUUID(),\r
                                     currCldsVfcData.getVfcName());\r
                             }\r
                         }\r
                     } else {\r
-                        vfcUuidNode.put("", "");\r
+                        vfcUuidNode.addProperty("", "");\r
                     }\r
                     if (currCldsVfData.getCldsKPIList() != null && !currCldsVfData.getCldsKPIList().isEmpty()) {\r
                         for (CldsVfKPIData currCldsVfKPIData : currCldsVfData.getCldsKPIList()) {\r
-                            kpiObjectNode.put(currCldsVfKPIData.getThresholdValue(),\r
+                            // ToDo: something wrong happened here\r
+                            kpiObjectNode.addProperty(currCldsVfKPIData.getThresholdValue(),\r
                                 currCldsVfKPIData.getThresholdValue());\r
                         }\r
                     } else {\r
-                        kpiObjectNode.put("", "");\r
+                        kpiObjectNode.addProperty("", "");\r
                     }\r
-                    vfObjectNode.putPOJO("vfc", vfcUuidNode);\r
-                    vfObjectNode.putPOJO("kpi", kpiObjectNode);\r
-                    vfUuidObjectNode.putPOJO(currCldsVfData.getVfInvariantResourceUUID(), vfObjectNode);\r
+                    vfObjectNode.add("vfc", vfcUuidNode);\r
+                    vfObjectNode.add("kpi", kpiObjectNode);\r
+                    vfUuidObjectNode.add(currCldsVfData.getVfInvariantResourceUUID(), vfObjectNode);\r
                 }\r
             }\r
         } else {\r
-            ObjectNode vfcUuidNode = mapper.createObjectNode();\r
-            vfcUuidNode.put("", "");\r
-            ObjectNode vfcObjectNode = mapper.createObjectNode();\r
-            vfcObjectNode.putPOJO("vfc", vfcUuidNode);\r
-            vfUuidObjectNode.putPOJO("", vfcObjectNode);\r
+            JsonObject vfcUuidNode = new JsonObject();\r
+            vfcUuidNode.addProperty("", "");\r
+            JsonObject vfcObjectNode = new JsonObject();\r
+            vfcObjectNode.add("vfc", vfcUuidNode);\r
+            vfUuidObjectNode.add("", vfcObjectNode);\r
         }\r
         return vfUuidObjectNode;\r
     }\r
index efd664c..d9093f4 100644 (file)
@@ -25,11 +25,10 @@ package org.onap.clamp.clds.client.req.sdc;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.security.GeneralSecurityException;
@@ -47,7 +46,7 @@ import org.onap.clamp.clds.model.properties.ModelProperties;
 import org.onap.clamp.clds.model.properties.Tca;
 import org.onap.clamp.clds.model.sdc.SdcResource;
 import org.onap.clamp.clds.model.sdc.SdcServiceDetail;
-import org.onap.clamp.clds.util.JacksonUtils;
+import org.onap.clamp.clds.util.JsonUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Primary;
 import org.springframework.stereotype.Component;
@@ -98,16 +97,15 @@ public class SdcRequests {
      * @return SDC Locations request in the JSON Format
      */
     public String formatSdcLocationsReq(ModelProperties prop, String artifactName) {
-        ObjectMapper objectMapper = JacksonUtils.getObjectMapperInstance();
         Global global = prop.getGlobal();
         List<String> locationsList = global.getLocation();
-        ArrayNode locationsArrayNode = objectMapper.createArrayNode();
-        ObjectNode locationObject = objectMapper.createObjectNode();
+        JsonArray locationsArrayNode = new JsonArray();
+        JsonObject locationObject = new JsonObject();
         for (String currLocation : locationsList) {
             locationsArrayNode.add(currLocation);
         }
-        locationObject.put("artifactName", artifactName);
-        locationObject.putPOJO("locations", locationsArrayNode);
+        locationObject.addProperty("artifactName", artifactName);
+        locationObject.add("locations", locationsArrayNode);
         String locationJsonFormat = locationObject.toString();
         logger.info("Value of location Json Artifact:" + locationsArrayNode);
         return locationJsonFormat;
@@ -207,18 +205,18 @@ public class SdcRequests {
      */
     protected String getYamlvalue(String jsonGlobal) throws IOException {
         String yamlFileValue = "";
-        ObjectNode root = JacksonUtils.getObjectMapperInstance().readValue(jsonGlobal, ObjectNode.class);
-        Iterator<Entry<String, JsonNode>> entryItr = root.fields();
+        JsonObject root = JsonUtils.GSON.fromJson(jsonGlobal, JsonObject.class);
+        Iterator<Entry<String, JsonElement>> entryItr = root.entrySet().iterator();
         while (entryItr.hasNext()) {
-            Entry<String, JsonNode> entry = entryItr.next();
+            Entry<String, JsonElement> entry = entryItr.next();
             String key = entry.getKey();
             if (key != null && key.equalsIgnoreCase("global")) {
-                ArrayNode arrayNode = (ArrayNode) entry.getValue();
-                for (JsonNode anArrayNode : arrayNode) {
-                    ObjectNode node = (ObjectNode) anArrayNode;
-                    ArrayNode arrayValueNode = (ArrayNode) node.get("value");
-                    JsonNode jsonNode = arrayValueNode.get(0);
-                    yamlFileValue = jsonNode.asText();
+                JsonArray arrayNode = entry.getValue().getAsJsonArray();
+                for (JsonElement anArrayNode : arrayNode) {
+                    JsonObject node = anArrayNode.getAsJsonObject();
+                    JsonArray arrayValueNode = node.get("value").getAsJsonArray();
+                    JsonElement jsonNode = arrayValueNode.get(0);
+                    yamlFileValue = jsonNode.getAsString();
                     logger.info("value:" + yamlFileValue);
                 }
                 break;
index 1478342..6b8f043 100644 (file)
@@ -25,10 +25,9 @@ package org.onap.clamp.clds.client.req.tca;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 
+import com.google.gson.JsonArray;
+import com.google.gson.JsonObject;
 import java.io.IOException;
 import java.util.Map;
 
@@ -38,6 +37,7 @@ import org.onap.clamp.clds.model.properties.ModelProperties;
 import org.onap.clamp.clds.model.properties.Tca;
 import org.onap.clamp.clds.model.properties.TcaItem;
 import org.onap.clamp.clds.model.properties.TcaThreshold;
+import org.onap.clamp.clds.util.JsonUtils;
 import org.yaml.snakeyaml.Yaml;
 
 /**
@@ -71,10 +71,10 @@ public class TcaRequestFormatter {
             modelProperties.setCurrentModelElementId(tca.getId());
             // Always one tcaItem so must be set to id 0
             modelProperties.setPolicyUniqueId("0");
-            ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("tca.policy.template", service);
+            JsonObject rootNode = refProp.getJsonTemplate("tca.policy.template", service ).getAsJsonObject();
             String policyName = modelProperties.getCurrentPolicyScopeAndPolicyName();
-            rootNode.put("policyName", policyName);
-            ((ObjectNode) rootNode.get("content")).replace("tca_policy",
+            rootNode.addProperty("policyName", policyName);
+            rootNode.get("content").getAsJsonObject().add("tca_policy",
                     createPolicyContent(refProp, modelProperties, service, policyName, tca));
             String tcaPolicyReq = rootNode.toString();
             logger.info("tcaPolicyReq=" + tcaPolicyReq);
@@ -104,7 +104,7 @@ public class TcaRequestFormatter {
      *            modelProperties.setCurrentModelElementId will be used
      * @return The Json node containing what should be sent to policy
      */
-    public static JsonNode createPolicyContent(ClampProperties refProp, ModelProperties modelProperties, String service,
+    public static JsonObject createPolicyContent(ClampProperties refProp, ModelProperties modelProperties, String service,
             String policyName, Tca tca) {
         try {
             String serviceToUse = service;
@@ -120,14 +120,12 @@ public class TcaRequestFormatter {
             if (policyNameToUse == null) {
                 policyNameToUse = modelProperties.getCurrentPolicyScopeAndPolicyName();
             }
-            ObjectNode rootNode = (ObjectNode) refProp.getJsonTemplate("tca.template", serviceToUse);
-            ((ObjectNode) rootNode.get("metricsPerEventName").get(0)).put("eventName",
-                    tcaToUse.getTcaItem().getEventName());
-            ((ObjectNode) rootNode.get("metricsPerEventName").get(0)).put("policyName", policyNameToUse);
-            ((ObjectNode) rootNode.get("metricsPerEventName").get(0)).put("controlLoopSchemaType",
-                    tcaToUse.getTcaItem().getControlLoopSchemaType());
-            ObjectNode thresholdsParent = ((ObjectNode) rootNode.get("metricsPerEventName").get(0));
-            addThresholds(refProp, serviceToUse, thresholdsParent, tcaToUse.getTcaItem(), modelProperties);
+            JsonObject rootNode = refProp.getJsonTemplate("tca.template", serviceToUse).getAsJsonObject();
+            JsonObject metricsPerEventName = rootNode.get("metricsPerEventName").getAsJsonArray().get(0).getAsJsonObject();
+            metricsPerEventName.addProperty("eventName", tcaToUse.getTcaItem().getEventName());
+            metricsPerEventName.addProperty("policyName", policyNameToUse);
+            metricsPerEventName.addProperty("controlLoopSchemaType",tcaToUse.getTcaItem().getControlLoopSchemaType());
+            addThresholds(refProp, serviceToUse, metricsPerEventName, tcaToUse.getTcaItem(), modelProperties);
             logger.info("tcaPolicyContent=" + rootNode.toString());
             return rootNode;
         } catch (IOException e) {
@@ -154,17 +152,17 @@ public class TcaRequestFormatter {
      *            The Model Properties created from BPMN JSON and BPMN
      *            properties JSON
      */
-    private static void addThresholds(ClampProperties refProp, String service, ObjectNode appendToNode, TcaItem tcaItem,
+    private static void addThresholds(ClampProperties refProp, String service, JsonObject appendToNode, TcaItem tcaItem,
             ModelProperties modelProperties) {
-        ArrayNode tcaNodes = appendToNode.withArray("thresholds");
+        JsonArray tcaNodes = appendToNode.get("thresholds").getAsJsonArray();
         try {
             for (TcaThreshold tcaThreshold : tcaItem.getTcaThresholds()) {
-                ObjectNode tcaNode = (ObjectNode) refProp.getJsonTemplate("tca.thresholds.template", service);
-                tcaNode.put("closedLoopControlName", modelProperties.getControlNameAndPolicyUniqueId());
-                tcaNode.put("fieldPath", tcaThreshold.getFieldPath());
-                tcaNode.put("thresholdValue", tcaThreshold.getThreshold());
-                tcaNode.put("direction", tcaThreshold.getOperator());
-                tcaNode.put("closedLoopEventStatus", tcaThreshold.getClosedLoopEventStatus());
+                JsonObject tcaNode = refProp.getJsonTemplate("tca.thresholds.template", service).getAsJsonObject();
+                tcaNode.addProperty("closedLoopControlName", modelProperties.getControlNameAndPolicyUniqueId());
+                tcaNode.addProperty("fieldPath", tcaThreshold.getFieldPath());
+                tcaNode.addProperty("thresholdValue", tcaThreshold.getThreshold());
+                tcaNode.addProperty("direction", tcaThreshold.getOperator());
+                tcaNode.addProperty("closedLoopEventStatus", tcaThreshold.getClosedLoopEventStatus());
                 tcaNodes.add(tcaNode);
             }
         } catch (IOException e) {
@@ -187,7 +185,7 @@ public class TcaRequestFormatter {
      */
     public static String updatedBlueprintWithConfiguration(ClampProperties refProp, ModelProperties modelProperties,
             String yamlValue) {
-        String jsonPolicy = ((ObjectNode) createPolicyContent(refProp, modelProperties, null, null, null)).toString();
+        String jsonPolicy = JsonUtils.GSON.toJson(createPolicyContent(refProp, modelProperties, null, null, null));
         logger.info("Yaml that will be updated:" + yamlValue);
         Yaml yaml = new Yaml();
         Map<String, Object> loadedYaml = (Map<String, Object>) yaml.load(yamlValue);
index 9acad94..4f1e8a2 100644 (file)
 
 package org.onap.clamp.clds.config;
 
-import com.fasterxml.jackson.databind.JsonNode;
 import com.google.common.base.Splitter;
 
+import com.google.gson.JsonElement;
 import java.io.IOException;
 import java.net.URL;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
 
 import org.apache.commons.io.IOUtils;
-import org.onap.clamp.clds.util.JacksonUtils;
+import org.onap.clamp.clds.util.JsonUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContext;
 import org.springframework.core.env.Environment;
@@ -89,10 +89,10 @@ public class ClampProperties {
      * @throws IOException
      *         In case of issues with the JSON parser
      */
-    public JsonNode getJsonTemplate(String key) throws IOException {
+    public JsonElement getJsonTemplate(String key) throws IOException {
         String fileReference = getStringValue(key);
         return (fileReference != null)
-            ? JacksonUtils.getObjectMapperInstance().readValue(getFileContentFromPath(fileReference), JsonNode.class)
+            ? JsonUtils.GSON.fromJson(getFileContentFromPath(fileReference), JsonElement.class)
             : null;
     }
 
@@ -109,10 +109,10 @@ public class ClampProperties {
      * @throws IOException
      *         In case of issues with the JSON parser
      */
-    public JsonNode getJsonTemplate(String key1, String key2) throws IOException {
+    public JsonElement getJsonTemplate(String key1, String key2) throws IOException {
         String fileReference = getStringValue(key1, key2);
         return (fileReference != null)
-            ? JacksonUtils.getObjectMapperInstance().readValue(getFileContentFromPath(fileReference), JsonNode.class)
+            ? JsonUtils.GSON.fromJson(getFileContentFromPath(fileReference), JsonElement.class)
             : null;
     }
 
index 0b87333..d1beb95 100644 (file)
 
 package org.onap.clamp.clds.config;
 
+import com.google.gson.JsonParseException;
+import com.google.gson.reflect.TypeToken;
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.Type;
 import java.nio.charset.StandardCharsets;
 
+import java.util.List;
 import org.apache.commons.io.IOUtils;
 import org.onap.clamp.clds.exception.CldsUsersException;
 import org.onap.clamp.clds.service.CldsUser;
-import org.onap.clamp.clds.util.JacksonUtils;
+import org.onap.clamp.clds.util.JsonUtils;
 
 public class CldsUserJsonDecoder {
 
@@ -55,8 +59,8 @@ public class CldsUserJsonDecoder {
         try {
             // the ObjectMapper readValue method closes the stream no need to do
             // it
-            return JacksonUtils.getObjectMapperInstance().readValue(cldsUsersString, CldsUser[].class);
-        } catch (IOException e) {
+            return JsonUtils.GSON.fromJson(cldsUsersString, CldsUser[].class);
+        } catch (JsonParseException e) {
             throw new CldsUsersException("Exception occurred during the decoding of the clds-users.json", e);
         }
     }
index 2cab17b..2f0e698 100644 (file)
 
 package org.onap.clamp.clds.config.sdc;
 
-import com.fasterxml.jackson.core.type.TypeReference;
 
-import java.io.IOException;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+import com.google.gson.reflect.TypeToken;
 import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.lang.reflect.Type;
+import java.nio.charset.StandardCharsets;
 import java.util.List;
-
-import org.onap.clamp.clds.util.JacksonUtils;
+import org.onap.clamp.clds.util.JsonUtils;
 
 /**
  * This class is used to decode the configuration found in
@@ -39,6 +42,8 @@ import org.onap.clamp.clds.util.JacksonUtils;
  */
 public class BlueprintParserMappingConfiguration {
 
+    private static final Type BLUEPRINT_MAP_CONF_TYPE = new TypeToken<List<BlueprintParserMappingConfiguration>>() {
+    }.getType();
     private String blueprintKey;
     private boolean dcaeDeployable;
     private BlueprintParserFilesConfiguration files;
@@ -63,9 +68,7 @@ public class BlueprintParserMappingConfiguration {
         return dcaeDeployable;
     }
 
-    public static List<BlueprintParserMappingConfiguration> createFromJson(InputStream json) throws IOException {
-        TypeReference<List<BlueprintParserMappingConfiguration>> mapType = new TypeReference<List<BlueprintParserMappingConfiguration>>() {
-        };
-        return JacksonUtils.getObjectMapperInstance().readValue(json, mapType);
+    public static List<BlueprintParserMappingConfiguration> createFromJson(InputStream json) {
+        return JsonUtils.GSON.fromJson(new InputStreamReader(json, StandardCharsets.UTF_8), BLUEPRINT_MAP_CONF_TYPE);
     }
 }
index 0f75d46..b21c75f 100644 (file)
@@ -25,16 +25,18 @@ package org.onap.clamp.clds.config.sdc;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
 
+import com.google.gson.JsonObject;
 import java.io.IOException;
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Map;
 
 import javax.annotation.PostConstruct;
 
 import org.onap.clamp.clds.exception.sdc.controller.SdcParametersException;
-import org.onap.clamp.clds.util.JacksonUtils;
+import org.onap.clamp.clds.util.JsonUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.ApplicationContext;
@@ -59,13 +61,13 @@ public class SdcControllersConfiguration {
     /**
      * The root of the JSON.
      */
-    private JsonNode jsonRootNode;
+    private JsonObject jsonRootNode;
 
     @PostConstruct
     public void loadConfiguration() throws IOException {
         Resource resource = appContext.getResource(sdcControllerFile);
         // Try to load json tree
-        jsonRootNode = JacksonUtils.getObjectMapperInstance().readValue(resource.getInputStream(), JsonNode.class);
+        jsonRootNode = JsonUtils.GSON.fromJson(new InputStreamReader(resource.getInputStream(), StandardCharsets.UTF_8), JsonObject.class);
     }
 
     public SdcSingleControllerConfiguration getSdcSingleControllerConfiguration(String controllerName) {
@@ -80,8 +82,9 @@ public class SdcControllersConfiguration {
     public Map<String, SdcSingleControllerConfiguration> getAllDefinedControllers() {
         Map<String, SdcSingleControllerConfiguration> result = new HashMap<>();
         if (jsonRootNode.get(CONTROLLER_SUBTREE_KEY) != null) {
-            jsonRootNode.get(CONTROLLER_SUBTREE_KEY).fields().forEachRemaining(entry -> result.put(entry.getKey(),
-                    new SdcSingleControllerConfiguration(entry.getValue(), entry.getKey())));
+            jsonRootNode.get(CONTROLLER_SUBTREE_KEY).getAsJsonObject().entrySet().forEach(
+                entry -> result.put(entry.getKey(),
+                    new SdcSingleControllerConfiguration(entry.getValue().getAsJsonObject(), entry.getKey())));
         } else {
             throw new SdcParametersException(
                     CONTROLLER_SUBTREE_KEY + " key not found in the file: " + sdcControllerFile);
index ca756aa..564e01f 100644 (file)
@@ -25,8 +25,8 @@ package org.onap.clamp.clds.config.sdc;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
 
+import com.google.gson.JsonObject;
 import java.security.GeneralSecurityException;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -52,7 +52,7 @@ public class SdcSingleControllerConfiguration implements IConfiguration {
     /**
      * The root of the JSON.
      */
-    private JsonNode jsonRootNode;
+    private JsonObject jsonRootNode;
     // All keys that can be present in the JSON
     public static final String CONSUMER_GROUP_ATTRIBUTE_NAME = "consumerGroup";
     public static final String CONSUMER_ID_ATTRIBUTE_NAME = "consumerId";
@@ -90,12 +90,12 @@ public class SdcSingleControllerConfiguration implements IConfiguration {
      * This constructor builds a SdcSingleControllerConfiguration from the
      * corresponding json.
      * 
-     * @param jsonRootNode
+     * @param jsonNode
      *            The JSON node
      * @param controllerName
      *            The controller name that must appear in the JSON
      */
-    public SdcSingleControllerConfiguration(JsonNode jsonNode, String controllerName) {
+    public SdcSingleControllerConfiguration(JsonObject jsonNode, String controllerName) {
         jsonRootNode = jsonNode;
         setSdcControllerName(controllerName);
         testAllRequiredParameters();
@@ -113,7 +113,7 @@ public class SdcSingleControllerConfiguration implements IConfiguration {
 
     private String getStringConfig(String key) {
         if (jsonRootNode != null && jsonRootNode.get(key) != null) {
-            String config = jsonRootNode.get(key).asText();
+            String config = jsonRootNode.get(key).getAsString();
             return config.isEmpty() ? null : config;
         }
         return null;
@@ -121,7 +121,7 @@ public class SdcSingleControllerConfiguration implements IConfiguration {
 
     private Integer getIntConfig(String key) {
         if (jsonRootNode != null && jsonRootNode.get(key) != null) {
-            return jsonRootNode.get(key).asInt();
+            return jsonRootNode.get(key).getAsInt();
         } else {
             return 0;
         }
@@ -129,8 +129,8 @@ public class SdcSingleControllerConfiguration implements IConfiguration {
 
     private String getEncryptedStringConfig(String key) throws GeneralSecurityException, DecoderException {
         if (jsonRootNode != null && jsonRootNode.get(key) != null) {
-            return jsonRootNode.get(key).asText().isEmpty() ? null
-                    : CryptoUtils.decrypt(jsonRootNode.get(key).asText());
+            return jsonRootNode.get(key).getAsString().isEmpty() ? null
+                    : CryptoUtils.decrypt(jsonRootNode.get(key).getAsString());
         }
         return null;
     }
@@ -143,7 +143,7 @@ public class SdcSingleControllerConfiguration implements IConfiguration {
     @Override
     public String getConsumerGroup() {
         if (jsonRootNode != null && jsonRootNode.get(CONSUMER_GROUP_ATTRIBUTE_NAME) != null) {
-            String config = jsonRootNode.get(CONSUMER_GROUP_ATTRIBUTE_NAME).asText();
+            String config = jsonRootNode.get(CONSUMER_GROUP_ATTRIBUTE_NAME).getAsString();
             return "NULL".equals(config) || config.isEmpty() ? null : config;
         }
         return null;
@@ -198,8 +198,8 @@ public class SdcSingleControllerConfiguration implements IConfiguration {
 
     @Override
     public boolean activateServerTLSAuth() {
-        if (jsonRootNode != null && jsonRootNode.get(ACTIVATE_SERVER_TLS_AUTH) != null) {
-            return jsonRootNode.get(ACTIVATE_SERVER_TLS_AUTH).asBoolean(false);
+        if (jsonRootNode != null && jsonRootNode.get(ACTIVATE_SERVER_TLS_AUTH) != null && jsonRootNode.get(ACTIVATE_SERVER_TLS_AUTH).isJsonPrimitive()) {
+            return jsonRootNode.get(ACTIVATE_SERVER_TLS_AUTH).getAsBoolean();
         } else {
             return false;
         }
@@ -231,7 +231,7 @@ public class SdcSingleControllerConfiguration implements IConfiguration {
             throw new SdcParametersException("Json is null for controller " + this.getSdcControllerName());
         }
         if (this.getConsumerGroup() == null && (jsonRootNode.get(CONSUMER_GROUP_ATTRIBUTE_NAME) == null
-                || !"NULL".equals(jsonRootNode.get(CONSUMER_GROUP_ATTRIBUTE_NAME).asText()))) {
+                || !"NULL".equals(jsonRootNode.get(CONSUMER_GROUP_ATTRIBUTE_NAME).getAsString()))) {
             throw new SdcParametersException(CONSUMER_GROUP_ATTRIBUTE_NAME + errorMessageKeyNotFound);
         }
         if (this.getConsumerID() == null || this.getConsumerID().isEmpty()) {
@@ -277,7 +277,7 @@ public class SdcSingleControllerConfiguration implements IConfiguration {
     public List<String> getMsgBusAddress() {
         List<String> addressesList = new ArrayList<>();
         if (jsonRootNode != null && jsonRootNode.get(MESSAGE_BUS_ADDRESSES) != null) {
-            jsonRootNode.get(MESSAGE_BUS_ADDRESSES).forEach(k -> addressesList.add(k.asText()));
+            jsonRootNode.get(MESSAGE_BUS_ADDRESSES).getAsJsonArray().forEach(k -> addressesList.add(k.getAsString()));
             return addressesList;
         } else {
             return addressesList;
index 75801ae..082bfe3 100644 (file)
@@ -23,9 +23,6 @@
 
 package org.onap.clamp.clds.model;
 
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-
-@JsonIgnoreProperties(ignoreUnknown = true)
 public class CldsModelInstance {
 
     private String modelInstanceId;
index 1c54dae..bafe48d 100644 (file)
 package org.onap.clamp.clds.model.actions;
 
 import com.att.eelf.configuration.EELFLogger;
-import com.fasterxml.jackson.databind.JsonNode;
-
-import java.io.IOException;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
 import java.util.Arrays;
 import java.util.List;
-
 import org.onap.clamp.clds.model.CldsEvent;
-import org.onap.clamp.clds.util.JacksonUtils;
+import org.onap.clamp.clds.util.JsonUtils;
 
 /**
  * Interface for actions that the user can do according to the last event.
@@ -44,7 +43,7 @@ public interface ActionsHandler {
         SIMPLE_MODEL("simpleModel"), POLICY_MODEL("policyModel");
         private final String type;
 
-        private ModelType(String type) {
+        ModelType(String type) {
             this.type = type;
         }
 
@@ -53,7 +52,7 @@ public interface ActionsHandler {
         }
     }
 
-    public EELFLogger getLogger();
+    EELFLogger getLogger();
 
     /**
      * This method determines a list of actions that the user can do according to
@@ -155,13 +154,15 @@ public interface ActionsHandler {
         boolean result = false;
         try {
             if (propText != null) {
-                JsonNode modelJson = JacksonUtils.getObjectMapperInstance().readTree(propText);
-                JsonNode modelJsonOfType = modelJson.get(key.getType());
-                if (modelJsonOfType != null && modelJsonOfType.asBoolean()) {
+                JsonObject modelJson = JsonUtils.GSON.fromJson(propText, JsonObject.class);
+                JsonElement modelJsonOfType = modelJson.get(key.getType());
+                if (modelJsonOfType != null
+                    && modelJsonOfType.isJsonPrimitive()
+                    && modelJsonOfType.getAsJsonPrimitive().getAsBoolean()) {
                     result = true;
                 }
             }
-        } catch (IOException e) {
+        } catch (JsonParseException e) {
             getLogger().error("Error while parsing propText json", e);
         }
         return result;
index 571e5b1..8e8debe 100644 (file)
@@ -25,15 +25,12 @@ package org.onap.clamp.clds.model.properties;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
 
 /**
- * Provide base ModelElement functionality. Perform base parsing of properties
- * for a ModelElement (such as, VesCollector, Policy, Tca, Holmes, ...)
+ * Provide base ModelElement functionality. Perform base parsing of properties for a ModelElement (such as,
+ * VesCollector, Policy, Tca, Holmes, ...)
  */
 public abstract class AbstractModelElement {
 
@@ -43,17 +40,14 @@ public abstract class AbstractModelElement {
     private final ModelBpmn modelBpmn;
     private final String id;
     protected String topicPublishes;
-    protected final JsonNode modelElementJsonNode;
+    protected final JsonElement modelElementJsonNode;
     private boolean isFound;
     private final ModelProperties modelProp;
-    private static final String LOG_ELEMENT_NOT_FOUND = "Value '{}' for key 'name' not found in JSON";
-    private static final String LOG_ELEMENT_NOT_FOUND_IN_JSON = "Value '{}' for key 'name' not found in JSON {}";
 
     /**
-     * Perform base parsing of properties for a ModelElement (such as, VesCollector,
-     * Policy and Tca)
+     * Perform base parsing of properties for a ModelElement (such as, VesCollector, Policy and Tca)
      */
-    protected AbstractModelElement(String type, ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) {
+    protected AbstractModelElement(String type, ModelProperties modelProp, ModelBpmn modelBpmn, JsonObject modelJson) {
         this.type = type;
         this.modelProp = modelProp;
         this.modelBpmn = modelBpmn;
@@ -69,163 +63,6 @@ public abstract class AbstractModelElement {
         return topicPublishes;
     }
 
-    /**
-     * Return the value field of the json node element that has a name field equals
-     * to the given name.
-     */
-    public static String getValueByName(JsonNode nodeIn, String name) {
-        String value = null;
-        if (nodeIn != null) {
-            for (JsonNode node : nodeIn) {
-                if (node.path("name").asText().equals(name)) {
-                    JsonNode vnode = node.path("value");
-                    if (vnode.isArray()) {
-                        // if array, assume value is in first element
-                        value = vnode.path(0).asText();
-                    } else {
-                        // otherwise, just return text
-                        value = vnode.asText();
-                    }
-                }
-            }
-        }
-        if (value == null || value.length() == 0) {
-            logger.warn(LOG_ELEMENT_NOT_FOUND, name);
-        } else {
-            logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, nodeIn.toString());
-        }
-        return value;
-    }
-
-    /**
-     * Return the Json value field of the json node element that has a name field
-     * equals to the given name.
-     */
-    public static JsonNode getJsonNodeByName(JsonNode nodeIn, String name) {
-        JsonNode vnode = null;
-        if (nodeIn != null) {
-            for (JsonNode node : nodeIn) {
-                if (node.path("name").asText().equals(name)) {
-                    vnode = node.path("value");
-                }
-            }
-        }
-        if (vnode == null) {
-            logger.warn(LOG_ELEMENT_NOT_FOUND, name);
-        } else {
-            logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, nodeIn.toString());
-        }
-        return vnode;
-    }
-
-    /**
-     * Return the value field of the json node element that has a name field that
-     * equals the given name.
-     */
-    public static String getNodeValueByName(JsonNode nodeIn, String name) {
-        String value = null;
-        if (nodeIn != null) {
-            value = nodeIn.path(name).asText();
-        }
-        if (value == null || value.length() == 0) {
-            logger.warn(LOG_ELEMENT_NOT_FOUND, name);
-        } else {
-            logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, nodeIn.toString());
-        }
-        return value;
-    }
-
-    /**
-     * Return the value field of the json node element that has a name field that
-     * equals the given name.
-     */
-    public static List<String> getNodeValuesByName(JsonNode nodeIn, String name) {
-        List<String> values = new ArrayList<>();
-        if (nodeIn != null) {
-            for (JsonNode node : nodeIn) {
-                if (node.path("name").asText().equals(name)) {
-                    JsonNode vnode = node.path("value");
-                    if (vnode.isArray()) {
-                        // if array, assume value is in first element
-                        values.add(vnode.path(0).asText());
-                    } else {
-                        // otherwise, just return text
-                        values.add(vnode.asText());
-                    }
-                }
-            }
-        }
-        return values;
-    }
-
-    /**
-     * Return the int value field of the json node element that has a name field
-     * equals to the given name.
-     */
-    public static Integer getIntValueByName(JsonNode nodeIn, String name) {
-        String value = getValueByName(nodeIn, name);
-        return Integer.valueOf(value);
-    }
-
-    /**
-     * Return an array of values for the field of the json node element that has a
-     * name field equals to the given name.
-     */
-    public static List<String> getValuesByName(JsonNode nodeIn, String name) {
-        List<String> values = null;
-        if (nodeIn != null) {
-            for (JsonNode node : nodeIn) {
-                if (node.path("name").asText().equals(name)) {
-                    values = getValuesList(node);
-                }
-            }
-        }
-        if (values == null || values.isEmpty()) {
-            logger.warn(LOG_ELEMENT_NOT_FOUND, name);
-        } else {
-            logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, nodeIn.toString());
-        }
-        return values;
-    }
-
-    /**
-     * Return an array of String values.
-     */
-    public static List<String> getValuesList(JsonNode nodeIn) {
-        ArrayList<String> al = new ArrayList<>();
-        if (nodeIn != null) {
-            Iterator<JsonNode> itr = nodeIn.path("value").elements();
-            while (itr.hasNext()) {
-                JsonNode node = itr.next();
-                al.add(node.asText());
-            }
-        }
-        return al;
-    }
-
-    /**
-     * Return the value field of the json node element that has a name field equals
-     * to the given name.
-     */
-    public String getValueByName(String name) {
-        return getValueByName(modelElementJsonNode, name);
-    }
-
-    /**
-     * Return the int value field of the json node element that has a name field
-     * equals to the given name.
-     */
-    public Integer getIntValueByName(String name) {
-        return getIntValueByName(modelElementJsonNode, name);
-    }
-
-    /**
-     * Return an array of values for the field of the json node element that has a
-     * name field equals to the given name.
-     */
-    public List<String> getValuesByName(String name) {
-        return getValuesByName(modelElementJsonNode, name);
-    }
 
     /**
      * @return the id
index e867407..6649148 100644 (file)
@@ -25,9 +25,11 @@ package org.onap.clamp.clds.model.properties;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
 
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
 import java.util.List;
+import org.onap.clamp.clds.util.JsonUtils;
 
 /**
  * Parse global json properties.
@@ -45,7 +47,7 @@ public class Global {
     private String actionSet;
     private List<String> resourceVf;
     private List<String> resourceVfc;
-    private JsonNode deployParameters;
+    private JsonObject deployParameters;
     private List<String> location;
     private String vnfScope;
 
@@ -54,15 +56,15 @@ public class Global {
      *
      * @param modelJson
      */
-    public Global(JsonNode modelJson) {
-        JsonNode globalNode = modelJson.get("global");
-        service = AbstractModelElement.getValueByName(globalNode, "service");
-        actionSet = AbstractModelElement.getValueByName(globalNode, "actionSet");
-        resourceVf = AbstractModelElement.getValuesByName(globalNode, "vf");
-        resourceVfc = AbstractModelElement.getValuesByName(globalNode, "vfc");
-        deployParameters = AbstractModelElement.getJsonNodeByName(globalNode, "deployParameters");
-        location = AbstractModelElement.getValuesByName(globalNode, "location");
-        vnfScope = AbstractModelElement.getValueByName(globalNode, "vnf");
+    public Global(JsonObject modelJson) {
+        JsonElement globalNode = modelJson.get("global");
+        service = JsonUtils.getStringValueByName(globalNode, "service");
+        actionSet = JsonUtils.getStringValueByName(globalNode, "actionSet");
+        resourceVf = JsonUtils.getStringValuesByName(globalNode, "vf");
+        resourceVfc = JsonUtils.getStringValuesByName(globalNode, "vfc");
+        deployParameters = JsonUtils.getJsonObjectByName(globalNode, "deployParameters");
+        location = JsonUtils.getStringValuesByName(globalNode, "location");
+        vnfScope = JsonUtils.getStringValueByName(globalNode, "vnf");
     }
 
     /**
@@ -136,11 +138,11 @@ public class Global {
         this.location = location;
     }
 
-    public JsonNode getDeployParameters() {
+    public JsonObject getDeployParameters() {
         return deployParameters;
     }
 
-    public void setDeployParameters(JsonNode deployParameters) {
+    public void setDeployParameters(JsonObject deployParameters) {
         this.deployParameters = deployParameters;
     }
 
index 530e2db..b0607e9 100644 (file)
@@ -23,7 +23,8 @@
 
 package org.onap.clamp.clds.model.properties;
 
-import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.JsonObject;
+import org.onap.clamp.clds.util.JsonUtils;
 
 /**
  * Parse Holmes bpmn parameters json properties.
@@ -49,11 +50,11 @@ public class Holmes extends AbstractModelElement {
      * @param modelBpmn
      * @param modelJson
      */
-    public Holmes(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) {
+    public Holmes(ModelProperties modelProp, ModelBpmn modelBpmn, JsonObject modelJson) {
         super(TYPE_HOLMES, modelProp, modelBpmn, modelJson);
 
-        correlationLogic = this.getValueByName("correlationalLogic");
-        configPolicyName = this.getValueByName("configPolicyName");
+        correlationLogic = JsonUtils.getStringValueByName(modelElementJsonNode, "correlationalLogic");
+        configPolicyName = JsonUtils.getStringValueByName(modelElementJsonNode, "configPolicyName");
     }
 
     public static final String getType() {
index dbd5d8a..248a52f 100644 (file)
@@ -25,11 +25,11 @@ package org.onap.clamp.clds.model.properties;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 
-import java.io.IOException;
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
@@ -39,7 +39,7 @@ import java.util.Map.Entry;
 
 import org.onap.clamp.clds.exception.ModelBpmnException;
 import org.onap.clamp.clds.service.CldsService;
-import org.onap.clamp.clds.util.JacksonUtils;
+import org.onap.clamp.clds.util.JsonUtils;
 
 /**
  * Parse Model BPMN properties.
@@ -66,22 +66,22 @@ public class ModelBpmn {
     public static ModelBpmn create(String modelBpmnPropText) {
         try {
             ModelBpmn modelBpmn = new ModelBpmn();
-            ObjectNode root = JacksonUtils.getObjectMapperInstance().readValue(modelBpmnPropText, ObjectNode.class);
+            JsonObject root = JsonUtils.GSON.fromJson(modelBpmnPropText, JsonObject.class);
             // iterate over each entry like:
             // "Policy":[{"id":"Policy","from":"StartEvent_1"}]
-            Iterator<Entry<String, JsonNode>> entryItr = root.fields();
+            Iterator<Entry<String, JsonElement>> entryItr = root.entrySet().iterator();
             List<String> bpmnElementIdList = new ArrayList<>();
             while (entryItr.hasNext()) {
                 // process the entry
-                Entry<String, JsonNode> entry = entryItr.next();
+                Entry<String, JsonElement> entry = entryItr.next();
                 String type = entry.getKey();
-                ArrayNode arrayNode = (ArrayNode) entry.getValue();
+                JsonArray arrayNode = entry.getValue().getAsJsonArray();
                 // process each id/from object, like:
                 // {"id":"Policy","from":"StartEvent_1"}
-                for (JsonNode anArrayNode : arrayNode) {
-                    ObjectNode node = (ObjectNode) anArrayNode;
-                    String id = node.get("id").asText();
-                    String fromId = node.get("from").asText();
+                for (JsonElement anArrayNode : arrayNode) {
+                    JsonObject node = anArrayNode.getAsJsonObject();
+                    String id = node.get("id").getAsString();
+                    String fromId = node.get("from").getAsString();
                     ModelBpmnEntry modelBpmnEntry = new ModelBpmnEntry(type, id, fromId);
                     modelBpmn.addEntry(modelBpmnEntry);
                     bpmnElementIdList.add(id);
@@ -89,7 +89,7 @@ public class ModelBpmn {
                 modelBpmn.setBpmnElementIds(bpmnElementIdList);
             }
             return modelBpmn;
-        } catch (IOException e) {
+        } catch (JsonParseException e) {
             throw new ModelBpmnException("Exception occurred during the decoding of the bpmn JSON", e);
         }
     }
index 3d7bbcc..61eeac1 100644 (file)
@@ -25,23 +25,21 @@ package org.onap.clamp.clds.model.properties;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
-
-import java.io.IOException;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonParseException;
 import java.lang.reflect.InvocationTargetException;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
-
 import org.apache.camel.Exchange;
 import org.onap.clamp.clds.client.req.policy.PolicyClient;
 import org.onap.clamp.clds.config.ClampProperties;
 import org.onap.clamp.clds.exception.ModelBpmnException;
 import org.onap.clamp.clds.model.CldsModel;
 import org.onap.clamp.clds.service.CldsService;
-import org.onap.clamp.clds.util.JacksonUtils;
+import org.onap.clamp.clds.util.JsonUtils;
 
 /**
  * Parse model properties.
@@ -51,7 +49,7 @@ public class ModelProperties {
     protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsService.class);
     protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
     private ModelBpmn modelBpmn;
-    private JsonNode modelJson;
+    private JsonObject modelJson;
     private final String modelName;
     private final String controlName;
     private final String actionCd;
@@ -65,6 +63,7 @@ public class ModelProperties {
     public static final String POLICY_GUARD_SUFFIX = "_Guard_";
     private static final Object lock = new Object();
     private static Map<Class<? extends AbstractModelElement>, String> modelElementClasses = new ConcurrentHashMap<>();
+
     static {
         synchronized (lock) {
             modelElementClasses.put(Policy.class, Policy.getType());
@@ -99,9 +98,9 @@ public class ModelProperties {
             this.actionCd = actionCd;
             this.testOnly = isATest;
             modelBpmn = ModelBpmn.create(modelBpmnText);
-            modelJson = JacksonUtils.getObjectMapperInstance().readTree(modelPropText);
+            modelJson = JsonUtils.GSON.fromJson(modelPropText, JsonObject.class);
             instantiateMissingModelElements();
-        } catch (IOException e) {
+        } catch (JsonParseException e) {
             throw new ModelBpmnException("Exception occurred when trying to decode the BPMN Properties JSON", e);
         }
     }
@@ -112,7 +111,7 @@ public class ModelProperties {
      * after instantiation of this ModelProperties, we need to build the missing
      * ModelElement instances.
      */
-    private final void instantiateMissingModelElements() {
+    private void instantiateMissingModelElements() {
         if (modelElementClasses.size() != modelElements.size()) {
             Set<String> missingTypes = new HashSet<>(modelElementClasses.values());
             missingTypes.removeAll(modelElements.keySet());
@@ -124,11 +123,11 @@ public class ModelProperties {
                 .forEach(entry -> {
                     try {
                         modelElements.put(entry.getValue(),
-                            (entry.getKey().getConstructor(ModelProperties.class, ModelBpmn.class, JsonNode.class)
+                            (entry.getKey().getConstructor(ModelProperties.class, ModelBpmn.class, JsonObject.class)
                                 .newInstance(this, modelBpmn, modelJson)));
                     } catch (InstantiationException | NoSuchMethodException | IllegalAccessException
                         | InvocationTargetException e) {
-                        logger.warn("Unable to instantiate a ModelElement, exception follows: ", e);
+                        logger.warn("Unable to instantiate a ModelElement "+ entry.getValue()+", exception follows: ", e);
                     }
                 });
         }
@@ -143,10 +142,10 @@ public class ModelProperties {
     public static String getVf(CldsModel model) {
         List<String> vfs = null;
         try {
-            JsonNode modelJson = JacksonUtils.getObjectMapperInstance().readTree(model.getPropText());
+            JsonObject modelJson = JsonUtils.GSON.fromJson(model.getPropText(), JsonObject.class);
             Global global = new Global(modelJson);
             vfs = global.getResourceVf();
-        } catch (IOException e) {
+        } catch (JsonParseException e) {
             logger.warn("no VF found", e);
         }
         String vf = null;
index 501eb80..059d732 100644 (file)
@@ -25,12 +25,14 @@ package org.onap.clamp.clds.model.properties;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
 
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import java.util.Map.Entry;
 
 /**
  * Parse Policy json properties.
@@ -65,15 +67,15 @@ public class Policy extends AbstractModelElement {
      * @param modelJson
      * @throws IOException
      */
-    public Policy(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) throws IOException {
+    public Policy(ModelProperties modelProp, ModelBpmn modelBpmn, JsonObject modelJson) throws IOException {
         super(TYPE_POLICY, modelProp, modelBpmn, modelJson);
 
         // process policies
         if (modelElementJsonNode != null) {
-            Iterator<JsonNode> itr = modelElementJsonNode.elements();
+            Iterator<Entry<String, JsonElement>> itr = modelElementJsonNode.getAsJsonObject().entrySet().iterator();
             policyChains = new ArrayList<>();
             while (itr.hasNext()) {
-                policyChains.add(new PolicyChain(itr.next()));
+                policyChains.add(new PolicyChain(itr.next().getValue()));
             }
         }
     }
index cf24c78..f29ba16 100644 (file)
@@ -25,12 +25,13 @@ package org.onap.clamp.clds.model.properties;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
-
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import org.onap.clamp.clds.util.JsonUtils;
 
 /**
  * Parse Policy json properties.
@@ -66,20 +67,21 @@ public class PolicyChain {
     private List<PolicyItem>          policyItems;
     private String                    policyType;
 
-    public PolicyChain(JsonNode node) throws IOException {
-
-        policyId = AbstractModelElement.getValueByName(node, "pid");
-        timeout = AbstractModelElement.getIntValueByName(node, "timeout");
-        policyType = AbstractModelElement.getValueByName(node, "policyType");
+    public PolicyChain(JsonElement node) throws IOException {
+        if (node != null && node.isJsonArray() && node.getAsJsonArray().size() > 0) {
+            JsonArray operationalPolicyParameters = node.getAsJsonArray();
+            policyId = JsonUtils.getStringValueByName(node, "pid");
+            timeout = JsonUtils.getIntValueByName(node, "timeout");
+            policyType = JsonUtils.getStringValueByName(node, "policyType");
 
-        if(node != null && node.size() > 0) {
-            JsonNode policyNode = node.get(node.size() - 1).get("policyConfigurations");
-            if(policyNode != null) {
-                Iterator<JsonNode> itr = policyNode.elements();
-                policyItems = new ArrayList<>();
-                while (itr.hasNext()) {
-                    policyItems.add(new PolicyItem(itr.next()));
-                }
+            JsonArray policyConfigurations = operationalPolicyParameters.get(operationalPolicyParameters.size() - 1)
+                .getAsJsonObject()
+                .get("policyConfigurations")
+                .getAsJsonArray();
+            Iterator<JsonElement> itr = policyConfigurations.iterator();
+            policyItems = new ArrayList<>();
+            while (itr.hasNext()) {
+                policyItems.add(new PolicyItem(itr.next()));
 
             }
         }
index d6deddc..bb57d5d 100644 (file)
@@ -25,14 +25,14 @@ package org.onap.clamp.clds.model.properties;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.core.type.TypeReference;
-import com.fasterxml.jackson.databind.JsonNode;
 
+import com.google.gson.JsonElement;
+import com.google.gson.reflect.TypeToken;
 import java.io.IOException;
 import java.util.List;
 import java.util.Map;
 
-import org.onap.clamp.clds.util.JacksonUtils;
+import org.onap.clamp.clds.util.JsonUtils;
 import org.yaml.snakeyaml.Yaml;
 
 /**
@@ -86,51 +86,48 @@ public class PolicyItem implements Cloneable {
     /**
      * Parse Policy given json node.
      *
-     * @param node
+     * @param item
      * @throws IOException
      */
-    public PolicyItem(JsonNode node) throws IOException {
-        id = AbstractModelElement.getValueByName(node, "_id");
-        recipe = AbstractModelElement.getValueByName(node, "recipe");
-        maxRetries = AbstractModelElement.getIntValueByName(node, "maxRetries");
-        retryTimeLimit = AbstractModelElement.getIntValueByName(node, "retryTimeLimit");
-        parentPolicy = AbstractModelElement.getValueByName(node, "parentPolicy");
-        parentPolicyConditions = AbstractModelElement.getValuesByName(node, "parentPolicyConditions");
-        targetResourceId = AbstractModelElement.getValueByName(node, "targetResourceId");
+    public PolicyItem(JsonElement item) throws IOException {
+        id = JsonUtils.getStringValueByName(item, "_id");
+        recipe = JsonUtils.getStringValueByName(item, "recipe");
+        maxRetries = JsonUtils.getIntValueByName(item, "maxRetries");
+        retryTimeLimit = JsonUtils.getIntValueByName(item, "retryTimeLimit");
+        parentPolicy = JsonUtils.getStringValueByName(item, "parentPolicy");
+        parentPolicyConditions = JsonUtils.getStringValuesByName(item, "parentPolicyConditions");
+        targetResourceId = JsonUtils.getStringValueByName(item, "targetResourceId");
         if (targetResourceId != null && targetResourceId.isEmpty()) {
             this.setTargetResourceId(null);
         }
-        recipeInfo = AbstractModelElement.getValueByName(node, "recipeInfo");
-        recipeLevel = AbstractModelElement.getValueByName(node, "recipeLevel");
-        recipeInput = AbstractModelElement.getValueByName(node, "recipeInput");
-        String payload = AbstractModelElement.getValueByName(node, "recipePayload");
+        recipeInfo = JsonUtils.getStringValueByName(item, "recipeInfo");
+        recipeLevel = JsonUtils.getStringValueByName(item, "recipeLevel");
+        recipeInput = JsonUtils.getStringValueByName(item, "recipeInput");
+        String payload = JsonUtils.getStringValueByName(item, "recipePayload");
 
         if (payload != null && !payload.isEmpty()) {
             if (payload.trim().startsWith("{") && payload.trim().endsWith("}")) {
                 // Seems to be a JSON
-                recipePayload = JacksonUtils.getObjectMapperInstance().readValue(payload,
-                    new TypeReference<Map<String, String>>() {
-                    });
+                recipePayload = JsonUtils.GSON.fromJson(payload, new TypeToken<Map<String, String>>() {}.getType());
             } else {
                 // SHould be a YAML then
-                Yaml yaml = new Yaml();
-                recipePayload = (Map<String, String>) yaml.load(payload);
+                recipePayload = new Yaml().load(payload);
             }
         }
-        oapRop = AbstractModelElement.getValueByName(node, "oapRop");
-        oapLimit = AbstractModelElement.getValueByName(node, "oapLimit");
-        actor = AbstractModelElement.getValueByName(node, "actor");
-
-        enableGuardPolicy = AbstractModelElement.getValueByName(node, "enableGuardPolicy");
-        guardPolicyType = AbstractModelElement.getValueByName(node, "guardPolicyType");
-        guardTargets = AbstractModelElement.getValueByName(node, "guardTargets");
-        minGuard = AbstractModelElement.getValueByName(node, "minGuard");
-        maxGuard = AbstractModelElement.getValueByName(node, "maxGuard");
-        limitGuard = AbstractModelElement.getValueByName(node, "limitGuard");
-        timeUnitsGuard = AbstractModelElement.getValueByName(node, "timeUnitsGuard");
-        timeWindowGuard = AbstractModelElement.getValueByName(node, "timeWindowGuard");
-        guardActiveStart = AbstractModelElement.getValueByName(node, "guardActiveStart");
-        guardActiveEnd = AbstractModelElement.getValueByName(node, "guardActiveEnd");
+        oapRop = JsonUtils.getStringValueByName(item, "oapRop");
+        oapLimit = JsonUtils.getStringValueByName(item, "oapLimit");
+        actor = JsonUtils.getStringValueByName(item, "actor");
+
+        enableGuardPolicy = JsonUtils.getStringValueByName(item, "enableGuardPolicy");
+        guardPolicyType = JsonUtils.getStringValueByName(item, "guardPolicyType");
+        guardTargets = JsonUtils.getStringValueByName(item, "guardTargets");
+        minGuard = JsonUtils.getStringValueByName(item, "minGuard");
+        maxGuard = JsonUtils.getStringValueByName(item, "maxGuard");
+        limitGuard = JsonUtils.getStringValueByName(item, "limitGuard");
+        timeUnitsGuard = JsonUtils.getStringValueByName(item, "timeUnitsGuard");
+        timeWindowGuard = JsonUtils.getStringValueByName(item, "timeWindowGuard");
+        guardActiveStart = JsonUtils.getStringValueByName(item, "guardActiveStart");
+        guardActiveEnd = JsonUtils.getStringValueByName(item, "guardActiveEnd");
     }
 
     /**
index 7297ccb..5080822 100644 (file)
@@ -25,7 +25,10 @@ package org.onap.clamp.clds.model.properties;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import java.util.Map.Entry;
+import java.util.Set;
 
 /**
  * Parse ONAP Tca json properties.
@@ -47,12 +50,14 @@ public class Tca extends AbstractModelElement {
      * @param modelBpmn
      * @param modelJson
      */
-    public Tca(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) {
+    public Tca(ModelProperties modelProp, ModelBpmn modelBpmn, JsonObject modelJson) {
         super(TYPE_TCA, modelProp, modelBpmn, modelJson);
 
         // process Server_Configurations
         if (modelElementJsonNode != null) {
-            tcaItem = new TcaItem(modelElementJsonNode.elements().next());
+            //this is wrong assumption that there is only one property object
+            Set<Entry<String, JsonElement>> entries = modelElementJsonNode.getAsJsonObject().entrySet();
+            tcaItem = new TcaItem(entries.iterator().next().getValue());
         }
     }
 
index 3a4ea71..987b776 100644 (file)
@@ -25,11 +25,13 @@ package org.onap.clamp.clds.model.properties;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
 
+import com.google.gson.JsonArray;
+import com.google.gson.JsonElement;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
+import org.onap.clamp.clds.util.JsonUtils;
 
 /**
  * Parse ONAP Tca Item json properties.
@@ -50,21 +52,23 @@ public class TcaItem {
     /**
      * Parse Tca Item given json node
      *
-     * @param node
+     * @param tcaJson
      */
-    public TcaItem(JsonNode node) {
+    public TcaItem(JsonElement tcaJson) {
 
-        tcaName = AbstractModelElement.getValueByName(node, "tname");
-        tcaUuId = AbstractModelElement.getValueByName(node, "tuuid");
-        policyId = AbstractModelElement.getValueByName(node, "tcaPolId");
-        eventName = AbstractModelElement.getValueByName(node, "eventName");
-        controlLoopSchemaType = AbstractModelElement.getValueByName(node, "controlLoopSchemaType");
+        tcaName = JsonUtils.getStringValueByName(tcaJson, "tname");
+        tcaUuId = JsonUtils.getStringValueByName(tcaJson, "tuuid");
+        policyId = JsonUtils.getStringValueByName(tcaJson, "tcaPolId");
+        eventName = JsonUtils.getStringValueByName(tcaJson, "eventName");
+        controlLoopSchemaType = JsonUtils.getStringValueByName(tcaJson, "controlLoopSchemaType");
         // process service Configurations
-        JsonNode serviceConfigurationsNode = node.get(node.size() - 1).get("serviceConfigurations");
-        Iterator<JsonNode> itr = serviceConfigurationsNode.elements();
+        JsonArray tcaConfigurationArray = tcaJson.getAsJsonArray();
+        JsonArray serviceConfigurationsNode = tcaConfigurationArray.get(tcaConfigurationArray.size() - 1)
+            .getAsJsonObject().get("serviceConfigurations").getAsJsonArray();
+        Iterator<JsonElement> itr = serviceConfigurationsNode.iterator();
         tcaThresholds = new ArrayList<>();
         while (itr.hasNext()) {
-            tcaThresholds.add(new TcaThreshold(itr.next()));
+            tcaThresholds.add(new TcaThreshold(itr.next().getAsJsonArray()));
         }
     }
 
index 05b8ae3..0903d72 100644 (file)
@@ -25,7 +25,7 @@ package org.onap.clamp.clds.model.properties;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
+import com.google.gson.JsonArray;
 
 /**
  * Parse ONAP Tca Threshold json properties.
@@ -44,21 +44,21 @@ public class TcaThreshold {
     /**
      * Parse Tca Threshhold given json node
      *
-     * @param node
+     * @param tcaTresholdConfiguration
      */
-    public TcaThreshold(JsonNode node) {
+    public TcaThreshold(JsonArray tcaTresholdConfiguration) {
 
-        if (node.get(0) != null) {
-            fieldPath = node.get(0).asText();
+        if (tcaTresholdConfiguration.get(0) != null) {
+            fieldPath = tcaTresholdConfiguration.get(0).getAsString();
         }
-        if (node.get(1) != null) {
-            operator = node.get(1).asText();
+        if (tcaTresholdConfiguration.get(1) != null) {
+            operator = tcaTresholdConfiguration.get(1).getAsString();
         }
-        if (node.get(2) != null) {
-            threshold = Integer.valueOf(node.get(2).asText());
+        if (tcaTresholdConfiguration.get(2) != null) {
+            threshold = Integer.valueOf(tcaTresholdConfiguration.get(2).getAsString());
         }
-        if (node.get(3) != null) {
-            closedLoopEventStatus = node.get(3).asText();
+        if (tcaTresholdConfiguration.get(3) != null) {
+            closedLoopEventStatus = tcaTresholdConfiguration.get(3).getAsString();
         }
     }
 
index 382c1d7..94cffbb 100644 (file)
@@ -25,8 +25,8 @@ package org.onap.clamp.clds.sdc.controller.installer;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 
+import com.google.gson.JsonObject;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -51,7 +51,7 @@ import org.onap.clamp.clds.model.properties.ModelProperties;
 import org.onap.clamp.clds.service.CldsService;
 import org.onap.clamp.clds.service.CldsTemplateService;
 import org.onap.clamp.clds.transform.XslTransformer;
-import org.onap.clamp.clds.util.JacksonUtils;
+import org.onap.clamp.clds.util.JsonUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.ApplicationContext;
@@ -59,9 +59,8 @@ import org.springframework.transaction.annotation.Transactional;
 import org.yaml.snakeyaml.Yaml;
 
 /**
- * This class will be instantiated by spring config, and used by Sdc Controller.
- * There is no state kept by the bean. It's used to deploy the csar/notification
- * received from SDC in DB.
+ * This class will be instantiated by spring config, and used by Sdc Controller. There is no state kept by the bean.
+ * It's used to deploy the csar/notification received from SDC in DB.
  */
 public class CsarInstallerImpl implements CsarInstaller {
 
@@ -103,7 +102,7 @@ public class CsarInstallerImpl implements CsarInstaller {
         for (Entry<String, BlueprintArtifact> blueprint : csar.getMapOfBlueprints().entrySet()) {
             alreadyInstalled = alreadyInstalled
                 && (CldsModel.retrieve(cldsDao, buildModelName(csar, blueprint.getKey()), true).getId() != null) ? true
-                    : false;
+                : false;
         }
         return alreadyInstalled;
     }
@@ -165,22 +164,20 @@ public class CsarInstallerImpl implements CsarInstaller {
         return listConfig.get(0);
     }
 
-    private static String getAllBlueprintParametersInJson(BlueprintArtifact blueprintArtifact) {
-        ObjectNode node = JacksonUtils.getObjectMapperInstance().createObjectNode();
+    String getAllBlueprintParametersInJson(BlueprintArtifact blueprintArtifact) {
+        JsonObject node = new JsonObject();
         Yaml yaml = new Yaml();
         Map<String, Object> inputsNodes = ((Map<String, Object>) ((Map<String, Object>) yaml
             .load(blueprintArtifact.getDcaeBlueprint())).get("inputs"));
         inputsNodes.entrySet().stream().filter(e -> !e.getKey().contains("policy_id")).forEach(elem -> {
-            Object defaultNode = ((Map<String, Object>) elem.getValue()).get("default");
-            if (defaultNode != null && defaultNode instanceof String) {
-                node.put(elem.getKey(), (String) defaultNode);
-            } else if (defaultNode != null) {
-                node.putPOJO(elem.getKey(), defaultNode);
+            Object defaultValue = ((Map<String, Object>) elem.getValue()).get("default");
+            if (defaultValue != null) {
+                addPropertyToNode(node, elem.getKey(), defaultValue);
             } else {
-                node.put(elem.getKey(), "");
+                node.addProperty(elem.getKey(), "");
             }
         });
-        node.put("policy_id", "AUTO_GENERATED_POLICY_ID_AT_SUBMIT");
+        node.addProperty("policy_id", "AUTO_GENERATED_POLICY_ID_AT_SUBMIT");
         return node.toString();
     }
 
@@ -217,14 +214,10 @@ public class CsarInstallerImpl implements CsarInstaller {
     }
 
     /**
-     * This call must be done when deploying the SDC notification as this call get
-     * the latest version of the artifact (version can be specified to DCAE call)
+     * This call must be done when deploying the SDC notification as this call get the latest version of the artifact
+     * (version can be specified to DCAE call)
      *
-     * @param blueprintArtifact
      * @return The DcaeInventoryResponse object containing the dcae values
-     * @throws IOException
-     * @throws ParseException
-     * @throws InterruptedException
      */
     private DcaeInventoryResponse queryDcaeToGetServiceTypeId(BlueprintArtifact blueprintArtifact)
         throws IOException, ParseException, InterruptedException {
@@ -292,4 +285,18 @@ public class CsarInstallerImpl implements CsarInstaller {
             + inputParams + "]}");
         return cldsModel.save(cldsDao, null);
     }
+
+    private void addPropertyToNode(JsonObject node, String key, Object value) {
+        if (value instanceof String) {
+            node.addProperty(key, (String) value);
+        } else if (value instanceof Number) {
+            node.addProperty(key, (Number) value);
+        } else if (value instanceof Boolean) {
+            node.addProperty(key, (Boolean) value);
+        } else if (value instanceof Character) {
+            node.addProperty(key, (Character) value);
+        } else {
+            node.addProperty(key, JsonUtils.GSON.toJson(value));
+        }
+    }
 }
index 206a424..2bad07f 100644 (file)
@@ -26,11 +26,12 @@ package org.onap.clamp.clds.service;
 
 import com.att.eelf.configuration.EELFLogger;
 import com.att.eelf.configuration.EELFManager;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.node.ObjectNode;
 
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.reflect.TypeToken;
 import java.io.IOException;
+import java.lang.reflect.Type;
 import java.security.GeneralSecurityException;
 import java.util.Date;
 import java.util.List;
@@ -64,12 +65,11 @@ import org.onap.clamp.clds.model.CldsServiceData;
 import org.onap.clamp.clds.model.CldsTemplate;
 import org.onap.clamp.clds.model.DcaeEvent;
 import org.onap.clamp.clds.model.ValueItem;
-import org.onap.clamp.clds.model.properties.AbstractModelElement;
 import org.onap.clamp.clds.model.properties.ModelProperties;
 import org.onap.clamp.clds.model.sdc.SdcServiceInfo;
 import org.onap.clamp.clds.sdc.controller.installer.CsarInstallerImpl;
 import org.onap.clamp.clds.transform.XslTransformer;
-import org.onap.clamp.clds.util.JacksonUtils;
+import org.onap.clamp.clds.util.JsonUtils;
 import org.onap.clamp.clds.util.LoggingUtils;
 import org.onap.clamp.clds.util.ONAPLogConstants;
 import org.slf4j.event.Level;
@@ -86,6 +86,8 @@ import org.springframework.web.client.HttpClientErrorException;
 @Component
 public class CldsService extends SecureServiceBase {
 
+    public static final Type LIST_OF_SDC_SERVICE_INFO_TYPE = new TypeToken<List<SdcServiceInfo>>() {
+    }.getType();
     @Produce(uri = "direct:processSubmit")
     private CamelProxy camelProxy;
     protected static final EELFLogger securityLogger = EELFManager.getInstance().getSecurityLogger();
@@ -333,7 +335,7 @@ public class CldsService extends SecureServiceBase {
      *
      * @param action
      * @param modelName
-     * @param validateFlag
+     * @param test
      * @param model
      * @return
      * @throws TransformerException
@@ -500,7 +502,7 @@ public class CldsService extends SecureServiceBase {
      *         In case of issues
      */
     public String getSdcProperties() throws IOException {
-        return ((ObjectNode) refProp.getJsonTemplate(GLOBAL_PROPERTIES_KEY)).toString();
+        return refProp.getJsonTemplate(GLOBAL_PROPERTIES_KEY).toString();
     }
 
     /**
@@ -581,21 +583,19 @@ public class CldsService extends SecureServiceBase {
         if (StringUtils.isBlank(responseStr)) {
             return "";
         }
-        ObjectMapper objectMapper = JacksonUtils.getObjectMapperInstance();
-        List<SdcServiceInfo> rawList = objectMapper.readValue(responseStr,
-            objectMapper.getTypeFactory().constructCollectionType(List.class, SdcServiceInfo.class));
-        ObjectNode invariantIdServiceNode = objectMapper.createObjectNode();
-        ObjectNode serviceNode = objectMapper.createObjectNode();
+        List<SdcServiceInfo> rawList = JsonUtils.GSON.fromJson(responseStr, LIST_OF_SDC_SERVICE_INFO_TYPE);
+        JsonObject invariantIdServiceNode = new JsonObject();
+        JsonObject serviceNode = new JsonObject();
         logger.info("value of cldsserviceiNfolist: {}", rawList);
         if (rawList != null && !rawList.isEmpty()) {
             List<SdcServiceInfo> cldsSdcServiceInfoList = sdcCatalogServices.removeDuplicateServices(rawList);
             for (SdcServiceInfo currCldsSdcServiceInfo : cldsSdcServiceInfoList) {
                 if (currCldsSdcServiceInfo != null) {
-                    invariantIdServiceNode.put(currCldsSdcServiceInfo.getInvariantUUID(),
+                    invariantIdServiceNode.addProperty(currCldsSdcServiceInfo.getInvariantUUID(),
                         currCldsSdcServiceInfo.getName());
                 }
             }
-            serviceNode.putPOJO("service", invariantIdServiceNode);
+            serviceNode.add("service", invariantIdServiceNode);
         }
         return serviceNode.toString();
     }
@@ -710,16 +710,17 @@ public class CldsService extends SecureServiceBase {
     }
 
     private void checkForDuplicateServiceVf(String modelName, String modelPropText) throws IOException {
-        JsonNode globalNode = JacksonUtils.getObjectMapperInstance().readTree(modelPropText).get("global");
-        String service = AbstractModelElement.getValueByName(globalNode, "service");
-        List<String> resourceVf = AbstractModelElement.getValuesByName(globalNode, "vf");
+        JsonElement globalNode = JsonUtils.GSON.fromJson(modelPropText, JsonObject.class).get("global");
+        String service = JsonUtils.getStringValueByName(globalNode, "service");
+        List<String> resourceVf = JsonUtils.getStringValuesByName(globalNode, "vf");
         if (service != null && resourceVf != null && !resourceVf.isEmpty()) {
             List<CldsModelProp> cldsModelPropList = cldsDao.getDeployedModelProperties();
             for (CldsModelProp cldsModelProp : cldsModelPropList) {
-                JsonNode currentNode = JacksonUtils.getObjectMapperInstance().readTree(cldsModelProp.getPropText())
+                JsonElement currentNode = JsonUtils.GSON
+                    .fromJson(cldsModelProp.getPropText(), JsonObject.class)
                     .get("global");
-                String currentService = AbstractModelElement.getValueByName(currentNode, "service");
-                List<String> currentVf = AbstractModelElement.getValuesByName(currentNode, "vf");
+                String currentService = JsonUtils.getStringValueByName(currentNode, "service");
+                List<String> currentVf = JsonUtils.getStringValuesByName(currentNode, "vf");
                 if (currentVf != null && !currentVf.isEmpty()) {
                     if (!modelName.equalsIgnoreCase(cldsModelProp.getName()) && service.equalsIgnoreCase(currentService)
                         && resourceVf.get(0).equalsIgnoreCase(currentVf.get(0))) {
index b30397d..82b7727 100644 (file)
@@ -87,7 +87,7 @@ public class CldsUser {
 
     /**
      * Sets the permissions.
-     * 
+     *
      * @param permissionsArray
      *            the permissions to set
      */
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP CLAMP
  * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights
  *                             reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * limitations under the License.
  * ============LICENSE_END============================================
  * ===================================================================
- * 
+ *
  */
 
 package org.onap.clamp.clds.service;
 
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-import javax.ws.rs.ext.ContextResolver;
-
-import org.onap.clamp.clds.util.JacksonUtils;
-
-/**
- * This class is to restrcit the class type that can be de-serialized.
- */
-public class JacksonObjectMapperProvider implements ContextResolver<ObjectMapper> {
+import com.google.gson.Gson;
+import com.google.gson.JsonDeserializationContext;
+import com.google.gson.JsonDeserializer;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonParseException;
+import java.lang.reflect.Type;
 
-    private final ObjectMapper defaultObjectMapper;
-
-    public JacksonObjectMapperProvider() {
-        defaultObjectMapper = createDefaultMapper();
-    }
+public class SecureServicePermissionDeserializer implements JsonDeserializer<SecureServicePermission> {
 
     @Override
-    public ObjectMapper getContext(Class<?> type) {
-        return defaultObjectMapper;
-    }
-
-    private static ObjectMapper createDefaultMapper() {
-        return JacksonUtils.getObjectMapperInstance();
+    public SecureServicePermission deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
+        throws JsonParseException {
+        if (json.isJsonPrimitive()) {
+            return new SecureServicePermission(json.getAsString());
+        } else {
+            // if not string try default deserialization
+            return new Gson().fromJson(json, SecureServicePermission.class);
+        }
     }
 }
diff --git a/src/main/java/org/onap/clamp/clds/util/JacksonUtils.java b/src/main/java/org/onap/clamp/clds/util/JacksonUtils.java
deleted file mode 100644 (file)
index 1f5419d..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License"); 
- * you may not use this file except in compliance with the License. 
- * You may obtain a copy of the License at
- * 
- * http://www.apache.org/licenses/LICENSE-2.0
- * 
- * Unless required by applicable law or agreed to in writing, software 
- * distributed under the License is distributed on an "AS IS" BASIS, 
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
- * See the License for the specific language governing permissions and 
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- * 
- */
-
-package org.onap.clamp.clds.util;
-
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * This class is used to access the jackson with restricted type access.
- */
-public class JacksonUtils {
-
-    private static ObjectMapper objectMapper;
-
-    private JacksonUtils() {
-    }
-
-    /**
-     * Call this method to retrieve a secure ObjectMapper.
-     * 
-     * @return an ObjectMapper instance (same for clamp)
-     */
-    public static synchronized ObjectMapper getObjectMapperInstance() {
-        if (objectMapper == null) {
-            objectMapper = new ObjectMapper();
-            // This is to disable the security hole that could be opened for
-            // json deserialization, if needed do this
-            // objectMapper.enableDefaultTyping(DefaultTyping.NON_FINAL);
-            objectMapper.disableDefaultTyping();
-        }
-        return objectMapper;
-    }
-}
diff --git a/src/main/java/org/onap/clamp/clds/util/JsonUtils.java b/src/main/java/org/onap/clamp/clds/util/JsonUtils.java
new file mode 100644 (file)
index 0000000..96ddc29
--- /dev/null
@@ -0,0 +1,170 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ *                             reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.util;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+import com.google.common.collect.Lists;
+import com.google.gson.Gson;
+import com.google.gson.GsonBuilder;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import com.google.gson.JsonPrimitive;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+import java.util.Spliterator;
+import java.util.Spliterators;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+import org.onap.clamp.clds.model.properties.AbstractModelElement;
+import org.onap.clamp.clds.service.SecureServicePermission;
+import org.onap.clamp.clds.service.SecureServicePermissionDeserializer;
+
+/**
+ * This class is used to access the jackson with restricted type access.
+ */
+public class JsonUtils {
+
+    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(AbstractModelElement.class);
+    private static final String LOG_ELEMENT_NOT_FOUND = "Value '{}' for key 'name' not found in JSON";
+    private static final String LOG_ELEMENT_NOT_FOUND_IN_JSON = "Value '{}' for key 'name' not found in JSON {}";
+
+    public static final Gson GSON = new GsonBuilder()
+        .registerTypeAdapter(SecureServicePermission.class, new SecureServicePermissionDeserializer())
+        .create();
+
+    private JsonUtils() {
+    }
+
+
+    /**
+     * Return the value field of the json node element that has a name field equals to the given name.
+     */
+    public static String getStringValueByName(JsonElement jsonElement, String name) {
+        String value = extractJsonValueFromElement(jsonElement, name)
+            .map(JsonUtils::extractStringValueFromElement)
+            .orElse(null);
+        if (value == null) {
+            if (logger.isDebugEnabled()) {
+                logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, jsonElement.toString());
+            } else {
+                logger.warn(LOG_ELEMENT_NOT_FOUND, name);
+            }
+        }
+        return value;
+    }
+
+    /**
+     * Return an array of values for the field of the json node element that has a name field equals to the given name.
+     */
+    public static List<String> getStringValuesByName(JsonElement jsonElement, String name) {
+        List<String> values = extractJsonValueFromElement(jsonElement, name)
+            .map(JsonUtils::extractStringValuesFromElement).orElse(new ArrayList<>());
+        if (values.isEmpty()) {
+            if (logger.isDebugEnabled()) {
+                logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, jsonElement.toString());
+            } else {
+                logger.warn(LOG_ELEMENT_NOT_FOUND, name);
+            }
+        }
+        return values;
+    }
+
+    /**
+     * Return the int value field of the json node element that has a name field equals to the given name.
+     */
+    public static Integer getIntValueByName(JsonElement element, String name) {
+        String value = getStringValueByName(element, name);
+        return Integer.valueOf(value);
+    }
+
+
+    /**
+     * Return the Json value field of the json node element that has a name field equals to the given name.
+     */
+    public static JsonObject getJsonObjectByName(JsonElement jsonElement, String name) {
+        JsonObject jsonObject = extractJsonValueFromElement(jsonElement, name).map(JsonElement::getAsJsonObject)
+            .orElse(null);
+        if (jsonObject  == null) {
+            logger.warn(LOG_ELEMENT_NOT_FOUND, name);
+        } else {
+            logger.debug(LOG_ELEMENT_NOT_FOUND_IN_JSON, name, jsonElement.toString());
+        }
+        return jsonObject;
+    }
+
+    private static Optional<JsonElement> extractJsonValueFromElement(JsonElement jsonElement, String name) {
+        if(jsonElement != null ){
+            if (jsonElement.isJsonArray()) {
+                return extractValueJsonFromArray(jsonElement, name);
+            } else if (hasMatchingParameterName(name, jsonElement)) {
+                return Optional.of(jsonElement);
+            }
+        }
+        return Optional.empty();
+    }
+
+    private static Optional<JsonElement> extractValueJsonFromArray(JsonElement jsonElement, String name) {
+        for (JsonElement element : jsonElement.getAsJsonArray()) {
+            if (hasMatchingParameterName(name, element)) {
+                return Optional.of(element.getAsJsonObject().get("value"));
+            }
+        }
+        return Optional.empty();
+    }
+
+    private static boolean hasMatchingParameterName(String name, JsonElement element) {
+        return element.isJsonObject()
+            && element.getAsJsonObject().has("name")
+            && name.equals(element.getAsJsonObject().get("name").getAsString());
+    }
+
+    private static String extractStringValueFromElement(JsonElement element) {
+        if (element.isJsonArray()) {
+            return element.getAsJsonArray().get(0).getAsString();
+        } else if (element.isJsonPrimitive()) {
+            return element.getAsJsonPrimitive().getAsString();
+        } else {
+            return GSON.toJson(element);
+        }
+    }
+
+    private static List<String> extractStringValuesFromElement(JsonElement element) {
+        if (element.isJsonArray()) {
+            return StreamSupport.stream(
+                Spliterators.spliteratorUnknownSize(element.getAsJsonArray().iterator(), Spliterator.ORDERED),
+                false)
+                .filter(JsonElement::isJsonPrimitive)
+                .map(JsonElement::getAsJsonPrimitive)
+                .filter(JsonPrimitive::isString)
+                .map(JsonPrimitive::getAsString)
+                .collect(Collectors.toList());
+        } else {
+            String value = extractStringValueFromElement(element);
+            return Lists.newArrayList(value);
+        }
+
+    }
+}
index c492f74..91a4cab 100644 (file)
@@ -73,6 +73,7 @@ server.http-to-https-redirection.port=8080
 server.servlet.context-path=/
 #Modified engine-rest applicationpath
 spring.profiles.active=clamp-default,clamp-aaf-authentication,clamp-sdc-controller
+spring.http.converters.preferred-json-mapper=gson
 
 #The max number of active threads in this pool
 server.tomcat.max-threads=200
index c828f78..1b01f54 100644 (file)
@@ -23,9 +23,8 @@
 
 package org.onap.clamp.clds.client;
 
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.common.collect.ImmutableMap;
+import com.google.gson.JsonObject;
 import java.io.IOException;
 import org.assertj.core.api.Assertions;
 import org.junit.Before;
@@ -61,9 +60,13 @@ public class DcaeDispatcherServicesTest {
     @InjectMocks
     DcaeDispatcherServices dcaeDispatcherServices;
 
-    private final String STATUS_RESPONSE_PROCESSING = "{\"operationType\": \"deploy\",\"status\": \"processing\"}";
-    private final String STATUS_RESPONSE_ACTIVE = "{\"operationType\": \"deploy\",\"status\": \"succeeded\"}";
+    private static final String STATUS_RESPONSE_PROCESSING = "{\"operationType\": \"deploy\","
+        + "\"status\": \"processing\"}";
+    private static final String STATUS_RESPONSE_ACTIVE = "{\"operationType\": \"deploy\",\"status\": \"succeeded\"}";
 
+    /**
+     * Setup method.
+     */
     @Before
     public void setUp() {
         ImmutableMap.<String, String>builder()
@@ -126,10 +129,10 @@ public class DcaeDispatcherServicesTest {
     @Test
     public void shouldTriggerDeploymentCreation() throws IOException {
         //given
-        String deploymentID = "closedLoop_152367c8-b172-47b3-9e58-c53add75d869_deploymentId";
+        String deploymentId = "closedLoop_152367c8-b172-47b3-9e58-c53add75d869_deploymentId";
         String serviceTypeId = "e2ba40f7-bf42-41e7-acd7-48fd07586d90";
         Mockito.when(clampProperties.getJsonTemplate("dcae.deployment.template"))
-                .thenReturn(new ObjectMapper().readTree("{}"));
+                .thenReturn(new JsonObject());
 
         Mockito.when(dcaeHttpConnectionManager
                 .doDcaeHttpQuery(DCAE_URL
@@ -138,11 +141,11 @@ public class DcaeDispatcherServicesTest {
                         "{\"serviceTypeId\":\"e2ba40f7-bf42-41e7-acd7-48fd07586d90\",\"inputs\":{}}",
                         "application/json"))
                 .thenReturn(DEPLOY_RESPONSE_STRING);
-        JsonNode blueprintInputJson = new ObjectMapper().readTree("{}");
+        JsonObject blueprintInputJson = new JsonObject();
 
         //when
         String operationStatus = dcaeDispatcherServices
-                .createNewDeployment(deploymentID, serviceTypeId, blueprintInputJson);
+                .createNewDeployment(deploymentId, serviceTypeId, blueprintInputJson);
 
         //then
         Assertions.assertThat(operationStatus).isEqualTo("http://deployment-handler.onap:8443/"
index f163456..3178580 100644 (file)
@@ -44,6 +44,9 @@ public class GuardPolicyAttributesConstructorTest {
     private ModelProperties modelProperties;
     private List<PolicyChain> policyChains;
 
+    /**
+     * @throws Exception thrown if resources not found.
+     */
     @Before
     public void setUp() throws Exception {
         String modelProp = ResourceFileUtil
index 293f0e6..4d78cf8 100644 (file)
 
 package org.onap.clamp.clds.client.req.policy;
 
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
 import com.google.common.collect.ImmutableMap;
-
+import com.google.gson.JsonElement;
 import java.io.IOException;
 import java.net.URLDecoder;
 import java.util.Map;
-
 import org.assertj.core.api.Assertions;
 import org.junit.Before;
 import org.junit.Test;
@@ -39,6 +36,7 @@ import org.mockito.Mockito;
 import org.onap.clamp.clds.config.ClampProperties;
 import org.onap.clamp.clds.model.properties.ModelProperties;
 import org.onap.clamp.clds.model.properties.PolicyChain;
+import org.onap.clamp.clds.util.JsonUtils;
 import org.onap.clamp.clds.util.ResourceFileUtil;
 import org.onap.policy.api.AttributeType;
 import org.onap.policy.controlloop.policy.ControlLoopPolicy;
@@ -54,6 +52,9 @@ public class OperationalPolicyAttributesConstructorTest {
     private ModelProperties modelProperties;
     private PolicyChain policyChain;
 
+    /**
+     * @throws Exception thrown if resource not found.
+     */
     @Before
     public void setUp() throws Exception {
         String modelProp = ResourceFileUtil
@@ -140,7 +141,7 @@ public class OperationalPolicyAttributesConstructorTest {
     private PolicyChain readPolicyChainFromResources() throws IOException {
         String policyChainText = ResourceFileUtil
             .getResourceAsString("example/operational-policy/json-policy-chain.json");
-        JsonNode policyChainNode = new ObjectMapper().readTree(policyChainText);
+        JsonElement policyChainNode = JsonUtils.GSON.fromJson(policyChainText, JsonElement.class);
         return new PolicyChain(policyChainNode);
     }
 }
diff --git a/src/test/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatterTest.java b/src/test/java/org/onap/clamp/clds/client/req/tca/TcaRequestFormatterTest.java
new file mode 100644 (file)
index 0000000..095df9d
--- /dev/null
@@ -0,0 +1,98 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights
+ *                             reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.client.req.tca;
+
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.mockito.Matchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import com.google.gson.JsonObject;
+import java.io.IOException;
+import org.junit.Test;
+import org.onap.clamp.clds.config.ClampProperties;
+import org.onap.clamp.clds.model.properties.ModelProperties;
+import org.onap.clamp.clds.model.properties.Tca;
+import org.onap.clamp.clds.model.properties.TcaItem;
+import org.onap.clamp.clds.util.JsonUtils;
+
+public class TcaRequestFormatterTest {
+
+    private static final String TCA_POLICY_PROPERTIES_TEMPLATE = "{"
+        + " \"domain\": \"measurementsForVfScaling\","
+        + " \"metricsPerEventName\": ["
+        + "  {"
+        + "   \"eventName\": \"???\","
+        + "   \"controlLoopSchemaType\": \"VNF\","
+        + "   \"policyScope\": \"DCAE\","
+        + "   \"policyName\": \"???\","
+        + "   \"policyVersion\": \"v0.0.1\","
+        + "   \"thresholds\": ["
+        + "   ]"
+        + "  }"
+        + " ]"
+        + "}";
+
+    @Test
+    public void shouldReturnFormattedTcaPolicyRequest() throws IOException {
+        //given
+        String service = "TestService";
+        String policy = "TestService_scope.PolicyName";
+        ClampProperties clampProperties = mock(ClampProperties.class);
+        String expectedRequestText = 
+            "{ "
+            + " \"domain\": \"measurementsForVfScaling\", "
+            + " \"metricsPerEventName\": [ "
+            + "  { "
+            + "   \"eventName\": \"vLoadBalancer\", "
+            + "   \"controlLoopSchemaType\": \"VNF\", "
+            + "   \"policyScope\": \"DCAE\", "
+            + "   \"policyName\": \"TestService_scope.PolicyName\", "
+            + "   \"policyVersion\": \"v0.0.1\", "
+            + "   \"thresholds\": [] "
+            + "  } "
+            + " ] "
+            + "}";
+    
+        JsonObject tcaPolicyPropertiesTemplate = JsonUtils.GSON
+            .fromJson(TCA_POLICY_PROPERTIES_TEMPLATE, JsonObject.class);
+
+        JsonObject expectedRequest = JsonUtils.GSON.fromJson(expectedRequestText, JsonObject.class);
+
+        ModelProperties modelProperties = mock(ModelProperties.class);
+        Tca tca = mock(Tca.class);
+        TcaItem tcaItem = mock(TcaItem.class);
+        when(clampProperties.getJsonTemplate(any(), any())).thenReturn(tcaPolicyPropertiesTemplate);
+        when(tca.getTcaItem()).thenReturn(tcaItem);
+        when(tcaItem.getEventName()).thenReturn("vLoadBalancer");
+        when(tcaItem.getControlLoopSchemaType()).thenReturn("VNF");
+
+        //when
+        JsonObject policyContent = TcaRequestFormatter
+            .createPolicyContent(clampProperties, modelProperties, service, policy, tca);
+
+        //then
+        assertThat(expectedRequest).isEqualTo(policyContent);
+    }
+}
\ No newline at end of file
index c04357d..a32a603 100644 (file)
 package org.onap.clamp.clds.config;
 
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertEquals;
 
-import java.util.Collections;
 import org.junit.Test;
 import org.onap.clamp.clds.service.CldsUser;
 
index 3f0a078..d27690b 100644 (file)
@@ -29,13 +29,13 @@ import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
+import com.google.gson.JsonObject;
 import java.io.IOException;
-
+import java.io.InputStreamReader;
+import java.nio.charset.StandardCharsets;
 import org.junit.Test;
 import org.onap.clamp.clds.exception.sdc.controller.SdcParametersException;
+import org.onap.clamp.clds.util.JsonUtils;
 import org.onap.clamp.clds.util.ResourceFileUtil;
 
 /**
@@ -43,13 +43,19 @@ import org.onap.clamp.clds.util.ResourceFileUtil;
  */
 public class SdcSingleControllerConfigurationTest {
 
+    /**
+     * @param fileName file for sdc controller configuration.
+     * @param sdcControllerName sdc controller name.
+     * @return instance of SdcSingleControllerConfiguration.
+     */
     public static SdcSingleControllerConfiguration loadControllerConfiguration(String fileName,
-        String sdcControllerName) throws IOException {
-        JsonNode jsonNode = new ObjectMapper().readValue(ResourceFileUtil.getResourceAsStream(fileName),
-            JsonNode.class);
-        SdcSingleControllerConfiguration sdcSingleControllerConfiguration = new SdcSingleControllerConfiguration(
-            jsonNode, sdcControllerName);
-        return sdcSingleControllerConfiguration;
+        String sdcControllerName) {
+
+        InputStreamReader streamReader = new InputStreamReader(ResourceFileUtil.getResourceAsStream(fileName),
+            StandardCharsets.UTF_8);
+        JsonObject jsonNode = JsonUtils.GSON.fromJson(streamReader, JsonObject.class);
+
+        return new SdcSingleControllerConfiguration(jsonNode, sdcControllerName);
     }
 
     @Test
index 85218ab..6ab800b 100644 (file)
@@ -160,7 +160,7 @@ public class CldsServiceItCase {
     }
 
     @Test
-    public void testGetCLDSDetails() throws IOException {
+    public void testGetCldsDetails() throws IOException {
         List<CldsMonitoringDetails> cldsMonitoringDetailsList = cldsService.getCldsDetails();
         assertNotNull(cldsMonitoringDetailsList);
     }
index 12e8dd9..8e03153 100644 (file)
@@ -69,22 +69,22 @@ public class DcaeHttpConnectionManagerItCase {
     @Autowired
     DcaeHttpConnectionManager dcaeHttpConnectionManager;
 
-    private static TrustManager[] trustAllCerts = new TrustManager[] {
-            new X509TrustManager() {
+    private static TrustManager[] trustAllCerts = new TrustManager[]{
+        new X509TrustManager() {
 
-                @Override
-                public java.security.cert.X509Certificate[] getAcceptedIssuers() {
-                    return null;
-                }
+            @Override
+            public java.security.cert.X509Certificate[] getAcceptedIssuers() {
+                return null;
+            }
 
-                @Override
-                public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
-                }
+            @Override
+            public void checkClientTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
+            }
 
-                @Override
-                public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
-                }
+            @Override
+            public void checkServerTrusted(X509Certificate[] arg0, String arg1) throws CertificateException {
             }
+        }
     };
 
     private void enableSslNoCheck() throws NoSuchAlgorithmException, KeyManagementException {
index 31594cb..3acc439 100644 (file)
@@ -24,7 +24,9 @@
 
 package org.onap.clamp.clds.it;
 
+import com.google.gson.reflect.TypeToken;
 import java.io.IOException;
+import java.lang.reflect.Type;
 import java.util.List;
 import java.util.Map;
 
@@ -47,7 +49,7 @@ import org.onap.clamp.clds.model.properties.Policy;
 import org.onap.clamp.clds.model.properties.PolicyItem;
 import org.onap.clamp.clds.model.properties.Tca;
 import org.onap.clamp.clds.transform.XslTransformer;
-import org.onap.clamp.clds.util.JacksonUtils;
+import org.onap.clamp.clds.util.JsonUtils;
 import org.onap.clamp.clds.util.LoggingUtils;
 import org.onap.clamp.clds.util.ResourceFileUtil;
 import org.onap.policy.api.AttributeType;
@@ -67,6 +69,8 @@ import org.springframework.test.context.junit4.SpringRunner;
 @SpringBootTest
 public class PolicyClientItCase {
 
+    private static final Type MAP_OF_STRING_TO_OBJECT_TYPE = new TypeToken<Map<String, Object>>() {}.getType();
+
     @Autowired
     private CldsDao cldsDao;
     @Autowired
@@ -82,6 +86,11 @@ public class PolicyClientItCase {
     String modelBpmnPropJson;
     ModelProperties prop;
 
+    /**
+     * Setup method.
+     * @throws IOException thrown if resources not found
+     * @throws TransformerException thrown if invalid xml given to transformation
+     */
     @Before
     public void setUp() throws IOException, TransformerException {
         modelProp = ResourceFileUtil.getResourceAsString("example/model-properties/tca_new/model-properties.json");
@@ -94,7 +103,7 @@ public class PolicyClientItCase {
     }
 
     @Test
-    public void testSendGuardPolicy() throws TransformerException, IOException {
+    public void testSendGuardPolicy() {
         // Normally there is only one Guard
         List<PolicyItem> policyItems = GuardPolicyAttributesConstructor
             .getAllPolicyGuardsFromPolicyChain(prop.getType(Policy.class).getPolicyChains().get(0));
@@ -105,8 +114,7 @@ public class PolicyClientItCase {
         String response = policyClient.sendGuardPolicy(
             GuardPolicyAttributesConstructor.formatAttributes(prop, policyItem), prop, LoggingUtils.getRequestId(),
             policyItem);
-        Map<String, Object> mapNodes = JacksonUtils.getObjectMapperInstance()
-            .convertValue(JacksonUtils.getObjectMapperInstance().readTree(response), Map.class);
+        Map<String, Object> mapNodes = JsonUtils.GSON.fromJson(response, MAP_OF_STRING_TO_OBJECT_TYPE);
         Assertions.assertThat(mapNodes).contains(Assertions.entry("policyClass", "Decision"),
             Assertions.entry("policyName",
                 modelName.replace("-", "_") + "." + controlName + "_Policy_12lup3h_0_Guard_6TtHGPq"),
@@ -124,14 +132,13 @@ public class PolicyClientItCase {
     }
 
     @Test
-    public void testSendBrmsPolicy()
-        throws TransformerException, BuilderException, IllegalArgumentException, IOException {
+    public void testSendBrmsPolicy() throws BuilderException, IllegalArgumentException, IOException {
         Map<AttributeType, Map<String, String>> attributes = OperationalPolicyAttributesConstructor.formatAttributes(
             refProp, prop, prop.getType(Policy.class).getId(), prop.getType(Policy.class).getPolicyChains().get(0));
         String response = policyClient.sendBrmsPolicy(attributes, prop, LoggingUtils.getRequestId());
 
-        Map<String, Object> mapNodes = JacksonUtils.getObjectMapperInstance()
-            .convertValue(JacksonUtils.getObjectMapperInstance().readTree(response), Map.class);
+        Map<String, Object> mapNodes = JsonUtils.GSON.fromJson(response, MAP_OF_STRING_TO_OBJECT_TYPE);
+
         Assertions.assertThat(mapNodes).contains(Assertions.entry("policyClass", "Config"),
             Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_Policy_12lup3h_0"),
             Assertions.entry("policyConfigType", PolicyConfigType.BRMS_PARAM.name()),
@@ -144,14 +151,13 @@ public class PolicyClientItCase {
     }
 
     @Test
-    public void testSendMicroServiceInJson()
-        throws TransformerException, BuilderException, IllegalArgumentException, IOException {
+    public void testSendMicroServiceInJson() throws IllegalArgumentException {
         prop.setCurrentModelElementId(prop.getType(Policy.class).getId());
         String jsonToSend = "{\"test\":\"test\"}";
         String response = policyClient.sendMicroServiceInJson(jsonToSend, prop, LoggingUtils.getRequestId());
 
-        Map<String, Object> mapNodes = JacksonUtils.getObjectMapperInstance()
-            .convertValue(JacksonUtils.getObjectMapperInstance().readTree(response), Map.class);
+        Map<String, Object> mapNodes = JsonUtils.GSON.fromJson(response, MAP_OF_STRING_TO_OBJECT_TYPE);
+
         Assertions.assertThat(mapNodes).contains(Assertions.entry("policyClass", "Config"),
             Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_Policy_12lup3h"),
             Assertions.entry("policyConfigType", PolicyConfigType.MicroService.name()),
@@ -165,8 +171,8 @@ public class PolicyClientItCase {
     public void testSendBasePolicyInOther() throws IllegalArgumentException, IOException {
         String body = "test";
         String response = policyClient.sendBasePolicyInOther(body, "myPolicy", prop, LoggingUtils.getRequestId());
-        Map<String, Object> mapNodes = JacksonUtils.getObjectMapperInstance()
-            .convertValue(JacksonUtils.getObjectMapperInstance().readTree(response), Map.class);
+        Map<String, Object> mapNodes = JsonUtils.GSON.fromJson(response, MAP_OF_STRING_TO_OBJECT_TYPE);
+
         Assertions.assertThat(mapNodes).contains(Assertions.entry("policyClass", "Config"),
             Assertions.entry("policyName", "myPolicy"),
             Assertions.entry("policyConfigType", PolicyConfigType.Base.name()),
@@ -181,8 +187,8 @@ public class PolicyClientItCase {
         String tcaJson = TcaRequestFormatter.createPolicyJson(refProp, prop);
         String response = policyClient.sendMicroServiceInOther(tcaJson, prop);
 
-        Map<String, Object> mapNodes = JacksonUtils.getObjectMapperInstance()
-            .convertValue(JacksonUtils.getObjectMapperInstance().readTree(response), Map.class);
+        Map<String, Object> mapNodes = JsonUtils.GSON.fromJson(response, MAP_OF_STRING_TO_OBJECT_TYPE);
+
         Assertions.assertThat(mapNodes).contains(Assertions.entry("policyClass", "Config"),
             Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_TCA_1d13unw"),
             Assertions.entry("policyConfigType", PolicyConfigType.MicroService.name()),
@@ -196,10 +202,10 @@ public class PolicyClientItCase {
         String[] responses = policyClient.deleteMicrosService(prop).split("\\}\\{");
 
         // There are 2 responses appended to the result, one for PDP one for PAP !
-        Map<String, Object> mapNodesPdp = JacksonUtils.getObjectMapperInstance()
-            .convertValue(JacksonUtils.getObjectMapperInstance().readTree(responses[0] + "}"), Map.class);
-        Map<String, Object> mapNodesPap = JacksonUtils.getObjectMapperInstance()
-            .convertValue(JacksonUtils.getObjectMapperInstance().readTree("{" + responses[1]), Map.class);
+        Map<String, Object> mapNodesPdp = JsonUtils.GSON.fromJson(responses[0] + "}",
+            MAP_OF_STRING_TO_OBJECT_TYPE);
+        Map<String, Object> mapNodesPap = JsonUtils.GSON.fromJson("{" + responses[1],
+            MAP_OF_STRING_TO_OBJECT_TYPE);
 
         Assertions.assertThat(mapNodesPdp).contains(
             Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_TCA_1d13unw"),
@@ -221,11 +227,10 @@ public class PolicyClientItCase {
         prop.setGuardUniqueId(policyItems.get(0).getId());
         String[] responses = policyClient.deleteGuard(prop).split("\\}\\{");
 
-        // There are 2 responses appended to the result, one for PDP one for PAP !
-        Map<String, Object> mapNodesPdp = JacksonUtils.getObjectMapperInstance()
-            .convertValue(JacksonUtils.getObjectMapperInstance().readTree(responses[0] + "}"), Map.class);
-        Map<String, Object> mapNodesPap = JacksonUtils.getObjectMapperInstance()
-            .convertValue(JacksonUtils.getObjectMapperInstance().readTree("{" + responses[1]), Map.class);
+        Map<String, Object> mapNodesPdp = JsonUtils.GSON.fromJson(responses[0] + "}",
+            MAP_OF_STRING_TO_OBJECT_TYPE);
+        Map<String, Object> mapNodesPap = JsonUtils.GSON.fromJson("{" + responses[1],
+            MAP_OF_STRING_TO_OBJECT_TYPE);
 
         Assertions.assertThat(mapNodesPdp).contains(
             Assertions.entry("policyName",
@@ -245,11 +250,10 @@ public class PolicyClientItCase {
         prop.setCurrentModelElementId(prop.getType(Policy.class).getId());
         String[] responses = policyClient.deleteBrms(prop).split("\\}\\{");
 
-        // There are 2 responses appended to the result, one for PDP one for PAP !
-        Map<String, Object> mapNodesPdp = JacksonUtils.getObjectMapperInstance()
-            .convertValue(JacksonUtils.getObjectMapperInstance().readTree(responses[0] + "}"), Map.class);
-        Map<String, Object> mapNodesPap = JacksonUtils.getObjectMapperInstance()
-            .convertValue(JacksonUtils.getObjectMapperInstance().readTree("{" + responses[1]), Map.class);
+        Map<String, Object> mapNodesPdp = JsonUtils.GSON.fromJson(responses[0] + "}",
+            MAP_OF_STRING_TO_OBJECT_TYPE);
+        Map<String, Object> mapNodesPap = JsonUtils.GSON.fromJson("{" + responses[1],
+            MAP_OF_STRING_TO_OBJECT_TYPE);
 
         Assertions.assertThat(mapNodesPdp).contains(
             Assertions.entry("policyName", modelName.replace("-", "_") + "." + controlName + "_Policy_12lup3h_0"),
@@ -273,7 +277,8 @@ public class PolicyClientItCase {
         String tosca = policyClient.importToscaModel(cldsToscaModel);
 
         Assertions.assertThat(tosca).contains(
-            "{\"serviceName\":\"tca-policy-test\",\"description\":\"tca-policy-test\",\"requestID\":null,\"filePath\":\"/tmp/tosca-models/tca-policy-test.yml\",");
+            "{\"serviceName\":\"tca-policy-test\",\"description\":\"tca-policy-test\","
+                + "\"requestID\":null,\"filePath\":\"/tmp/tosca-models/tca-policy-test.yml\",");
         Assertions.assertThat(tosca).contains(toscaModelYaml);
     }
 }
index 9d58ba8..630e8c0 100644 (file)
@@ -28,8 +28,8 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
-import com.fasterxml.jackson.databind.node.ObjectNode;
 
+import com.google.gson.JsonElement;
 import java.io.IOException;
 import java.util.List;
 
@@ -62,24 +62,34 @@ public class CldsReferencePropertiesItCase {
         assertNull(refProp.getStringValue("does.not.exist"));
     }
 
-    /**
-     * Test getting prop value as a JSON Node / template.
-     *
-     * @throws IOException
-     *         when JSON parsing fails
-     */
     @Test
-    public void testGetJsonTemplate() throws IOException {
-        // ui.location.default={"DC1":"Data Center 1","DC2":"Data Center
-        // 2","DC3":"Data Center 3"}
-        ObjectNode root = (ObjectNode) refProp.getJsonTemplate("ui.location.default");
+    public void shouldReturnJsonFromTemplate() throws IOException {
+        //when
+        JsonElement root = refProp.getJsonTemplate("ui.location.default");
+
+        //then
         assertNotNull(root);
-        assertEquals(root.get("DC1").asText(), "Data Center 1");
-        // Test composite key
-        root = (ObjectNode) refProp.getJsonTemplate("ui.location", "default");
+        assertTrue(root.isJsonObject());
+        assertEquals(root.getAsJsonObject().get("DC1").getAsString(), "Data Center 1");
+    }
+
+    @Test
+    public void shouldReturnJsonFromTemplate_2() throws IOException {
+        //when
+        JsonElement root = refProp.getJsonTemplate("ui.location", "default");
+
+        //then
         assertNotNull(root);
-        assertEquals(root.get("DC1").asText(), "Data Center 1");
-        root = (ObjectNode) refProp.getJsonTemplate("ui.location", "");
+        assertTrue(root.isJsonObject());
+        assertEquals(root.getAsJsonObject().get("DC1").getAsString(), "Data Center 1");
+    }
+
+    @Test
+    public void shouldReturnNullIfPropertyNotFound() throws IOException {
+        //when
+        JsonElement root = refProp.getJsonTemplate("ui.location", "");
+
+        //then
         assertNull(root);
     }
 
index 0cab4b9..8fd817c 100644 (file)
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import com.google.gson.JsonSyntaxException;
 import java.io.IOException;
 import java.util.Map;
 
@@ -71,7 +72,7 @@ public class SdcControllersConfigurationItCase {
             sdcControllersConfiguration.getSdcSingleControllerConfiguration("sdc-controller2").getSdcControllerName());
     }
 
-    @Test(expected = IOException.class)
+    @Test(expected = JsonSyntaxException.class)
     public void testBadJsonLoading() throws IOException {
         loadFile("classpath:/clds/sdc-controllers-config-bad.json");
         fail("Should have raised an exception");
index 9eaca5f..c6dbce4 100644 (file)
@@ -23,7 +23,6 @@
 
 package org.onap.clamp.clds.it.sdc.controller;
 
-import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -89,8 +88,11 @@ public class SdcSingleControllerItCase {
         return notifData;
     }
 
+    /**
+     * Initialization method.
+     */
     @Before
-    public void init() throws IOException {
+    public void init() {
         sdcSingleController = new SdcSingleController(clampProp, Mockito.mock(CsarInstaller.class),
             SdcSingleControllerConfigurationTest.loadControllerConfiguration("clds/sdc-controller-config-TLS.json",
                 "sdc-controller1"),
index 7d3a215..871d0a6 100644 (file)
  * limitations under the License.\r
  * ============LICENSE_END============================================\r
  * ===================================================================\r
- * \r
+ *\r
  */\r
 \r
 package org.onap.clamp.clds.model.prop;\r
 \r
-import com.fasterxml.jackson.databind.JsonNode;\r
-\r
+import com.google.gson.JsonObject;\r
 import org.onap.clamp.clds.model.properties.AbstractModelElement;\r
 import org.onap.clamp.clds.model.properties.ModelBpmn;\r
 import org.onap.clamp.clds.model.properties.ModelProperties;\r
+import org.onap.clamp.clds.util.JsonUtils;\r
 \r
 /**\r
  * A CustomModelElement to test the capability to add new elements on the fly.\r
@@ -40,10 +40,10 @@ public class CustomModelElement extends AbstractModelElement {
     /**\r
      * Main Constructor.\r
      */\r
-    public CustomModelElement(ModelProperties modelProp, ModelBpmn modelBpmn, JsonNode modelJson) {\r
+    public CustomModelElement(ModelProperties modelProp, ModelBpmn modelBpmn, JsonObject modelJson) {\r
         super(CUSTOM_TYPE, modelProp, modelBpmn, modelJson);\r
-        topicPublishes = getValueByName("topicPublishes");\r
-        test = this.getValueByName("test");\r
+        topicPublishes = JsonUtils.getStringValueByName(modelElementJsonNode, "topicPublishes");\r
+        test = JsonUtils.getStringValueByName(modelElementJsonNode, "test");\r
     }\r
 \r
     public static final String getType() {\r
index 295ccc5..4195f90 100644 (file)
@@ -23,6 +23,7 @@
 
 package org.onap.clamp.clds.model.prop;
 
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
@@ -36,6 +37,7 @@ import org.onap.clamp.clds.model.CldsModel;
 import org.onap.clamp.clds.model.properties.Holmes;
 import org.onap.clamp.clds.model.properties.ModelProperties;
 import org.onap.clamp.clds.model.properties.Policy;
+import org.onap.clamp.clds.model.properties.PolicyItem;
 import org.onap.clamp.clds.model.properties.Tca;
 import org.onap.clamp.clds.util.ResourceFileUtil;
 
@@ -61,11 +63,12 @@ public class ModelPropertiesTest {
         assertEquals(1, policy.getPolicyChains().size());
         assertEquals("0", policy.getPolicyChains().get(0).getPolicyId());
         assertEquals(1, policy.getPolicyChains().get(0).getPolicyItems().size());
-        assertEquals("resourceid", policy.getPolicyChains().get(0).getPolicyItems().get(0).getTargetResourceId());
-        assertEquals(180, policy.getPolicyChains().get(0).getPolicyItems().get(0).getRetryTimeLimit());
-        assertEquals(3, policy.getPolicyChains().get(0).getPolicyItems().get(0).getMaxRetries());
-        assertEquals("", policy.getPolicyChains().get(0).getPolicyItems().get(0).getParentPolicy());
-        assertEquals(null, policy.getPolicyChains().get(0).getPolicyItems().get(0).getParentPolicyConditions());
+        PolicyItem firstPolicyItem = policy.getPolicyChains().get(0).getPolicyItems().get(0);
+        assertEquals("resourceid", firstPolicyItem.getTargetResourceId());
+        assertEquals(180, firstPolicyItem.getRetryTimeLimit());
+        assertEquals(3, firstPolicyItem.getMaxRetries());
+        assertEquals("", firstPolicyItem.getParentPolicy());
+        assertThat(firstPolicyItem.getParentPolicyConditions()).isEmpty();
         Tca tca = prop.getType(Tca.class);
         assertNotNull(tca);
         assertTrue(tca.isFound());
@@ -91,8 +94,8 @@ public class ModelPropertiesTest {
             prop.getGlobal().getResourceVf().toArray()));
         assertTrue(Arrays.equals(new String[] { "SNDGCA64", "ALPRGAED", "LSLEILAA", "MDTWNJC1" },
             prop.getGlobal().getLocation().toArray()));
-        assertEquals("value1", prop.getGlobal().getDeployParameters().get("input1").asText());
-        assertEquals("value2", prop.getGlobal().getDeployParameters().get("input2").asText());
+        assertEquals("value1", prop.getGlobal().getDeployParameters().get("input1").getAsString());
+        assertEquals("value2", prop.getGlobal().getDeployParameters().get("input2").getAsString());
     }
 
     @Test
@@ -107,11 +110,12 @@ public class ModelPropertiesTest {
         assertEquals(1, policy.getPolicyChains().size());
         assertEquals("0", policy.getPolicyChains().get(0).getPolicyId());
         assertEquals(1, policy.getPolicyChains().get(0).getPolicyItems().size());
-        assertEquals("resourceid", policy.getPolicyChains().get(0).getPolicyItems().get(0).getTargetResourceId());
-        assertEquals(180, policy.getPolicyChains().get(0).getPolicyItems().get(0).getRetryTimeLimit());
-        assertEquals(3, policy.getPolicyChains().get(0).getPolicyItems().get(0).getMaxRetries());
-        assertEquals("", policy.getPolicyChains().get(0).getPolicyItems().get(0).getParentPolicy());
-        assertEquals(null, policy.getPolicyChains().get(0).getPolicyItems().get(0).getParentPolicyConditions());
+        PolicyItem firstPolicyItem = policy.getPolicyChains().get(0).getPolicyItems().get(0);
+        assertEquals("resourceid", firstPolicyItem.getTargetResourceId());
+        assertEquals(180, firstPolicyItem.getRetryTimeLimit());
+        assertEquals(3, firstPolicyItem.getMaxRetries());
+        assertEquals("", firstPolicyItem.getParentPolicy());
+        assertThat(firstPolicyItem.getParentPolicyConditions()).isEmpty();
         Holmes holmes = prop.getType(Holmes.class);
         assertNotNull(holmes);
         assertTrue(holmes.isFound());
@@ -124,8 +128,8 @@ public class ModelPropertiesTest {
             prop.getGlobal().getResourceVf().toArray()));
         assertTrue(Arrays.equals(new String[] { "SNDGCA64", "ALPRGAED", "LSLEILAA", "MDTWNJC1" },
             prop.getGlobal().getLocation().toArray()));
-        assertEquals("value1", prop.getGlobal().getDeployParameters().get("input1").asText());
-        assertEquals("value2", prop.getGlobal().getDeployParameters().get("input2").asText());
+        assertEquals("value1", prop.getGlobal().getDeployParameters().get("input1").getAsString());
+        assertEquals("value2", prop.getGlobal().getDeployParameters().get("input2").getAsString());
     }
 
     @Test
index 119fd21..5adb064 100644 (file)
@@ -31,15 +31,17 @@ public class SdcResourceBasicInfoTest {
     @Test
     public void testHashCode() {
         SdcResourceBasicInfo sdc1a = new SdcResourceBasicInfo();
-        SdcResourceBasicInfo sdc1b = new SdcResourceBasicInfo();
-        SdcResourceBasicInfo sdc2 = new SdcResourceBasicInfo();
         sdc1a.setName("test1");
         sdc1a.setVersion("1.0");
-        sdc1b.setName("test1");
-        sdc1b.setVersion("2.0");
+
+        SdcResourceBasicInfo sdc2 = new SdcResourceBasicInfo();
         sdc2.setName("test2");
         sdc2.setVersion("2.0");
 
+        SdcResourceBasicInfo sdc1b = new SdcResourceBasicInfo();
+        sdc1b.setName("test1");
+        sdc1b.setVersion("2.0");
+
         Assertions.assertThat(sdc1a.hashCode()).isNotEqualTo(sdc1b.hashCode());
         Assertions.assertThat(sdc1b.hashCode()).isNotEqualTo(sdc2.hashCode());
         sdc1b.setVersion("1.0");
@@ -50,12 +52,14 @@ public class SdcResourceBasicInfoTest {
     @Test
     public void testCompareTo() {
         SdcResourceBasicInfo sdc1a = new SdcResourceBasicInfo();
-        SdcResourceBasicInfo sdc1b = new SdcResourceBasicInfo();
-        SdcResourceBasicInfo sdc2 = new SdcResourceBasicInfo();
         sdc1a.setName("test1");
         sdc1a.setVersion("1.0");
+
+        SdcResourceBasicInfo sdc1b = new SdcResourceBasicInfo();
         sdc1b.setName("test1");
         sdc1b.setVersion("2.0");
+
+        SdcResourceBasicInfo sdc2 = new SdcResourceBasicInfo();
         sdc2.setName("test2");
         sdc2.setVersion("2.0");
 
@@ -68,12 +72,14 @@ public class SdcResourceBasicInfoTest {
     @Test
     public void testEquals() {
         SdcResourceBasicInfo sdc1a = new SdcResourceBasicInfo();
-        SdcResourceBasicInfo sdc1b = new SdcResourceBasicInfo();
-        SdcResourceBasicInfo sdc2 = new SdcResourceBasicInfo();
         sdc1a.setName("test1");
         sdc1a.setVersion("1.0");
+
+        SdcResourceBasicInfo sdc1b = new SdcResourceBasicInfo();
         sdc1b.setName("test1");
         sdc1b.setVersion("2.0");
+
+        SdcResourceBasicInfo sdc2 = new SdcResourceBasicInfo();
         sdc2.setName("test2");
         sdc2.setVersion("2.0");
 
diff --git a/src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImplTest.java b/src/test/java/org/onap/clamp/clds/sdc/controller/installer/CsarInstallerImplTest.java
new file mode 100644 (file)
index 0000000..a995c52
--- /dev/null
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2019 Nokia Intellectual Property. All rights
+ *                             reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.sdc.controller.installer;
+
+import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import com.google.gson.JsonObject;
+import java.io.IOException;
+import org.junit.Test;
+import org.onap.clamp.clds.util.JsonUtils;
+import org.onap.clamp.clds.util.ResourceFileUtil;
+
+public class CsarInstallerImplTest {
+
+    @Test
+    public void shouldReturnInputParametersFromBlueprint() throws IOException {
+        //given
+        String expectedBlueprintInputsText = "{\"aaiEnrichmentHost\":\"aai.onap.svc.cluster.local\""
+            + ",\"aaiEnrichmentPort\":\"8443\""
+            + ",\"enableAAIEnrichment\":true"
+            + ",\"dmaap_host\":\"message-router\""
+            + ",\"dmaap_port\":\"3904\""
+            + ",\"enableRedisCaching\":false"
+            + ",\"redisHosts\":\"dcae-redis:6379\""
+            + ",\"tag_version\":\"nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.0\""
+            + ",\"consul_host\":\"consul-server\""
+            + ",\"consul_port\":\"8500\",\"cbs_host\":\"{\\\"test\\\":"
+            + "{\\\"test\\\":\\\"test\\\"}}\",\"cbs_port\":\"10000\""
+            + ",\"external_port\":\"32010\",\"policy_id\":\"AUTO_GENERATED_POLICY_ID_AT_SUBMIT\"}";
+
+        JsonObject expectedBlueprintInputs = JsonUtils.GSON.fromJson(expectedBlueprintInputsText, JsonObject.class);
+        String dceaBlueprint = ResourceFileUtil.getResourceAsString("tosca/dcea_blueprint.yml");
+        BlueprintArtifact blueprintArtifact = mock(BlueprintArtifact.class);
+        when(blueprintArtifact.getDcaeBlueprint()).thenReturn(dceaBlueprint);
+        CsarInstallerImpl csarInstaller = new CsarInstallerImpl();
+
+        //when
+        String parametersInJson = csarInstaller.getAllBlueprintParametersInJson(blueprintArtifact);
+
+        //then
+        assertThat(JsonUtils.GSON.fromJson(parametersInJson, JsonObject.class)).isEqualTo(expectedBlueprintInputs);
+    }
+}
\ No newline at end of file
diff --git a/src/test/java/org/onap/clamp/clds/util/JacksonUtilsTest.java b/src/test/java/org/onap/clamp/clds/util/JacksonUtilsTest.java
deleted file mode 100644 (file)
index 1d9e4e7..0000000
+++ /dev/null
@@ -1,96 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP CLAMP
- * ================================================================================
- * Copyright (C) 2018 AT&T Intellectual Property. All rights
- *                             reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END============================================
- * ===================================================================
- *
- */
-
-package org.onap.clamp.clds.util;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-
-import java.io.IOException;
-
-import org.junit.Test;
-
-public class JacksonUtilsTest {
-
-    public static class TestClass extends TestObject {
-
-        String test2;
-        TestObject2 object2;
-
-        public TestClass(String value1, String value2) {
-            super(value1);
-            test2 = value2;
-        }
-
-        public TestClass() {
-        }
-
-        public String getTest2() {
-            return test2;
-        }
-
-        public void setTest2(String test2) {
-            this.test2 = test2;
-        }
-
-        public TestObject2 getObject2() {
-            return object2;
-        }
-
-        public void setObject2(TestObject2 object2) {
-            this.object2 = object2;
-        }
-    }
-
-    @Test
-    public void testGetObjectMapperInstance() {
-        assertNotNull(JacksonUtils.getObjectMapperInstance());
-    }
-
-    /**
-     * This method test that the security hole in Jackson is not enabled in the
-     * default ObjectMapper.
-     *
-     * @throws JsonParseException
-     *         In case of issues
-     * @throws JsonMappingException
-     *         In case of issues
-     * @throws IOException
-     *         In case of issues
-     */
-    @Test
-    public void testCreateBeanDeserializer() throws JsonParseException, JsonMappingException, IOException {
-        TestClass test = new TestClass("value1", "value2");
-        test.setObject2(new TestObject2("test3"));
-        Object testObject = JacksonUtils.getObjectMapperInstance()
-            .readValue("[\"org.onap.clamp.clds.util.JacksonUtilsTest$TestClass\""
-                + ",{\"test\":\"value1\",\"test2\":\"value2\",\"object2\":[\"org.onap.clamp.clds.util.TestObject2\","
-                + "{\"test3\":\"test3\"}]}]", Object.class);
-        assertNotNull(testObject);
-        assertFalse(testObject instanceof TestObject);
-        assertFalse(testObject instanceof TestClass);
-    }
-}
diff --git a/src/test/java/org/onap/clamp/clds/util/JsonUtilsTest.java b/src/test/java/org/onap/clamp/clds/util/JsonUtilsTest.java
new file mode 100644 (file)
index 0000000..3e11b8a
--- /dev/null
@@ -0,0 +1,157 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP CLAMP
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights
+ *                             reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END============================================
+ * Modifications copyright (c) 2019 Nokia
+ * ===================================================================
+ *
+ */
+
+package org.onap.clamp.clds.util;
+
+import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
+import java.io.IOException;
+
+import java.util.List;
+import org.junit.Test;
+
+public class JsonUtilsTest {
+
+    public static class TestClass extends TestObject {
+
+        String test2;
+        TestObject2 object2;
+
+        TestClass(String value1, String value2) {
+            super(value1);
+            test2 = value2;
+        }
+
+        void setObject2(TestObject2 object2) {
+            this.object2 = object2;
+        }
+    }
+
+    private static final JsonObject DEPLOY_PARAMETERS = JsonUtils.GSON.fromJson(
+        "{\n"
+            + "        \"aaiEnrichmentHost\": \"aai.onap.svc.cluster.local\",\n"
+            + "        \"aaiEnrichmentPort\": \"8443\",\n"
+            + "        \"enableAAIEnrichment\": true,\n"
+            + "        \"dmaap_host\": \"message-router\",\n"
+            + "        \"dmaap_port\": \"3904\",\n"
+            + "        \"enableRedisCaching\": false,\n"
+            + "        \"redisHosts\": \"dcae-redis:6379\",\n"
+            + "        \"tag_version\": \"nexus3.onap.org:10001/onap/org.onap.dcaegen2."
+            + "deployments.tca-cdap-container:1.1.0\",\n"
+            + "        \"consul_host\": \"consul-server\",\n"
+            + "        \"consul_port\": \"8500\",\n"
+            + "        \"cbs_host\": \"config-binding-service\",\n"
+            + "        \"cbs_port\": \"10000\",\n"
+            + "        \"external_port\": \"32010\",\n"
+            + "        \"policy_id\": \"AUTO_GENERATED_POLICY_ID_AT_SUBMIT\"\n"
+            + "      }", JsonObject.class);
+
+
+    @Test
+    public void testGetObjectMapperInstance() {
+        assertNotNull(JsonUtils.GSON);
+    }
+
+    /**
+     * This method test that the security hole in Jackson is not enabled in the default ObjectMapper.
+     */
+    @Test
+    public void testCreateBeanDeserializer() {
+        TestClass test = new TestClass("value1", "value2");
+        test.setObject2(new TestObject2("test3"));
+        Object testObject = JsonUtils.GSON.fromJson("[\"org.onap.clamp.clds.util.JsonUtilsTest$TestClass\""
+            + ",{\"test\":\"value1\",\"test2\":\"value2\",\"object2\":[\"org.onap.clamp.clds.util.TestObject2\","
+            + "{\"test3\":\"test3\"}]}]", Object.class);
+        assertNotNull(testObject);
+        assertFalse(testObject instanceof TestObject);
+    }
+
+
+    @Test
+    public void shouldReturnJsonValueByName() throws IOException {
+        //given
+        String modelProperties = ResourceFileUtil
+            .getResourceAsString("example/model-properties/custom/modelBpmnPropertiesMultiVF.json");
+        JsonElement globalElement = JsonUtils.GSON.fromJson(modelProperties, JsonObject.class).get("global");
+
+        //when
+        String locationName = JsonUtils.getStringValueByName(globalElement, "location");
+        String timeoutValue = JsonUtils.getStringValueByName(globalElement, "timeout");
+
+        //then
+        assertThat(locationName).isEqualTo("SNDGCA64");
+        assertThat(timeoutValue).isEqualTo("500");
+    }
+
+    @Test
+    public void shouldReturnJsonObjectByPropertyName() throws IOException {
+        //given
+        String modelProperties = ResourceFileUtil
+            .getResourceAsString("example/model-properties/custom/modelBpmnPropertiesMultiVF.json");
+        JsonElement globalElement = JsonUtils.GSON.fromJson(modelProperties, JsonObject.class).get("global");
+
+        //when
+        JsonObject deployParameters = JsonUtils.getJsonObjectByName(globalElement, "deployParameters");
+
+        //then
+        assertThat(deployParameters).isEqualToComparingFieldByField(DEPLOY_PARAMETERS);
+    }
+
+    @Test
+    public void shouldReturnJsonValuesByPropertyName() throws IOException {
+        //given
+        String modelProperties = ResourceFileUtil
+            .getResourceAsString("example/model-properties/custom/modelBpmnPropertiesMultiVF.json");
+        JsonElement globalElement = JsonUtils.GSON.fromJson(modelProperties, JsonObject.class).get("global");
+
+        //when
+        List<String> vfs = JsonUtils.getStringValuesByName(globalElement, "vf");
+
+        //then
+        assertThat(vfs).containsExactly(
+            "6c7aaec2-59eb-41d9-8681-b7f976ab668d",
+            "8sadsad0-a98s-6a7s-fd12-sadji9sa8d12",
+            "8sfd71ad-a90d-asd9-as87-8a7sd81adsaa"
+        );
+    }
+
+
+    @Test
+    public void shouldReturnJsonValueAsInteger() throws IOException {
+        //given
+        String modelProperties = ResourceFileUtil
+            .getResourceAsString("example/model-properties/custom/modelBpmnPropertiesMultiVF.json");
+        JsonElement globalElement = JsonUtils.GSON.fromJson(modelProperties, JsonObject.class).get("global");
+
+        //when
+        Integer timeoutValue = JsonUtils.getIntValueByName(globalElement, "timeout");
+
+        //then
+        assertThat(timeoutValue).isEqualTo(500);
+    }
+}
diff --git a/src/test/resources/example/model-properties/custom/modelBpmnPropertiesMultiVF.json b/src/test/resources/example/model-properties/custom/modelBpmnPropertiesMultiVF.json
new file mode 100644 (file)
index 0000000..211aaec
--- /dev/null
@@ -0,0 +1,273 @@
+{
+    "global":
+    [
+        {
+            "name": "service",
+            "value":
+            [
+                "0f983e18-4603-4bb4-a98c-e29691fb16a1"
+            ]
+        },
+
+        {
+            "name": "vf",
+            "value":
+            [
+                "6c7aaec2-59eb-41d9-8681-b7f976ab668d",
+                "8sadsad0-a98s-6a7s-fd12-sadji9sa8d12",
+                "8sfd71ad-a90d-asd9-as87-8a7sd81adsaa"
+            ]
+        },
+
+        {
+            "name": "actionSet",
+            "value":
+            [
+                "vnfRecipe"
+            ]
+        },
+
+        {
+            "name": "location",
+            "value":
+            [
+                "SNDGCA64"
+            ]
+        },
+        {
+            "name": "timeout",
+            "value": "500"
+        },
+        {
+            "name": "deployParameters",
+            "value": {
+                "aaiEnrichmentHost": "aai.onap.svc.cluster.local",
+                "aaiEnrichmentPort": "8443",
+                "enableAAIEnrichment": true,
+                "dmaap_host": "message-router",
+                "dmaap_port": "3904",
+                "enableRedisCaching": false,
+                "redisHosts": "dcae-redis:6379",
+                "tag_version": "nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.0",
+                "consul_host": "consul-server",
+                "consul_port": "8500",
+                "cbs_host": "config-binding-service",
+                "cbs_port": "10000",
+                "external_port": "32010",
+                "policy_id": "AUTO_GENERATED_POLICY_ID_AT_SUBMIT"
+            }
+        }
+    ],
+
+    "Policy_":
+    {
+        "Policy1":
+        [
+            {
+                "name": "pname",
+                "value": "Policy1"
+            },
+
+            {
+                "name": "pid",
+                "value": "1"
+            },
+
+            {
+                "name": "timeout",
+                "value": "500"
+            },
+
+            {
+                "policyConfigurations":
+                [
+                    [
+                        {
+                            "name": "recipe",
+                            "value":
+                            [
+                                "restart"
+                            ]
+                        },
+
+                        {
+                            "name": "maxRetries",
+                            "value":
+                            [
+                                "3"
+                            ]
+                        },
+
+                        {
+                            "name": "retryTimeLimit",
+                            "value":
+                            [
+                                "180"
+                            ]
+                        },
+
+                        {
+                            "name": "_id",
+                            "value":
+                            [
+                                "n9bQ4t6"
+                            ]
+                        },
+
+                        {
+                            "name": "parentPolicy",
+                            "value":
+                            [
+                                ""
+                            ]
+                        },
+                        {
+                            "name": "targetResourceId",
+                            "value":
+                            [
+                                "resource-id"
+                            ]
+                        }
+                    ],
+
+                    [
+                        {
+                            "name": "recipe",
+                            "value":
+                            [
+                                "rebuild"
+                            ]
+                        },
+
+                        {
+                            "name": "maxRetries",
+                            "value":
+                            [
+                                "3"
+                            ]
+                        },
+
+                        {
+                            "name": "retryTimeLimit",
+                            "value":
+                            [
+                                "180"
+                            ]
+                        },
+
+                        {
+                            "name": "_id",
+                            "value":
+                            [
+                                "ItE5xKT"
+                            ]
+                        },
+
+                        {
+                            "name": "parentPolicy",
+                            "value":
+                            [
+                                "n9bQ4t6"
+                            ]
+                        },
+
+                        {
+                            "name": "parentPolicyConditions",
+                            "value":
+                            [
+                                "Failure_Retries",
+                                "Failure_Timeout",
+                                "Failure_Exception",
+                                "Failure"
+                            ]
+                        },
+                        {
+                            "name": "targetResourceId",
+                            "value":
+                            [
+                                "resource-id"
+                            ]
+                        }
+                    ]
+                ]
+            }
+        ]
+    },
+
+    "TCA_":
+    {
+        "Narra":
+        [
+            {
+                "name": "tname",
+                "value": "Narra"
+            },
+
+            {
+                "name": "tuuid",
+                "value": "886be8da-14fe-tca1-d04b-d13b55d58df9"
+            },
+
+            {
+                "name": "tnfc",
+                "value": "ENBE"
+            },
+
+            {
+                "name": "tcaEnab",
+                "value": "on"
+            },
+
+            {
+                "name": "tcaPol",
+                "value": "Policy1"
+            },
+
+            {
+                "name": "tcaPolId",
+                "value": "1"
+            },
+
+            {
+                "name": "tcaInt",
+                "value": "2"
+            },
+
+            {
+                "name": "tcaSev",
+                "value": "Warning"
+            },
+
+            {
+                "name": "tcaVio",
+                "value": "3"
+            },
+
+            {
+                "serviceConfigurations":
+                [
+                    [
+                        "PMRRCCONNESTABFAILCELLLATENCY",
+                        "LESS",
+                        "4",
+                        "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[?(@.Name == 'PMRRCCONNESTABFAILCELLLATENCY')].Value"
+                    ],
+
+                    [
+                        "PMRAATTCBRA",
+                        "GREATER",
+                        "30",
+                        "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[?(@.Name == 'PMRAATTCBRA')].Value"
+                    ]
+                ]
+            }
+        ]
+    },
+    
+    "CustomType_": [
+      {
+         "name": "test",
+         "value": "This is a test"
+      }
+    ]
+}
\ No newline at end of file
diff --git a/src/test/resources/tosca/dcea_blueprint.yml b/src/test/resources/tosca/dcea_blueprint.yml
new file mode 100644 (file)
index 0000000..0d3ea04
--- /dev/null
@@ -0,0 +1,170 @@
+#
+# ============LICENSE_START====================================================
+# =============================================================================
+# Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+# =============================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ============LICENSE_END======================================================
+
+tosca_definitions_version: cloudify_dsl_1_3
+
+description: >
+  This blueprint deploys/manages the TCA module as a Docker container
+
+imports:
+  - http://www.getcloudify.org/spec/cloudify/3.4/types.yaml
+  - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/k8splugin/1.4.4/k8splugin_types.yaml
+  - https://nexus.onap.org/service/local/repositories/raw/content/org.onap.dcaegen2.platform.plugins/R4/dcaepolicyplugin/2.3.0/dcaepolicyplugin_types.yaml
+inputs:
+  aaiEnrichmentHost:
+    type: string
+    default: "aai.onap.svc.cluster.local"
+  aaiEnrichmentPort:
+    type: string
+    default: "8443"
+  enableAAIEnrichment:
+    type: string
+    default: true
+  dmaap_host:
+    type: string
+    default: message-router
+  dmaap_port:
+    type: string
+    default: "3904"
+  enableRedisCaching:
+    type: string
+    default: false
+  redisHosts:
+    type: string
+    default: dcae-redis:6379
+  tag_version:
+    type: string
+    default: "nexus3.onap.org:10001/onap/org.onap.dcaegen2.deployments.tca-cdap-container:1.1.0"
+  consul_host:
+    type: string
+    default: consul-server
+  consul_port:
+    type: string
+    default: "8500"
+  cbs_host:
+    type: string
+    default:
+      test:
+        test: test
+  cbs_port:
+    type: string
+    default: "10000"
+  policy_id:
+    type: string
+    default: "none"
+  external_port:
+    type: string
+    description: Kubernetes node port on which CDAPgui is exposed
+    default: "32010"
+
+node_templates:
+  tca_k8s:
+    type: dcae.nodes.ContainerizedServiceComponent
+    relationships:
+      - target: tca_policy
+        type: cloudify.relationships.depends_on
+    properties:
+      service_component_type: 'dcaegen2-analytics-tca'
+      docker_config: {}
+      image:
+        get_input: tag_version
+      log_info:
+        log_directory: "/opt/app/TCAnalytics/logs"
+      application_config:
+        app_config:
+          appDescription: DCAE Analytics Threshold Crossing Alert Application
+          appName: dcae-tca-ak-serv
+          tcaAlertsAbatementTableName: TCAAlertsAbatementTable
+          tcaAlertsAbatementTableTTLSeconds: '1728000'
+          tcaSubscriberOutputStreamName: TCASubscriberOutputStream
+          tcaVESAlertsTableName: TCAVESAlertsTable
+          tcaVESAlertsTableTTLSeconds: '1728000'
+          tcaVESMessageStatusTableName: TCAVESMessageStatusTable
+          tcaVESMessageStatusTableTTLSeconds: '86400'
+          thresholdCalculatorFlowletInstances: '2'
+        app_preferences:
+          aaiEnrichmentHost:
+            get_input: aaiEnrichmentHost
+          aaiEnrichmentIgnoreSSLCertificateErrors: 'true'
+          aaiEnrichmentPortNumber: '8443'
+          aaiEnrichmentProtocol: https
+          aaiEnrichmentUserName: DCAE
+          aaiEnrichmentUserPassword: DCAE
+          aaiVMEnrichmentAPIPath: /aai/v11/search/nodes-query
+          aaiVNFEnrichmentAPIPath: /aai/v11/network/generic-vnfs/generic-vnf
+          enableAAIEnrichment:
+            get_input: enableAAIEnrichment
+          enableRedisCaching:
+            get_input: enableRedisCaching
+          redisHosts:
+            get_input: redisHosts
+          enableAlertCEFFormat: 'false'
+          publisherContentType: application/json
+          publisherHostName:
+            get_input: dmaap_host
+          publisherHostPort:
+            get_input: dmaap_port
+          publisherMaxBatchSize: '1'
+          publisherMaxRecoveryQueueSize: '100000'
+          publisherPollingInterval: '20000'
+          publisherProtocol: http
+          publisherTopicName: unauthenticated.DCAE_CL_OUTPUT
+          subscriberConsumerGroup: OpenDCAE-c12
+          subscriberConsumerId: c12
+          subscriberContentType: application/json
+          subscriberHostName:
+            get_input: dmaap_host
+          subscriberHostPort:
+            get_input: dmaap_port
+          subscriberMessageLimit: '-1'
+          subscriberPollingInterval: '30000'
+          subscriberProtocol: http
+          subscriberTimeoutMS: '-1'
+          subscriberTopicName: unauthenticated.VES_MEASUREMENT_OUTPUT
+          tca_policy: '{"domain":"measurementsForVfScaling","metricsPerEventName":[{"eventName":"vFirewallBroadcastPackets","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta","thresholdValue":300,"direction":"LESS_OR_EQUAL","severity":"MAJOR","closedLoopEventStatus":"ONSET"},{"closedLoopControlName":"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta","thresholdValue":700,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]},{"eventName":"vLoadBalancer","controlLoopSchemaType":"VM","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta","thresholdValue":300,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]},{"eventName":"Measurement_vGMUX","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":0,"direction":"EQUAL","severity":"MAJOR","closedLoopEventStatus":"ABATED"},{"closedLoopControlName":"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":0,"direction":"GREATER","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]}]}'
+    interfaces:
+      cloudify.interfaces.lifecycle:
+        start:
+          inputs:
+            envs:
+              DMAAPHOST:
+                { get_input: dmaap_host }
+              DMAAPPORT:
+                { get_input: dmaap_port }
+              DMAAPPUBTOPIC: "unauthenticated.DCAE_CL_OUTPUT"
+              DMAAPSUBTOPIC: "unauthenticated.VES_MEASUREMENT_OUTPUT"
+              AAIHOST:
+                { get_input: aaiEnrichmentHost }
+              AAIPORT:
+                { get_input: aaiEnrichmentPort }
+              CONSUL_HOST:
+                { get_input: consul_host }
+              CONSUL_PORT:
+                { get_input: consul_port }
+              CBS_HOST:
+                { get_input: cbs_host }
+              CBS_PORT:
+                { get_input: cbs_port }
+              CONFIG_BINDING_SERVICE: "config_binding_service"
+            ports:
+              - concat: ["11011:", { get_input: external_port }]
+  tca_policy:
+    type: dcae.nodes.policy
+    properties:
+      policy_id:
+        get_input: policy_id