Improve logs and comments. 89/30489/1
authorDeterme, Sebastien (sd378r) <sd378r@intl.att.com>
Tue, 6 Feb 2018 15:45:28 +0000 (16:45 +0100)
committerDeterme, Sebastien (sd378r) <sd378r@intl.att.com>
Tue, 6 Feb 2018 15:45:28 +0000 (16:45 +0100)
Additional info added to logs and comments reworked

Issue-ID: CLAMP-85,CLAMP-74
Change-Id: Ic4cf9104ea1587cbfc3a8088f7e59f80ab65ffa0
Signed-off-by: Determe, Sebastien (sd378r) <sd378r@intl.att.com>
src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java

index 372f8e8..6684f1a 100644 (file)
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================\r
  * ONAP CLAMP\r
  * ================================================================================\r
- * Copyright (C) 2017 AT&T Intellectual Property. All rights\r
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights\r
  *                             reserved.\r
  * ================================================================================\r
  * Licensed under the Apache License, Version 2.0 (the "License");\r
@@ -81,20 +81,29 @@ public class SdcCatalogServices {
 \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       RESOURCE_VF_TYPE              = "VF";\r
+    private static final String       RESOURCE_VFC_TYPE             = "VFC";\r
+    private static final String       RESOURCE_CVFC_TYPE            = "CVFC";\r
     private static final String SDC_REQUESTID_PROPERTY_NAME = "sdc.header.requestId";\r
-    private static final String SDC_METADATA_URL_PREFIX = "/metadata";\r
-    private static final String SDC_INSTANCE_ID_PROPERTY_NAME = "sdc.InstanceID";\r
-    private static final String SDC_CATALOG_URL_PROPERTY_NAME = "sdc.catalog.url";\r
-    private static final String SDC_SERVICE_URL_PROPERTY_NAME = "sdc.serviceUrl";\r
-    private static final String SDC_INSTANCE_ID_CLAMP = "CLAMP-Tool";\r
-    private static final String RESOURCE_URL_PREFIX = "resources";\r
+    private static final 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
+    private RefProp                   refProp;\r
 \r
-    // returns SDC id and password as a HTTP Basic Auth string (for example: Basic dGVzdDoxMjM0NTY=)\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
     private String getSdcBasicAuth() throws GeneralSecurityException, DecoderException {\r
         String sdcId = refProp.getStringValue("sdc.serviceUsername");\r
         String sdcPw = refProp.getStringValue("sdc.servicePassword");\r
@@ -106,7 +115,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
@@ -150,7 +159,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
@@ -179,8 +188,9 @@ public class SdcCatalogServices {
 \r
     /**\r
      * To remove duplicate serviceUUIDs from sdc resources List.\r
-     *\r
+     * \r
      * @param rawCldsSdcResourceList\r
+     * @return List of CldsSdcResource\r
      */\r
     public List<CldsSdcResource> removeDuplicateSdcResourceInstances(List<CldsSdcResource> rawCldsSdcResourceList) {\r
         List<CldsSdcResource> cldsSdcResourceList = null;\r
@@ -206,8 +216,9 @@ public class SdcCatalogServices {
 \r
     /**\r
      * To remove duplicate basic resources with same resourceUUIDs.\r
-     *\r
+     * \r
      * @param rawCldsSdcResourceListBasicList\r
+     * @return List of CldsSdcResourceBasicInfo\r
      */\r
     public List<CldsSdcResourceBasicInfo> removeDuplicateSdcResourceBasicInfo(\r
             List<CldsSdcResourceBasicInfo> rawCldsSdcResourceListBasicList) {\r
@@ -235,7 +246,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
@@ -262,6 +273,14 @@ 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
     private List<CldsSdcServiceInfo> getCldsSdcServicesListFromJson(String jsonStr) {\r
         ObjectMapper objectMapper = new ObjectMapper();\r
         if (StringUtils.isBlank(jsonStr)) {\r
@@ -276,6 +295,14 @@ 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
     private List<CldsSdcResourceBasicInfo> getAllSdcResourcesListFromJson(String jsonStr) {\r
         ObjectMapper objectMapper = new ObjectMapper();\r
         if (StringUtils.isBlank(jsonStr)) {\r
@@ -292,7 +319,7 @@ public class SdcCatalogServices {
 \r
     /**\r
      * To get CldsSdcServiceDetail by parsing json string.\r
-     *\r
+     * \r
      * @param jsonStr\r
      * @return\r
      */\r
@@ -410,8 +437,9 @@ public class SdcCatalogServices {
 \r
     /**\r
      * Check if the SDC Info in cache has expired.\r
-     *\r
+     * \r
      * @param cldsServiceData\r
+     * @return boolean flag\r
      * @throws GeneralSecurityException\r
      *             In case of issues with the decryting the encrypted password\r
      * @throws DecoderException\r
@@ -436,8 +464,9 @@ public class SdcCatalogServices {
 \r
     /**\r
      * Get the Service Data with Alarm Conditions for a given invariantServiceUuid.\r
-     *\r
+     * \r
      * @param invariantServiceUuid\r
+     * @return The CldsServiceData\r
      * @throws GeneralSecurityException\r
      *             In case of issues with the decryting the encrypted password\r
      * @throws DecoderException\r
@@ -577,17 +606,17 @@ public class SdcCatalogServices {
 \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
+                    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
+                    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
@@ -757,6 +786,8 @@ public class SdcCatalogServices {
         cldsAlarmConditionList.add(cldsAlarmCondition);\r
     }\r
 \r
+\r
+    // Get the responses for the current artifact from the artifacts URL.\r
     private String getResponsesFromArtifactUrl(String artifactsUrl) {\r
         String hostUrl = refProp.getStringValue("sdc.hostUrl");\r
         String artifactsUrlReworked = artifactsUrl.replaceAll("\"", "");\r
@@ -770,6 +801,10 @@ 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 The URL to trigger\r
+     * @return The String containing the payload\r
+     * \r
      */\r
     public String getCldsServicesOrResourcesBasedOnURL(String url) {\r
         Date startTime = new Date();\r
@@ -797,9 +832,13 @@ public class SdcCatalogServices {
             logger.error("Exception occurred during query to SDC", e);\r
             return "";\r
         } catch (DecoderException e) {\r
+               LoggingUtils.setResponseContext("900", "Get sdc resources failed", this.getClass().getName());\r
+            LoggingUtils.setErrorContext("900", "Get sdc resources error");\r
             logger.error("Exception when attempting to decode the Hex string", e);\r
             throw new SdcCommunicationException("Exception when attempting to decode the Hex string", e);\r
         } catch (GeneralSecurityException e) {\r
+               LoggingUtils.setResponseContext("900", "Get sdc resources failed", this.getClass().getName());\r
+            LoggingUtils.setErrorContext("900", "Get sdc resources error");\r
             logger.error("Exception when attempting to decrypt the encrypted password", e);\r
             throw new SdcCommunicationException("Exception when attempting to decrypt the encrypted password", e);\r
         } finally {\r
@@ -884,7 +923,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
@@ -906,7 +945,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
@@ -926,7 +965,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
@@ -1044,7 +1083,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
@@ -1094,7 +1133,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
@@ -1126,6 +1165,7 @@ public class SdcCatalogServices {
         return artifactUuid;\r
     }\r
 \r
+    // To get all sdc VF/VFC Resources basic info.\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
@@ -1148,6 +1188,7 @@ public class SdcCatalogServices {
         return resourceUuid;\r
     }\r
 \r
+    // Method to get service invariant uuid from model properties.\r
     private String getServiceInvariantUuidFromProps(ModelProperties props) {\r
         String invariantUuid = "";\r
         Global globalProps = props.getGlobal();\r
@@ -1159,7 +1200,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