* See the License for the specific language governing permissions and\r
* limitations under the License.\r
* ============LICENSE_END============================================\r
+ * Modifications copyright (c) 2018 Nokia\r
* ===================================================================\r
- * ECOMP is a trademark and service mark of AT&T Intellectual Property.\r
+ *\r
*/\r
\r
package org.onap.clamp.clds.client.req.sdc;\r
\r
import com.att.eelf.configuration.EELFLogger;\r
import com.att.eelf.configuration.EELFManager;\r
-import com.fasterxml.jackson.databind.JsonNode;\r
-import com.fasterxml.jackson.databind.ObjectMapper;\r
-import com.fasterxml.jackson.databind.node.ArrayNode;\r
-import com.fasterxml.jackson.databind.node.ObjectNode;\r
-import com.fasterxml.jackson.databind.node.TextNode;\r
\r
+import com.google.gson.JsonArray;\r
+import com.google.gson.JsonElement;\r
+import com.google.gson.JsonObject;\r
+import com.google.gson.JsonParseException;\r
+import com.google.gson.reflect.TypeToken;\r
import java.io.BufferedReader;\r
-import java.io.DataOutputStream;\r
import java.io.IOException;\r
import java.io.InputStream;\r
import java.io.InputStreamReader;\r
import java.io.Reader;\r
import java.io.StringReader;\r
+import java.lang.reflect.Type;\r
import java.net.HttpURLConnection;\r
import java.net.URL;\r
import java.nio.charset.StandardCharsets;\r
import java.util.Iterator;\r
import java.util.List;\r
\r
-import javax.ws.rs.BadRequestException;\r
-\r
import org.apache.commons.codec.DecoderException;\r
-import org.apache.commons.codec.digest.DigestUtils;\r
import org.apache.commons.csv.CSVFormat;\r
import org.apache.commons.csv.CSVRecord;\r
import org.apache.commons.io.IOUtils;\r
import org.onap.clamp.clds.model.CldsVfData;\r
import org.onap.clamp.clds.model.CldsVfKPIData;\r
import org.onap.clamp.clds.model.CldsVfcData;\r
-import org.onap.clamp.clds.model.properties.Global;\r
-import org.onap.clamp.clds.model.properties.ModelProperties;\r
-import org.onap.clamp.clds.model.sdc.SdcArtifact;\r
import org.onap.clamp.clds.model.sdc.SdcResource;\r
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.JacksonUtils;\r
+import org.onap.clamp.clds.util.JsonUtils;\r
import org.onap.clamp.clds.util.LoggingUtils;\r
import org.springframework.beans.factory.annotation.Autowired;\r
+import org.springframework.context.annotation.Primary;\r
import org.springframework.stereotype.Component;\r
\r
@Component\r
+@Primary\r
public class SdcCatalogServices {\r
\r
private static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcCatalogServices.class);\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 LoggingUtils utils = new LoggingUtils(logger);\r
+\r
+ private static final Type LIST_SDC_SERVICE_INFO_TYPE = new TypeToken<List<SdcServiceInfo>>() {\r
+ }.getType();\r
+\r
+ private static final Type LIST_SDC_RESOURCE_BASIC_INFO_TYPE = new TypeToken<List<SdcResourceBasicInfo>>() {\r
+ }.getType();\r
+\r
@Autowired\r
private ClampProperties refProp;\r
\r
*\r
* @return The String with Basic Auth and password\r
* @throws GeneralSecurityException\r
- * In case of issue when decryting the SDC password\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
+ * In case of issues with the decoding of the HexString message\r
*/\r
- private String getSdcBasicAuth() throws GeneralSecurityException, DecoderException {\r
+ public String getSdcBasicAuth() throws GeneralSecurityException, DecoderException {\r
String sdcId = refProp.getStringValue("sdc.serviceUsername");\r
String sdcPw = refProp.getStringValue("sdc.servicePassword");\r
String password = CryptoUtils.decrypt(sdcPw);\r
}\r
\r
/**\r
- * This method get the SDC services Information with the corresponding\r
- * Service UUID.\r
- * \r
+ * This method get the SDC services Information with the corresponding Service\r
+ * UUID.\r
+ *\r
* @param uuid\r
- * The service 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
+ * In case of issue when decryting the SDC password\r
* @throws DecoderException\r
- * In case of issues with the decoding of the Hex String\r
+ * In case of issues with the decoding of the Hex String\r
*/\r
public String getSdcServicesInformation(String uuid) throws GeneralSecurityException, DecoderException {\r
Date startTime = new Date();\r
String baseUrl = refProp.getStringValue(SDC_SERVICE_URL_PROPERTY_NAME);\r
String basicAuth = getSdcBasicAuth();\r
- LoggingUtils.setTargetContext("SDC", "getSdcServicesInformation");\r
try {\r
String url = baseUrl;\r
if (uuid != null && !uuid.isEmpty()) {\r
}\r
URL urlObj = new URL(url);\r
HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();\r
+ conn = utils.invoke(conn, "SDC", "getSdcServicesInformation");\r
conn.setRequestProperty(refProp.getStringValue(SDC_INSTANCE_ID_PROPERTY_NAME), SDC_INSTANCE_ID_CLAMP);\r
conn.setRequestProperty(HttpHeaders.AUTHORIZATION, basicAuth);\r
conn.setRequestProperty(HttpHeaders.CONTENT_TYPE, "application/json;charset=UTF-8");\r
conn.setRequestMethod("GET");\r
String resp = getResponse(conn);\r
logger.debug("Services list received from SDC:" + resp);\r
- // metrics log\r
- LoggingUtils.setResponseContext("0", "Get sdc services success", this.getClass().getName());\r
+ utils.invokeReturn();\r
return resp;\r
} catch (IOException e) {\r
LoggingUtils.setResponseContext("900", "Get sdc services failed", this.getClass().getName());\r
LoggingUtils.setTimeContext(startTime, new Date());\r
metricsLogger.info("getSdcServicesInformation complete");\r
}\r
+ utils.invokeReturn();\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
+ * A list of CldsSdcServiceInfo\r
* @return A list of CldsSdcServiceInfo without duplicate service UUID\r
*/\r
public List<SdcServiceInfo> removeDuplicateServices(List<SdcServiceInfo> rawCldsSdcServiceList) {\r
\r
/**\r
* To remove duplicate serviceUUIDs from sdc resources List.\r
- * \r
+ *\r
* @param rawCldsSdcResourceList\r
* @return List of CldsSdcResource\r
*/\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<SdcResourceBasicInfo> removeDuplicateSdcResourceBasicInfo(\r
- List<SdcResourceBasicInfo> rawCldsSdcResourceListBasicList) {\r
- List<SdcResourceBasicInfo> cldsSdcResourceBasicInfoList = null;\r
+ List<SdcResourceBasicInfo> rawCldsSdcResourceListBasicList) {\r
+ List<SdcResourceBasicInfo> cldsSdcResourceBasicInfoList = new ArrayList<>();\r
if (rawCldsSdcResourceListBasicList != null && !rawCldsSdcResourceListBasicList.isEmpty()) {\r
// sort list\r
Collections.sort(rawCldsSdcResourceListBasicList);\r
// and then take only the resources with the max version (last in\r
// the list with the same name)\r
- cldsSdcResourceBasicInfoList = new ArrayList<>();\r
for (int i = 1; i < rawCldsSdcResourceListBasicList.size(); i++) {\r
// compare name with previous - if not equal, then keep the\r
// previous (it's the last with that name)\r
}\r
// add the last in the list\r
cldsSdcResourceBasicInfoList\r
- .add(rawCldsSdcResourceListBasicList.get(rawCldsSdcResourceListBasicList.size() - 1));\r
+ .add(rawCldsSdcResourceListBasicList.get(rawCldsSdcResourceListBasicList.size() - 1));\r
}\r
return cldsSdcResourceBasicInfoList;\r
}\r
\r
/**\r
* To get ServiceUUID by using serviceInvariantUUID.\r
- * \r
+ *\r
* @param invariantId\r
- * The invariant ID\r
+ * The invariant ID\r
* @return The service UUID\r
* @throws GeneralSecurityException\r
- * In case of issue when decryting the SDC password\r
+ * In case of issue when decryting the SDC password\r
* @throws DecoderException\r
- * In case of issues with the decoding of the Hex String\r
+ * In case of issues with the decoding of the Hex String\r
*/\r
public String getServiceUuidFromServiceInvariantId(String invariantId)\r
- throws GeneralSecurityException, DecoderException {\r
+ throws GeneralSecurityException, DecoderException {\r
String serviceUuid = "";\r
String responseStr = getSdcServicesInformation(null);\r
List<SdcServiceInfo> rawCldsSdcServicesList = getCldsSdcServicesListFromJson(responseStr);\r
if (cldsSdcServicesList != null && !cldsSdcServicesList.isEmpty()) {\r
for (SdcServiceInfo currCldsSdcServiceInfo : cldsSdcServicesList) {\r
if (currCldsSdcServiceInfo != null && currCldsSdcServiceInfo.getInvariantUUID() != null\r
- && currCldsSdcServiceInfo.getInvariantUUID().equalsIgnoreCase(invariantId)) {\r
+ && currCldsSdcServiceInfo.getInvariantUUID().equalsIgnoreCase(invariantId)) {\r
serviceUuid = currCldsSdcServiceInfo.getUuid();\r
break;\r
}\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
- * an empty list\r
+ * The Json string that must be decoded\r
+ * @return The list of CldsSdcServiceInfo, if there is a failure it return an\r
+ * empty list\r
*/\r
private List<SdcServiceInfo> getCldsSdcServicesListFromJson(String jsonStr) {\r
if (StringUtils.isBlank(jsonStr)) {\r
return new ArrayList<>();\r
}\r
try {\r
- return JacksonUtils.getObjectMapperInstance().readValue(jsonStr, JacksonUtils.getObjectMapperInstance()\r
- .getTypeFactory().constructCollectionType(List.class, SdcServiceInfo.class));\r
- } catch (IOException e) {\r
+ return JsonUtils.GSON.fromJson(jsonStr, LIST_SDC_SERVICE_INFO_TYPE);\r
+ } catch (JsonParseException e) {\r
logger.error("Error when attempting to decode the JSON containing CldsSdcServiceInfo", e);\r
return new ArrayList<>();\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
+ * The JSOn string that must be decoded\r
+ * @return The list of CldsSdcResourceBasicInfo, an empty list in case of issues\r
*/\r
private List<SdcResourceBasicInfo> getAllSdcResourcesListFromJson(String jsonStr) {\r
if (StringUtils.isBlank(jsonStr)) {\r
return new ArrayList<>();\r
}\r
try {\r
- return JacksonUtils.getObjectMapperInstance().readValue(jsonStr, JacksonUtils.getObjectMapperInstance()\r
- .getTypeFactory().constructCollectionType(List.class, SdcResourceBasicInfo.class));\r
- } catch (IOException e) {\r
+ return JsonUtils.GSON.fromJson(jsonStr, LIST_SDC_RESOURCE_BASIC_INFO_TYPE);\r
+ } catch (JsonParseException e) {\r
logger.error("Exception occurred when attempting to decode the list of CldsSdcResourceBasicInfo JSON", e);\r
return new ArrayList<>();\r
}\r
\r
/**\r
* To get CldsSdcServiceDetail by parsing json string.\r
- * \r
+ *\r
* @param jsonStr\r
* @return\r
*/\r
public SdcServiceDetail decodeCldsSdcServiceDetailFromJson(String jsonStr) {\r
try {\r
- return JacksonUtils.getObjectMapperInstance().readValue(jsonStr, SdcServiceDetail.class);\r
- } catch (IOException e) {\r
+ return JsonUtils.GSON.fromJson(jsonStr, SdcServiceDetail.class);\r
+ } catch (JsonParseException e) {\r
logger.error("Exception when attempting to decode the CldsSdcServiceDetail JSON", e);\r
return null;\r
}\r
}\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
- }\r
- try {\r
- logger.info("userid=" + userid);\r
- byte[] postData = formattedSdcReq.getBytes(StandardCharsets.UTF_8);\r
- int postDataLength = postData.length;\r
- HttpURLConnection conn = getSdcHttpUrlConnection(userid, postDataLength, url, formattedSdcReq);\r
- try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) {\r
- wr.write(postData);\r
- }\r
- boolean requestFailed = true;\r
- int responseCode = conn.getResponseCode();\r
- logger.info("responseCode=" + responseCode);\r
- if (responseCode == 200) {\r
- requestFailed = false;\r
- }\r
- String responseStr = getResponse(conn);\r
- if (responseStr != null && requestFailed) {\r
- logger.error("requestFailed - responseStr=" + responseStr);\r
- throw new BadRequestException(responseStr);\r
- }\r
- return responseStr;\r
- } catch (IOException e) {\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
- private HttpURLConnection getSdcHttpUrlConnection(String userid, int postDataLength, String url, String content) {\r
- try {\r
- logger.info("userid=" + userid);\r
- String basicAuth = getSdcBasicAuth();\r
- String sdcXonapInstanceId = refProp.getStringValue("sdc.sdcX-InstanceID");\r
- URL urlObj = new URL(url);\r
- HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();\r
- conn.setDoOutput(true);\r
- conn.setRequestProperty(refProp.getStringValue(SDC_INSTANCE_ID_PROPERTY_NAME), sdcXonapInstanceId);\r
- conn.setRequestProperty(HttpHeaders.AUTHORIZATION, basicAuth);\r
- conn.setRequestProperty(HttpHeaders.CONTENT_TYPE, "application/json");\r
- conn.setRequestProperty(HttpHeaders.CONTENT_MD5,\r
- Base64.getEncoder().encodeToString(DigestUtils.md5Hex(content).getBytes("UTF-8")));\r
- conn.setRequestProperty("USER_ID", userid);\r
- conn.setRequestMethod("POST");\r
- conn.setRequestProperty("charset", "utf-8");\r
- conn.setRequestProperty(HttpHeaders.CONTENT_LENGTH, Integer.toString(postDataLength));\r
- conn.setUseCaches(false);\r
- conn.setRequestProperty(refProp.getStringValue(SDC_REQUESTID_PROPERTY_NAME), LoggingUtils.getRequestId());\r
- return conn;\r
- } catch (IOException e) {\r
- logger.error("Exception when attempting to open connection with SDC", e);\r
- throw new SdcCommunicationException("Exception when attempting to open connection with SDC", e);\r
- } catch (DecoderException e) {\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
- 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
- }\r
- }\r
-\r
- private String getResponse(HttpURLConnection conn) {\r
+ public String getResponse(HttpURLConnection conn) {\r
try (InputStream is = getInputStream(conn)) {\r
try (BufferedReader in = new BufferedReader(new InputStreamReader(is))) {\r
return IOUtils.toString(in);\r
\r
/**\r
* Check if the SDC Info in cache has expired.\r
- * \r
+ *\r
* @param cldsServiceData\r
- * The object representing the service data\r
+ * The object representing the service data\r
* @return boolean flag\r
* @throws GeneralSecurityException\r
- * In case of issues with the decryting the encrypted password\r
+ * In case of issues with the decryting the encrypted password\r
* @throws DecoderException\r
- * In case of issues with the decoding of the Hex String\r
+ * In case of issues with the decoding of the Hex String\r
*/\r
public boolean isCldsSdcCacheDataExpired(CldsServiceData cldsServiceData)\r
- throws GeneralSecurityException, DecoderException {\r
+ throws GeneralSecurityException, DecoderException {\r
if (cldsServiceData != null && cldsServiceData.getServiceUUID() != null) {\r
String cachedServiceUuid = cldsServiceData.getServiceUUID();\r
String latestServiceUuid = getServiceUuidFromServiceInvariantId(cldsServiceData.getServiceInvariantUUID());\r
String configuredMaxAge = refProp.getStringValue("clds.service.cache.invalidate.after.seconds");\r
if (configuredMaxAge == null) {\r
logger.warn(\r
- "clds.service.cache.invalidate.after.seconds NOT set in clds-reference.properties file, taking 60s as default");\r
+ "clds.service.cache.invalidate.after.seconds NOT set in clds-reference.properties file, taking 60s as default");\r
configuredMaxAge = "60";\r
}\r
return (!cachedServiceUuid.equalsIgnoreCase(latestServiceUuid)) || (cldsServiceData.getAgeOfRecord() != null\r
- && cldsServiceData.getAgeOfRecord() > Long.parseLong(configuredMaxAge));\r
+ && cldsServiceData.getAgeOfRecord() > Long.parseLong(configuredMaxAge));\r
} else {\r
return true;\r
}\r
}\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 The CldsServiceData\r
* @throws GeneralSecurityException\r
- * In case of issues with the decryting the encrypted password\r
+ * In case of issues with the decryting the encrypted password\r
* @throws DecoderException\r
- * In case of issues with the decoding of the Hex String\r
+ * In case of issues with the decoding of the Hex String\r
*/\r
public CldsServiceData getCldsServiceDataWithAlarmConditions(String invariantServiceUuid)\r
- throws GeneralSecurityException, DecoderException {\r
+ throws GeneralSecurityException, DecoderException {\r
String url = refProp.getStringValue(SDC_SERVICE_URL_PROPERTY_NAME);\r
String catalogUrl = refProp.getStringValue(SDC_CATALOG_URL_PROPERTY_NAME);\r
String serviceUuid = getServiceUuidFromServiceInvariantId(invariantServiceUuid);\r
if (responseStr != null) {\r
SdcServiceDetail cldsSdcServiceDetail;\r
try {\r
- cldsSdcServiceDetail = JacksonUtils.getObjectMapperInstance().readValue(responseStr,\r
- SdcServiceDetail.class);\r
- } catch (IOException e) {\r
+ cldsSdcServiceDetail = JsonUtils.GSON.fromJson(responseStr, SdcServiceDetail.class);\r
+ } catch (JsonParseException e) {\r
logger.error("Exception when decoding the CldsServiceData JSON from SDC", e);\r
throw new SdcCommunicationException("Exception when decoding the CldsServiceData JSON from SDC", e);\r
}\r
cldsServiceData.setServiceUUID(cldsSdcServiceDetail.getUuid());\r
cldsServiceData.setServiceInvariantUUID(cldsSdcServiceDetail.getInvariantUUID());\r
List<SdcResource> cldsSdcResourceList = removeDuplicateSdcResourceInstances(\r
- cldsSdcServiceDetail.getResources());\r
+ cldsSdcServiceDetail.getResources());\r
if (cldsSdcResourceList != null && !cldsSdcResourceList.isEmpty()) {\r
List<CldsVfData> cldsVfDataList = new ArrayList<>();\r
for (SdcResource currCldsSdcResource : cldsSdcResourceList) {\r
if (currCldsSdcResource != null && currCldsSdcResource.getResoucreType() != null\r
- && "VF".equalsIgnoreCase(currCldsSdcResource.getResoucreType())) {\r
+ && "VF".equalsIgnoreCase(currCldsSdcResource.getResoucreType())) {\r
CldsVfData currCldsVfData = new CldsVfData();\r
currCldsVfData.setVfName(currCldsSdcResource.getResourceInstanceName());\r
currCldsVfData.setVfInvariantResourceUUID(currCldsSdcResource.getResourceInvariantUUID());\r
}\r
\r
private void getAllVfcForVfList(List<CldsVfData> cldsVfDataList, String catalogUrl)\r
- throws GeneralSecurityException {\r
+ throws GeneralSecurityException {\r
// todo : refact this..\r
if (cldsVfDataList != null && !cldsVfDataList.isEmpty()) {\r
List<SdcResourceBasicInfo> allVfResources = getAllSdcVForVfcResourcesBasedOnResourceType(RESOURCE_VF_TYPE);\r
List<SdcResourceBasicInfo> allVfcResources = getAllSdcVForVfcResourcesBasedOnResourceType(\r
- RESOURCE_VFC_TYPE);\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
- currCldsVfData.getVfInvariantResourceUUID(), allVfResources);\r
+ currCldsVfData.getVfInvariantResourceUUID(), allVfResources);\r
if (resourceUuid != null) {\r
String vfResourceUuidUrl = catalogUrl + RESOURCE_URL_PREFIX + "/" + resourceUuid\r
- + SDC_METADATA_URL_PREFIX;\r
+ + SDC_METADATA_URL_PREFIX;\r
String vfResponse = getCldsServicesOrResourcesBasedOnURL(vfResourceUuidUrl);\r
if (vfResponse != null) {\r
// Below 2 line are to get the KPI(field path) data\r
// alarm conditions from artifact\r
for (CldsVfcData currCldsVfcData : vfcDataListFromVfResponse) {\r
if (currCldsVfcData != null\r
- && currCldsVfcData.getVfcInvariantResourceUUID() != null) {\r
+ && currCldsVfcData.getVfcInvariantResourceUUID() != null) {\r
String resourceVfcUuid = getResourceUuidFromResourceInvariantUuid(\r
- currCldsVfcData.getVfcInvariantResourceUUID(), allVfcResources);\r
+ currCldsVfcData.getVfcInvariantResourceUUID(), allVfcResources);\r
if (resourceVfcUuid != null) {\r
String vfcResourceUuidUrl = catalogUrl + RESOURCE_URL_PREFIX + "/"\r
- + resourceVfcUuid + SDC_METADATA_URL_PREFIX;\r
+ + resourceVfcUuid + SDC_METADATA_URL_PREFIX;\r
String vfcResponse = getCldsServicesOrResourcesBasedOnURL(\r
- vfcResourceUuidUrl);\r
+ vfcResourceUuidUrl);\r
if (vfcResponse != null) {\r
List<CldsAlarmCondition> alarmCondtionsFromVfc = getAlarmCondtionsFromVfc(\r
- vfcResponse);\r
+ vfcResponse);\r
currCldsVfcData.setCldsAlarmConditions(alarmCondtionsFromVfc);\r
}\r
} else {\r
logger.info("No resourceVFC UUID found for given invariantID:"\r
- + currCldsVfcData.getVfcInvariantResourceUUID());\r
+ + currCldsVfcData.getVfcInvariantResourceUUID());\r
}\r
}\r
}\r
}\r
} else {\r
logger.info("No resourceUUID found for given invariantREsourceUUID:"\r
- + currCldsVfData.getVfInvariantResourceUUID());\r
+ + currCldsVfData.getVfInvariantResourceUUID());\r
}\r
}\r
}\r
}\r
\r
private List<CldsVfcData> getVfcDataListFromVfResponse(String vfResponse) {\r
- ObjectNode vfResponseNode;\r
+ JsonObject vfResponseNode;\r
try {\r
- vfResponseNode = (ObjectNode) JacksonUtils.getObjectMapperInstance().readTree(vfResponse);\r
- } catch (IOException e) {\r
+ vfResponseNode = JsonUtils.GSON.fromJson(vfResponse, JsonObject.class);\r
+ } catch (JsonParseException e) {\r
logger.error("Exception when decoding the JSON list of CldsVfcData", e);\r
return new ArrayList<>();\r
}\r
- ArrayNode vfcArrayNode = (ArrayNode) vfResponseNode.get("resources");\r
+ JsonArray vfcArrayNode = vfResponseNode.get("resources").getAsJsonArray();\r
List<CldsVfcData> cldsVfcDataList = new ArrayList<>();\r
if (vfcArrayNode != null) {\r
- for (JsonNode vfcjsonNode : vfcArrayNode) {\r
- ObjectNode currVfcNode = (ObjectNode) vfcjsonNode;\r
- TextNode resourceTypeNode = (TextNode) currVfcNode.get("resoucreType");\r
- if (resourceTypeNode != null && "VFC".equalsIgnoreCase(resourceTypeNode.textValue())) {\r
- handleVFCtypeNode(currVfcNode, cldsVfcDataList);\r
- } else if (resourceTypeNode != null && "CVFC".equalsIgnoreCase(resourceTypeNode.textValue())) {\r
- handleCVFCtypeNode(currVfcNode, cldsVfcDataList);\r
+ for (JsonElement vfcjsonNode : vfcArrayNode) {\r
+ JsonObject currVfcNode = vfcjsonNode.getAsJsonObject();\r
+ JsonElement resourceTypeNode = currVfcNode.get("resoucreType");\r
+ if (resourceTypeNode != null && resourceTypeNode.isJsonPrimitive()) {\r
+ if ("VFC".equalsIgnoreCase(resourceTypeNode.getAsString())) {\r
+ handleVFCtypeNode(currVfcNode, cldsVfcDataList);\r
+ } else if ("CVFC".equalsIgnoreCase(resourceTypeNode.getAsString())) {\r
+ handleCVFCtypeNode(currVfcNode, cldsVfcDataList);\r
+ }\r
}\r
}\r
}\r
return cldsVfcDataList;\r
}\r
\r
- private void handleVFCtypeNode(ObjectNode currVfcNode, List<CldsVfcData> cldsVfcDataList) {\r
+ private void handleVFCtypeNode(JsonObject 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
+ String vfcResourceName = currVfcNode.get("resourceInstanceName").getAsString();\r
+ String vfcInvariantResourceUuid = currVfcNode.get("resourceInvariantUUID").getAsString();\r
+ currCldsVfcData.setVfcName(vfcResourceName);\r
+ currCldsVfcData.setVfcInvariantResourceUUID(vfcInvariantResourceUuid);\r
cldsVfcDataList.add(currCldsVfcData);\r
}\r
\r
- private void handleCVFCtypeNode(ObjectNode currVfcNode, List<CldsVfcData> cldsVfcDataList) {\r
+ private void handleCVFCtypeNode(JsonObject currVfcNode, List<CldsVfcData> cldsVfcDataList) {\r
handleVFCtypeNode(currVfcNode, cldsVfcDataList);\r
- cldsVfcDataList.addAll(getVFCfromCVFC(currVfcNode.get("resourceUUID").textValue()));\r
+ cldsVfcDataList.addAll(getVFCfromCVFC(currVfcNode.get("resourceUUID").getAsString()));\r
}\r
\r
private List<CldsVfcData> getVFCfromCVFC(String resourceUUID) {\r
String vfcResourceUUIDUrl = catalogUrl + RESOURCE_URL_PREFIX + "/" + resourceUUID + SDC_METADATA_URL_PREFIX;\r
try {\r
String vfcResponse = getCldsServicesOrResourcesBasedOnURL(vfcResourceUUIDUrl);\r
- ObjectNode vfResponseNode = (ObjectNode) JacksonUtils.getObjectMapperInstance().readTree(vfcResponse);\r
- ArrayNode vfcArrayNode = (ArrayNode) vfResponseNode.get("resources");\r
+ JsonObject vfResponseNode = JsonUtils.GSON.fromJson(vfcResponse, JsonObject.class);\r
+ JsonArray vfcArrayNode = vfResponseNode.get("resources").getAsJsonArray();\r
if (vfcArrayNode != null) {\r
- for (JsonNode vfcjsonNode : vfcArrayNode) {\r
- ObjectNode currVfcNode = (ObjectNode) vfcjsonNode;\r
- TextNode resourceTypeNode = (TextNode) currVfcNode.get("resoucreType");\r
- if (resourceTypeNode != null && "VFC".equalsIgnoreCase(resourceTypeNode.textValue())) {\r
+ for (JsonElement vfcjsonNode : vfcArrayNode) {\r
+ JsonObject currVfcNode = vfcjsonNode.getAsJsonObject();\r
+ JsonElement resourceTypeNode = currVfcNode.get("resoucreType");\r
+ if (resourceTypeNode != null && resourceTypeNode.isJsonPrimitive() && "VFC".equalsIgnoreCase(resourceTypeNode.getAsString())) {\r
handleVFCtypeNode(currVfcNode, cldsVfcDataList);\r
}\r
}\r
}\r
- } catch (IOException e) {\r
+ } catch (JsonParseException e) {\r
logger.error("Exception during JSON analyzis", e);\r
}\r
}\r
\r
private List<CldsAlarmCondition> getAlarmCondtionsFromVfc(String vfcResponse) throws GeneralSecurityException {\r
List<CldsAlarmCondition> cldsAlarmConditionList = new ArrayList<>();\r
- ObjectNode vfcResponseNode;\r
+ JsonObject vfcResponseNode;\r
try {\r
- vfcResponseNode = (ObjectNode) JacksonUtils.getObjectMapperInstance().readTree(vfcResponse);\r
- } catch (IOException e) {\r
+ vfcResponseNode = JsonUtils.GSON.fromJson(vfcResponse, JsonObject.class);\r
+ } catch (JsonParseException e) {\r
logger.error("Exception when decoding the JSON list of CldsAlarmCondition", e);\r
return cldsAlarmConditionList;\r
}\r
- ArrayNode artifactsArrayNode = (ArrayNode) vfcResponseNode.get("artifacts");\r
- if (artifactsArrayNode != null && artifactsArrayNode.size() > 0) {\r
- for (int index = 0; index < artifactsArrayNode.size(); index++) {\r
- ObjectNode currArtifactNode = (ObjectNode) artifactsArrayNode.get(index);\r
- TextNode artifactUrlNode = (TextNode) currArtifactNode.get("artifactURL");\r
- if (artifactUrlNode != null) {\r
- String responsesFromArtifactUrl = getResponsesFromArtifactUrl(artifactUrlNode.textValue());\r
+ JsonElement artifactsNode = vfcResponseNode.get("artifacts");\r
+ if (artifactsNode != null && artifactsNode.isJsonArray() && artifactsNode.getAsJsonArray().size() > 0) {\r
+ JsonArray artifactsList = artifactsNode.getAsJsonArray();\r
+ for (int index = 0; index < artifactsList.size(); index++) {\r
+ JsonObject currArtifactNode = artifactsList.get(index).getAsJsonObject();\r
+ JsonElement artifactUrlNode = currArtifactNode.get("artifactURL");\r
+ if (artifactUrlNode != null && artifactUrlNode.isJsonPrimitive()) {\r
+ String responsesFromArtifactUrl = getResponsesFromArtifactUrl(artifactUrlNode.getAsString());\r
cldsAlarmConditionList.addAll(parseCsvToGetAlarmConditions(responsesFromArtifactUrl));\r
logger.info(responsesFromArtifactUrl);\r
}\r
// Method to get the artifact for any particular VF\r
private List<CldsVfKPIData> getFieldPathFromVF(String vfResponse) throws GeneralSecurityException {\r
List<CldsVfKPIData> cldsVfKPIDataList = new ArrayList<>();\r
- ObjectNode vfResponseNode;\r
+ JsonObject vfResponseNode;\r
try {\r
- vfResponseNode = (ObjectNode) JacksonUtils.getObjectMapperInstance().readTree(vfResponse);\r
- } catch (IOException e) {\r
+ vfResponseNode = JsonUtils.GSON.fromJson(vfResponse, JsonObject.class);\r
+ } catch (JsonParseException e) {\r
logger.error("Exception when decoding the JSON list of CldsVfKPIData", e);\r
return cldsVfKPIDataList;\r
}\r
- ArrayNode artifactsArrayNode = (ArrayNode) vfResponseNode.get("artifacts");\r
+ JsonArray artifactsArrayNode = vfResponseNode.get("artifacts").getAsJsonArray();\r
if (artifactsArrayNode != null && artifactsArrayNode.size() > 0) {\r
for (int index = 0; index < artifactsArrayNode.size(); index++) {\r
- ObjectNode currArtifactNode = (ObjectNode) artifactsArrayNode.get(index);\r
- TextNode artifactUrlNode = (TextNode) currArtifactNode.get("artifactURL");\r
- TextNode artifactNameNode = (TextNode) currArtifactNode.get("artifactName");\r
+ JsonObject currArtifactNode = artifactsArrayNode.get(index).getAsJsonObject();\r
+ JsonElement artifactUrlNode = currArtifactNode.get("artifactURL");\r
+ JsonElement artifactNameNode = currArtifactNode.get("artifactName");\r
String artifactName = "";\r
if (artifactNameNode != null) {\r
- artifactName = artifactNameNode.textValue();\r
+ artifactName = artifactNameNode.getAsString();\r
artifactName = artifactName.substring(artifactName.lastIndexOf('.') + 1);\r
}\r
if (artifactUrlNode != null && "csv".equalsIgnoreCase(artifactName)) {\r
- String responsesFromArtifactUrl = getResponsesFromArtifactUrl(artifactUrlNode.textValue());\r
+ String responsesFromArtifactUrl = getResponsesFromArtifactUrl(artifactUrlNode.getAsString());\r
cldsVfKPIDataList.addAll(parseCsvToGetFieldPath(responsesFromArtifactUrl));\r
logger.info(responsesFromArtifactUrl);\r
}\r
return null;\r
}\r
if (StringUtils.isBlank(record.get(1)) || StringUtils.isBlank(record.get(3))\r
- || StringUtils.isBlank(record.get(5))) {\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
return;\r
}\r
if (StringUtils.isBlank(record.get(1)) || StringUtils.isBlank(record.get(3))\r
- || StringUtils.isBlank(record.get(4))) {\r
+ || StringUtils.isBlank(record.get(4))) {\r
logger.debug("invalid csv alarm Record,one of column is having blank value : " + record);\r
return;\r
}\r
}\r
\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
+ * Service to services/resources/artifacts from sdc.Pass alarmConditions as true\r
+ * to get alarm conditons from artifact url and else it is false\r
+ *\r
* @param url\r
- * The URL to trigger\r
+ * The URL to trigger\r
* @return The String containing the payload\r
*/\r
public String getCldsServicesOrResourcesBasedOnURL(String url) {\r
String urlReworked = removeUnwantedBracesFromString(url);\r
URL urlObj = new URL(urlReworked);\r
HttpURLConnection conn = (HttpURLConnection) urlObj.openConnection();\r
+ conn = utils.invoke(conn, "SDC", "getSdcResources");\r
String basicAuth = getSdcBasicAuth();\r
conn.setRequestProperty(refProp.getStringValue(SDC_INSTANCE_ID_PROPERTY_NAME), SDC_INSTANCE_ID_CLAMP);\r
conn.setRequestProperty(HttpHeaders.AUTHORIZATION, basicAuth);\r
logger.info("Sdc resource url - " + urlReworked + " , responseCode=" + responseCode);\r
try (BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {\r
String response = IOUtils.toString(in);\r
- LoggingUtils.setResponseContext("0", "Get sdc resources success", this.getClass().getName());\r
return response;\r
}\r
} catch (IOException e) {\r
- LoggingUtils.setResponseContext("900", "Get sdc resources failed", this.getClass().getName());\r
LoggingUtils.setErrorContext("900", "Get sdc resources error");\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
LoggingUtils.setTimeContext(startTime, new Date());\r
metricsLogger.info("getCldsServicesOrResourcesBasedOnURL completed");\r
+ utils.invokeReturn();\r
}\r
}\r
\r
/**\r
* To create properties object by using cldsServicedata.\r
*\r
- * @param globalProps\r
- * @param cldsServiceData\r
- * @return\r
- * @throws IOException\r
- * In case of issues during the parsing of the Global Properties\r
+ * @throws IOException In case of issues during the parsing of the Global Properties\r
*/\r
public String createPropertiesObjectByUUID(CldsServiceData cldsServiceData) throws IOException {\r
String totalPropsStr;\r
- ObjectMapper mapper = JacksonUtils.getObjectMapperInstance();\r
- ObjectNode globalPropsJson = (ObjectNode) refProp.getJsonTemplate(CldsService.GLOBAL_PROPERTIES_KEY);\r
+ JsonObject globalPropsJson = refProp.getJsonTemplate(CldsService.GLOBAL_PROPERTIES_KEY).getAsJsonObject();\r
if (cldsServiceData != null && cldsServiceData.getServiceUUID() != null) {\r
// Objectnode to save all byservice, byvf , byvfc and byalarm nodes\r
- ObjectNode byIdObjectNode = mapper.createObjectNode();\r
+ JsonObject byIdObjectNode = new JsonObject();\r
// To create vf ResourceUUID node with serviceInvariantUUID\r
- ObjectNode invariantUuidObjectNodeWithVf = createVfObjectNodeByServiceInvariantUuid(cldsServiceData);\r
- byIdObjectNode.putPOJO("byService", invariantUuidObjectNodeWithVf);\r
+ JsonObject invariantUuidObjectNodeWithVf = createVfObjectNodeByServiceInvariantUuid(cldsServiceData);\r
+ byIdObjectNode.add("byService", invariantUuidObjectNodeWithVf);\r
// To create byVf and vfcResourceNode with vfResourceUUID\r
- ObjectNode vfcObjectNodeByVfUuid = createVfcObjectNodeByVfUuid(cldsServiceData.getCldsVfs());\r
- byIdObjectNode.putPOJO("byVf", vfcObjectNodeByVfUuid);\r
+ JsonObject vfcObjectNodeByVfUuid = createVfcObjectNodeByVfUuid(cldsServiceData.getCldsVfs());\r
+ byIdObjectNode.add("byVf", vfcObjectNodeByVfUuid);\r
// To create byKpi\r
- ObjectNode kpiObjectNode = mapper.createObjectNode();\r
+ JsonObject kpiJsonObject = new JsonObject();\r
if (cldsServiceData.getCldsVfs() != null && !cldsServiceData.getCldsVfs().isEmpty()) {\r
for (CldsVfData currCldsVfData : cldsServiceData.getCldsVfs()) {\r
if (currCldsVfData != null) {\r
- createKpiObjectNodeByVfUuid(kpiObjectNode, currCldsVfData.getCldsKPIList());\r
+ createKpiObjectNodeByVfUuid(kpiJsonObject, currCldsVfData.getCldsKPIList());\r
}\r
}\r
}\r
- byIdObjectNode.putPOJO("byKpi", kpiObjectNode);\r
+ byIdObjectNode.add("byKpi", kpiJsonObject);\r
// To create byVfc and alarmCondition with vfcResourceUUID\r
- ObjectNode vfcResourceUuidObjectNode = mapper.createObjectNode();\r
+ JsonObject vfcResourceUuidObjectNode = new JsonObject();\r
if (cldsServiceData.getCldsVfs() != null && !cldsServiceData.getCldsVfs().isEmpty()) {\r
for (CldsVfData currCldsVfData : cldsServiceData.getCldsVfs()) {\r
if (currCldsVfData != null) {\r
}\r
}\r
}\r
- byIdObjectNode.putPOJO("byVfc", vfcResourceUuidObjectNode);\r
+ byIdObjectNode.add("byVfc", vfcResourceUuidObjectNode);\r
// To create byAlarmCondition with alarmConditionKey\r
List<CldsAlarmCondition> allAlarmConditions = getAllAlarmConditionsFromCldsServiceData(cldsServiceData,\r
- "alarmCondition");\r
- ObjectNode alarmCondObjectNodeByAlarmKey = createAlarmCondObjectNodeByAlarmKey(allAlarmConditions);\r
- byIdObjectNode.putPOJO("byAlarmCondition", alarmCondObjectNodeByAlarmKey);\r
+ "alarmCondition");\r
+ JsonObject alarmCondObjectNodeByAlarmKey = createAlarmCondObjectNodeByAlarmKey(allAlarmConditions);\r
+ byIdObjectNode.add("byAlarmCondition", alarmCondObjectNodeByAlarmKey);\r
// To create byAlertDescription with AlertDescription\r
List<CldsAlarmCondition> allAlertDescriptions = getAllAlarmConditionsFromCldsServiceData(cldsServiceData,\r
- "alertDescription");\r
- ObjectNode alertDescObjectNodeByAlert = createAlarmCondObjectNodeByAlarmKey(allAlertDescriptions);\r
- byIdObjectNode.putPOJO("byAlertDescription", alertDescObjectNodeByAlert);\r
- globalPropsJson.putPOJO("shared", byIdObjectNode);\r
+ "alertDescription");\r
+ JsonObject alertDescObjectNodeByAlert = createAlarmCondObjectNodeByAlarmKey(allAlertDescriptions);\r
+ byIdObjectNode.add("byAlertDescription", alertDescObjectNodeByAlert);\r
+ globalPropsJson.add("shared", byIdObjectNode);\r
logger.info("Global properties JSON created with SDC info:" + globalPropsJson);\r
}\r
totalPropsStr = globalPropsJson.toString();\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
+ * CldsServiceData the Service Data to analyze\r
* @param eventName\r
- * The String event name that will be used to filter the alarm\r
- * list\r
+ * The String event name that will be used to filter the alarm list\r
* @return The list of CldsAlarmCondition for the event name specified\r
*/\r
public List<CldsAlarmCondition> getAllAlarmConditionsFromCldsServiceData(CldsServiceData cldsServiceData,\r
- String eventName) {\r
+ String eventName) {\r
List<CldsAlarmCondition> alarmCondList = new ArrayList<>();\r
if (cldsServiceData != null && cldsServiceData.getCldsVfs() != null\r
- && !cldsServiceData.getCldsVfs().isEmpty()) {\r
+ && !cldsServiceData.getCldsVfs().isEmpty()) {\r
for (CldsVfData currCldsVfData : cldsServiceData.getCldsVfs()) {\r
alarmCondList.addAll(getAllAlarmConditionsFromCldsVfData(currCldsVfData, eventName));\r
}\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
+ * The Vf Data to analyze\r
* @param eventName\r
- * The String event name that will be used to filter the alarm\r
- * list\r
+ * The String event name that will be used to filter the alarm list\r
* @return The list of CldsAlarmCondition for the event name specified\r
*/\r
private List<CldsAlarmCondition> getAllAlarmConditionsFromCldsVfData(CldsVfData currCldsVfData, String 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
+ * The VfC Data to analyze\r
* @param eventName\r
- * The String event name that will be used to filter the alarm\r
- * list\r
+ * The String event name that will be used to filter the alarm list\r
* @return The list of CldsAlarmCondition for the event name specified\r
*/\r
private List<CldsAlarmCondition> getAllAlarmConditionsFromCldsVfcData(CldsVfcData currCldsVfcData,\r
- String eventName) {\r
+ String eventName) {\r
List<CldsAlarmCondition> alarmCondList = new ArrayList<>();\r
if (currCldsVfcData != null && currCldsVfcData.getCldsAlarmConditions() != null\r
- && !currCldsVfcData.getCldsAlarmConditions().isEmpty()) {\r
+ && !currCldsVfcData.getCldsAlarmConditions().isEmpty()) {\r
for (CldsAlarmCondition currCldsAlarmCondition : currCldsVfcData.getCldsAlarmConditions()) {\r
if (currCldsAlarmCondition != null\r
- && currCldsAlarmCondition.getEventName().equalsIgnoreCase(eventName)) {\r
+ && currCldsAlarmCondition.getEventName().equalsIgnoreCase(eventName)) {\r
alarmCondList.add(currCldsAlarmCondition);\r
}\r
}\r
return alarmCondList;\r
}\r
\r
- private ObjectNode createAlarmCondObjectNodeByAlarmKey(List<CldsAlarmCondition> cldsAlarmCondList) {\r
- ObjectMapper mapper = JacksonUtils.getObjectMapperInstance();\r
- ObjectNode alarmCondKeyNode = mapper.createObjectNode();\r
+ private JsonObject createAlarmCondObjectNodeByAlarmKey(List<CldsAlarmCondition> cldsAlarmCondList) {\r
+ JsonObject alarmCondKeyNode = new JsonObject();\r
if (cldsAlarmCondList != null && !cldsAlarmCondList.isEmpty()) {\r
for (CldsAlarmCondition currCldsAlarmCondition : cldsAlarmCondList) {\r
if (currCldsAlarmCondition != null) {\r
- ObjectNode alarmCondNode = mapper.createObjectNode();\r
- alarmCondNode.put("eventSourceType", currCldsAlarmCondition.getEventSourceType());\r
- alarmCondNode.put("eventSeverity", currCldsAlarmCondition.getSeverity());\r
- alarmCondKeyNode.putPOJO(currCldsAlarmCondition.getAlarmConditionKey(), alarmCondNode);\r
+ JsonObject alarmCondNode = new JsonObject();\r
+ alarmCondNode.addProperty("eventSourceType", currCldsAlarmCondition.getEventSourceType());\r
+ alarmCondNode.addProperty("eventSeverity", currCldsAlarmCondition.getSeverity());\r
+ alarmCondKeyNode.add(currCldsAlarmCondition.getAlarmConditionKey(), alarmCondNode);\r
}\r
}\r
} else {\r
- ObjectNode alarmCondNode = mapper.createObjectNode();\r
- alarmCondNode.put("eventSourceType", "");\r
- alarmCondNode.put("eventSeverity", "");\r
- alarmCondKeyNode.putPOJO("", alarmCondNode);\r
+ JsonObject alarmCondNode = new JsonObject();\r
+ alarmCondNode.addProperty("eventSourceType", "");\r
+ alarmCondNode.addProperty("eventSeverity", "");\r
+ alarmCondKeyNode.add("", alarmCondNode);\r
}\r
return alarmCondKeyNode;\r
}\r
\r
- private ObjectNode createVfObjectNodeByServiceInvariantUuid(CldsServiceData cldsServiceData) {\r
- ObjectMapper mapper = JacksonUtils.getObjectMapperInstance();\r
- ObjectNode invariantUuidObjectNode = mapper.createObjectNode();\r
- ObjectNode vfObjectNode = mapper.createObjectNode();\r
- ObjectNode vfUuidNode = mapper.createObjectNode();\r
+ private JsonObject createVfObjectNodeByServiceInvariantUuid(CldsServiceData cldsServiceData) {\r
+ JsonObject invariantUuidObjectNode = new JsonObject();\r
+ JsonObject vfObjectNode = new JsonObject();\r
+ JsonObject vfUuidNode = new JsonObject();\r
List<CldsVfData> cldsVfsList = cldsServiceData.getCldsVfs();\r
if (cldsVfsList != null && !cldsVfsList.isEmpty()) {\r
for (CldsVfData currCldsVfData : cldsVfsList) {\r
if (currCldsVfData != null) {\r
- vfUuidNode.put(currCldsVfData.getVfInvariantResourceUUID(), currCldsVfData.getVfName());\r
+ vfUuidNode.addProperty(currCldsVfData.getVfInvariantResourceUUID(), currCldsVfData.getVfName());\r
}\r
}\r
} else {\r
- vfUuidNode.put("", "");\r
+ vfUuidNode.addProperty("", "");\r
}\r
- vfObjectNode.putPOJO("vf", vfUuidNode);\r
- invariantUuidObjectNode.putPOJO(cldsServiceData.getServiceInvariantUUID(), vfObjectNode);\r
+ vfObjectNode.add("vf", vfUuidNode);\r
+ invariantUuidObjectNode.add(cldsServiceData.getServiceInvariantUUID(), vfObjectNode);\r
return invariantUuidObjectNode;\r
}\r
\r
- private void createKpiObjectNodeByVfUuid(ObjectNode vfResourceUuidObjectNode,\r
- List<CldsVfKPIData> cldsVfKpiDataList) {\r
- ObjectMapper mapper = JacksonUtils.getObjectMapperInstance();\r
+ private void createKpiObjectNodeByVfUuid(JsonObject vfResourceUuidObjectNode,\r
+ List<CldsVfKPIData> cldsVfKpiDataList) {\r
if (cldsVfKpiDataList != null && !cldsVfKpiDataList.isEmpty()) {\r
for (CldsVfKPIData currCldsVfKpiData : cldsVfKpiDataList) {\r
if (currCldsVfKpiData != null) {\r
- ObjectNode thresholdNameObjectNode = mapper.createObjectNode();\r
- ObjectNode fieldPathObjectNode = mapper.createObjectNode();\r
- ObjectNode nfNamingCodeNode = mapper.createObjectNode();\r
- fieldPathObjectNode.put(currCldsVfKpiData.getFieldPathValue(),\r
- currCldsVfKpiData.getFieldPathValue());\r
- nfNamingCodeNode.put(currCldsVfKpiData.getNfNamingValue(), currCldsVfKpiData.getNfNamingValue());\r
- thresholdNameObjectNode.putPOJO("fieldPath", fieldPathObjectNode);\r
- thresholdNameObjectNode.putPOJO("nfNamingCode", nfNamingCodeNode);\r
- vfResourceUuidObjectNode.putPOJO(currCldsVfKpiData.getThresholdValue(), thresholdNameObjectNode);\r
+ JsonObject thresholdNameObjectNode = new JsonObject();\r
+ JsonObject fieldPathObjectNode = new JsonObject();\r
+ JsonObject nfNamingCodeNode = new JsonObject();\r
+ fieldPathObjectNode.addProperty(currCldsVfKpiData.getFieldPathValue(),\r
+ currCldsVfKpiData.getFieldPathValue());\r
+ nfNamingCodeNode.addProperty(currCldsVfKpiData.getNfNamingValue(), currCldsVfKpiData.getNfNamingValue());\r
+ thresholdNameObjectNode.add("fieldPath", fieldPathObjectNode);\r
+ thresholdNameObjectNode.add("nfNamingCode", nfNamingCodeNode);\r
+ vfResourceUuidObjectNode.add(currCldsVfKpiData.getThresholdValue(), thresholdNameObjectNode);\r
}\r
}\r
}\r
}\r
\r
- private void createAlarmCondObjectNodeByVfcUuid(ObjectNode vfcResourceUuidObjectNode,\r
- List<CldsVfcData> cldsVfcDataList) {\r
- ObjectMapper mapper = JacksonUtils.getObjectMapperInstance();\r
- ObjectNode vfcObjectNode = mapper.createObjectNode();\r
- ObjectNode alarmCondNode = mapper.createObjectNode();\r
- ObjectNode alertDescNode = mapper.createObjectNode();\r
+ private void createAlarmCondObjectNodeByVfcUuid(JsonObject vfcResourceUuidObjectNode,\r
+ List<CldsVfcData> cldsVfcDataList) {\r
+ JsonObject vfcObjectNode = new JsonObject();\r
+ JsonObject alarmCondNode = new JsonObject();\r
+ JsonObject alertDescNode = new JsonObject();\r
if (cldsVfcDataList != null && !cldsVfcDataList.isEmpty()) {\r
for (CldsVfcData currCldsVfcData : cldsVfcDataList) {\r
if (currCldsVfcData != null) {\r
if (currCldsVfcData.getCldsAlarmConditions() != null\r
- && !currCldsVfcData.getCldsAlarmConditions().isEmpty()) {\r
+ && !currCldsVfcData.getCldsAlarmConditions().isEmpty()) {\r
for (CldsAlarmCondition currCldsAlarmCondition : currCldsVfcData.getCldsAlarmConditions()) {\r
if ("alarmCondition".equalsIgnoreCase(currCldsAlarmCondition.getEventName())) {\r
- alarmCondNode.put(currCldsAlarmCondition.getAlarmConditionKey(),\r
- currCldsAlarmCondition.getAlarmConditionKey());\r
+ alarmCondNode.addProperty(currCldsAlarmCondition.getAlarmConditionKey(),\r
+ currCldsAlarmCondition.getAlarmConditionKey());\r
} else {\r
- alertDescNode.put(currCldsAlarmCondition.getAlarmConditionKey(),\r
- currCldsAlarmCondition.getAlarmConditionKey());\r
+ alertDescNode.addProperty(currCldsAlarmCondition.getAlarmConditionKey(),\r
+ currCldsAlarmCondition.getAlarmConditionKey());\r
}\r
}\r
}\r
- vfcObjectNode.putPOJO("alarmCondition", alarmCondNode);\r
- vfcObjectNode.putPOJO("alertDescription", alertDescNode);\r
- vfcResourceUuidObjectNode.putPOJO(currCldsVfcData.getVfcInvariantResourceUUID(), vfcObjectNode);\r
+ vfcObjectNode.add("alarmCondition", alarmCondNode);\r
+ vfcObjectNode.add("alertDescription", alertDescNode);\r
+ vfcResourceUuidObjectNode.add(currCldsVfcData.getVfcInvariantResourceUUID(), vfcObjectNode);\r
}\r
}\r
} else {\r
- alarmCondNode.put("", "");\r
- vfcObjectNode.putPOJO("alarmCondition", alarmCondNode);\r
- alertDescNode.put("", "");\r
- vfcObjectNode.putPOJO("alertDescription", alarmCondNode);\r
- vfcResourceUuidObjectNode.putPOJO("", vfcObjectNode);\r
+ alarmCondNode.addProperty("", "");\r
+ vfcObjectNode.add("alarmCondition", alarmCondNode);\r
+ alertDescNode.addProperty("", "");\r
+ vfcObjectNode.add("alertDescription", alarmCondNode);\r
+ vfcResourceUuidObjectNode.add("", vfcObjectNode);\r
}\r
}\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
- private ObjectNode createVfcObjectNodeByVfUuid(List<CldsVfData> cldsVfDataList) {\r
- ObjectMapper mapper = JacksonUtils.getObjectMapperInstance();\r
- ObjectNode vfUuidObjectNode = mapper.createObjectNode();\r
+ private JsonObject createVfcObjectNodeByVfUuid(List<CldsVfData> cldsVfDataList) {\r
+ JsonObject vfUuidObjectNode = new JsonObject();\r
if (cldsVfDataList != null && !cldsVfDataList.isEmpty()) {\r
for (CldsVfData currCldsVfData : cldsVfDataList) {\r
if (currCldsVfData != null) {\r
- ObjectNode vfObjectNode = mapper.createObjectNode();\r
- ObjectNode vfcUuidNode = mapper.createObjectNode();\r
- ObjectNode kpiObjectNode = mapper.createObjectNode();\r
+ JsonObject vfObjectNode = new JsonObject();\r
+ JsonObject vfcUuidNode = new JsonObject();\r
+ JsonObject kpiObjectNode = new JsonObject();\r
if (currCldsVfData.getCldsVfcs() != null && !currCldsVfData.getCldsVfcs().isEmpty()) {\r
for (CldsVfcData currCldsVfcData : currCldsVfData.getCldsVfcs()) {\r
if (currCldsVfcData.getCldsAlarmConditions() != null\r
- && !currCldsVfcData.getCldsAlarmConditions().isEmpty()) {\r
- vfcUuidNode.put(currCldsVfcData.getVfcInvariantResourceUUID(),\r
- currCldsVfcData.getVfcName());\r
+ && !currCldsVfcData.getCldsAlarmConditions().isEmpty()) {\r
+ vfcUuidNode.addProperty(currCldsVfcData.getVfcInvariantResourceUUID(),\r
+ currCldsVfcData.getVfcName());\r
}\r
}\r
} else {\r
- vfcUuidNode.put("", "");\r
+ vfcUuidNode.addProperty("", "");\r
}\r
if (currCldsVfData.getCldsKPIList() != null && !currCldsVfData.getCldsKPIList().isEmpty()) {\r
for (CldsVfKPIData currCldsVfKPIData : currCldsVfData.getCldsKPIList()) {\r
- kpiObjectNode.put(currCldsVfKPIData.getThresholdValue(),\r
- currCldsVfKPIData.getThresholdValue());\r
+ // ToDo: something wrong happened here\r
+ kpiObjectNode.addProperty(currCldsVfKPIData.getThresholdValue(),\r
+ currCldsVfKPIData.getThresholdValue());\r
}\r
} else {\r
- kpiObjectNode.put("", "");\r
+ kpiObjectNode.addProperty("", "");\r
}\r
- vfObjectNode.putPOJO("vfc", vfcUuidNode);\r
- vfObjectNode.putPOJO("kpi", kpiObjectNode);\r
- vfUuidObjectNode.putPOJO(currCldsVfData.getVfInvariantResourceUUID(), vfObjectNode);\r
+ vfObjectNode.add("vfc", vfcUuidNode);\r
+ vfObjectNode.add("kpi", kpiObjectNode);\r
+ vfUuidObjectNode.add(currCldsVfData.getVfInvariantResourceUUID(), vfObjectNode);\r
}\r
}\r
} else {\r
- ObjectNode vfcUuidNode = mapper.createObjectNode();\r
- vfcUuidNode.put("", "");\r
- ObjectNode vfcObjectNode = mapper.createObjectNode();\r
- vfcObjectNode.putPOJO("vfc", vfcUuidNode);\r
- vfUuidObjectNode.putPOJO("", vfcObjectNode);\r
+ JsonObject vfcUuidNode = new JsonObject();\r
+ vfcUuidNode.addProperty("", "");\r
+ JsonObject vfcObjectNode = new JsonObject();\r
+ vfcObjectNode.add("vfc", vfcUuidNode);\r
+ vfUuidObjectNode.add("", vfcObjectNode);\r
}\r
return vfUuidObjectNode;\r
}\r
\r
- /**\r
- * This method searches the equivalent artifact UUID for a specific\r
- * artifactName in a SdcServiceDetail.\r
- * \r
- * @param cldsSdcServiceDetail\r
- * The SdcServiceDetail that will be analyzed\r
- * @param artifactName\r
- * The artifact name that will be searched\r
- * @return The artifact UUID found\r
- */\r
- public String getArtifactIdIfArtifactAlreadyExists(SdcServiceDetail cldsSdcServiceDetail, String artifactName) {\r
- String artifactUuid = null;\r
- boolean artifactExists = false;\r
- if (cldsSdcServiceDetail != null && cldsSdcServiceDetail.getResources() != null\r
- && !cldsSdcServiceDetail.getResources().isEmpty()) {\r
- for (SdcResource currCldsSdcResource : cldsSdcServiceDetail.getResources()) {\r
- if (artifactExists) {\r
- break;\r
- }\r
- if (currCldsSdcResource != null && currCldsSdcResource.getArtifacts() != null\r
- && !currCldsSdcResource.getArtifacts().isEmpty()) {\r
- for (SdcArtifact currCldsSdcArtifact : currCldsSdcResource.getArtifacts()) {\r
- if (currCldsSdcArtifact != null && currCldsSdcArtifact.getArtifactName() != null\r
- && currCldsSdcArtifact.getArtifactName().equalsIgnoreCase(artifactName)) {\r
- artifactUuid = currCldsSdcArtifact.getArtifactUUID();\r
- artifactExists = true;\r
- break;\r
- }\r
- }\r
- }\r
- }\r
- }\r
- return artifactUuid;\r
- }\r
-\r
// To get all sdc VF/VFC Resources basic info.\r
private List<SdcResourceBasicInfo> getAllSdcVForVfcResourcesBasedOnResourceType(String resourceType) {\r
String catalogUrl = refProp.getStringValue(SDC_CATALOG_URL_PROPERTY_NAME);\r
}\r
\r
private String getResourceUuidFromResourceInvariantUuid(String resourceInvariantUuid,\r
- List<SdcResourceBasicInfo> resourceInfoList) {\r
+ List<SdcResourceBasicInfo> resourceInfoList) {\r
String resourceUuid = null;\r
if (resourceInfoList != null && !resourceInfoList.isEmpty()) {\r
for (SdcResourceBasicInfo currResource : resourceInfoList) {\r
if (currResource != null && currResource.getInvariantUUID() != null && currResource.getUuid() != null\r
- && currResource.getInvariantUUID().equalsIgnoreCase(resourceInvariantUuid)) {\r
+ && currResource.getInvariantUUID().equalsIgnoreCase(resourceInvariantUuid)) {\r
resourceUuid = currResource.getUuid();\r
break;\r
}\r
}\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
- if (globalProps != null && globalProps.getService() != null) {\r
- invariantUuid = globalProps.getService();\r
- }\r
- return invariantUuid;\r
- }\r
-\r
- /**\r
- * This method upload the BluePrint to SDC.\r
- * \r
- * @param prop\r
- * The Clds model Properties\r
- * @param userid\r
- * The user id for SDC\r
- * @param sdcReqUrlsList\r
- * The list of SDC URL to try\r
- * @param formattedSdcReq\r
- * The blueprint to upload\r
- * @param formattedSdcLocationReq\r
- * THe location Blueprint to upload\r
- * @param artifactName\r
- * The artifact name from where we can get the Artifact UUID\r
- * @param locationArtifactName\r
- * The location artifact name from where we can get the Artifact\r
- * UUID\r
- * @throws GeneralSecurityException\r
- * In case of issues with the decryting the encrypted password\r
- * @throws DecoderException\r
- * In case of issues with the decoding of the Hex String\r
- */\r
- public void uploadToSdc(ModelProperties prop, String userid, List<String> sdcReqUrlsList, String formattedSdcReq,\r
- String formattedSdcLocationReq, String artifactName, String locationArtifactName)\r
- throws GeneralSecurityException, DecoderException {\r
- logger.info("userid=" + userid);\r
- String serviceInvariantUuid = getServiceInvariantUuidFromProps(prop);\r
- if (sdcReqUrlsList != null && !sdcReqUrlsList.isEmpty()) {\r
- for (String url : sdcReqUrlsList) {\r
- if (url != null) {\r
- String originalServiceUuid = getServiceUuidFromServiceInvariantId(serviceInvariantUuid);\r
- logger.info("ServiceUUID used before upload in url:" + originalServiceUuid);\r
- String sdcServicesInformation = getSdcServicesInformation(originalServiceUuid);\r
- SdcServiceDetail cldsSdcServiceDetail = decodeCldsSdcServiceDetailFromJson(sdcServicesInformation);\r
- String uploadedArtifactUuid = getArtifactIdIfArtifactAlreadyExists(cldsSdcServiceDetail,\r
- artifactName);\r
- // Upload artifacts to sdc\r
- String updateUrl = uploadedArtifactUuid != null ? url + "/" + uploadedArtifactUuid : url;\r
- String responseStr = uploadArtifactToSdc(prop, userid, updateUrl, formattedSdcReq);\r
- logger.info("value of sdc Response of uploading to sdc :" + responseStr);\r
- String updatedServiceUuid = getServiceUuidFromServiceInvariantId(serviceInvariantUuid);\r
- if (!originalServiceUuid.equalsIgnoreCase(updatedServiceUuid)) {\r
- url = url.replace(originalServiceUuid, updatedServiceUuid);\r
- }\r
- logger.info("ServiceUUID used after upload in ulr:" + updatedServiceUuid);\r
- sdcServicesInformation = getSdcServicesInformation(updatedServiceUuid);\r
- cldsSdcServiceDetail = decodeCldsSdcServiceDetailFromJson(sdcServicesInformation);\r
- uploadedArtifactUuid = getArtifactIdIfArtifactAlreadyExists(cldsSdcServiceDetail,\r
- locationArtifactName);\r
- // To send location information also to sdc\r
- updateUrl = uploadedArtifactUuid != null ? url + "/" + uploadedArtifactUuid : url;\r
- responseStr = uploadArtifactToSdc(prop, userid, updateUrl, formattedSdcLocationReq);\r
- logger.info("value of sdc Response of uploading location to sdc :" + responseStr);\r
- }\r
- }\r
- }\r
- }\r
}\r