* ============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
\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
/**\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
\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
\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
\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
\r
/**\r
* To get ServiceUUID by using serviceInvariantUUID.\r
- *\r
+ * \r
* @param invariantId\r
* The invariant ID\r
* @return The service UUID\r
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
}\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
\r
/**\r
* To get CldsSdcServiceDetail by parsing json string.\r
- *\r
+ * \r
* @param jsonStr\r
* @return\r
*/\r
\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
\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
\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
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
/**\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
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
\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
\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
\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
\r
/**\r
* Method to create vfc and kpi nodes inside vf node\r
- *\r
+ * \r
* @param mapper\r
* @param cldsVfDataList\r
* @return\r
/**\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
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
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
\r
/**\r
* This method upload the BluePrint to SDC.\r
- *\r
+ * \r
* @param prop\r
* The Clds model Properties\r
* @param userid\r