Fix Checkstyle issues
[clamp.git] / src / main / java / org / onap / clamp / clds / service / CldsService.java
index e895519..2a89b19 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP CLAMP
  * ================================================================================
- * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights
+ * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights
  *                             reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -26,15 +26,15 @@ 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;
-import java.util.Optional;
 import java.util.UUID;
 
 import javax.servlet.http.HttpServletRequest;
@@ -44,35 +44,27 @@ import javax.xml.transform.TransformerException;
 
 import org.apache.camel.Produce;
 import org.apache.commons.codec.DecoderException;
-import org.apache.commons.lang3.StringUtils;
 import org.json.simple.parser.ParseException;
 import org.onap.clamp.clds.camel.CamelProxy;
 import org.onap.clamp.clds.client.DcaeDispatcherServices;
 import org.onap.clamp.clds.client.DcaeInventoryServices;
-import org.onap.clamp.clds.client.req.sdc.SdcCatalogServices;
 import org.onap.clamp.clds.config.ClampProperties;
 import org.onap.clamp.clds.dao.CldsDao;
-import org.onap.clamp.clds.exception.CldsConfigException;
 import org.onap.clamp.clds.exception.policy.PolicyClientException;
 import org.onap.clamp.clds.exception.sdc.SdcCommunicationException;
-import org.onap.clamp.clds.model.CldsDbServiceCache;
 import org.onap.clamp.clds.model.CldsEvent;
 import org.onap.clamp.clds.model.CldsInfo;
 import org.onap.clamp.clds.model.CldsModel;
 import org.onap.clamp.clds.model.CldsModelProp;
 import org.onap.clamp.clds.model.CldsMonitoringDetails;
-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.SdcResource;
-import org.onap.clamp.clds.model.sdc.SdcServiceDetail;
 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;
@@ -89,29 +81,58 @@ import org.springframework.web.client.HttpClientErrorException;
 @Component
 public class CldsService extends SecureServiceBase {
 
+    /**
+     * The constant LIST_OF_SDC_SERVICE_INFO_TYPE.
+     */
+    public static final Type LIST_OF_SDC_SERVICE_INFO_TYPE = new TypeToken<List<SdcServiceInfo>>() {
+        }.getType();
     @Produce(uri = "direct:processSubmit")
     private CamelProxy camelProxy;
+    /**
+     * The constant securityLogger.
+     */
     protected static final EELFLogger securityLogger = EELFManager.getInstance().getSecurityLogger();
+    /**
+     * The constant logger.
+     */
     protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsService.class);
 
+    /**
+     * The constant GLOBAL_PROPERTIES_KEY.
+     */
     public static final String GLOBAL_PROPERTIES_KEY = "files.globalProperties";
-    private final String cldsPersmissionTypeCl;
     private final String cldsPermissionTypeClManage;
     private final String cldsPermissionTypeClEvent;
     private final String cldsPermissionTypeFilterVf;
-    private final String cldsPermissionTypeTemplate;
     private final String cldsPermissionInstance;
+    /**
+     * The Permission read cl.
+     */
     final SecureServicePermission permissionReadCl;
+    /**
+     * The Permission update cl.
+     */
     final SecureServicePermission permissionUpdateCl;
+    /**
+     * The Permission read template.
+     */
     final SecureServicePermission permissionReadTemplate;
+    /**
+     * The Permission update template.
+     */
     final SecureServicePermission permissionUpdateTemplate;
+    /**
+     * The Permission read tosca.
+     */
     final SecureServicePermission permissionReadTosca;
+    /**
+     * The Permission update tosca.
+     */
     final SecureServicePermission permissionUpdateTosca;
 
     private final CldsDao cldsDao;
     private final XslTransformer cldsBpmnTransformer;
     private final ClampProperties refProp;
-    private final SdcCatalogServices sdcCatalogServices;
     private final DcaeDispatcherServices dcaeDispatcherServices;
     private final DcaeInventoryServices dcaeInventoryServices;
     private LoggingUtils util = new LoggingUtils(logger);
