import java.io.StringReader;\r
import java.net.HttpURLConnection;\r
import java.net.URL;\r
+import java.security.GeneralSecurityException;\r
import java.util.ArrayList;\r
import java.util.Collections;\r
import java.util.Date;\r
import org.springframework.beans.factory.annotation.Autowired;\r
\r
public class SdcCatalogServices {\r
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcCatalogServices.class);\r
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();\r
-\r
- private static final String RESOURCE_VF_TYPE = "VF";\r
- private static final String RESOURCE_VFC_TYPE = "VFC";\r
-\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
@Autowired\r
private RefProp refProp;\r
+ @Autowired\r
+ private SdcReq sdcReq;\r
\r
/**\r
* This method get the SDC services Information with the corresponding\r
* @param uuid\r
* The service UUID\r
* @return A Json String with all the service list\r
+ * @throws GeneralSecurityException\r
+ * In case of issue when decryting the SDC password\r
*/\r
- public String getSdcServicesInformation(String uuid) {\r
+ public String getSdcServicesInformation(String uuid) throws GeneralSecurityException {\r
Date startTime = new Date();\r
String baseUrl = refProp.getStringValue("sdc.serviceUrl");\r
- String basicAuth = SdcReq.getSdcBasicAuth(refProp);\r
+ String basicAuth = sdcReq.getSdcBasicAuth();\r
LoggingUtils.setTargetContext("SDC", "getSdcServicesInformation");\r
-\r
try {\r
String url = baseUrl;\r
if (uuid != null) {\r
url = baseUrl + "/" + uuid + "/metadata";\r
}\r
URL urlObj = new URL(url);\r
-\r
HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();\r
-\r
conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), "CLAMP-Tool");\r
conn.setRequestProperty("Authorization", basicAuth);\r
conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8");\r
conn.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId());\r
conn.setRequestMethod("GET");\r
-\r
String resp = getResponse(conn);\r
if (resp != null) {\r
- logger.info(resp);
+ logger.info(resp);\r
// metrics log\r
LoggingUtils.setResponseContext("0", "Get sdc services success", this.getClass().getName());\r
return resp;\r
LoggingUtils.setTimeContext(startTime, new Date());\r
metricsLogger.info("getSdcServicesInformation complete");\r
}\r
-\r
return "";\r
}\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\r
*/\r
\r
/**\r
* To remove duplicate basic resources with same resourceUUIDs.\r
- *\r
+ * \r
* @param rawCldsSdcResourceListBasicList\r
* @return\r
*/\r
\r
/**\r
* To get ServiceUUID by using serviceInvariantUUID.\r
- *\r
+ * \r
* @param invariantId\r
* The invariant ID\r
* @return The service UUID\r
+ * @throws GeneralSecurityException\r
+ * In case of issue when decryting the SDC password\r
*/\r
- public String getServiceUuidFromServiceInvariantId(String invariantId) {\r
+ public String getServiceUuidFromServiceInvariantId(String invariantId) throws GeneralSecurityException {\r
String serviceUuid = "";\r
String responseStr = getSdcServicesInformation(null);\r
List<CldsSdcServiceInfo> rawCldsSdcServicesList = getCldsSdcServicesListFromJson(responseStr);\r
\r
/**\r
* To get CldsAsdsServiceInfo class by parsing json string.\r
- *\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
if (StringUtils.isBlank(jsonStr)) {\r
return new ArrayList<>();\r
}\r
-\r
try {\r
return objectMapper.readValue(jsonStr,\r
objectMapper.getTypeFactory().constructCollectionType(List.class, CldsSdcResourceBasicInfo.class));\r
\r
/**\r
* To get CldsAsdsResource class by parsing json string.\r
- *\r
+ * \r
* @param jsonStr\r
* @return\r
* @throws IOException\r
\r
/**\r
* To get CldsSdcServiceDetail by parsing json string.\r
- *\r
+ * \r
* @param jsonStr\r
* @return\r
*/\r
\r
/**\r
* To upload artifact to sdc based on serviceUUID and resource name on url.\r
- *\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) {
+ public String uploadArtifactToSdc(ModelProperties prop, String userid, String url, String formattedSdcReq)\r
+ throws GeneralSecurityException {\r
// Verify whether it is triggered by Validation Test button from UI\r
if (prop.isTest()) {\r
return "sdc artifact upload not executed for test action";\r
}\r
try {\r
logger.info("userid=" + userid);\r
- String md5Text = SdcReq.calculateMD5ByString(formattedSdcReq);\r
- byte[] postData = SdcReq.stringToByteArray(formattedSdcReq);\r
+ String md5Text = sdcReq.calculateMD5ByString(formattedSdcReq);\r
+ byte[] postData = sdcReq.stringToByteArray(formattedSdcReq);\r
int postDataLength = postData.length;\r
HttpURLConnection conn = getSdcHttpUrlConnection(userid, postDataLength, url, md5Text);\r
try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) {\r
if (responseCode == 200) {\r
requestFailed = false;\r
}\r
-\r
String responseStr = getResponse(conn);\r
if (responseStr != null && requestFailed) {\r
logger.error("requestFailed - responseStr=" + responseStr);\r
logger.error("Exception when attempting to communicate with SDC", e);\r
throw new SdcCommunicationException("Exception when attempting to communicate with SDC", e);\r
}\r
-\r
}\r
\r
- private HttpURLConnection getSdcHttpUrlConnection(String userid, int postDataLength, String url, String md5Text) {\r
+ private HttpURLConnection getSdcHttpUrlConnection(String userid, int postDataLength, String url, String md5Text)\r
+ throws GeneralSecurityException {\r
try {\r
logger.info("userid=" + userid);\r
- String basicAuth = SdcReq.getSdcBasicAuth(refProp);\r
+ String basicAuth = sdcReq.getSdcBasicAuth();\r
String sdcXonapInstanceId = refProp.getStringValue("sdc.sdcX-InstanceID");\r
URL urlObj = new URL(url);\r
HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();\r
}\r
}\r
\r
- public boolean isCldsSdcCacheDataExpired(CldsServiceData cldsServiceData) {\r
+ /**\r
+ * Check if the SDC Info in cache has expired.\r
+ * \r
+ * @param cldsServiceData\r
+ * @return\r
+ * @throws GeneralSecurityException\r
+ */\r
+ public boolean isCldsSdcCacheDataExpired(CldsServiceData cldsServiceData) throws GeneralSecurityException {\r
boolean expired = false;\r
if (cldsServiceData != null && cldsServiceData.getServiceUUID() != null) {\r
String cachedServiceUuid = cldsServiceData.getServiceUUID();\r
return expired;\r
}\r
\r
- public CldsServiceData getCldsServiceDataWithAlarmConditions(String invariantServiceUuid) {\r
+ /**\r
+ * Get the Service Data with Alarm Conditions for a given\r
+ * invariantServiceUuid.\r
+ * \r
+ * @param invariantServiceUuid\r
+ * @return\r
+ * @throws GeneralSecurityException\r
+ */\r
+ public CldsServiceData getCldsServiceDataWithAlarmConditions(String invariantServiceUuid)\r
+ throws GeneralSecurityException {\r
String url = refProp.getStringValue("sdc.serviceUrl");\r
String catalogUrl = refProp.getStringValue("sdc.catalog.url");\r
String serviceUuid = getServiceUuidFromServiceInvariantId(invariantServiceUuid);\r
}\r
cldsServiceData.setServiceUUID(cldsSdcServiceDetail.getUuid());\r
cldsServiceData.setServiceInvariantUUID(cldsSdcServiceDetail.getInvariantUUID());\r
-\r
// To remove duplicate resources from serviceDetail and add valid\r
// vfs to service\r
if (cldsSdcServiceDetail != null && cldsSdcServiceDetail.getResources() != null) {\r
return cldsServiceData;\r
}\r
\r
- private void getAllVfcForVfList(List<CldsVfData> cldsVfDataList, String catalogUrl) {\r
+ private void getAllVfcForVfList(List<CldsVfData> cldsVfDataList, String catalogUrl)\r
+ throws GeneralSecurityException {\r
// todo : refact this..\r
if (cldsVfDataList != null && !cldsVfDataList.isEmpty()) {\r
List<CldsSdcResourceBasicInfo> allVfResources = getAllSdcVForVfcResourcesBasedOnResourceType(\r
RESOURCE_VF_TYPE);\r
List<CldsSdcResourceBasicInfo> allVfcResources = getAllSdcVForVfcResourcesBasedOnResourceType(\r
RESOURCE_VFC_TYPE);\r
+ allVfcResources.addAll(getAllSdcVForVfcResourcesBasedOnResourceType(RESOURCE_CVFC_TYPE));\r
for (CldsVfData currCldsVfData : cldsVfDataList) {\r
if (currCldsVfData != null && currCldsVfData.getVfInvariantResourceUUID() != null) {\r
String resourceUuid = getResourceUuidFromResourceInvariantUuid(\r
// associated with the VF's\r
List<CldsVfKPIData> cldsVfKPIDataList = getFieldPathFromVF(vfResponse);\r
currCldsVfData.setCldsKPIList(cldsVfKPIDataList);\r
-\r
List<CldsVfcData> vfcDataListFromVfResponse = getVfcDataListFromVfResponse(vfResponse);\r
if (vfcDataListFromVfResponse != null) {\r
currCldsVfData.setCldsVfcs(vfcDataListFromVfResponse);\r
}\r
}\r
\r
- private List<CldsVfcData> getVfcDataListFromVfResponse(String vfResponse) {\r
+ private List<CldsVfcData> getVfcDataListFromVfResponse(String vfResponse) throws GeneralSecurityException {\r
ObjectMapper mapper = new ObjectMapper();\r
ObjectNode vfResponseNode;\r
try {\r
currCldsVfcData.setVfcInvariantResourceUUID(vfcInvariantResourceUuid.textValue());\r
cldsVfcDataList.add(currCldsVfcData);\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
}\r
}\r
return cldsVfcDataList;\r
}\r
\r
- private List<CldsVfcData> getVFCfromCVFC(String resourceUUID) {\r
+ private List<CldsVfcData> getVFCfromCVFC(String resourceUUID) throws GeneralSecurityException {\r
String catalogUrl = refProp.getStringValue("sdc.catalog.url");\r
List<CldsVfcData> cldsVfcDataList = new ArrayList<>();\r
-\r
if (resourceUUID != null) {\r
String vfcResourceUUIDUrl = catalogUrl + "resources" + "/" + resourceUUID + "/metadata";\r
try {\r
ObjectMapper mapper = new ObjectMapper();\r
ObjectNode vfResponseNode = (ObjectNode) mapper.readTree(vfcResponse);\r
ArrayNode vfcArrayNode = (ArrayNode) vfResponseNode.get("resources");\r
-\r
if (vfcArrayNode != null) {\r
for (JsonNode vfcjsonNode : vfcArrayNode) {\r
CldsVfcData currCldsVfcData = new CldsVfcData();\r
return (id != null) ? id.replaceAll("\"", "") : "";\r
}\r
\r
- private List<CldsAlarmCondition> getAlarmCondtionsFromVfc(String vfcResponse) {\r
+ private List<CldsAlarmCondition> getAlarmCondtionsFromVfc(String vfcResponse) throws GeneralSecurityException {\r
List<CldsAlarmCondition> cldsAlarmConditionList = new ArrayList<>();\r
ObjectMapper mapper = new ObjectMapper();\r
ObjectNode vfcResponseNode;\r
return cldsAlarmConditionList;\r
}\r
ArrayNode artifactsArrayNode = (ArrayNode) vfcResponseNode.get("artifacts");\r
-\r
if (artifactsArrayNode != null && artifactsArrayNode.size() > 0) {\r
for (int index = 0; index < artifactsArrayNode.size(); index++) {\r
ObjectNode currArtifactNode = (ObjectNode) artifactsArrayNode.get(index);\r
}\r
\r
// Method to get the artifact for any particular VF\r
- private List<CldsVfKPIData> getFieldPathFromVF(String vfResponse) {\r
+ private List<CldsVfKPIData> getFieldPathFromVF(String vfResponse) throws GeneralSecurityException {\r
List<CldsVfKPIData> cldsVfKPIDataList = new ArrayList<>();\r
ObjectMapper mapper = new ObjectMapper();\r
ObjectNode vfResponseNode;\r
return cldsVfKPIDataList;\r
}\r
ArrayNode artifactsArrayNode = (ArrayNode) vfResponseNode.get("artifacts");\r
-\r
if (artifactsArrayNode != null && artifactsArrayNode.size() > 0) {\r
for (int index = 0; index < artifactsArrayNode.size(); index++) {\r
ObjectNode currArtifactNode = (ObjectNode) artifactsArrayNode.get(index);\r
artifactName = artifactNameNode.textValue();\r
artifactName = artifactName.substring(artifactName.lastIndexOf('.') + 1);\r
}\r
- if (artifactUrlNode != null && "csv".equalsIgnoreCase(artifactName)) {
+ if (artifactUrlNode != null && "csv".equalsIgnoreCase(artifactName)) {\r
String responsesFromArtifactUrl = getResponsesFromArtifactUrl(artifactUrlNode.textValue());\r
cldsVfKPIDataList.addAll(parseCsvToGetFieldPath(responsesFromArtifactUrl));\r
logger.info(responsesFromArtifactUrl);\r
logger.debug("invalid csv field path Record,total columns less than 6: " + record);\r
return null;\r
}\r
-\r
if (StringUtils.isBlank(record.get(1)) || StringUtils.isBlank(record.get(3))\r
|| StringUtils.isBlank(record.get(5))) {\r
logger.debug("Invalid csv field path Record,one of column is having blank value : " + record);\r
return null;\r
}\r
-\r
CldsVfKPIData cldsVfKPIData = new CldsVfKPIData();\r
cldsVfKPIData.setNfNamingCode(record.get(0).trim());\r
cldsVfKPIData.setNfNamingValue(record.get(1).trim());\r
-\r
cldsVfKPIData.setFieldPath(record.get(2).trim());\r
cldsVfKPIData.setFieldPathValue(record.get(3).trim());\r
-\r
cldsVfKPIData.setThresholdName(record.get(4).trim());\r
cldsVfKPIData.setThresholdValue(record.get(5).trim());\r
return cldsVfKPIData;\r
-\r
}\r
\r
// Method to get the artifactURL Data and set the CldsVfKPIData node\r
cldsAlarmConditionList.add(cldsAlarmCondition);\r
}\r
\r
- public String getResponsesFromArtifactUrl(String artifactsUrl) {\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
String hostUrl = refProp.getStringValue("sdc.hostUrl");\r
String artifactsUrlReworked = artifactsUrl.replaceAll("\"", "");\r
String artifactUrl = hostUrl + artifactsUrlReworked;\r
\r
/**\r
* Service to services/resources/artifacts from sdc.Pass alarmConditions as\r
- * true to get alarmconditons from artifact url and else it is false\r
- *\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
+ public String getCldsServicesOrResourcesBasedOnURL(String url, boolean alarmConditions)\r
+ throws GeneralSecurityException {\r
Date startTime = new Date();\r
try {\r
LoggingUtils.setTargetContext("SDC", "getCldsServicesOrResourcesBasedOnURL");\r
String urlReworked = removeUnwantedBracesFromString(url);\r
URL urlObj = new URL(urlReworked);\r
-\r
HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();\r
- String basicAuth = SdcReq.getSdcBasicAuth(refProp);\r
+ String basicAuth = sdcReq.getSdcBasicAuth();\r
conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), "CLAMP-Tool");\r
conn.setRequestProperty("Authorization", basicAuth);\r
conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8");\r
conn.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId());\r
conn.setRequestMethod("GET");\r
-\r
int responseCode = conn.getResponseCode();\r
logger.info("Sdc resource url - " + urlReworked + " , responseCode=" + responseCode);\r
StringBuilder response;\r
LoggingUtils.setTimeContext(startTime, new Date());\r
metricsLogger.info("getCldsServicesOrResourcesBasedOnURL completed");\r
}\r
-\r
}\r
\r
/**\r
ObjectMapper mapper = new ObjectMapper();\r
ObjectNode globalPropsJson;\r
if (cldsServiceData != null && cldsServiceData.getServiceUUID() != null) {\r
-\r
// Objectnode to save all byservice, byvf , byvfc and byalarm nodes\r
ObjectNode byIdObjectNode = mapper.createObjectNode();\r
-\r
// To create vf ResourceUUID node with serviceInvariantUUID\r
ObjectNode invariantUuidObjectNodeWithVf = createVfObjectNodeByServiceInvariantUuid(mapper,\r
cldsServiceData);\r
byIdObjectNode.putPOJO("byService", invariantUuidObjectNodeWithVf);\r
-\r
// To create byVf and vfcResourceNode with vfResourceUUID\r
ObjectNode vfcObjectNodeByVfUuid = createVfcObjectNodeByVfUuid(mapper, cldsServiceData.getCldsVfs());\r
byIdObjectNode.putPOJO("byVf", vfcObjectNodeByVfUuid);\r
-\r
// To create byKpi\r
ObjectNode kpiObjectNode = mapper.createObjectNode();\r
if (cldsServiceData.getCldsVfs() != null && !cldsServiceData.getCldsVfs().isEmpty()) {\r
}\r
}\r
byIdObjectNode.putPOJO("byKpi", kpiObjectNode);\r
-\r
// To create byVfc and alarmCondition with vfcResourceUUID\r
ObjectNode vfcResourceUuidObjectNode = mapper.createObjectNode();\r
if (cldsServiceData.getCldsVfs() != null && !cldsServiceData.getCldsVfs().isEmpty()) {\r
}\r
}\r
byIdObjectNode.putPOJO("byVfc", vfcResourceUuidObjectNode);\r
-\r
// To create byAlarmCondition with alarmConditionKey\r
List<CldsAlarmCondition> allAlarmConditions = getAllAlarmConditionsFromCldsServiceData(cldsServiceData,\r
"alarmCondition");\r
ObjectNode alarmCondObjectNodeByAlarmKey = createAlarmCondObjectNodeByAlarmKey(mapper, allAlarmConditions);\r
-\r
byIdObjectNode.putPOJO("byAlarmCondition", alarmCondObjectNodeByAlarmKey);\r
-\r
// To create byAlertDescription with AlertDescription\r
List<CldsAlarmCondition> allAlertDescriptions = getAllAlarmConditionsFromCldsServiceData(cldsServiceData,\r
"alertDescription");\r
ObjectNode alertDescObjectNodeByAlert = createAlarmCondObjectNodeByAlarmKey(mapper, allAlertDescriptions);\r
-\r
byIdObjectNode.putPOJO("byAlertDescription", alertDescObjectNodeByAlert);\r
-\r
globalPropsJson = decodeGlobalProp(globalProps, mapper);\r
-\r
globalPropsJson.putPOJO("shared", byIdObjectNode);\r
logger.info("value of objNode:" + globalPropsJson);\r
} else {\r
*/\r
private List<CldsAlarmCondition> getAllAlarmConditionsFromCldsVfData(CldsVfData currCldsVfData, String eventName) {\r
List<CldsAlarmCondition> alarmCondList = new ArrayList<>();\r
-\r
if (currCldsVfData != null && currCldsVfData.getCldsVfcs() != null && !currCldsVfData.getCldsVfcs().isEmpty()) {\r
for (CldsVfcData currCldsVfcData : currCldsVfData.getCldsVfcs()) {\r
alarmCondList.addAll(getAllAlarmConditionsFromCldsVfcData(currCldsVfcData, eventName));\r
private List<CldsAlarmCondition> getAllAlarmConditionsFromCldsVfcData(CldsVfcData currCldsVfcData,\r
String eventName) {\r
List<CldsAlarmCondition> alarmCondList = new ArrayList<>();\r
-\r
if (currCldsVfcData != null && currCldsVfcData.getCldsAlarmConditions() != null\r
&& !currCldsVfcData.getCldsAlarmConditions().isEmpty()) {\r
for (CldsAlarmCondition currCldsAlarmCondition : currCldsVfcData.getCldsAlarmConditions()) {\r
private ObjectNode createAlarmCondObjectNodeByAlarmKey(ObjectMapper mapper,\r
List<CldsAlarmCondition> cldsAlarmCondList) {\r
ObjectNode alarmCondKeyNode = mapper.createObjectNode();\r
-\r
if (cldsAlarmCondList != null && !cldsAlarmCondList.isEmpty()) {\r
for (CldsAlarmCondition currCldsAlarmCondition : cldsAlarmCondList) {\r
if (currCldsAlarmCondition != null) {\r
for (CldsVfKPIData currCldsVfKpiData : cldsVfKpiDataList) {\r
if (currCldsVfKpiData != null) {\r
ObjectNode thresholdNameObjectNode = mapper.createObjectNode();\r
-\r
ObjectNode fieldPathObjectNode = mapper.createObjectNode();\r
ObjectNode nfNamingCodeNode = mapper.createObjectNode();\r
-\r
fieldPathObjectNode.put(currCldsVfKpiData.getFieldPathValue(),\r
currCldsVfKpiData.getFieldPathValue());\r
nfNamingCodeNode.put(currCldsVfKpiData.getNfNamingValue(), currCldsVfKpiData.getNfNamingValue());\r
-\r
thresholdNameObjectNode.putPOJO("fieldPath", fieldPathObjectNode);\r
thresholdNameObjectNode.putPOJO("nfNamingCode", nfNamingCodeNode);\r
-\r
vfResourceUuidObjectNode.putPOJO(currCldsVfKpiData.getThresholdValue(), thresholdNameObjectNode);\r
}\r
}\r
if (currCldsVfcData.getCldsAlarmConditions() != null\r
&& !currCldsVfcData.getCldsAlarmConditions().isEmpty()) {\r
for (CldsAlarmCondition currCldsAlarmCondition : currCldsVfcData.getCldsAlarmConditions()) {\r
- alarmCondNode.put(currCldsAlarmCondition.getAlarmConditionKey(),\r
- currCldsAlarmCondition.getAlarmConditionKey());\r
- if ("alarmCondition".equalsIgnoreCase(currCldsAlarmCondition.getEventName())) {
+ if ("alarmCondition".equalsIgnoreCase(currCldsAlarmCondition.getEventName())) {\r
alarmCondNode.put(currCldsAlarmCondition.getAlarmConditionKey(),\r
currCldsAlarmCondition.getAlarmConditionKey());\r
} else {\r
}\r
}\r
}\r
-\r
vfcObjectNode.putPOJO("alarmCondition", alarmCondNode);\r
vfcObjectNode.putPOJO("alertDescription", alertDescNode);\r
vfcResourceUuidObjectNode.putPOJO(currCldsVfcData.getVfcInvariantResourceUUID(), vfcObjectNode);\r
*/\r
private ObjectNode createVfcObjectNodeByVfUuid(ObjectMapper mapper, List<CldsVfData> cldsVfDataList) {\r
ObjectNode vfUuidObjectNode = mapper.createObjectNode();\r
-\r
if (cldsVfDataList != null && !cldsVfDataList.isEmpty()) {\r
for (CldsVfData currCldsVfData : cldsVfDataList) {\r
if (currCldsVfData != null) {\r
ObjectNode kpiObjectNode = mapper.createObjectNode();\r
if (currCldsVfData.getCldsVfcs() != null && !currCldsVfData.getCldsVfcs().isEmpty()) {\r
for (CldsVfcData currCldsVfcData : currCldsVfData.getCldsVfcs()) {\r
- vfcUuidNode.put(currCldsVfcData.getVfcInvariantResourceUUID(),\r
- currCldsVfcData.getVfcName());\r
+ if (currCldsVfcData.getCldsAlarmConditions() != null\r
+ && !currCldsVfcData.getCldsAlarmConditions().isEmpty()) {\r
+ vfcUuidNode.put(currCldsVfcData.getVfcInvariantResourceUUID(),\r
+ currCldsVfcData.getVfcName());\r
+ }\r
}\r
} else {\r
vfcUuidNode.put("", "");\r
}\r
\r
public String updateControlLoopStatusToDcae(String dcaeUrl, String invariantResourceUuid,\r
- String invariantServiceUuid, String artifactName) {\r
+ String invariantServiceUuid, String artifactName) throws GeneralSecurityException {\r
String baseUrl = refProp.getStringValue("sdc.serviceUrl");\r
- String basicAuth = SdcReq.getSdcBasicAuth(refProp);\r
+ String basicAuth = sdcReq.getSdcBasicAuth();\r
String postStatusData = "{ \n" + "\"event\" : \"" + "Created" + "\",\n" + "\"serviceUUID\" : \""\r
+ invariantServiceUuid + "\",\n" + "\"resourceUUID\" :\"" + invariantResourceUuid + "\",\n"\r
+ "\"artifactName\" : \"" + artifactName + "\",\n" + "} \n";\r
url = dcaeUrl + "/closed-loops";\r
}\r
URL urlObj = new URL(url);\r
-\r
HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();\r
conn.setRequestProperty(refProp.getStringValue("sdc.InstanceID"), "CLAMP-Tool");\r
conn.setRequestProperty("Authorization", basicAuth);\r
conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8");\r
conn.setRequestProperty("X-ECOMP-RequestID", LoggingUtils.getRequestId());\r
conn.setRequestMethod("POST");\r
-\r
- byte[] postData = SdcReq.stringToByteArray(postStatusData);\r
+ byte[] postData = sdcReq.stringToByteArray(postStatusData);\r
try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) {\r
wr.write(postData);\r
}\r
-\r
int responseCode = conn.getResponseCode();\r
logger.info("responseCode=" + responseCode);\r
-\r
String resp = getResponse(conn);\r
if (resp != null) {\r
return resp;\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
+ private List<CldsSdcResourceBasicInfo> getAllSdcVForVfcResourcesBasedOnResourceType(String resourceType)\r
+ throws GeneralSecurityException {\r
String catalogUrl = refProp.getStringValue("sdc.catalog.url");\r
String resourceUrl = catalogUrl + "resources?resourceType=" + resourceType;\r
String allSdcVfcResources = getCldsServicesOrResourcesBasedOnURL(resourceUrl, false);\r
* @param locationArtifactName\r
* The location artifact name from where we can get the Artifact\r
* UUID\r
- * \r
+ * @throws GeneralSecurityException\r
+ * In case of issues to decrypt the SDC password\r
*/\r
public void uploadToSdc(ModelProperties prop, String userid, List<String> sdcReqUrlsList, String formattedSdcReq,\r
- String formattedSdcLocationReq, String artifactName, String locationArtifactName) {\r
+ String formattedSdcLocationReq, String artifactName, String locationArtifactName)\r
+ throws GeneralSecurityException {\r
logger.info("userid=" + userid);\r
String serviceInvariantUuid = getServiceInvariantUuidFromProps(prop);\r
if (sdcReqUrlsList != null && !sdcReqUrlsList.isEmpty()) {\r