/**
* Construct an Operational Policy request given CLDS objects.
*/
-public class OperationalPolicyReq {
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(OperationalPolicyReq.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
+public final class OperationalPolicyReq {
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(OperationalPolicyReq.class);
private OperationalPolicyReq() {
}
return attributes;
}
- /**
- * Format Operational Policy yaml.
- *
- * @param refProp
- * @param prop
- * @return
- * @throws BuilderException
- * @throws UnsupportedEncodingException
- */
- public static String formatYaml(RefProp refProp, ModelProperties prop, String modelElementId,
+ private static String formatYaml(RefProp refProp, ModelProperties prop, String modelElementId,
PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException {
// get property objects
Global global = prop.getGlobal();
return URLEncoder.encode(results.getSpecification(), "UTF-8");
}
- /**
- * Format Operational Policy yaml.
- *
- * @param refProp
- * @param prop
- * @return
- * @throws BuilderException
- * @throws UnsupportedEncodingException
- */
- public static String formateNodeBYaml(RefProp refProp, ModelProperties prop, String modelElementId,
+ private static String formateNodeBYaml(RefProp refProp, ModelProperties prop, String modelElementId,
PolicyChain policyChain) throws BuilderException, UnsupportedEncodingException {
// get property objects
Global global = prop.getGlobal();
if (results.isValid()) {
logger.info("results.getSpecification()=" + results.getSpecification());
} else {
- // throw exception with error info
StringBuilder sb = new StringBuilder();
sb.append("Operation Policy validation problem: ControlLoopPolicyBuilder failed with following messages: ");
for (Message message : results.getMessages()) {
}
}
- /**
- * Adding AOTS actor and other recipe for yaml
- *
- * @param inOrigList
- * @return
- */
- private static List<PolicyItem> addAOTSActorRecipe(RefProp refProp, String service, List<PolicyItem> inOrigList) {
+ // Adding AOTS actor and other recipe for yaml
+ private static List<PolicyItem> addAOTSActorRecipe(RefProp refProp, String service, List<PolicyItem> inOrigList) {
List<PolicyItem> outList = new ArrayList<>();
try {
PolicyItem policyItem = inOrigList.get(0);
return outList;
}
- /**
- * Order list of PolicyItems so that parents come before any of their
- * children
- *
- * @param inOrigList
- * @return
- */
- private static List<PolicyItem> orderParentFirst(List<PolicyItem> inOrigList) {
+ // Order list of PolicyItems so that parents come before any of their children
+ private static List<PolicyItem> orderParentFirst(List<PolicyItem> inOrigList) {
List<PolicyItem> inList = new ArrayList<>();
inList.addAll(inOrigList);
List<PolicyItem> outList = new ArrayList<>();
return outList;
}
- /**
- * Convert a List of resource strings to an array of Resource objects.
- *
- * @param stringList
- * @param resourceType
- * @return
- */
private static Resource[] convertToResource(List<String> stringList, ResourceType resourceType) {
if (stringList == null || stringList.isEmpty()) {
return new Resource[0];
return stringList.stream().map(stringElem -> new Resource(stringElem, resourceType)).toArray(Resource[]::new);
}
- /**
- * Convert a List of policy result strings to an array of PolicyResult
- * objects.
- *
- * @param prList
- * @return
- */
private static PolicyResult[] convertToPolicyResult(List<String> prList) {
if (prList == null || prList.isEmpty()) {
return new PolicyResult[0];
* Policy utility methods - specifically, send the policy.
*/
public class PolicyClient {
-
protected static final String POLICY_PREFIX_BASE = "Config_";
- protected static final String POLICY_PREFIX_BRMS_PARAM = "Config_BRMS_Param_";
- protected static final String POLICY_PREFIX_MICROSERVICE = "Config_MS_";
protected static final String LOG_POLICY_PREFIX = "Response is ";
protected static final EELFLogger logger = EELFManager.getInstance().getLogger(PolicyClient.class);
protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
PolicyParameters policyParameters = new PolicyParameters();
// Set Policy Type
policyParameters.setPolicyConfigType(PolicyConfigType.MicroService);
- // policyParameters.setOnapName(refProp.getStringValue(POLICY_ONAPNAME_PROPERTY_NAME));
policyParameters.setEcompName(refProp.getStringValue(POLICY_ONAPNAME_PROPERTY_NAME));
policyParameters.setPolicyName(prop.getCurrentPolicyScopeAndPolicyName());
policyParameters.setConfigBody(configBody);
return versions;
}
- /**
- * This method create a new policy engine.
- *
- * @return A new policy engine
- */
private PolicyEngine getPolicyEngine() {
PolicyEngine policyEngine;
try {
import org.springframework.beans.factory.annotation.Autowired;\r
\r
public class SdcCatalogServices {\r
- protected static final EELFLogger logger = EELFManager.getInstance()\r
- .getLogger(SdcCatalogServices.class);\r
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();\r
- private static final String RESOURCE_VF_TYPE = "VF";\r
- private static final String RESOURCE_VFC_TYPE = "VFC";\r
- private static final String RESOURCE_CVFC_TYPE = "CVFC";\r
- public static final String SDC_REQUESTID_PROPERTY_NAME = "sdc.header.requestId";\r
- private static final String SDC_METADATA_URL_PREFIX = "/metadata";\r
- private static final String SDC_INSTANCE_ID_PROPERTY_NAME = "sdc.InstanceID";\r
- private static final String SDC_CATALOG_URL_PROPERTY_NAME = "sdc.catalog.url";\r
- private static final String SDC_SERVICE_URL_PROPERTY_NAME = "sdc.serviceUrl";\r
- private static final String SDC_INSTANCE_ID_CLAMP = "CLAMP-Tool";\r
- private static final String RESOURCE_URL_PREFIX = "resources";\r
+\r
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcCatalogServices.class);\r
+ private static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();\r
+ private static final String RESOURCE_VF_TYPE = "VF";\r
+ private static final String RESOURCE_VFC_TYPE = "VFC";\r
+ private static final String RESOURCE_CVFC_TYPE = "CVFC";\r
+ private static final String SDC_REQUESTID_PROPERTY_NAME = "sdc.header.requestId";\r
+ private static final String SDC_METADATA_URL_PREFIX = "/metadata";\r
+ private static final String SDC_INSTANCE_ID_PROPERTY_NAME = "sdc.InstanceID";\r
+ private static final String SDC_CATALOG_URL_PROPERTY_NAME = "sdc.catalog.url";\r
+ private static final String SDC_SERVICE_URL_PROPERTY_NAME = "sdc.serviceUrl";\r
+ private static final String SDC_INSTANCE_ID_CLAMP = "CLAMP-Tool";\r
+ private static final String RESOURCE_URL_PREFIX = "resources";\r
@Autowired\r
- private RefProp refProp;\r
- protected CryptoUtils cryptoUtils = new CryptoUtils();\r
+ private RefProp refProp;\r
+ private CryptoUtils cryptoUtils = new CryptoUtils();\r
\r
- /**\r
- * Return SDC id and pw as a HTTP Basic Auth string (for example: Basic\r
- * dGVzdDoxMjM0NTY=).\r
- *\r
- * @return The String with Basic Auth and password\r
- * @throws GeneralSecurityException\r
- * In case of issue when decryting the SDC password\r
- * @throws DecoderException\r
- * In case of issues with the decoding of the HexString message\r
- */\r
+ // returns SDC id and password as a HTTP Basic Auth string (for example: Basic dGVzdDoxMjM0NTY=)\r
private String getSdcBasicAuth() throws GeneralSecurityException, DecoderException {\r
String sdcId = refProp.getStringValue("sdc.serviceUsername");\r
String sdcPw = refProp.getStringValue("sdc.servicePassword");\r
/**\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\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\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
- public List<CldsSdcServiceInfo> getCldsSdcServicesListFromJson(String jsonStr) {\r
+ private List<CldsSdcServiceInfo> getCldsSdcServicesListFromJson(String jsonStr) {\r
ObjectMapper objectMapper = new ObjectMapper();\r
if (StringUtils.isBlank(jsonStr)) {\r
return new ArrayList<>();\r
}\r
}\r
\r
- /**\r
- * To get List of CldsSdcResourceBasicInfo class by parsing json string.\r
- *\r
- * @param jsonStr\r
- * The JSOn string that must be decoded\r
- * @return The list of CldsSdcResourceBasicInfo, an empty list in case of\r
- * issues\r
- */\r
- public List<CldsSdcResourceBasicInfo> getAllSdcResourcesListFromJson(String jsonStr) {\r
+ private List<CldsSdcResourceBasicInfo> getAllSdcResourcesListFromJson(String jsonStr) {\r
ObjectMapper objectMapper = new ObjectMapper();\r
if (StringUtils.isBlank(jsonStr)) {\r
return new ArrayList<>();\r
}\r
}\r
\r
- /**\r
- * To get CldsAsdsResource class by parsing json string.\r
- * \r
- * @param jsonStr\r
- * @return\r
- * @throws IOException\r
- */\r
- public CldsSdcResource getCldsSdcResourceFromJson(String jsonStr) throws IOException {\r
- ObjectMapper objectMapper = new ObjectMapper();\r
- return objectMapper.readValue(jsonStr, CldsSdcResource.class);\r
- }\r
-\r
/**\r
* To get CldsSdcServiceDetail by parsing json string.\r
- * \r
+ *\r
* @param jsonStr\r
* @return\r
*/\r
}\r
}\r
\r
- /**\r
- * To upload artifact to sdc based on serviceUUID and resource name on url.\r
- * \r
- * @param prop\r
- * @param userid\r
- * @param url\r
- * @param formattedSdcReq\r
- * @return\r
- * @throws GeneralSecurityException\r
- */\r
- public String uploadArtifactToSdc(ModelProperties prop, String userid, String url, String formattedSdcReq)\r
- throws GeneralSecurityException {\r
+\r
+ // upload artifact to sdc based on serviceUUID and resource name on url\r
+ private String uploadArtifactToSdc(ModelProperties prop, String userid, String url, String formattedSdcReq) {\r
// Verify whether it is triggered by Validation Test button from UI\r
if (prop.isTestOnly()) {\r
return "sdc artifact upload not executed for test action";\r
}\r
}\r
\r
- private HttpURLConnection getSdcHttpUrlConnection(String userid, int postDataLength, String url, String content)\r
- throws GeneralSecurityException {\r
+ private HttpURLConnection getSdcHttpUrlConnection(String userid, int postDataLength, String url, String content) {\r
try {\r
logger.info("userid=" + userid);\r
String basicAuth = getSdcBasicAuth();\r
\r
/**\r
* Check if the SDC Info in cache has expired.\r
- * \r
+ *\r
* @param cldsServiceData\r
- * @return\r
* @throws GeneralSecurityException\r
* In case of issues with the decryting the encrypted password\r
* @throws DecoderException\r
}\r
\r
/**\r
- * Get the Service Data with Alarm Conditions for a given\r
- * invariantServiceUuid.\r
- * \r
+ * Get the Service Data with Alarm Conditions for a given invariantServiceUuid.\r
+ *\r
* @param invariantServiceUuid\r
- * @return\r
* @throws GeneralSecurityException\r
* In case of issues with the decryting the encrypted password\r
* @throws DecoderException\r
String catalogUrl = refProp.getStringValue(SDC_CATALOG_URL_PROPERTY_NAME);\r
String serviceUuid = getServiceUuidFromServiceInvariantId(invariantServiceUuid);\r
String serviceDetailUrl = url + "/" + serviceUuid + SDC_METADATA_URL_PREFIX;\r
- String responseStr = getCldsServicesOrResourcesBasedOnURL(serviceDetailUrl, false);\r
+ String responseStr = getCldsServicesOrResourcesBasedOnURL(serviceDetailUrl);\r
ObjectMapper objectMapper = new ObjectMapper();\r
CldsServiceData cldsServiceData = new CldsServiceData();\r
if (responseStr != null) {\r
if (resourceUuid != null) {\r
String vfResourceUuidUrl = catalogUrl + RESOURCE_URL_PREFIX + "/" + resourceUuid\r
+ SDC_METADATA_URL_PREFIX;\r
- String vfResponse = getCldsServicesOrResourcesBasedOnURL(vfResourceUuidUrl, false);\r
+ String vfResponse = getCldsServicesOrResourcesBasedOnURL(vfResourceUuidUrl);\r
if (vfResponse != null) {\r
// Below 2 line are to get the KPI(field path) data\r
// associated with the VF's\r
String vfcResourceUuidUrl = catalogUrl + RESOURCE_URL_PREFIX + "/"\r
+ resourceVfcUuid + SDC_METADATA_URL_PREFIX;\r
String vfcResponse = getCldsServicesOrResourcesBasedOnURL(\r
- vfcResourceUuidUrl, false);\r
+ vfcResourceUuidUrl);\r
if (vfcResponse != null) {\r
List<CldsAlarmCondition> alarmCondtionsFromVfc = getAlarmCondtionsFromVfc(\r
vfcResponse);\r
List<CldsVfcData> cldsVfcDataList = new ArrayList<>();\r
if (vfcArrayNode != null) {\r
for (JsonNode vfcjsonNode : vfcArrayNode) {\r
- CldsVfcData currCldsVfcData = new CldsVfcData();\r
ObjectNode currVfcNode = (ObjectNode) vfcjsonNode;\r
TextNode resourceTypeNode = (TextNode) currVfcNode.get("resoucreType");\r
if (resourceTypeNode != null && "VFC".equalsIgnoreCase(resourceTypeNode.textValue())) {\r
- TextNode vfcResourceName = (TextNode) currVfcNode.get("resourceInstanceName");\r
- TextNode vfcInvariantResourceUuid = (TextNode) currVfcNode.get("resourceInvariantUUID");\r
- currCldsVfcData.setVfcName(vfcResourceName.textValue());\r
- currCldsVfcData.setVfcInvariantResourceUUID(vfcInvariantResourceUuid.textValue());\r
- cldsVfcDataList.add(currCldsVfcData);\r
+ handleVFCtypeNode(currVfcNode, cldsVfcDataList);\r
} else if (resourceTypeNode != null && "CVFC".equalsIgnoreCase(resourceTypeNode.textValue())) {\r
- TextNode vfcResourceName = (TextNode) currVfcNode.get("resourceInstanceName");\r
- TextNode vfcInvariantResourceUuid = (TextNode) currVfcNode.get("resourceInvariantUUID");\r
- currCldsVfcData.setVfcName(vfcResourceName.textValue());\r
- currCldsVfcData.setVfcInvariantResourceUUID(vfcInvariantResourceUuid.textValue());\r
- cldsVfcDataList.add(currCldsVfcData);\r
- cldsVfcDataList.addAll(getVFCfromCVFC(currVfcNode.get("resourceUUID").textValue()));\r
+ handleCVFCtypeNode(currVfcNode, cldsVfcDataList);\r
}\r
}\r
}\r
return cldsVfcDataList;\r
}\r
\r
- private List<CldsVfcData> getVFCfromCVFC(String resourceUUID) throws GeneralSecurityException {\r
+ private void handleVFCtypeNode(ObjectNode currVfcNode, List<CldsVfcData> cldsVfcDataList) {\r
+ CldsVfcData currCldsVfcData = new CldsVfcData();\r
+ TextNode vfcResourceName = (TextNode) currVfcNode.get("resourceInstanceName");\r
+ TextNode vfcInvariantResourceUuid = (TextNode) currVfcNode.get("resourceInvariantUUID");\r
+ currCldsVfcData.setVfcName(vfcResourceName.textValue());\r
+ currCldsVfcData.setVfcInvariantResourceUUID(vfcInvariantResourceUuid.textValue());\r
+ cldsVfcDataList.add(currCldsVfcData);\r
+ }\r
+\r
+ private void handleCVFCtypeNode(ObjectNode currVfcNode, List<CldsVfcData> cldsVfcDataList) {\r
+ handleVFCtypeNode(currVfcNode, cldsVfcDataList);\r
+ cldsVfcDataList.addAll(getVFCfromCVFC(currVfcNode.get("resourceUUID").textValue()));\r
+ }\r
+\r
+ private List<CldsVfcData> getVFCfromCVFC(String resourceUUID) {\r
String catalogUrl = refProp.getStringValue(SDC_CATALOG_URL_PROPERTY_NAME);\r
List<CldsVfcData> cldsVfcDataList = new ArrayList<>();\r
if (resourceUUID != null) {\r
String vfcResourceUUIDUrl = catalogUrl + RESOURCE_URL_PREFIX + "/" + resourceUUID + SDC_METADATA_URL_PREFIX;\r
try {\r
- String vfcResponse = getCldsServicesOrResourcesBasedOnURL(vfcResourceUUIDUrl, false);\r
+ String vfcResponse = getCldsServicesOrResourcesBasedOnURL(vfcResourceUUIDUrl);\r
ObjectMapper mapper = new ObjectMapper();\r
ObjectNode vfResponseNode = (ObjectNode) mapper.readTree(vfcResponse);\r
ArrayNode vfcArrayNode = (ArrayNode) vfResponseNode.get("resources");\r
if (vfcArrayNode != null) {\r
for (JsonNode vfcjsonNode : vfcArrayNode) {\r
- CldsVfcData currCldsVfcData = new CldsVfcData();\r
ObjectNode currVfcNode = (ObjectNode) vfcjsonNode;\r
TextNode resourceTypeNode = (TextNode) currVfcNode.get("resoucreType");\r
if (resourceTypeNode != null && "VFC".equalsIgnoreCase(resourceTypeNode.textValue())) {\r
- TextNode vfcResourceName = (TextNode) currVfcNode.get("resourceInstanceName");\r
- TextNode vfcInvariantResourceUUID = (TextNode) currVfcNode.get("resourceInvariantUUID");\r
- currCldsVfcData.setVfcName(vfcResourceName.textValue());\r
- currCldsVfcData.setVfcInvariantResourceUUID(vfcInvariantResourceUUID.textValue());\r
- cldsVfcDataList.add(currCldsVfcData);\r
+ handleVFCtypeNode(currVfcNode, cldsVfcDataList);\r
}\r
}\r
}\r
cldsAlarmConditionList.add(cldsAlarmCondition);\r
}\r
\r
- /**\r
- * Get the responses for the current artifact from the artifacts URL.\r
- * \r
- * @param artifactsUrl\r
- * @return\r
- * @throws GeneralSecurityException\r
- */\r
- public String getResponsesFromArtifactUrl(String artifactsUrl) throws GeneralSecurityException {\r
+ private String getResponsesFromArtifactUrl(String artifactsUrl) {\r
String hostUrl = refProp.getStringValue("sdc.hostUrl");\r
String artifactsUrlReworked = artifactsUrl.replaceAll("\"", "");\r
String artifactUrl = hostUrl + artifactsUrlReworked;\r
logger.info("value of artifactURl:" + artifactUrl);\r
- String currArtifactResponse = getCldsServicesOrResourcesBasedOnURL(artifactUrl, true);\r
+ String currArtifactResponse = getCldsServicesOrResourcesBasedOnURL(artifactUrl);\r
logger.info("value of artifactResponse:" + currArtifactResponse);\r
return currArtifactResponse;\r
}\r
/**\r
* Service to services/resources/artifacts from sdc.Pass alarmConditions as\r
* true to get alarm conditons from artifact url and else it is false\r
- * \r
- * @param url\r
- * @param alarmConditions\r
- * @return\r
- * @throws GeneralSecurityException\r
- * In case of issue when decrypting the SDC password\r
- * \r
*/\r
- public String getCldsServicesOrResourcesBasedOnURL(String url, boolean alarmConditions)\r
- throws GeneralSecurityException {\r
+ public String getCldsServicesOrResourcesBasedOnURL(String url) {\r
Date startTime = new Date();\r
try {\r
LoggingUtils.setTargetContext("SDC", "getCldsServicesOrResourcesBasedOnURL");\r
\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
- /**\r
- * To get all sdc VF/VFC Resources basic info.\r
- * \r
- * @param resourceType\r
- * The resourceType\r
- * @return The list of CldsSdcResourceBasicInfo\r
- * @throws GeneralSecurityException\r
- * In case of issue when decryting the SDC password\r
- * \r
- */\r
- private List<CldsSdcResourceBasicInfo> getAllSdcVForVfcResourcesBasedOnResourceType(String resourceType)\r
- throws GeneralSecurityException {\r
+ private List<CldsSdcResourceBasicInfo> getAllSdcVForVfcResourcesBasedOnResourceType(String resourceType) {\r
String catalogUrl = refProp.getStringValue(SDC_CATALOG_URL_PROPERTY_NAME);\r
String resourceUrl = catalogUrl + "resources?resourceType=" + resourceType;\r
- String allSdcVfcResources = getCldsServicesOrResourcesBasedOnURL(resourceUrl, false);\r
+ String allSdcVfcResources = getCldsServicesOrResourcesBasedOnURL(resourceUrl);\r
return removeDuplicateSdcResourceBasicInfo(getAllSdcResourcesListFromJson(allSdcVfcResources));\r
}\r
\r
return resourceUuid;\r
}\r
\r
- /**\r
- * Method to get service invariant uuid from model properties.\r
- * \r
- * @param props\r
- * The Clds model properties\r
- * @return The Service Id\r
- */\r
private String getServiceInvariantUuidFromProps(ModelProperties props) {\r
String invariantUuid = "";\r
Global globalProps = props.getGlobal();\r
\r
/**\r
* This method upload the BluePrint to SDC.\r
- * \r
+ *\r
* @param prop\r
* The Clds model Properties\r
* @param userid\r
import com.att.ajsc.common.AjscProvider;
import com.att.ajsc.common.AjscService;
-import java.security.GeneralSecurityException;
import java.util.ArrayList;
import java.util.List;
*/
@Repository("cldsDao")
public class CldsDao {
-
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsDao.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(CldsDao.class);
private JdbcTemplate jdbcTemplateObject;
private SimpleJdbcCall procGetModel;
private SimpleJdbcCall procGetModelTemplate;
return getModel(null, controlNameUuid);
}
- /**
- * Get a model from the database given the model name or a controlNameUuid.
- *
- * @param modelName
- * @return model
- */
+ // Get a model from the database given the model name or a controlNameUuid.
private CldsModel getModel(String modelName, String controlNameUuid) {
CldsModel model = new CldsModel();
model.setName(modelName);
}
}
- /**
- * Delete a list of modelInstance from the database using parameter values
- * and returns updated model object. This method is defunct - DCAE Proxy
- * will not undeploy individual instances. It will send an empty list of
- * deployed instances to indicate all have been removed. Or it will send an
- * updated list to indicate those that are still deployed with any not on
- * the list considered undeployed.
- *
- * @param controlNameUUid
- * @param modelInstancesList
- * @return
- */
- private CldsModel delModelInstance(String controlNameUUid, List<CldsModelInstance> modelInstancesList) {
- CldsModel model = new CldsModel();
- for (CldsModelInstance currModelInstance : modelInstancesList) {
- SqlParameterSource in = new MapSqlParameterSource().addValue("v_control_name_uuid", controlNameUUid)
- .addValue("v_vm_name", currModelInstance.getVmName());
- Map<String, Object> out = logSqlExecution(procDelModelInstance, in);
- model.setId((String) (out.get("v_model_id")));
- }
- return model;
- }
-
/**
* Insert an event in the database - require either modelName or
* controlNamePrefix/controlNameUuid.
return event;
}
- /**
- * Method to delete all model instances based on controlNameUUID
- *
- * @param controlNameUUid
- * @return
- */
private String delAllModelInstances(String controlNameUUid) {
SqlParameterSource in = new MapSqlParameterSource().addValue("v_control_name_uuid", controlNameUUid);
Map<String, Object> out = logSqlExecution(procDelAllModelInstances, in);
package org.onap.clamp.clds.model.refprop;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-
-import javax.annotation.PostConstruct;
-
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.core.io.Resource;
+import javax.annotation.PostConstruct;
+import java.io.IOException;
+import java.util.Properties;
+
/**
* Holds reference properties.
*/
public class RefProp {
- protected static final EELFLogger logger = EELFManager.getInstance().getLogger(RefProp.class);
- protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();
@Autowired
- private ApplicationContext appContext;
-
- private Properties prop;
-
+ private ApplicationContext appContext;
+ private Properties prop;
@Value("${org.onap.clamp.config.files.cldsReference:'classpath:/clds/clds-reference.properties'}")
- private String cldsReferenceValuesFile;
+ private String cldsReferenceValuesFile;
@PostConstruct
public void loadConfig() throws IOException {
return objectMapper.readValue(getStringValue(key1, key2), JsonNode.class);
}
- /**
- * Get list of values for a property field containing json and a
- * field/keyword within that json.
- *
- * @param fieldName
- * @param value
- * @return
- * @throws IOException
- */
- public List<String> decodeToList(String fieldName, String value) throws IOException {
- JsonNode decode = getJsonTemplate(fieldName);
- Iterator<JsonNode> itr = decode.path(value).elements();
- ArrayList<String> al = new ArrayList<>();
- while (itr.hasNext()) {
- JsonNode node = itr.next();
- al.add(node.asText());
- }
- return al;
- }
-
}
private SdcCatalogServices sdcCatalogWired = new SdcCatalogServices();
@Test
- public void removeDuplicateServicesTest() throws Exception {
+ public void removeDuplicateServicesTest() {
CldsSdcServiceInfo service1a = new CldsSdcServiceInfo();
service1a.setName("service1");
service1a.setVersion("1.0");
service1a.setInvariantUUID("invariantUUID1.0");
- List<CldsSdcServiceInfo> rawCldsSdcServiceList = new LinkedList<CldsSdcServiceInfo>();
+ List<CldsSdcServiceInfo> rawCldsSdcServiceList = new LinkedList<>();
rawCldsSdcServiceList.add(service1a);
rawCldsSdcServiceList.add(service1a);
@Test
public void removeDuplicateSdcResourceInstancesTest() {
- List<CldsSdcResource> rawCldsSdcResourceList = new LinkedList<CldsSdcResource>();
+ List<CldsSdcResource> rawCldsSdcResourceList = new LinkedList<>();
CldsSdcResource sdcResource1a = new CldsSdcResource();
sdcResource1a.setResourceInstanceName("resource1");
@Test
public void removeDuplicateSdcResourceBasicInfoTest() {
- List<CldsSdcResourceBasicInfo> rawCldsSdcResourceList = new LinkedList<CldsSdcResourceBasicInfo>();
+ List<CldsSdcResourceBasicInfo> rawCldsSdcResourceList = new LinkedList<>();
CldsSdcResourceBasicInfo sdcResource1a = new CldsSdcResourceBasicInfo();
sdcResource1a.setName("resource1");
+ "/29018914-966c-442d-9d08-251b9dc45b8f/metadata";
Mockito.doReturn(IOUtils.toString(
SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcServiceDetailsExample.json"),
- "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(serviceResourceDetailUrl, false);
+ "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(serviceResourceDetailUrl);
String resourceDetailUrl = refProp.getStringValue("sdc.catalog.url")
+ "resources/585822c7-4027-4f84-ba50-e9248606f136/metadata";
Mockito.doReturn(IOUtils.toString(
SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcResourceDetailsExample.json"),
- "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(resourceDetailUrl, false);
+ "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(resourceDetailUrl);
String securityRulesDetailUrl = refProp.getStringValue("sdc.catalog.url")
+ "resources/d57e57d2-e3c6-470d-8d16-e6ea05f536c5/metadata";
Mockito.doReturn(IOUtils.toString(
SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcSecurityRules.json"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(securityRulesDetailUrl, false);
+ .when(spy).getCldsServicesOrResourcesBasedOnURL(securityRulesDetailUrl);
String cinderVolumeDetailUrl = refProp.getStringValue("sdc.catalog.url")
+ "resources/b4288e07-597a-44a2-aa98-ad36e551a39d/metadata";
Mockito.doReturn(IOUtils.toString(
SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcCinderVolume.json"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(cinderVolumeDetailUrl, false);
+ .when(spy).getCldsServicesOrResourcesBasedOnURL(cinderVolumeDetailUrl);
String vfcGenericDetailUrl = refProp.getStringValue("sdc.catalog.url")
+ "resources/2c8f1219-8000-4001-aa13-496a0396d40f/metadata";
Mockito.doReturn(IOUtils.toString(
SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcVFCGenericWithAlarms.json"),
- "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(vfcGenericDetailUrl, false);
+ "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(vfcGenericDetailUrl);
String csvAlarmsDetailUrl = refProp.getStringValue("sdc.catalog.url")
+ "resources/2c8f1219-8000-4001-aa13-496a0396d40f/resourceInstances/virc_fe_be/artifacts/5138e316-0237-49aa-817a-b3d8eaf77392";
Mockito.doReturn(IOUtils.toString(
SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcAlarmsList.csv"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl, false);
+ .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl);
Mockito.doReturn(IOUtils.toString(
SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcAlarmsList.csv"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl, true);
+ .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl);
String csvAlarmsDetailUrl2 = refProp.getStringValue("sdc.catalog.url")
+ "resources/d7646638-2572-4a94-b497-c028ac15f9ca/artifacts/5138e316-0237-49aa-817a-b3d8eaf77392";
Mockito.doReturn(IOUtils.toString(
SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcAlarmsList.csv"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl2, true);
+ .when(spy).getCldsServicesOrResourcesBasedOnURL(csvAlarmsDetailUrl2);
String allVfResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources?resourceType=VF";
Mockito.doReturn(IOUtils.toString(
SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcVFResources.json"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfResourcesDetailUrl, false);
+ .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfResourcesDetailUrl);
String vfcResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url")
+ "resources/a0475018-1e7e-4ddd-8bee-33cbf958c2e6/metadata";
Mockito.doReturn(IOUtils.toString(
SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcCVFCResourceExample.json"),
- "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(vfcResourcesDetailUrl, false);
+ "UTF-8")).when(spy).getCldsServicesOrResourcesBasedOnURL(vfcResourcesDetailUrl);
String allVfcResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources?resourceType=VFC";
Mockito.doReturn(IOUtils.toString(
SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcVFCResources.json"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfcResourcesDetailUrl, false);
+ .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfcResourcesDetailUrl);
String allCvfcResourcesDetailUrl = refProp.getStringValue("sdc.catalog.url") + "resources?resourceType=CVFC";
Mockito.doReturn(IOUtils.toString(
SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcCVFCResources.json"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(allCvfcResourcesDetailUrl, false);
+ .when(spy).getCldsServicesOrResourcesBasedOnURL(allCvfcResourcesDetailUrl);
String allVfAlarms = refProp.getStringValue("sdc.catalog.url")
+ "resources/84855843-5247-4e97-a2bd-5395a510253b/artifacts/d57ac7ec-f3c3-4793-983a-c75ac3a43153";
Mockito.doReturn(IOUtils.toString(
SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcMeasurementsList.csv"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfAlarms, true);
+ .when(spy).getCldsServicesOrResourcesBasedOnURL(allVfAlarms);
String vfcResourceExample = refProp.getStringValue("sdc.catalog.url")
+ "resources/d7646638-2572-4a94-b497-c028ac15f9ca/metadata";
Mockito.doReturn(IOUtils.toString(
SdcCatalogServicesItCase.class.getResourceAsStream("/example/sdc/sdcVFCResourceExample.json"), "UTF-8"))
- .when(spy).getCldsServicesOrResourcesBasedOnURL(vfcResourceExample, false);
+ .when(spy).getCldsServicesOrResourcesBasedOnURL(vfcResourceExample);
CldsServiceData cldsServiceData = spy
.getCldsServiceDataWithAlarmConditions("a33ed748-3477-4434-b3f3-b5560f5e7d9c");