@@ -119,28 +140,48 @@ public class CldsService extends SecureServiceBase {
     @Autowired
     private HttpServletRequest request;
 
+    /**
+     * Instantiates a new Clds service.
+     *
+     * @param cldsDao                    the clds dao
+     * @param cldsBpmnTransformer        the clds bpmn transformer
+     * @param refProp                    the ref prop
+     * @param dcaeDispatcherServices     the dcae dispatcher services
+     * @param dcaeInventoryServices      the dcae inventory services
+     * @param cldsPersmissionTypeCl      the clds persmission type cl
+     * @param cldsPermissionTypeClManage the clds permission type cl manage
+     * @param cldsPermissionTypeClEvent  the clds permission type cl event
+     * @param cldsPermissionTypeFilterVf the clds permission type filter vf
+     * @param cldsPermissionTypeTemplate the clds permission type template
+     * @param cldsPermissionTypeTosca    the clds permission type tosca
+     * @param cldsPermissionInstance     the clds permission instance
+     */
     @Autowired
     public CldsService(CldsDao cldsDao, XslTransformer cldsBpmnTransformer, ClampProperties refProp,
-        SdcCatalogServices sdcCatalogServices, DcaeDispatcherServices dcaeDispatcherServices,
+        DcaeDispatcherServices dcaeDispatcherServices,
         DcaeInventoryServices dcaeInventoryServices,
-        @Value("${clamp.config.security.permission.type.cl:permission-type-cl}") String cldsPersmissionTypeCl,
-        @Value("${clamp.config.security.permission.type.cl.manage:permission-type-cl-manage}") String cldsPermissionTypeClManage,
-        @Value("${clamp.config.security.permission.type.cl.event:permission-type-cl-event}") String cldsPermissionTypeClEvent,
-        @Value("${clamp.config.security.permission.type.filter.vf:permission-type-filter-vf}") String cldsPermissionTypeFilterVf,
-        @Value("${clamp.config.security.permission.type.template:permission-type-template}") String cldsPermissionTypeTemplate,
-        @Value("${clamp.config.security.permission.type.tosca:permission-type-tosca}") String cldsPermissionTypeTosca,
-        @Value("${clamp.config.security.permission.instance:dev}") String cldsPermissionInstance) {
+        @Value("${clamp.config.security.permission.type.cl:permission-type-cl}")
+                                   String cldsPersmissionTypeCl,
+        @Value("${clamp.config.security.permission.type.cl.manage:permission-type-cl-manage}")
+                                   String cldsPermissionTypeClManage,
+        @Value("${clamp.config.security.permission.type.cl.event:permission-type-cl-event}")
+                                   String cldsPermissionTypeClEvent,
+        @Value("${clamp.config.security.permission.type.filter.vf:permission-type-filter-vf}")
+                                   String cldsPermissionTypeFilterVf,
+        @Value("${clamp.config.security.permission.type.template:permission-type-template}")
+                                   String cldsPermissionTypeTemplate,
+        @Value("${clamp.config.security.permission.type.tosca:permission-type-tosca}")
+                                   String cldsPermissionTypeTosca,
+        @Value("${clamp.config.security.permission.instance:dev}")
+                                   String cldsPermissionInstance) {
         this.cldsDao = cldsDao;
         this.cldsBpmnTransformer = cldsBpmnTransformer;
         this.refProp = refProp;
-        this.sdcCatalogServices = sdcCatalogServices;
         this.dcaeDispatcherServices = dcaeDispatcherServices;
         this.dcaeInventoryServices = dcaeInventoryServices;
-        this.cldsPersmissionTypeCl = cldsPersmissionTypeCl;
         this.cldsPermissionTypeClManage = cldsPermissionTypeClManage;
         this.cldsPermissionTypeClEvent = cldsPermissionTypeClEvent;
         this.cldsPermissionTypeFilterVf = cldsPermissionTypeFilterVf;
-        this.cldsPermissionTypeTemplate = cldsPermissionTypeTemplate;
         this.cldsPermissionInstance = cldsPermissionInstance;
         permissionReadCl = SecureServicePermission.create(cldsPersmissionTypeCl, cldsPermissionInstance, "read");
         permissionUpdateCl = SecureServicePermission.create(cldsPersmissionTypeCl, cldsPermissionInstance, "update");
@@ -153,8 +194,9 @@ public class CldsService extends SecureServiceBase {
             "update");
     }
 
-    /*
-     * @return list of CLDS-Monitoring-Details: CLOSELOOP_NAME | Close loop name
+    /**
+     * Gets clds details.
+     * list of CLDS-Monitoring-Details: CLOSELOOP_NAME | Close loop name
      * used in the CLDS application (prefix: ClosedLoop- + unique ClosedLoop ID)
      * MODEL_NAME | Model Name in CLDS application SERVICE_TYPE_ID | TypeId returned
      * from the DCAE application when the ClosedLoop is submitted
@@ -162,11 +204,12 @@ public class CldsService extends SecureServiceBase {
      * generated when the ClosedLoop is deployed in DCAE. TEMPLATE_NAME | Template
      * used to generate the ClosedLoop model. ACTION_CD | Current state of the
      * ClosedLoop in CLDS application.
+     * @return the clds details
      */
     public List<CldsMonitoringDetails> getCldsDetails() {
         util.entering(request, "CldsService: GET model details");
         Date startTime = new Date();
-        List<CldsMonitoringDetails> cldsMonitoringDetailsList = cldsDao.getCLDSMonitoringDetails();
+        List<CldsMonitoringDetails> cldsMonitoringDetailsList = cldsDao.getCldsMonitoringDetails();
         // audit log
         LoggingUtils.setTimeContext(startTime, new Date());
         auditLogger.info("GET cldsDetails completed");
@@ -174,9 +217,11 @@ public class CldsService extends SecureServiceBase {
         return cldsMonitoringDetailsList;
     }
 
-    /*
+    /**
+     * Gets clds info.
      * CLDS IFO service will return 3 things 1. User Name 2. CLDS code version that
      * is currently installed from pom.xml file 3. User permissions
+     * @return the clds info
      */
     public CldsInfo getCldsInfo() {
         util.entering(request, "CldsService: GET cldsInfo");
@@ -198,7 +243,7 @@ public class CldsService extends SecureServiceBase {
      * This is subset of the json getModel. This is only expected to be used for
      * testing purposes, not by the UI.
      *
-     * @param modelName
+     * @param modelName the model name
      * @return bpmn xml text - content of bpmn given name
      */
     public String getBpmnXml(String modelName) {
@@ -219,7 +264,7 @@ public class CldsService extends SecureServiceBase {
      * This is subset of the json getModel. This is only expected to be used for
      * testing purposes, not by the UI.
      *
-     * @param modelName
+     * @param modelName the model name
      * @return image xml text - content of image given name
      */
     public String getImageXml(String modelName) {
@@ -238,7 +283,7 @@ public class CldsService extends SecureServiceBase {
     /**
      * REST service that retrieves a CLDS model by name from the database.
      *
-     * @param modelName
+     * @param modelName the model name
      * @return clds model - clds model for the given model name
      */
     public CldsModel getModel(String modelName) {
@@ -278,7 +323,9 @@ public class CldsService extends SecureServiceBase {
     /**
      * REST service that saves a CLDS model by name in the database.
      *
-     * @param modelName
+     * @param modelName the model name
+     * @param cldsModel the clds model
+     * @return the clds model
      */
     public CldsModel putModel(String modelName, CldsModel cldsModel) {
         util.entering(request, "CldsService: PUT model");
@@ -334,19 +381,13 @@ public class CldsService extends SecureServiceBase {
     /**
      * REST service that saves and processes an action for a CLDS model by name.
      *
-     * @param action
-     * @param modelName
-     * @param validateFlag
-     * @param model
-     * @return
-     * @throws TransformerException
-     *         In case of issues when doing the XSLT of the BPMN flow
-     * @throws ParseException
-     *         In case of issues when parsing the JSON
-     * @throws GeneralSecurityException
-     *         In case of issues when decrypting the password
-     * @throws DecoderException
-     *         In case of issues with the Hex String decoding
+     * @param action    the action
+     * @param modelName the model name
+     * @param test      the test
+     * @param model     the model
+     * @return response entity
+     * @throws TransformerException In case of issues when doing the XSLT of the BPMN flow
+     * @throws ParseException       In case of issues when parsing the JSON
      */
     public ResponseEntity<?> putModelAndProcessAction(String action, String modelName, String test, CldsModel model)
         throws TransformerException, ParseException {
@@ -406,11 +447,14 @@ public class CldsService extends SecureServiceBase {
             errorMessage = e.getMessage();
         }
 
-        if (!errorMessage.isEmpty()) {
+        if (null == errorMessage || (null != errorMessage && !errorMessage.isEmpty())) {
             CldsEvent.insEvent(cldsDao, model.getControlName(), getUserId(), actionCd, CldsEvent.ACTION_STATE_ERROR,
                 null);
             // Need a refresh as new events have been inserted
             model = CldsModel.retrieve(cldsDao, modelName, false);
+            if (null == errorMessage) {
+                errorMessage = "No response from Policy";
+            }
             model.setErrorMessageForUi(errorMessage);
             util.exiting(HttpStatus.INTERNAL_SERVER_ERROR.toString(), "putModelAndProcessAction failed", Level.INFO,
                 ONAPLogConstants.ResponseStatus.ERROR);
@@ -427,8 +471,9 @@ public class CldsService extends SecureServiceBase {
     /**
      * REST service that accepts events for a model.
      *
-     * @param test
-     * @param dcaeEvent
+     * @param test      the test
+     * @param dcaeEvent the dcae event
+     * @return the string
      */
     public String postDcaeEvent(String test, DcaeEvent dcaeEvent) {
         util.entering(request, "CldsService: Post dcae event");
@@ -471,84 +516,22 @@ public class CldsService extends SecureServiceBase {
     }
 
     /**
-     * REST service that retrieves sdc services
-     *
-     * @throws GeneralSecurityException
-     *         In case of issue when decryting the SDC password
-     * @throws DecoderException
-     *         In case of issues with the decoding of the Hex String
-     */
-    public String getSdcServices() throws GeneralSecurityException, DecoderException {
-        util.entering(request, "CldsService: GET sdc services");
-        Date startTime = new Date();
-        String retStr;
-        try {
-            retStr = createUiServiceFormatJson(sdcCatalogServices.getSdcServicesInformation(null));
-        } catch (IOException e) {
-            logger.error("IOException during SDC communication", e);
-            throw new SdcCommunicationException("IOException during SDC communication", e);
-        }
-        logger.info("value of sdcServices : {}", retStr);
-        // audit log
-        LoggingUtils.setTimeContext(startTime, new Date());
-        auditLogger.info("GET sdc services completed");
-        util.exiting("200", "Get sdc services success", Level.INFO, ONAPLogConstants.ResponseStatus.COMPLETED);
-        return retStr;
-    }
-
-    /**
-     * REST service that retrieves total properties required by UI
+     * REST service that retrieves total properties required by UI.
      *
-     * @throws IOException
-     *         In case of issues
+     * @return the sdc properties
+     * @throws IOException In case of issues
      */
     public String getSdcProperties() throws IOException {
-        return createPropertiesObjectByUUID("{}");
+        return refProp.getJsonTemplate(GLOBAL_PROPERTIES_KEY).toString();
     }
 
-    /**
-     * REST service that retrieves total properties by using invariantUUID based on
-     * refresh and non refresh
-     *
-     * @throws GeneralSecurityException
-     *         In case of issues with the decryting the encrypted password
-     * @throws DecoderException
-     *         In case of issues with the decoding of the Hex String
-     * @throws IOException
-     *         In case of issue to convert CldsServiceCache to InputStream
-     */
-    public String getSdcPropertiesByServiceUUIDForRefresh(String serviceInvariantUUID, Boolean refresh)
-        throws GeneralSecurityException, DecoderException, IOException {
-        util.entering(request, "CldsService: GET sdc properties by uuid");
-        Date startTime = new Date();
-        CldsServiceData cldsServiceData = new CldsServiceData();
-        cldsServiceData.setServiceInvariantUUID(serviceInvariantUUID);
-        if (!Optional.ofNullable(refresh).orElse(false)) {
-            cldsServiceData = cldsDao.getCldsServiceCache(serviceInvariantUUID);
-        }
-        if (sdcCatalogServices.isCldsSdcCacheDataExpired(cldsServiceData)) {
-            cldsServiceData = sdcCatalogServices.getCldsServiceDataWithAlarmConditions(serviceInvariantUUID);
-            cldsDao.setCldsServiceCache(new CldsDbServiceCache(cldsServiceData));
-        }
-        // filter out VFs the user is not authorized for
-        cldsServiceData.filterVfs(this);
-        // format retrieved data into properties json
-        String sdcProperties = sdcCatalogServices.createPropertiesObjectByUUID(cldsServiceData);
-        // audit log
-        LoggingUtils.setTimeContext(startTime, new Date());
-        auditLogger.info("GET sdc properties by uuid completed");
-        util.exiting("200", "Get sdc properties by uuid success", Level.INFO,
-            ONAPLogConstants.ResponseStatus.COMPLETED);
-        return sdcProperties;
-    }
 
     /**
      * Determine if the user is authorized for a particular VF by its invariant
      * UUID.
      *
-     * @param vfInvariantUuid
-     * @throws NotAuthorizedException
-     * @return
+     * @param vfInvariantUuid the vf invariant uuid
+     * @return boolean or throws NotAuthorizedException
      */
     public boolean isAuthorizedForVf(String vfInvariantUuid) {
         if (cldsPermissionTypeFilterVf != null && !cldsPermissionTypeFilterVf.isEmpty()) {
@@ -567,8 +550,8 @@ public class CldsService extends SecureServiceBase {
      * Determine if the user is authorized for a particular VF by its invariant
      * UUID. If not authorized, then NotAuthorizedException is thrown.
      *
-     * @param model
-     * @return
+     * @param model The clds model
+     * @return boolean or throws NotAuthorizedException
      */
     private boolean isAuthorizedForVf(CldsModel model) {
         String vf = ModelProperties.getVf(model);
@@ -580,137 +563,13 @@ public class CldsService extends SecureServiceBase {
         }
     }
 
-    private String createUiServiceFormatJson(String responseStr) throws IOException {
-        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();
-        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(),
-                        currCldsSdcServiceInfo.getName());
-                }
-            }
-            serviceNode.putPOJO("service", invariantIdServiceNode);
-        }
-        return serviceNode.toString();
-    }
-
-    private String createPropertiesObjectByUUID(String cldsResponseStr) throws IOException {
-        ObjectMapper mapper = JacksonUtils.getObjectMapperInstance();
-        SdcServiceDetail cldsSdcServiceDetail = mapper.readValue(cldsResponseStr, SdcServiceDetail.class);
-        ObjectNode globalPropsJson = (ObjectNode) refProp.getJsonTemplate(GLOBAL_PROPERTIES_KEY);
-        if (cldsSdcServiceDetail != null && cldsSdcServiceDetail.getUuid() != null) {
-            /**
-             * to create json with vf, alarm and locations
-             */
-            ObjectNode serviceObjectNode = createEmptyVfAlarmObject();
-            ObjectNode vfObjectNode = mapper.createObjectNode();
-            /**
-             * to create json with vf and vfresourceId
-             */
-            createVfObjectNode(vfObjectNode, cldsSdcServiceDetail.getResources());
-            serviceObjectNode.putPOJO(cldsSdcServiceDetail.getInvariantUUID(), vfObjectNode);
-            ObjectNode byServiceBasicObjetNode = mapper.createObjectNode();
-            byServiceBasicObjetNode.putPOJO("byService", serviceObjectNode);
-            /**
-             * to create json with VFC Node
-             */
-            ObjectNode emptyvfcobjectNode = createByVFCObjectNode(cldsSdcServiceDetail.getResources());
-            byServiceBasicObjetNode.putPOJO("byVf", emptyvfcobjectNode);
-            globalPropsJson.putPOJO("shared", byServiceBasicObjetNode);
-            logger.info("valuie of objNode: {}", globalPropsJson);
-        }
-        return globalPropsJson.toString();
-    }
-
-    private ObjectNode createEmptyVfAlarmObject() {
-        ObjectMapper mapper = JacksonUtils.getObjectMapperInstance();
-        ObjectNode emptyObjectNode = mapper.createObjectNode();
-        emptyObjectNode.put("", "");
-        ObjectNode vfObjectNode = mapper.createObjectNode();
-        vfObjectNode.putPOJO("vf", emptyObjectNode);
-        vfObjectNode.putPOJO("location", emptyObjectNode);
-        vfObjectNode.putPOJO("alarmCondition", emptyObjectNode);
-        ObjectNode emptyServiceObjectNode = mapper.createObjectNode();
-        emptyServiceObjectNode.putPOJO("", vfObjectNode);
-        return emptyServiceObjectNode;
-    }
-
-    private void createVfObjectNode(ObjectNode vfObjectNode2, List<SdcResource> rawCldsSdcResourceList) {
-        ObjectMapper mapper = JacksonUtils.getObjectMapperInstance();
-        ObjectNode vfNode = mapper.createObjectNode();
-        vfNode.put("", "");
-        // To remove repeated resource instance name from
-        // resourceInstanceList
-        List<SdcResource> cldsSdcResourceList = sdcCatalogServices
-            .removeDuplicateSdcResourceInstances(rawCldsSdcResourceList);
-        /**
-         * Creating vf resource node using cldsSdcResource Object
-         */
-        if (cldsSdcResourceList != null && !cldsSdcResourceList.isEmpty()) {
-            for (SdcResource cldsSdcResource : cldsSdcResourceList) {
-                if (cldsSdcResource != null && "VF".equalsIgnoreCase(cldsSdcResource.getResoucreType())) {
-                    vfNode.put(cldsSdcResource.getResourceUUID(), cldsSdcResource.getResourceName());
-                }
-            }
-        }
-        vfObjectNode2.putPOJO("vf", vfNode);
-        /**
-         * creating location json object using properties file value
-         */
-        ObjectNode locationJsonNode;
-        try {
-            locationJsonNode = (ObjectNode) mapper.readValue(refProp.getStringValue("ui.location.default"),
-                JsonNode.class);
-        } catch (IOException e) {
-            logger.error("Unable to load ui.location.default JSON in clds-references.properties properly", e);
-            throw new CldsConfigException(
-                "Unable to load ui.location.default JSON in clds-references.properties properly", e);
-        }
-        vfObjectNode2.putPOJO("location", locationJsonNode);
-        /**
-         * creating alarm json object using properties file value
-         */
-        String alarmStringValue = refProp.getStringValue("ui.alarm.default");
-        logger.info("value of alarm: {}", alarmStringValue);
-        ObjectNode alarmStringJsonNode;
-        try {
-            alarmStringJsonNode = (ObjectNode) mapper.readValue(alarmStringValue, JsonNode.class);
-        } catch (IOException e) {
-            logger.error("Unable to ui.alarm.default JSON in clds-references.properties properly", e);
-            throw new CldsConfigException("Unable to load ui.alarm.default JSON in clds-references.properties properly",
-                e);
-        }
-        vfObjectNode2.putPOJO("alarmCondition", alarmStringJsonNode);
-    }
-
-    private ObjectNode createByVFCObjectNode(List<SdcResource> cldsSdcResourceList) {
-        ObjectMapper mapper = JacksonUtils.getObjectMapperInstance();
-        ObjectNode emptyObjectNode = mapper.createObjectNode();
-        ObjectNode emptyvfcobjectNode = mapper.createObjectNode();
-        ObjectNode vfCObjectNode = mapper.createObjectNode();
-        vfCObjectNode.putPOJO("vfC", emptyObjectNode);
-        ObjectNode subVfCObjectNode = mapper.createObjectNode();
-        subVfCObjectNode.putPOJO("vfc", emptyObjectNode);
-        if (cldsSdcResourceList != null && !cldsSdcResourceList.isEmpty()) {
-            for (SdcResource cldsSdcResource : cldsSdcResourceList) {
-                if (cldsSdcResource != null && "VF".equalsIgnoreCase(cldsSdcResource.getResoucreType())) {
-                    vfCObjectNode.putPOJO(cldsSdcResource.getResourceUUID(), subVfCObjectNode);
-                }
-            }
-        }
-        emptyvfcobjectNode.putPOJO("", vfCObjectNode);
-        return emptyvfcobjectNode;
-    }
-
+    /**
+     * Deploy model response entity.
+     *
+     * @param modelName the model name
+     * @param model     the model
+     * @return the response entity
+     */
     public ResponseEntity<CldsModel> deployModel(String modelName, CldsModel model) {
         util.entering(request, "CldsService: Deploy model");
         Date startTime = new Date();
@@ -760,6 +619,13 @@ public class CldsService extends SecureServiceBase {
         }
     }
 
+    /**
+     * Un deploy model response entity.
+     *
+     * @param modelName the model name
+     * @param model     the model
+     * @return the response entity
+     */
     public ResponseEntity<CldsModel> unDeployModel(String modelName, CldsModel model) {
         util.entering(request, "CldsService: Undeploy model");
         Date startTime = new Date();
@@ -821,16 +687,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))) {
@@ -842,6 +709,11 @@ public class CldsService extends SecureServiceBase {
         }
     }
 
+    /**
+     * Sets logging util.
+     *
+     * @param utilP the util p
+     */
     // Created for the integration test
     public void setLoggingUtil(LoggingUtils utilP) {
         util = utilP;