Remove globalClds.properties 95/34095/1
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>
Mon, 5 Mar 2018 16:46:49 +0000 (17:46 +0100)
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>
Mon, 5 Mar 2018 16:46:49 +0000 (17:46 +0100)
Remove the globalClds.properties and merge that to
application.properties

Issue-ID: CLAMP-136
Change-Id: I9c5bc8745b576ca8fad0cca3bff4c136329515d8
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java
src/main/java/org/onap/clamp/clds/service/CldsService.java
src/main/resources/application.properties
src/main/resources/clds/globalClds.properties [deleted file]
src/main/resources/clds/templates/globalProperties.json [new file with mode: 0644]
src/test/resources/application.properties
src/test/resources/clds/templates/globalProperties.json [new file with mode: 0644]

index 5664653..fd7d096 100644 (file)
@@ -72,6 +72,7 @@ import org.onap.clamp.clds.model.sdc.SdcResource;
 import org.onap.clamp.clds.model.sdc.SdcResourceBasicInfo;\r
 import org.onap.clamp.clds.model.sdc.SdcServiceDetail;\r
 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.LoggingUtils;\r
 import org.springframework.beans.factory.annotation.Autowired;\r
@@ -840,11 +841,13 @@ public class SdcCatalogServices {
      * @param globalProps\r
      * @param cldsServiceData\r
      * @return\r
+     * @throws IOException\r
+     *             In case of issues during the parsing of the Global Properties\r
      */\r
-    public String createPropertiesObjectByUUID(String globalProps, CldsServiceData cldsServiceData) {\r
+    public String createPropertiesObjectByUUID(CldsServiceData cldsServiceData) throws IOException {\r
         String totalPropsStr;\r
         ObjectMapper mapper = new ObjectMapper();\r
-        ObjectNode globalPropsJson;\r
+        ObjectNode globalPropsJson = (ObjectNode) refProp.getJsonTemplate(CldsService.GLOBAL_PROPERTIES_KEY);\r
         if (cldsServiceData != null && cldsServiceData.getServiceUUID() != null) {\r
             // Objectnode to save all byservice, byvf , byvfc and byalarm nodes\r
             ObjectNode byIdObjectNode = mapper.createObjectNode();\r
@@ -886,28 +889,13 @@ public class SdcCatalogServices {
                     "alertDescription");\r
             ObjectNode alertDescObjectNodeByAlert = createAlarmCondObjectNodeByAlarmKey(mapper, allAlertDescriptions);\r
             byIdObjectNode.putPOJO("byAlertDescription", alertDescObjectNodeByAlert);\r
-            globalPropsJson = decodeGlobalProp(globalProps, mapper);\r
             globalPropsJson.putPOJO("shared", byIdObjectNode);\r
             logger.info("Global properties JSON created with SDC info:" + globalPropsJson);\r
-        } else {\r
-            /**\r
-             * to create json with total properties when no serviceUUID passed\r
-             */\r
-            globalPropsJson = decodeGlobalProp(globalProps, mapper);\r
         }\r
         totalPropsStr = globalPropsJson.toString();\r
         return totalPropsStr;\r
     }\r
 \r
-    private ObjectNode decodeGlobalProp(String globalProps, ObjectMapper mapper) {\r
-        try {\r
-            return (ObjectNode) mapper.readValue(globalProps, JsonNode.class);\r
-        } catch (IOException e) {\r
-            logger.error("Exception occurred during decoding of the global props, returning an empty objectNode", e);\r
-            return mapper.createObjectNode();\r
-        }\r
-    }\r
-\r
     /**\r
      * Method to get alarm conditions/alert description from Service Data.\r
      * \r
index 3b6bc37..2968f60 100644 (file)
@@ -87,7 +87,6 @@ import org.onap.clamp.clds.transform.XslTransformer;
 import org.onap.clamp.clds.util.LoggingUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.context.ApplicationContext;
 import org.springframework.http.HttpStatus;
 import org.springframework.stereotype.Component;
 import org.springframework.web.client.HttpClientErrorException;
@@ -102,9 +101,8 @@ public class CldsService extends SecureServiceBase {
     @Produce(uri = "direct:processSubmit")
     private CamelProxy camelProxy;
     protected static final EELFLogger securityLogger = EELFManager.getInstance().getSecurityLogger();
-    @Autowired
-    private ApplicationContext appContext;
     private static final String RESOURCE_NAME = "clds-version.properties";
+    public static final String GLOBAL_PROPERTIES_KEY = "files.globalProperties";
     @Value("${clamp.config.security.permission.type.cl:permission-type-cl}")
     private String cldsPersmissionTypeCl;
     @Value("${clamp.config.security.permission.type.cl.manage:permission-type-cl-manage}")
@@ -132,9 +130,6 @@ public class CldsService extends SecureServiceBase {
                 "update");
     }
 
-    @Value("${org.onap.clamp.config.files.globalClds:'classpath:/clds/globalClds.properties'}")
-    private String globalClds;
-    private Properties globalCldsProperties;
     @Autowired
     private CldsDao cldsDao;
     @Autowired
@@ -585,7 +580,7 @@ public class CldsService extends SecureServiceBase {
     @Path("/properties")
     @Produces(MediaType.APPLICATION_JSON)
     public String getSdcProperties() throws IOException {
-        return createPropertiesObjectByUUID(getGlobalCldsString(), "{}");
+        return createPropertiesObjectByUUID("{}");
     }
 
     /**
@@ -620,7 +615,7 @@ public class CldsService extends SecureServiceBase {
         // filter out VFs the user is not authorized for
         cldsServiceData.filterVfs(this);
         // format retrieved data into properties json
-        String sdcProperties = sdcCatalogServices.createPropertiesObjectByUUID(getGlobalCldsString(), cldsServiceData);
+        String sdcProperties = sdcCatalogServices.createPropertiesObjectByUUID(cldsServiceData);
         // audit log
         LoggingUtils.setTimeContext(startTime, new Date());
         LoggingUtils.setResponseContext("0", "Get sdc properties by uuid success", this.getClass().getName());
@@ -689,10 +684,10 @@ public class CldsService extends SecureServiceBase {
         return serviceNode.toString();
     }
 
-    private String createPropertiesObjectByUUID(String globalProps, String cldsResponseStr) throws IOException {
+    private String createPropertiesObjectByUUID(String cldsResponseStr) throws IOException {
         ObjectMapper mapper = new ObjectMapper();
         SdcServiceDetail cldsSdcServiceDetail = mapper.readValue(cldsResponseStr, SdcServiceDetail.class);
-        ObjectNode globalPropsJson = null;
+        ObjectNode globalPropsJson = (ObjectNode) refProp.getJsonTemplate(GLOBAL_PROPERTIES_KEY);
         if (cldsSdcServiceDetail != null && cldsSdcServiceDetail.getUuid() != null) {
             /**
              * to create json with vf, alarm and locations
@@ -711,14 +706,8 @@ public class CldsService extends SecureServiceBase {
              */
             ObjectNode emptyvfcobjectNode = createByVFCObjectNode(mapper, cldsSdcServiceDetail.getResources());
             byServiceBasicObjetNode.putPOJO("byVf", emptyvfcobjectNode);
-            globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class);
             globalPropsJson.putPOJO("shared", byServiceBasicObjetNode);
             logger.info("valuie of objNode: {}", globalPropsJson);
-        } else {
-            /**
-             * to create json with total properties when no serviceUUID passed
-             */
-            globalPropsJson = (ObjectNode) mapper.readValue(globalProps, JsonNode.class);
         }
         return globalPropsJson.toString();
     }
