diff options
author | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2017-12-14 10:41:03 +0100 |
---|---|---|
committer | Lukasz Muszkieta <lukasz.muszkieta@nokia.com> | 2017-12-15 12:44:46 +0100 |
commit | a4096a47f893c1ed0a231303093c3fbba6865641 (patch) | |
tree | e3f49fa87f032160127316bce1530711bb6f9e84 /src/main | |
parent | cb766efc03a625bf95ece11b5f840deea31df236 (diff) |
Code refactoring
Change-Id: Ic2737bf71f8b236939e9aa46ed619e6ad0e40b3a
Issue-ID: CLAMP-93
Signed-off-by: Lukasz Muszkieta <lukasz.muszkieta@nokia.com>
Diffstat (limited to 'src/main')
6 files changed, 81 insertions, 289 deletions
diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java b/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java index db84a1240..970d7a87a 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java +++ b/src/main/java/org/onap/clamp/clds/client/req/policy/OperationalPolicyReq.java @@ -62,9 +62,8 @@ import org.onap.policy.controlloop.policy.builder.Results; /** * 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() { } @@ -151,16 +150,7 @@ public class 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(); @@ -207,16 +197,7 @@ public class OperationalPolicyReq { 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(); @@ -277,7 +258,6 @@ public class OperationalPolicyReq { 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()) { @@ -288,13 +268,8 @@ public class OperationalPolicyReq { } } - /** - * 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); @@ -328,14 +303,8 @@ public class OperationalPolicyReq { 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<>(); @@ -379,13 +348,6 @@ public class OperationalPolicyReq { 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]; @@ -393,13 +355,6 @@ public class OperationalPolicyReq { 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]; diff --git a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java b/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java index 957153560..2e2169f8f 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java +++ b/src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java @@ -62,10 +62,7 @@ import org.springframework.context.ApplicationContext; * 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(); @@ -187,7 +184,6 @@ public class PolicyClient { 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); @@ -335,11 +331,6 @@ public class PolicyClient { return versions; } - /** - * This method create a new policy engine. - * - * @return A new policy engine - */ private PolicyEngine getPolicyEngine() { PolicyEngine policyEngine; try { diff --git a/src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java b/src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java index c725be2b2..14421da5f 100644 --- a/src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java +++ b/src/main/java/org/onap/clamp/clds/client/req/sdc/SdcCatalogServices.java @@ -78,33 +78,24 @@ import org.onap.clamp.clds.util.LoggingUtils; import org.springframework.beans.factory.annotation.Autowired;
public class SdcCatalogServices {
- protected static final EELFLogger logger = EELFManager.getInstance()
- .getLogger(SdcCatalogServices.class);
- protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
- private static final String RESOURCE_VF_TYPE = "VF";
- private static final String RESOURCE_VFC_TYPE = "VFC";
- private static final String RESOURCE_CVFC_TYPE = "CVFC";
- public static final String SDC_REQUESTID_PROPERTY_NAME = "sdc.header.requestId";
- private static final String SDC_METADATA_URL_PREFIX = "/metadata";
- private static final String SDC_INSTANCE_ID_PROPERTY_NAME = "sdc.InstanceID";
- private static final String SDC_CATALOG_URL_PROPERTY_NAME = "sdc.catalog.url";
- private static final String SDC_SERVICE_URL_PROPERTY_NAME = "sdc.serviceUrl";
- private static final String SDC_INSTANCE_ID_CLAMP = "CLAMP-Tool";
- private static final String RESOURCE_URL_PREFIX = "resources";
+
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(SdcCatalogServices.class);
+ private static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();
+ private static final String RESOURCE_VF_TYPE = "VF";
+ private static final String RESOURCE_VFC_TYPE = "VFC";
+ private static final String RESOURCE_CVFC_TYPE = "CVFC";
+ private static final String SDC_REQUESTID_PROPERTY_NAME = "sdc.header.requestId";
+ private static final String SDC_METADATA_URL_PREFIX = "/metadata";
+ private static final String SDC_INSTANCE_ID_PROPERTY_NAME = "sdc.InstanceID";
+ private static final String SDC_CATALOG_URL_PROPERTY_NAME = "sdc.catalog.url";
+ private static final String SDC_SERVICE_URL_PROPERTY_NAME = "sdc.serviceUrl";
+ private static final String SDC_INSTANCE_ID_CLAMP = "CLAMP-Tool";
+ private static final String RESOURCE_URL_PREFIX = "resources";
@Autowired
- private RefProp refProp;
- protected CryptoUtils cryptoUtils = new CryptoUtils();
+ private RefProp refProp;
+ private CryptoUtils cryptoUtils = new CryptoUtils();
- /**
- * Return SDC id and pw as a HTTP Basic Auth string (for example: Basic
- * dGVzdDoxMjM0NTY=).
- *
- * @return The String with Basic Auth and password
- * @throws GeneralSecurityException
- * In case of issue when decryting the SDC password
- * @throws DecoderException
- * In case of issues with the decoding of the HexString message
- */
+ // returns SDC id and password as a HTTP Basic Auth string (for example: Basic dGVzdDoxMjM0NTY=)
private String getSdcBasicAuth() throws GeneralSecurityException, DecoderException {
String sdcId = refProp.getStringValue("sdc.serviceUsername");
String sdcPw = refProp.getStringValue("sdc.servicePassword");
@@ -116,7 +107,7 @@ public class SdcCatalogServices { /**
* This method get the SDC services Information with the corresponding
* Service UUID.
- *
+ *
* @param uuid
* The service UUID
* @return A Json String with all the service list
@@ -160,7 +151,7 @@ public class SdcCatalogServices { /**
* To remove duplicate serviceUUIDs from sdc services List.
- *
+ *
* @param rawCldsSdcServiceList
* A list of CldsSdcServiceInfo
* @return A list of CldsSdcServiceInfo without duplicate service UUID
@@ -189,9 +180,8 @@ public class SdcCatalogServices { /**
* To remove duplicate serviceUUIDs from sdc resources List.
- *
+ *
* @param rawCldsSdcResourceList
- * @return
*/
public List<CldsSdcResource> removeDuplicateSdcResourceInstances(List<CldsSdcResource> rawCldsSdcResourceList) {
List<CldsSdcResource> cldsSdcResourceList = null;
@@ -217,9 +207,8 @@ public class SdcCatalogServices { /**
* To remove duplicate basic resources with same resourceUUIDs.
- *
+ *
* @param rawCldsSdcResourceListBasicList
- * @return
*/
public List<CldsSdcResourceBasicInfo> removeDuplicateSdcResourceBasicInfo(
List<CldsSdcResourceBasicInfo> rawCldsSdcResourceListBasicList) {
@@ -247,7 +236,7 @@ public class SdcCatalogServices { /**
* To get ServiceUUID by using serviceInvariantUUID.
- *
+ *
* @param invariantId
* The invariant ID
* @return The service UUID
@@ -274,15 +263,7 @@ public class SdcCatalogServices { return serviceUuid;
}
- /**
- * To get CldsAsdsServiceInfo class by parsing json string.
- *
- * @param jsonStr
- * The Json string that must be decoded
- * @return The list of CldsSdcServiceInfo, if there is a failure it return
- * an empty list
- */
- public List<CldsSdcServiceInfo> getCldsSdcServicesListFromJson(String jsonStr) {
+ private List<CldsSdcServiceInfo> getCldsSdcServicesListFromJson(String jsonStr) {
ObjectMapper objectMapper = new ObjectMapper();
if (StringUtils.isBlank(jsonStr)) {
return new ArrayList<>();
@@ -296,15 +277,7 @@ public class SdcCatalogServices { }
}
- /**
- * To get List of CldsSdcResourceBasicInfo class by parsing json string.
- *
- * @param jsonStr
- * The JSOn string that must be decoded
- * @return The list of CldsSdcResourceBasicInfo, an empty list in case of
- * issues
- */
- public List<CldsSdcResourceBasicInfo> getAllSdcResourcesListFromJson(String jsonStr) {
+ private List<CldsSdcResourceBasicInfo> getAllSdcResourcesListFromJson(String jsonStr) {
ObjectMapper objectMapper = new ObjectMapper();
if (StringUtils.isBlank(jsonStr)) {
return new ArrayList<>();
@@ -319,20 +292,8 @@ public class SdcCatalogServices { }
/**
- * To get CldsAsdsResource class by parsing json string.
- *
- * @param jsonStr
- * @return
- * @throws IOException
- */
- public CldsSdcResource getCldsSdcResourceFromJson(String jsonStr) throws IOException {
- ObjectMapper objectMapper = new ObjectMapper();
- return objectMapper.readValue(jsonStr, CldsSdcResource.class);
- }
-
- /**
* To get CldsSdcServiceDetail by parsing json string.
- *
+ *
* @param jsonStr
* @return
*/
@@ -346,18 +307,9 @@ public class SdcCatalogServices { }
}
- /**
- * To upload artifact to sdc based on serviceUUID and resource name on url.
- *
- * @param prop
- * @param userid
- * @param url
- * @param formattedSdcReq
- * @return
- * @throws GeneralSecurityException
- */
- public String uploadArtifactToSdc(ModelProperties prop, String userid, String url, String formattedSdcReq)
- throws GeneralSecurityException {
+
+ // upload artifact to sdc based on serviceUUID and resource name on url
+ private String uploadArtifactToSdc(ModelProperties prop, String userid, String url, String formattedSdcReq) {
// Verify whether it is triggered by Validation Test button from UI
if (prop.isTestOnly()) {
return "sdc artifact upload not executed for test action";
@@ -388,8 +340,7 @@ public class SdcCatalogServices { }
}
- private HttpURLConnection getSdcHttpUrlConnection(String userid, int postDataLength, String url, String content)
- throws GeneralSecurityException {
+ private HttpURLConnection getSdcHttpUrlConnection(String userid, int postDataLength, String url, String content) {
try {
logger.info("userid=" + userid);
String basicAuth = getSdcBasicAuth();
@@ -460,9 +411,8 @@ public class SdcCatalogServices { /**
* Check if the SDC Info in cache has expired.
- *
+ *
* @param cldsServiceData
- * @return
* @throws GeneralSecurityException
* In case of issues with the decryting the encrypted password
* @throws DecoderException
@@ -486,11 +436,9 @@ public class SdcCatalogServices { }
/**
- * Get the Service Data with Alarm Conditions for a given
- * invariantServiceUuid.
- *
+ * Get the Service Data with Alarm Conditions for a given invariantServiceUuid.
+ *
* @param invariantServiceUuid
- * @return
* @throws GeneralSecurityException
* In case of issues with the decryting the encrypted password
* @throws DecoderException
@@ -502,7 +450,7 @@ public class SdcCatalogServices { String catalogUrl = refProp.getStringValue(SDC_CATALOG_URL_PROPERTY_NAME);
String serviceUuid = getServiceUuidFromServiceInvariantId(invariantServiceUuid);
String serviceDetailUrl = url + "/" + serviceUuid + SDC_METADATA_URL_PREFIX;
- String responseStr = getCldsServicesOrResourcesBasedOnURL(serviceDetailUrl, false);
+ String responseStr = getCldsServicesOrResourcesBasedOnURL(serviceDetailUrl);
ObjectMapper objectMapper = new ObjectMapper();
CldsServiceData cldsServiceData = new CldsServiceData();
if (responseStr != null) {
@@ -558,7 +506,7 @@ public class SdcCatalogServices { if (resourceUuid != null) {
String vfResourceUuidUrl = catalogUrl + RESOURCE_URL_PREFIX + "/" + resourceUuid
+ SDC_METADATA_URL_PREFIX;
- String vfResponse = getCldsServicesOrResourcesBasedOnURL(vfResourceUuidUrl, false);
+ String vfResponse = getCldsServicesOrResourcesBasedOnURL(vfResourceUuidUrl);
if (vfResponse != null) {
// Below 2 line are to get the KPI(field path) data
// associated with the VF's
@@ -579,7 +527,7 @@ public class SdcCatalogServices { String vfcResourceUuidUrl = catalogUrl + RESOURCE_URL_PREFIX + "/"
+ resourceVfcUuid + SDC_METADATA_URL_PREFIX;
String vfcResponse = getCldsServicesOrResourcesBasedOnURL(
- vfcResourceUuidUrl, false);
+ vfcResourceUuidUrl);
if (vfcResponse != null) {
List<CldsAlarmCondition> alarmCondtionsFromVfc = getAlarmCondtionsFromVfc(
vfcResponse);
@@ -616,49 +564,48 @@ public class SdcCatalogServices { List<CldsVfcData> cldsVfcDataList = new ArrayList<>();
if (vfcArrayNode != null) {
for (JsonNode vfcjsonNode : vfcArrayNode) {
- CldsVfcData currCldsVfcData = new CldsVfcData();
ObjectNode currVfcNode = (ObjectNode) vfcjsonNode;
TextNode resourceTypeNode = (TextNode) currVfcNode.get("resoucreType");
if (resourceTypeNode != null && "VFC".equalsIgnoreCase(resourceTypeNode.textValue())) {
- TextNode vfcResourceName = (TextNode) currVfcNode.get("resourceInstanceName");
- TextNode vfcInvariantResourceUuid = (TextNode) currVfcNode.get("resourceInvariantUUID");
- currCldsVfcData.setVfcName(vfcResourceName.textValue());
- currCldsVfcData.setVfcInvariantResourceUUID(vfcInvariantResourceUuid.textValue());
- cldsVfcDataList.add(currCldsVfcData);
+ handleVFCtypeNode(currVfcNode, cldsVfcDataList);
} else if (resourceTypeNode != null && "CVFC".equalsIgnoreCase(resourceTypeNode.textValue())) {
- TextNode vfcResourceName = (TextNode) currVfcNode.get("resourceInstanceName");
- TextNode vfcInvariantResourceUuid = (TextNode) currVfcNode.get("resourceInvariantUUID");
- currCldsVfcData.setVfcName(vfcResourceName.textValue());
- currCldsVfcData.setVfcInvariantResourceUUID(vfcInvariantResourceUuid.textValue());
- cldsVfcDataList.add(currCldsVfcData);
- cldsVfcDataList.addAll(getVFCfromCVFC(currVfcNode.get("resourceUUID").textValue()));
+ handleCVFCtypeNode(currVfcNode, cldsVfcDataList);
}
}
}
return cldsVfcDataList;
}
- private List<CldsVfcData> getVFCfromCVFC(String resourceUUID) throws GeneralSecurityException {
+ private void handleVFCtypeNode(ObjectNode currVfcNode, List<CldsVfcData> cldsVfcDataList) {
+ CldsVfcData currCldsVfcData = new CldsVfcData();
+ TextNode vfcResourceName = (TextNode) currVfcNode.get("resourceInstanceName");
+ TextNode vfcInvariantResourceUuid = (TextNode) currVfcNode.get("resourceInvariantUUID");
+ currCldsVfcData.setVfcName(vfcResourceName.textValue());
+ currCldsVfcData.setVfcInvariantResourceUUID(vfcInvariantResourceUuid.textValue());
+ cldsVfcDataList.add(currCldsVfcData);
+ }
+
+ private void handleCVFCtypeNode(ObjectNode currVfcNode, List<CldsVfcData> cldsVfcDataList) {
+ handleVFCtypeNode(currVfcNode, cldsVfcDataList);
+ cldsVfcDataList.addAll(getVFCfromCVFC(currVfcNode.get("resourceUUID").textValue()));
+ }
+
+ private List<CldsVfcData> getVFCfromCVFC(String resourceUUID) {
String catalogUrl = refProp.getStringValue(SDC_CATALOG_URL_PROPERTY_NAME);
List<CldsVfcData> cldsVfcDataList = new ArrayList<>();
if (resourceUUID != null) {
String vfcResourceUUIDUrl = catalogUrl + RESOURCE_URL_PREFIX + "/" + resourceUUID + SDC_METADATA_URL_PREFIX;
try {
- String vfcResponse = getCldsServicesOrResourcesBasedOnURL(vfcResourceUUIDUrl, false);
+ String vfcResponse = getCldsServicesOrResourcesBasedOnURL(vfcResourceUUIDUrl);
ObjectMapper mapper = new ObjectMapper();
ObjectNode vfResponseNode = (ObjectNode) mapper.readTree(vfcResponse);
ArrayNode vfcArrayNode = (ArrayNode) vfResponseNode.get("resources");
if (vfcArrayNode != null) {
for (JsonNode vfcjsonNode : vfcArrayNode) {
- CldsVfcData currCldsVfcData = new CldsVfcData();
ObjectNode currVfcNode = (ObjectNode) vfcjsonNode;
TextNode resourceTypeNode = (TextNode) currVfcNode.get("resoucreType");
if (resourceTypeNode != null && "VFC".equalsIgnoreCase(resourceTypeNode.textValue())) {
- TextNode vfcResourceName = (TextNode) currVfcNode.get("resourceInstanceName");
- TextNode vfcInvariantResourceUUID = (TextNode) currVfcNode.get("resourceInvariantUUID");
- currCldsVfcData.setVfcName(vfcResourceName.textValue());
- currCldsVfcData.setVfcInvariantResourceUUID(vfcInvariantResourceUUID.textValue());
- cldsVfcDataList.add(currCldsVfcData);
+ handleVFCtypeNode(currVfcNode, cldsVfcDataList);
}
}
}
@@ -811,19 +758,12 @@ public class SdcCatalogServices { cldsAlarmConditionList.add(cldsAlarmCondition);
}
- /**
- * Get the responses for the current artifact from the artifacts URL.
- *
- * @param artifactsUrl
- * @return
- * @throws GeneralSecurityException
- */
- public String getResponsesFromArtifactUrl(String artifactsUrl) throws GeneralSecurityException {
+ private String getResponsesFromArtifactUrl(String artifactsUrl) {
String hostUrl = refProp.getStringValue("sdc.hostUrl");
String artifactsUrlReworked = artifactsUrl.replaceAll("\"", "");
String artifactUrl = hostUrl + artifactsUrlReworked;
logger.info("value of artifactURl:" + artifactUrl);
- String currArtifactResponse = getCldsServicesOrResourcesBasedOnURL(artifactUrl, true);
+ String currArtifactResponse = getCldsServicesOrResourcesBasedOnURL(artifactUrl);
logger.info("value of artifactResponse:" + currArtifactResponse);
return currArtifactResponse;
}
@@ -831,16 +771,8 @@ public class SdcCatalogServices { /**
* Service to services/resources/artifacts from sdc.Pass alarmConditions as
* true to get alarm conditons from artifact url and else it is false
- *
- * @param url
- * @param alarmConditions
- * @return
- * @throws GeneralSecurityException
- * In case of issue when decrypting the SDC password
- *
*/
- public String getCldsServicesOrResourcesBasedOnURL(String url, boolean alarmConditions)
- throws GeneralSecurityException {
+ public String getCldsServicesOrResourcesBasedOnURL(String url) {
Date startTime = new Date();
try {
LoggingUtils.setTargetContext("SDC", "getCldsServicesOrResourcesBasedOnURL");
@@ -953,7 +885,7 @@ public class SdcCatalogServices { /**
* Method to get alarm conditions/alert description from Service Data.
- *
+ *
* @param cldsServiceData
* CldsServiceData the Service Data to analyze
* @param eventName
@@ -975,7 +907,7 @@ public class SdcCatalogServices { /**
* Method to get alarm conditions/alert description from VF Data.
- *
+ *
* @param currCldsVfData
* The Vf Data to analyze
* @param eventName
@@ -995,7 +927,7 @@ public class SdcCatalogServices { /**
* Method to get alarm conditions/alert description from VFC Data.
- *
+ *
* @param currCldsVfcData
* The VfC Data to analyze
* @param eventName
@@ -1113,7 +1045,7 @@ public class SdcCatalogServices { /**
* Method to create vfc and kpi nodes inside vf node
- *
+ *
* @param mapper
* @param cldsVfDataList
* @return
@@ -1163,7 +1095,7 @@ public class SdcCatalogServices { /**
* This method searches the equivalent artifact UUID for a specific
* artifactName in a SdcServiceDetail.
- *
+ *
* @param cldsSdcServiceDetail
* The SdcServiceDetail that will be analyzed
* @param artifactName
@@ -1195,21 +1127,10 @@ public class SdcCatalogServices { return artifactUuid;
}
- /**
- * To get all sdc VF/VFC Resources basic info.
- *
- * @param resourceType
- * The resourceType
- * @return The list of CldsSdcResourceBasicInfo
- * @throws GeneralSecurityException
- * In case of issue when decryting the SDC password
- *
- */
- private List<CldsSdcResourceBasicInfo> getAllSdcVForVfcResourcesBasedOnResourceType(String resourceType)
- throws GeneralSecurityException {
+ private List<CldsSdcResourceBasicInfo> getAllSdcVForVfcResourcesBasedOnResourceType(String resourceType) {
String catalogUrl = refProp.getStringValue(SDC_CATALOG_URL_PROPERTY_NAME);
String resourceUrl = catalogUrl + "resources?resourceType=" + resourceType;
- String allSdcVfcResources = getCldsServicesOrResourcesBasedOnURL(resourceUrl, false);
+ String allSdcVfcResources = getCldsServicesOrResourcesBasedOnURL(resourceUrl);
return removeDuplicateSdcResourceBasicInfo(getAllSdcResourcesListFromJson(allSdcVfcResources));
}
@@ -1228,13 +1149,6 @@ public class SdcCatalogServices { return resourceUuid;
}
- /**
- * Method to get service invariant uuid from model properties.
- *
- * @param props
- * The Clds model properties
- * @return The Service Id
- */
private String getServiceInvariantUuidFromProps(ModelProperties props) {
String invariantUuid = "";
Global globalProps = props.getGlobal();
@@ -1246,7 +1160,7 @@ public class SdcCatalogServices { /**
* This method upload the BluePrint to SDC.
- *
+ *
* @param prop
* The Clds model Properties
* @param userid
diff --git a/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java b/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java index 45d2786aa..9367bc24c 100644 --- a/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java +++ b/src/main/java/org/onap/clamp/clds/config/CldsConfiguration.java @@ -26,7 +26,6 @@ package org.onap.clamp.clds.config; import com.att.ajsc.common.AjscProvider; import com.att.ajsc.common.AjscService; -import java.security.GeneralSecurityException; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java index 625aea586..7e42b296a 100644 --- a/src/main/java/org/onap/clamp/clds/dao/CldsDao.java +++ b/src/main/java/org/onap/clamp/clds/dao/CldsDao.java @@ -54,9 +54,7 @@ import org.springframework.stereotype.Repository; */ @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; @@ -116,12 +114,7 @@ public class CldsDao { 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); @@ -280,29 +273,6 @@ public class CldsDao { } /** - * 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. * @@ -324,12 +294,6 @@ public class CldsDao { 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); diff --git a/src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java b/src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java index 4b26bc05d..5965a417b 100644 --- a/src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java +++ b/src/main/java/org/onap/clamp/clds/model/refprop/RefProp.java @@ -23,38 +23,27 @@ 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 { @@ -115,24 +104,4 @@ public class RefProp { 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; - } - } |