Code refactoring 17/26317/3
authorLukasz Muszkieta <lukasz.muszkieta@nokia.com>
Thu, 14 Dec 2017 09:41:03 +0000 (10:41 +0100)
committerLukasz Muszkieta <lukasz.muszkieta@nokia.com>
Fri, 15 Dec 2017 11:44:46 +0000 (12:44 +0100)
Change-Id: Ic2737bf71f8b236939e9aa46ed619e6ad0e40b3a
Issue-ID: CLAMP-93
Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java
src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java
src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java
src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java
src/main/java/org/onap/clamp/clds/dao/CldsDao.java
src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java
src/test/java/org/onap/clamp/clds/it/SdcCatalogServicesItCase.java

index db84a12..970d7a8 100644 (file)
@@ -62,9 +62,8 @@ import org.onap.policy.controlloop.policy.builder.Results;
 /**
  * Construct an Operational Policy request given CLDS objects.
  */
-public class OperationalPolicyReq {
-    protected static final EELFLogger logger        = EELFManager.getInstance().getLogger(OperationalPolicyReq.class);
-    protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
+public final class OperationalPolicyReq {
+    private static final EELFLogger logger = EELFManager.getInstance().getLogger(OperationalPolicyReq.class);
 
     private OperationalPolicyReq() {
     }
@@ -151,16 +150,7 @@ public class OperationalPolicyReq {
         return attributes;
     }
 
-    /**
-     * Format Operational Policy yaml.
-     *
-     * @param refProp
-     * @param prop
-     * @return
-     * @throws BuilderException
-     * @throws UnsupportedEncodingException
-     */
-    public static String formatYaml(RefProp refProp, ModelProperties prop, String modelElementId,
+    private static String formatYaml(RefProp refProp, ModelProperties prop, String modelElementId,
             PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException {
         // get property objects
         Global global = prop.getGlobal();
@@ -207,16 +197,7 @@ public class OperationalPolicyReq {
         return URLEncoder.encode(results.getSpecification(), "UTF-8");
     }
 
-    /**
-     * Format Operational Policy yaml.
-     *
-     * @param refProp
-     * @param prop
-     * @return
-     * @throws BuilderException
-     * @throws UnsupportedEncodingException
-     */
-    public static String formateNodeBYaml(RefProp refProp, ModelProperties prop, String modelElementId,
+    private static String formateNodeBYaml(RefProp refProp, ModelProperties prop, String modelElementId,
             PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException {
         // get property objects
         Global global = prop.getGlobal();
@@ -277,7 +258,6 @@ public class OperationalPolicyReq {
         if (results.isValid()) {
             logger.info("results.getSpecification()=" + results.getSpecification());
         } else {
-            // throw exception with error info
             StringBuilder sb = new StringBuilder();
             sb.append("Operation Policy validation problem: ControlLoopPolicyBuilder failed with following messages: ");
             for (Message message : results.getMessages()) {
@@ -288,13 +268,8 @@ public class OperationalPolicyReq {
         }
     }
 
-    /**
-     * Adding AOTS actor and other recipe for yaml
-     *
-     * @param inOrigList
-     * @return
-     */
-    private static List<PolicyItem> addAOTSActorRecipe(RefProp refProp, String service, List<PolicyItem> inOrigList) {
+     // Adding AOTS actor and other recipe for yaml
+     private static List<PolicyItem> addAOTSActorRecipe(RefProp refProp, String service, List<PolicyItem> inOrigList) {
         List<PolicyItem> outList = new ArrayList<>();
         try {
             PolicyItem policyItem = inOrigList.get(0);
@@ -328,14 +303,8 @@ public class OperationalPolicyReq {
         return outList;
     }
 
-    /**
-     * Order list of PolicyItems so that parents come before any of their
-     * children
-     *
-     * @param inOrigList
-     * @return
-     */
-    private static List<PolicyItem> orderParentFirst(List<PolicyItem> inOrigList) {
+     // Order list of PolicyItems so that parents come before any of their children
+     private static List<PolicyItem> orderParentFirst(List<PolicyItem> inOrigList) {
         List<PolicyItem> inList = new ArrayList<>();
         inList.addAll(inOrigList);
         List<PolicyItem> outList = new ArrayList<>();
@@ -379,13 +348,6 @@ public class OperationalPolicyReq {
         return outList;
     }
 
-    /**
-     * Convert a List of resource strings to an array of Resource objects.
-     *
-     * @param stringList
-     * @param resourceType
-     * @return
-     */
     private static Resource[] convertToResource(List<String> stringList, ResourceType resourceType) {
         if (stringList == null || stringList.isEmpty()) {
             return new Resource[0];
@@ -393,13 +355,6 @@ public class OperationalPolicyReq {
         return stringList.stream().map(stringElem -> new Resource(stringElem, resourceType)).toArray(Resource[]::new);
     }
 
-    /**
-     * Convert a List of policy result strings to an array of PolicyResult
-     * objects.
-     *
-     * @param prList
-     * @return
-     */
     private static PolicyResult[] convertToPolicyResult(List<String> prList) {
         if (prList == null || prList.isEmpty()) {
             return new PolicyResult[0];
index 9571535..2e2169f 100644 (file)
@@ -62,10 +62,7 @@ import org.springframework.context.ApplicationContext;
  * Policy utility methods - specifically, send the policy.
  */
 public class PolicyClient {
-
     protected static final String POLICY_PREFIX_BASE = "Config_";
-    protected static final String POLICY_PREFIX_BRMS_PARAM = "Config_BRMS_Param_";
-    protected static final String POLICY_PREFIX_MICROSERVICE = "Config_MS_";
     protected static final String LOG_POLICY_PREFIX = "Response is ";
     protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyClient.class);
     protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
@@ -187,7 +184,6 @@ public class PolicyClient {
         PolicyParameters policyParameters = new PolicyParameters();
         // Set Policy Type
         policyParameters.setPolicyConfigType(PolicyConfigType.MicroService);
-        // policyParameters.setOnapName(refProp.getStringValue(POLICY_ONAPNAME_PROPERTY_NAME));
         policyParameters.setEcompName(refProp.getStringValue(POLICY_ONAPNAME_PROPERTY_NAME));
         policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName());
         policyParameters.setConfigBody(configBody);
@@ -335,11 +331,6 @@ public class PolicyClient {
         return versions;
     }
 
-    /**
-     * This method create a new policy engine.
-     * 
-     * @return A new policy engine
-     */
     private PolicyEngine getPolicyEngine() {
         PolicyEngine policyEngine;
         try {
index c725be2..14421da 100644 (file)
@@ -78,33 +78,24 @@ import org.onap.clamp.clds.util.LoggingUtils;
 import org.springframework.beans.factory.annotation.Autowired;\r
 \r
 public class SdcCatalogServices {\r
-    protected static final EELFLogger logger                        = EELFManager.getInstance()\r
-            .getLogger(SdcCatalogServices.class);\r
-    protected static final EELFLogger metricsLogger                 = EELFManager.getInstance().getMetricsLogger();\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
-    public 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
+\r
+    private static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcCatalogServices.class);\r
+    private static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();\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
     @Autowired\r
-    private RefProp                   refProp;\r
-    protected CryptoUtils             cryptoUtils                   = new CryptoUtils();\r
+    private RefProp refProp;\r
+    private CryptoUtils cryptoUtils = new CryptoUtils();\r
 \r
-    /**\r
-     * Return SDC id and pw as a HTTP Basic Auth string (for example: Basic\r
-     * dGVzdDoxMjM0NTY=).\r
-     *\r
-     * @return The String with Basic Auth and password\r
-     * @throws GeneralSecurityException\r
-     *             In case of issue when decryting the SDC password\r
-     * @throws DecoderException\r
-     *             In case of issues with the decoding of the HexString message\r
-     */\r
+    // returns SDC id and password as a HTTP Basic Auth string (for example: Basic dGVzdDoxMjM0NTY=)\r
     private String getSdcBasicAuth() throws GeneralSecurityException, DecoderException {\r
         String sdcId = refProp.getStringValue("sdc.serviceUsername");\r
         String sdcPw = refProp.getStringValue("sdc.servicePassword");\r
@@ -116,7 +107,7 @@ public class SdcCatalogServices {
     /**\r
      * This method get the SDC services Information with the corresponding\r
      * Service UUID.\r
-     * \r
+     *\r
      * @param uuid\r
      *            The service UUID\r
      * @return A Json String with all the service list\r
@@ -160,7 +151,7 @@ public class SdcCatalogServices {
 \r
     /**\r
      * To remove duplicate serviceUUIDs from sdc services List.\r
-     * \r
+     *\r
      * @param rawCldsSdcServiceList\r
      *            A list of CldsSdcServiceInfo\r
      * @return A list of CldsSdcServiceInfo without duplicate service UUID\r
@@ -189,9 +180,8 @@ public class SdcCatalogServices {
 \r
     /**\r
      * To remove duplicate serviceUUIDs from sdc resources List.\r
-     * \r
+     *\r
      * @param rawCldsSdcResourceList\r
-     * @return\r
      */\r
     public List<CldsSdcResource> removeDuplicateSdcResourceInstances(List<CldsSdcResource> rawCldsSdcResourceList) {\r
         List<CldsSdcResource> cldsSdcResourceList = null;\r
@@ -217,9 +207,8 @@ public class SdcCatalogServices {
 \r
     /**\r
      * To remove duplicate basic resources with same resourceUUIDs.\r
-     * \r
+     *\r
      * @param rawCldsSdcResourceListBasicList\r
-     * @return\r
      */\r
     public List<CldsSdcResourceBasicInfo> removeDuplicateSdcResourceBasicInfo(\r
             List<CldsSdcResourceBasicInfo> rawCldsSdcResourceListBasicList) {\r
@@ -247,7 +236,7 @@ public class SdcCatalogServices {
 \r
     /**\r
      * To get ServiceUUID by using serviceInvariantUUID.\r
-     * \r
+     *\r
      * @param invariantId\r
      *            The invariant ID\r
      * @return The service UUID\r
@@ -274,15 +263,7 @@ public class SdcCatalogServices {
         return serviceUuid;\r
     }\r
 \r
-    /**\r
-     * To get CldsAsdsServiceInfo class by parsing json string.\r
-     * \r
-     * @param jsonStr\r
-     *            The Json string that must be decoded\r
-     * @return The list of CldsSdcServiceInfo, if there is a failure it return\r
-     *         an empty list\r
-     */\r
-    public List<CldsSdcServiceInfo> getCldsSdcServicesListFromJson(String jsonStr) {\r
+    private List<CldsSdcServiceInfo> getCldsSdcServicesListFromJson(String jsonStr) {\r
         ObjectMapper objectMapper = new ObjectMapper();\r
         if (StringUtils.isBlank(jsonStr)) {\r
             return new ArrayList<>();\r
@@ -296,15 +277,7 @@ public class SdcCatalogServices {
         }\r
     }\r
 \r
-    /**\r
-     * To get List of CldsSdcResourceBasicInfo class by parsing json string.\r
-     *\r
-     * @param jsonStr\r
-     *            The JSOn string that must be decoded\r
-     * @return The list of CldsSdcResourceBasicInfo, an empty list in case of\r
-     *         issues\r
-     */\r
-    public List<CldsSdcResourceBasicInfo> getAllSdcResourcesListFromJson(String jsonStr) {\r
+    private List<CldsSdcResourceBasicInfo> getAllSdcResourcesListFromJson(String jsonStr) {\r
         ObjectMapper objectMapper = new ObjectMapper();\r
         if (StringUtils.isBlank(jsonStr)) {\r
             return new ArrayList<>();\r
@@ -318,21 +291,9 @@ public class SdcCatalogServices {
         }\r
     }\r
 \r
-    /**\r
-     * To get CldsAsdsResource class by parsing json string.\r
-     * \r
-     * @param jsonStr\r
-     * @return\r
-     * @throws IOException\r
-     */\r
-    public CldsSdcResource getCldsSdcResourceFromJson(String jsonStr) throws IOException {\r
-        ObjectMapper objectMapper = new ObjectMapper();\r
-        return objectMapper.readValue(jsonStr, CldsSdcResource.class);\r
-    }\r
-\r
     /**\r
      * To get CldsSdcServiceDetail by parsing json string.\r
-     * \r
+     *\r
      * @param jsonStr\r
      * @return\r
      */\r
@@ -346,18 +307,9 @@ public class SdcCatalogServices {
         }\r
     }\r
 \r
-    /**\r
-     * To upload artifact to sdc based on serviceUUID and resource name on url.\r
-     * \r
-     * @param prop\r
-     * @param userid\r
-     * @param url\r
-     * @param formattedSdcReq\r
-     * @return\r
-     * @throws GeneralSecurityException\r
-     */\r
-    public String uploadArtifactToSdc(ModelProperties prop, String userid, String url, String formattedSdcReq)\r
-            throws GeneralSecurityException {\r
+\r
+    // upload artifact to sdc based on serviceUUID and resource name on url\r
+    private String uploadArtifactToSdc(ModelProperties prop, String userid, String url, String formattedSdcReq) {\r
         // Verify whether it is triggered by Validation Test button from UI\r
         if (prop.isTestOnly()) {\r
             return "sdc artifact upload not executed for test action";\r
@@ -388,8 +340,7 @@ public class SdcCatalogServices {
         }\r
     }\r
 \r
-    private HttpURLConnection getSdcHttpUrlConnection(String userid, int postDataLength, String url, String content)\r
-            throws GeneralSecurityException {\r
+    private HttpURLConnection getSdcHttpUrlConnection(String userid, int postDataLength, String url, String content) {\r
         try {\r
             logger.info("userid=" + userid);\r
             String basicAuth = getSdcBasicAuth();\r
@@ -460,9 +411,8 @@ public class SdcCatalogServices {
 \r
     /**\r
      * Check if the SDC Info in cache has expired.\r
-     * \r
+     *\r
      * @param cldsServiceData\r
-     * @return\r
      * @throws GeneralSecurityException\r
      *             In case of issues with the decryting the encrypted password\r
      * @throws DecoderException\r
@@ -486,11 +436,9 @@ public class SdcCatalogServices {
     }\r
 \r
     /**\r
-     * Get the Service Data with Alarm Conditions for a given\r
-     * invariantServiceUuid.\r
-     * \r
+     * Get the Service Data with Alarm Conditions for a given invariantServiceUuid.\r
+     *\r
      * @param invariantServiceUuid\r
-     * @return\r
      * @throws GeneralSecurityException\r
      *             In case of issues with the decryting the encrypted password\r
      * @throws DecoderException\r
@@ -502,7 +450,7 @@ public class SdcCatalogServices {
         String catalogUrl = refProp.getStringValue(SDC_CATALOG_URL_PROPERTY_NAME);\r
         String serviceUuid = getServiceUuidFromServiceInvariantId(invariantServiceUuid);\r
         String serviceDetailUrl = url + "/" + serviceUuid + SDC_METADATA_URL_PREFIX;\r
-        String responseStr = getCldsServicesOrResourcesBasedOnURL(serviceDetailUrl, false);\r
+        String responseStr = getCldsServicesOrResourcesBasedOnURL(serviceDetailUrl);\r
         ObjectMapper objectMapper = new ObjectMapper();\r
         CldsServiceData cldsServiceData = new CldsServiceData();\r
         if (responseStr != null) {\r
@@ -558,7 +506,7 @@ public class SdcCatalogServices {
                     if (resourceUuid != null) {\r
                         String vfResourceUuidUrl = catalogUrl + RESOURCE_URL_PREFIX + "/" + resourceUuid\r
                                 + SDC_METADATA_URL_PREFIX;\r
-                        String vfResponse = getCldsServicesOrResourcesBasedOnURL(vfResourceUuidUrl, false);\r
+                        String vfResponse = getCldsServicesOrResourcesBasedOnURL(vfResourceUuidUrl);\r
                         if (vfResponse != null) {\r
                             // Below 2 line are to get the KPI(field path) data\r
                             // associated with the VF's\r
@@ -579,7 +527,7 @@ public class SdcCatalogServices {
                                                 String vfcResourceUuidUrl = catalogUrl + RESOURCE_URL_PREFIX + "/"\r
                                                         + resourceVfcUuid + SDC_METADATA_URL_PREFIX;\r
                                                 String vfcResponse = getCldsServicesOrResourcesBasedOnURL(\r
-                                                        vfcResourceUuidUrl, false);\r
+                                                        vfcResourceUuidUrl);\r
                                                 if (vfcResponse != null) {\r
                                                     List<CldsAlarmCondition> alarmCondtionsFromVfc = getAlarmCondtionsFromVfc(\r
                                                             vfcResponse);\r
@@ -616,49 +564,48 @@ public class SdcCatalogServices {
         List<CldsVfcData> cldsVfcDataList = new ArrayList<>();\r
         if (vfcArrayNode != null) {\r
             for (JsonNode vfcjsonNode : vfcArrayNode) {\r
-                CldsVfcData currCldsVfcData = new CldsVfcData();\r
                 ObjectNode currVfcNode = (ObjectNode) vfcjsonNode;\r
                 TextNode resourceTypeNode = (TextNode) currVfcNode.get("resoucreType");\r
                 if (resourceTypeNode != null && "VFC".equalsIgnoreCase(resourceTypeNode.textValue())) {\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
-                    cldsVfcDataList.add(currCldsVfcData);\r
+                    handleVFCtypeNode(currVfcNode, cldsVfcDataList);\r
                 } else if (resourceTypeNode != null && "CVFC".equalsIgnoreCase(resourceTypeNode.textValue())) {\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
-                    cldsVfcDataList.add(currCldsVfcData);\r
-                    cldsVfcDataList.addAll(getVFCfromCVFC(currVfcNode.get("resourceUUID").textValue()));\r
+                    handleCVFCtypeNode(currVfcNode, cldsVfcDataList);\r
                 }\r
             }\r
         }\r
         return cldsVfcDataList;\r
     }\r
 \r
-    private List<CldsVfcData> getVFCfromCVFC(String resourceUUID) throws GeneralSecurityException {\r
+    private void handleVFCtypeNode(ObjectNode 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
+        cldsVfcDataList.add(currCldsVfcData);\r
+    }\r
+\r
+    private void handleCVFCtypeNode(ObjectNode currVfcNode, List<CldsVfcData> cldsVfcDataList) {\r
+        handleVFCtypeNode(currVfcNode, cldsVfcDataList);\r
+        cldsVfcDataList.addAll(getVFCfromCVFC(currVfcNode.get("resourceUUID").textValue()));\r
+    }\r
+\r
+    private List<CldsVfcData> getVFCfromCVFC(String resourceUUID) {\r
         String catalogUrl = refProp.getStringValue(SDC_CATALOG_URL_PROPERTY_NAME);\r
         List<CldsVfcData> cldsVfcDataList = new ArrayList<>();\r
         if (resourceUUID != null) {\r
             String vfcResourceUUIDUrl = catalogUrl + RESOURCE_URL_PREFIX + "/" + resourceUUID + SDC_METADATA_URL_PREFIX;\r
             try {\r
-                String vfcResponse = getCldsServicesOrResourcesBasedOnURL(vfcResourceUUIDUrl, false);\r
+                String vfcResponse = getCldsServicesOrResourcesBasedOnURL(vfcResourceUUIDUrl);\r
                 ObjectMapper mapper = new ObjectMapper();\r
                 ObjectNode vfResponseNode = (ObjectNode) mapper.readTree(vfcResponse);\r
                 ArrayNode vfcArrayNode = (ArrayNode) vfResponseNode.get("resources");\r
                 if (vfcArrayNode != null) {\r
                     for (JsonNode vfcjsonNode : vfcArrayNode) {\r
-                        CldsVfcData currCldsVfcData = new CldsVfcData();\r
                         ObjectNode currVfcNode = (ObjectNode) vfcjsonNode;\r
                         TextNode resourceTypeNode = (TextNode) currVfcNode.get("resoucreType");\r
                         if (resourceTypeNode != null && "VFC".equalsIgnoreCase(resourceTypeNode.textValue())) {\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
-                            cldsVfcDataList.add(currCldsVfcData);\r
+                            handleVFCtypeNode(currVfcNode, cldsVfcDataList);\r
                         }\r
                     }\r
                 }\r
@@ -811,19 +758,12 @@ public class SdcCatalogServices {
         cldsAlarmConditionList.add(cldsAlarmCondition);\r
     }\r
 \r
-    /**\r
-     * Get the responses for the current artifact from the artifacts URL.\r
-     * \r
-     * @param artifactsUrl\r
-     * @return\r
-     * @throws GeneralSecurityException\r
-     */\r
-    public String getResponsesFromArtifactUrl(String artifactsUrl) throws GeneralSecurityException {\r
+    private String getResponsesFromArtifactUrl(String artifactsUrl) {\r
         String hostUrl = refProp.getStringValue("sdc.hostUrl");\r
         String artifactsUrlReworked = artifactsUrl.replaceAll("\"", "");\r
         String artifactUrl = hostUrl + artifactsUrlReworked;\r
         logger.info("value of artifactURl:" + artifactUrl);\r
-        String currArtifactResponse = getCldsServicesOrResourcesBasedOnURL(artifactUrl, true);\r
+        String currArtifactResponse = getCldsServicesOrResourcesBasedOnURL(artifactUrl);\r
         logger.info("value of artifactResponse:" + currArtifactResponse);\r
         return currArtifactResponse;\r
     }\r
@@ -831,16 +771,8 @@ public class SdcCatalogServices {
     /**\r
      * Service to services/resources/artifacts from sdc.Pass alarmConditions as\r
      * true to get alarm conditons from artifact url and else it is false\r
-     * \r
-     * @param url\r
-     * @param alarmConditions\r
-     * @return\r
-     * @throws GeneralSecurityException\r
-     *             In case of issue when decrypting the SDC password\r
-     * \r
      */\r
-    public String getCldsServicesOrResourcesBasedOnURL(String url, boolean alarmConditions)\r
-            throws GeneralSecurityException {\r
+    public String getCldsServicesOrResourcesBasedOnURL(String url) {\r
         Date startTime = new Date();\r
         try {\r
             LoggingUtils.setTargetContext("SDC", "getCldsServicesOrResourcesBasedOnURL");\r
@@ -953,7 +885,7 @@ public class SdcCatalogServices {
 \r
     /**\r
      * Method to get alarm conditions/alert description from Service Data.\r
-     * \r
+     *\r
      * @param cldsServiceData\r
      *            CldsServiceData the Service Data to analyze\r
      * @param eventName\r
@@ -975,7 +907,7 @@ public class SdcCatalogServices {
 \r
     /**\r
      * Method to get alarm conditions/alert description from VF Data.\r
-     * \r
+     *\r
      * @param currCldsVfData\r
      *            The Vf Data to analyze\r
      * @param eventName\r
@@ -995,7 +927,7 @@ public class SdcCatalogServices {
 \r
     /**\r
      * Method to get alarm conditions/alert description from VFC Data.\r
-     * \r
+     *\r
      * @param currCldsVfcData\r
      *            The VfC Data to analyze\r
      * @param eventName\r
@@ -1113,7 +1045,7 @@ public class SdcCatalogServices {
 \r
     /**\r
      * Method to create vfc and kpi nodes inside vf node\r
-     * \r
+     *\r
      * @param mapper\r
      * @param cldsVfDataList\r
      * @return\r
@@ -1163,7 +1095,7 @@ public class SdcCatalogServices {
     /**\r
      * This method searches the equivalent artifact UUID for a specific\r
      * artifactName in a SdcServiceDetail.\r
-     * \r
+     *\r
      * @param cldsSdcServiceDetail\r
      *            The SdcServiceDetail that will be analyzed\r
      * @param artifactName\r
@@ -1195,21 +1127,10 @@ public class SdcCatalogServices {
         return artifactUuid;\r
     }\r
 \r
-    /**\r
-     * To get all sdc VF/VFC Resources basic info.\r
-     * \r
-     * @param resourceType\r
-     *            The resourceType\r
-     * @return The list of CldsSdcResourceBasicInfo\r
-     * @throws GeneralSecurityException\r
-     *             In case of issue when decryting the SDC password\r
-     * \r
-     */\r
-    private List<CldsSdcResourceBasicInfo> getAllSdcVForVfcResourcesBasedOnResourceType(String resourceType)\r
-            throws GeneralSecurityException {\r
+    private List<CldsSdcResourceBasicInfo> getAllSdcVForVfcResourcesBasedOnResourceType(String resourceType) {\r
         String catalogUrl = refProp.getStringValue(SDC_CATALOG_URL_PROPERTY_NAME);\r
         String resourceUrl = catalogUrl + "resources?resourceType=" + resourceType;\r
-        String allSdcVfcResources = getCldsServicesOrResourcesBasedOnURL(resourceUrl, false);\r
+        String allSdcVfcResources = getCldsServicesOrResourcesBasedOnURL(resourceUrl);\r
         return removeDuplicateSdcResourceBasicInfo(getAllSdcResourcesListFromJson(allSdcVfcResources));\r
     }\r
 \r
@@ -1228,13 +1149,6 @@ public class SdcCatalogServices {
         return resourceUuid;\r
     }\r
 \r
-    /**\r
-     * Method to get service invariant uuid from model properties.\r
-     * \r
-     * @param props\r
-     *            The Clds model properties\r
-     * @return The Service Id\r
-     */\r
     private String getServiceInvariantUuidFromProps(ModelProperties props) {\r
         String invariantUuid = "";\r
         Global globalProps = props.getGlobal();\r
@@ -1246,7 +1160,7 @@ public class SdcCatalogServices {
 \r
     /**\r
      * This method upload the BluePrint to SDC.\r
-     * \r
+     *\r
      * @param prop\r
      *            The Clds model Properties\r
      * @param userid\r
index 45d2786..9367bc2 100644 (file)
@@ -26,7 +26,6 @@ package org.onap.clamp.clds.config;
 import com.att.ajsc.common.AjscProvider;
 import com.att.ajsc.common.AjscService;
 
-import java.security.GeneralSecurityException;
 import java.util.ArrayList;
 import java.util.List;
 
index 625aea5..7e42b29 100644 (file)
@@ -54,9 +54,7 @@ import org.springframework.stereotype.Repository;
  */
 @Repository("cldsDao")
 public class CldsDao {
-
-    protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsDao.class);
-    protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
+    private static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsDao.class);
     private JdbcTemplate jdbcTemplateObject;
     private SimpleJdbcCall procGetModel;
     private SimpleJdbcCall procGetModelTemplate;
@@ -116,12 +114,7 @@ public class CldsDao {
         return getModel(null, controlNameUuid);
     }
 
-    /**
-     * Get a model from the database given the model name or a controlNameUuid.
-     *
-     * @param modelName
-     * @return model
-     */
+    // Get a model from the database given the model name or a controlNameUuid.
     private CldsModel getModel(String modelName, String controlNameUuid) {
         CldsModel model = new CldsModel();
         model.setName(modelName);
@@ -279,29 +272,6 @@ public class CldsDao {
         }
     }
 
-    /**
-     * Delete a list of modelInstance from the database using parameter values
-     * and returns updated model object. This method is defunct - DCAE Proxy
-     * will not undeploy individual instances. It will send an empty list of
-     * deployed instances to indicate all have been removed. Or it will send an
-     * updated list to indicate those that are still deployed with any not on
-     * the list considered undeployed.
-     *
-     * @param controlNameUUid
-     * @param modelInstancesList
-     * @return
-     */
-    private CldsModel delModelInstance(String controlNameUUid, List<CldsModelInstance> modelInstancesList) {
-        CldsModel model = new CldsModel();
-        for (CldsModelInstance currModelInstance : modelInstancesList) {
-            SqlParameterSource in = new MapSqlParameterSource().addValue("v_control_name_uuid", controlNameUUid)
-                    .addValue("v_vm_name", currModelInstance.getVmName());
-            Map<String, Object> out = logSqlExecution(procDelModelInstance, in);
-            model.setId((String) (out.get("v_model_id")));
-        }
-        return model;
-    }
-
     /**
      * Insert an event in the database - require either modelName or
      * controlNamePrefix/controlNameUuid.
@@ -324,12 +294,6 @@ public class CldsDao {
         return event;
     }
 
-    /**
-     * Method to delete all model instances based on controlNameUUID
-     *
-     * @param controlNameUUid
-     * @return
-     */
     private String delAllModelInstances(String controlNameUUid) {
         SqlParameterSource in = new MapSqlParameterSource().addValue("v_control_name_uuid", controlNameUUid);
         Map<String, Object> out = logSqlExecution(procDelAllModelInstances, in);
index 4b26bc0..5965a41 100644 (file)
 
 package org.onap.clamp.clds.model.refprop;
 
-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 java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import javax.annotation.PostConstruct;
-
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.ApplicationContext;
 import org.springframework.core.io.Resource;
 
+import javax.annotation.PostConstruct;
+import java.io.IOException;
+import java.util.Properties;
+
 /**
  * Holds reference properties.
  */
 public class RefProp {
-    protected static final EELFLogger logger      = EELFManager.getInstance().getLogger(RefProp.class);
-    protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
 
     @Autowired
-    private ApplicationContext        appContext;
-
-    private Properties                prop;
-
+    private ApplicationContext appContext;
+    private Properties prop;
     @Value("${org.onap.clamp.config.files.cldsReference:'classpath:/clds/clds-reference.properties'}")
-    private String                    cldsReferenceValuesFile;
+    private String cldsReferenceValuesFile;
 
     @PostConstruct
     public void loadConfig() throws IOException {
@@ -115,24 +104,4 @@ public class RefProp {
         return objectMapper.readValue(getStringValue(key1, key2), JsonNode.class);
     }
 
-    /**
-     * Get list of values for a property field containing json and a
-     * field/keyword within that json.
-     *
-     * @param fieldName
-     * @param value
-     * @return
-     * @throws IOException
-     */
-    public List<String> decodeToList(String fieldName, String value) throws IOException {
-        JsonNode decode = getJsonTemplate(fieldName);
-        Iterator<JsonNode> itr = decode.path(value).elements();
-        ArrayList<String> al = new ArrayList<>();
-        while (itr.hasNext()) {
-            JsonNode node = itr.next();
-            al.add(node.asText());
-        }
-        return al;
-    }
-
 }
index 5d3b770..f2eadbe 100644 (file)
@@ -55,14 +55,14 @@ public class SdcCatalogServicesItCase extends AbstractItCase {
     private SdcCatalogServices sdcCatalogWired = new SdcCatalogServices();
 
     @Test
-    public void removeDuplicateServicesTest() throws Exception {
+    public void removeDuplicateServicesTest() {
 
         CldsSdcServiceInfo service1a = new CldsSdcServiceInfo();
         service1a.setName("service1");
         service1a.setVersion("1.0");
         service1a.setInvariantUUID("invariantUUID1.0");
 
-        List<CldsSdcServiceInfo> rawCldsSdcServiceList = new LinkedList<CldsSdcServiceInfo>();
+        List<CldsSdcServiceInfo> rawCldsSdcServiceList = new LinkedList<>();
         rawCldsSdcServiceList.add(service1a);
         rawCldsSdcServiceList.add(service1a);
 
@@ -110,7 +110,7 @@ public class SdcCatalogServicesItCase extends AbstractItCase {
     @Test
     public void removeDuplicateSdcResourceInstancesTest() {
 
-        List<CldsSdcResource> rawCldsSdcResourceList = new LinkedList<CldsSdcResource>();
+        List<CldsSdcResource> rawCldsSdcResourceList = new LinkedList<>();
 
         CldsSdcResource sdcResource1a = new CldsSdcResource();
         sdcResource1a.setResourceInstanceName("resource1");
@@ -156,7 +156,7 @@ public class SdcCatalogServicesItCase extends AbstractItCase {
     @Test
     public void removeDuplicateSdcResourceBasicInfoTest() {
 
-        List<CldsSdcResourceBasicInfo> rawCldsSdcResourceList = new LinkedList<CldsSdcResourceBasicInfo>();
+        List<CldsSdcResourceBasicInfo> rawCldsSdcResourceList = new LinkedList<>();
 
         CldsSdcResourceBasicInfo sdcResource1a = new CldsSdcResourceBasicInfo();
         sdcResource1a.setName("resource1");
@@ -240,80 +240,80 @@ public class SdcCatalogServicesItCase extends AbstractItCase {
                 + "/29018914-966c-442d-9d08-251b9dc45b8f/metadata";
         Mockito.doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcServiceDetailsExample.json"),
-                "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(serviceResourceDetailUrl, false);
+                "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(serviceResourceDetailUrl);
 
         String resourceDetailUrl = refProp.getStringValue("sdc.catalog.url")
                 + "resources/585822c7-4027-4f84-ba50-e9248606f136/metadata";
         Mockito.doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcResourceDetailsExample.json"),
-                "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(resourceDetailUrl, false);
+                "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(resourceDetailUrl);
 
         String securityRulesDetailUrl = refProp.getStringValue("sdc.catalog.url")
                 + "resources/d57e57d2-e3c6-470d-8d16-e6ea05f536c5/metadata";
         Mockito.doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcSecurityRules.json"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(securityRulesDetailUrl, false);
+                .when(spy).getCldsServicesOrResourcesBasedOnURL(securityRulesDetailUrl);
 
         String cinderVolumeDetailUrl = refProp.getStringValue("sdc.catalog.url")
                 + "resources/b4288e07-597a-44a2-aa98-ad36e551a39d/metadata";
         Mockito.doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcCinderVolume.json"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(cinderVolumeDetailUrl, false);
+                .when(spy).getCldsServicesOrResourcesBasedOnURL(cinderVolumeDetailUrl);
 
         String vfcGenericDetailUrl = refProp.getStringValue("sdc.catalog.url")
                 + "resources/2c8f1219-8000-4001-aa13-496a0396d40f/metadata";
         Mockito.doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcVFCGenericWithAlarms.json"),
-                "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(vfcGenericDetailUrl, false);
+                "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(vfcGenericDetailUrl);
 
         String csvAlarmsDetailUrl = refProp.getStringValue("sdc.catalog.url")
                 + "resources/2c8f1219-8000-4001-aa13-496a0396d40f/resourceInstances/virc_fe_be/artifacts/5138e316-0237-49aa-817a-b3d8eaf77392";
         Mockito.doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcAlarmsList.csv"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl, false);
+                .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl);
 
         Mockito.doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcAlarmsList.csv"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl, true);
+                .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl);
 
         String csvAlarmsDetailUrl2 = refProp.getStringValue("sdc.catalog.url")
                 + "resources/d7646638-2572-4a94-b497-c028ac15f9ca/artifacts/5138e316-0237-49aa-817a-b3d8eaf77392";
         Mockito.doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcAlarmsList.csv"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl2, true);
+                .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl2);
 
         String allVfResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources?resourceType=VF";
         Mockito.doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcVFResources.json"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfResourcesDetailUrl, false);
+                .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfResourcesDetailUrl);
 
         String vfcResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url")
                 + "resources/a0475018-1e7e-4ddd-8bee-33cbf958c2e6/metadata";
         Mockito.doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcCVFCResourceExample.json"),
-                "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(vfcResourcesDetailUrl, false);
+                "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(vfcResourcesDetailUrl);
 
         String allVfcResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources?resourceType=VFC";
         Mockito.doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcVFCResources.json"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfcResourcesDetailUrl, false);
+                .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfcResourcesDetailUrl);
 
         String allCvfcResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources?resourceType=CVFC";
         Mockito.doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcCVFCResources.json"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(allCvfcResourcesDetailUrl, false);
+                .when(spy).getCldsServicesOrResourcesBasedOnURL(allCvfcResourcesDetailUrl);
 
         String allVfAlarms = refProp.getStringValue("sdc.catalog.url")
                 + "resources/84855843-5247-4e97-a2bd-5395a510253b/artifacts/d57ac7ec-f3c3-4793-983a-c75ac3a43153";
         Mockito.doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcMeasurementsList.csv"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfAlarms, true);
+                .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfAlarms);
 
         String vfcResourceExample = refProp.getStringValue("sdc.catalog.url")
                 + "resources/d7646638-2572-4a94-b497-c028ac15f9ca/metadata";
         Mockito.doReturn(IOUtils.toString(
                 SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcVFCResourceExample.json"), "UTF-8"))
-                .when(spy).getCldsServicesOrResourcesBasedOnURL(vfcResourceExample, false);
+                .when(spy).getCldsServicesOrResourcesBasedOnURL(vfcResourceExample);
 
         CldsServiceData cldsServiceData = spy
                 .getCldsServiceDataWithAlarmConditions("a33ed748-3477-4434-b3f3-b5560f5e7d9c");