@@ -903,19 +892,6 @@ public class CldsService extends SecureServiceBase {
         return model;
     }
 
-    private String getGlobalCldsString() {
-        try {
-            if (null == globalCldsProperties) {
-                globalCldsProperties = new Properties();
-                globalCldsProperties.load(appContext.getResource(globalClds).getInputStream());
-            }
-            return (String) globalCldsProperties.get("globalCldsProps");
-        } catch (IOException e) {
-            logger.error("Unable to load the globalClds due to an exception", e);
-            throw new CldsConfigException("Unable to load the globalClds due to an exception", e);
-        }
-    }
-
     private void checkForDuplicateServiceVf(String modelName, String modelPropText) throws IOException {
         JsonNode modelJson = new ObjectMapper().readTree(modelPropText);
         JsonNode globalNode = modelJson.get("global");
index 8c8b196..2c3537d 100644 (file)
@@ -108,7 +108,7 @@ async.queue.capacity=500
 \r
 org.onap.clamp.config.files.cldsPolicyConfig=classpath:/clds/clds-policy-config.properties\r
 org.onap.clamp.config.files.cldsUsers=classpath:/clds/clds-users.json\r
-org.onap.clamp.config.files.globalClds=classpath:/clds/globalClds.properties\r
+clamp.config.files.globalProperties=classpath:/clds/templates/globalProperties.json\r
 org.onap.clamp.config.files.sdcController=classpath:/clds/sdc-controllers-config.json\r
 \r
 # Properties for Clamp\r
diff --git a/src/main/resources/clds/globalClds.properties b/src/main/resources/clds/globalClds.properties
deleted file mode 100644 (file)
index e83fa6c..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-###\r
-# ============LICENSE_START=======================================================\r
-# ONAP CLAMP\r
-# ================================================================================\r
-# Copyright (C) 2017 AT&T Intellectual Property. All rights\r
-#                             reserved.\r
-# ================================================================================\r
-# Licensed under the Apache License, Version 2.0 (the "License"); \r
-# you may not use this file except in compliance with the License. \r
-# You may obtain a copy of the License at\r
-# \r
-# http://www.apache.org/licenses/LICENSE-2.0\r
-# \r
-# Unless required by applicable law or agreed to in writing, software \r
-# distributed under the License is distributed on an "AS IS" BASIS, \r
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. \r
-# See the License for the specific language governing permissions and \r
-# limitations under the License.\r
-# ============LICENSE_END============================================\r
-# ===================================================================\r
-# ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
-###\r
-\r
-globalCldsProps ={"tca":{"tname":"New_Set","tcaInt":"1","tcaVio":"1","eventName":{"vCPEvGMUXPacketLoss":"vCPEvGMUXPacketLoss","vLoadBalancer":"vLoadBalancer","vFirewallBroadcastPackets":"vFirewallBroadcastPackets"},"fieldPathM":{"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated":"receivedBroadcastPacketsAccumulated","$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta":"receivedDiscardedPacketsDelta"},"operator":{">":"GREATER",">=":"GREATER_OR_EQUAL","=":"EQUAL","<=":"LESS_OR_EQUAL","<":"LESS"},"opsPolicy":{"POLICY_test_X":"POLICY_test_X","POLICY_test_Y":"POLICY_test_Y"},"controlLoopSchemaType":{"":"","VM":"VM","VNF":"VNF"},"closedLoopEventStatus":{"":"","ONSET":"ONSET","ABATED":"ABATED"}},"global":{"actionSet":{"vnfRecipe":"VNF", "enbRecipe":"eNodeB"},"location":{"DC1":"Data Center 1","DC2":"Data Center 2","DC3":"Data Center 3"}},"policy":{"pname":"0","timeout":345,"vnfRecipe":{"":"","restart":"Restart","rebuild":"Rebuild","migrate":"Migrate","healthCheck":"Health Check"},"enbRecipe":{"":"","reset":"Reset"},"maxRetries":"3","retryTimeLimit":180,"resource":{"vCTS":"vCTS","v3CDB":"v3CDB","vUDR":"vUDR","vCOM":"vCOM","vRAR":"vRAR","vLCS":"vLCS","vUDR-BE":"vUDR-BE","vDBE":"vDBE"},"parentPolicyConditions":{"Failure_Retries":"Failure: Max Retries Exceeded","Failure_Timeout":"Failure: Time Limit Exceeded","Failure_Guard":"Failure: Guard","Failure_Exception":"Failure: Exception","Failure":"Failure: Other","Success":"Success"}},"shared":{"byService":{"":{"vf":{"":""},"location":{"":""},"alarmCondition":{"":""}}},"byVf":{"":{"vfc":{"":""}}}}}
diff --git a/src/main/resources/clds/templates/globalProperties.json b/src/main/resources/clds/templates/globalProperties.json
new file mode 100644 (file)
index 0000000..9ac9d94
--- /dev/null
@@ -0,0 +1,105 @@
+{
+       "tca": {
+               "tname": "New_Set",
+               "tcaInt": "1",
+               "tcaVio": "1",
+               "eventName": {
+                       "vCPEvGMUXPacketLoss": "vCPEvGMUXPacketLoss",
+                       "vLoadBalancer": "vLoadBalancer",
+                       "vFirewallBroadcastPackets": "vFirewallBroadcastPackets"
+               },
+               "fieldPathM": {
+                       "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated": "receivedBroadcastPacketsAccumulated",
+                       "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta": "receivedDiscardedPacketsDelta"
+               },
+               "operator": {
+                       ">": "GREATER",
+                       ">=": "GREATER_OR_EQUAL",
+                       "=": "EQUAL",
+                       "<=": "LESS_OR_EQUAL",
+                       "<": "LESS"
+               },
+               "opsPolicy": {
+                       "POLICY_test_X": "POLICY_test_X",
+                       "POLICY_test_Y": "POLICY_test_Y"
+               },
+               "controlLoopSchemaType": {
+                       "": "",
+                       "VM": "VM",
+                       "VNF": "VNF"
+               },
+               "closedLoopEventStatus": {
+                       "": "",
+                       "ONSET": "ONSET",
+                       "ABATED": "ABATED"
+               }
+       },
+       "global": {
+               "actionSet": {
+                       "vnfRecipe": "VNF",
+                       "enbRecipe": "eNodeB"
+               },
+               "location": {
+                       "DC1": "Data Center 1",
+                       "DC2": "Data Center 2",
+                       "DC3": "Data Center 3"
+               }
+       },
+       "policy": {
+               "pname": "0",
+               "timeout": 345,
+               "vnfRecipe": {
+                       "": "",
+                       "restart": "Restart",
+                       "rebuild": "Rebuild",
+                       "migrate": "Migrate",
+                       "healthCheck": "Health Check"
+               },
+               "enbRecipe": {
+                       "": "",
+                       "reset": "Reset"
+               },
+               "maxRetries": "3",
+               "retryTimeLimit": 180,
+               "resource": {
+                       "vCTS": "vCTS",
+                       "v3CDB": "v3CDB",
+                       "vUDR": "vUDR",
+                       "vCOM": "vCOM",
+                       "vRAR": "vRAR",
+                       "vLCS": "vLCS",
+                       "vUDR-BE": "vUDR-BE",
+                       "vDBE": "vDBE"
+               },
+               "parentPolicyConditions": {
+                       "Failure_Retries": "Failure: Max Retries Exceeded",
+                       "Failure_Timeout": "Failure: Time Limit Exceeded",
+                       "Failure_Guard": "Failure: Guard",
+                       "Failure_Exception": "Failure: Exception",
+                       "Failure": "Failure: Other",
+                       "Success": "Success"
+               }
+       },
+       "shared": {
+               "byService": {
+                       "": {
+                               "vf": {
+                                       "": ""
+                               },
+                               "location": {
+                                       "": ""
+                               },
+                               "alarmCondition": {
+                                       "": ""
+                               }
+                       }
+               },
+               "byVf": {
+                       "": {
+                               "vfc": {
+                                       "": ""
+                               }
+                       }
+               }
+       }
+}
index a676e10..e81e093 100644 (file)
@@ -108,7 +108,7 @@ async.queue.capacity=500
 \r
 org.onap.clamp.config.files.cldsPolicyConfig=classpath:/clds/clds-policy-config.properties\r
 org.onap.clamp.config.files.cldsUsers=classpath:/clds/clds-users.json\r
-org.onap.clamp.config.files.globalClds=classpath:/clds/globalClds.properties\r
+clamp.config.files.globalProperties=classpath:/clds/templates/globalProperties.json\r
 org.onap.clamp.config.files.sdcController=classpath:/clds/sdc-controllers-config.json\r
 \r
 # Properties for Clamp\r
diff --git a/src/test/resources/clds/templates/globalProperties.json b/src/test/resources/clds/templates/globalProperties.json
new file mode 100644 (file)
index 0000000..9ac9d94
--- /dev/null
@@ -0,0 +1,105 @@
+{
+       "tca": {
+               "tname": "New_Set",
+               "tcaInt": "1",
+               "tcaVio": "1",
+               "eventName": {
+                       "vCPEvGMUXPacketLoss": "vCPEvGMUXPacketLoss",
+                       "vLoadBalancer": "vLoadBalancer",
+                       "vFirewallBroadcastPackets": "vFirewallBroadcastPackets"
+               },
+               "fieldPathM": {
+                       "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated": "receivedBroadcastPacketsAccumulated",
+                       "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta": "receivedDiscardedPacketsDelta"
+               },
+               "operator": {
+                       ">": "GREATER",
+                       ">=": "GREATER_OR_EQUAL",
+                       "=": "EQUAL",
+                       "<=": "LESS_OR_EQUAL",
+                       "<": "LESS"
+               },
+               "opsPolicy": {
+                       "POLICY_test_X": "POLICY_test_X",
+                       "POLICY_test_Y": "POLICY_test_Y"
+               },
+               "controlLoopSchemaType": {
+                       "": "",
+                       "VM": "VM",
+                       "VNF": "VNF"
+               },
+               "closedLoopEventStatus": {
+                       "": "",
+                       "ONSET": "ONSET",
+                       "ABATED": "ABATED"
+               }
+       },
+       "global": {
+               "actionSet": {
+                       "vnfRecipe": "VNF",
+                       "enbRecipe": "eNodeB"
+               },
+               "location": {
+                       "DC1": "Data Center 1",
+                       "DC2": "Data Center 2",
+                       "DC3": "Data Center 3"
+               }
+       },
+       "policy": {
+               "pname": "0",
+               "timeout": 345,
+               "vnfRecipe": {
+                       "": "",
+                       "restart": "Restart",
+                       "rebuild": "Rebuild",
+                       "migrate": "Migrate",
+                       "healthCheck": "Health Check"
+               },
+               "enbRecipe": {
+                       "": "",
+                       "reset": "Reset"
+               },
+               "maxRetries": "3",
+               "retryTimeLimit": 180,
+               "resource": {
+                       "vCTS": "vCTS",
+                       "v3CDB": "v3CDB",
+                       "vUDR": "vUDR",
+                       "vCOM": "vCOM",
+                       "vRAR": "vRAR",
+                       "vLCS": "vLCS",
+                       "vUDR-BE": "vUDR-BE",
+                       "vDBE": "vDBE"
+               },
+               "parentPolicyConditions": {
+                       "Failure_Retries": "Failure: Max Retries Exceeded",
+                       "Failure_Timeout": "Failure: Time Limit Exceeded",
+                       "Failure_Guard": "Failure: Guard",
+                       "Failure_Exception": "Failure: Exception",
+                       "Failure": "Failure: Other",
+                       "Success": "Success"
+               }
+       },
+       "shared": {
+               "byService": {
+                       "": {
+                               "vf": {
+                                       "": ""
+                               },
+                               "location": {
+                                       "": ""
+                               },
+                               "alarmCondition": {
+                                       "": ""
+                               }
+                       }
+               },
+               "byVf": {
+                       "": {
+                               "vfc": {
+                                       "": ""
+                               }
+                       }
+               }
+       }
+}