summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authork.kedron <k.kedron@partner.samsung.com>2019-04-16 10:53:44 +0200
committerk.kedron <k.kedron@partner.samsung.com>2019-04-16 10:54:00 +0200
commit5eabd030a88d8e44f384f582f4c402fda2ac6a03 (patch)
tree6f42f5279100195a36c7a7dc8c9bf332b6fe1f18
parent03644961f67a8531245ddede5902af1a7d6a5d2c (diff)
Removed code duplication in PolicyClient
Removed code duplication in PolicyClient according to Sonar analysis Change-Id: I7fd7bdee228eb80661a8416ffc0aab0b2e8c7e04 Issue-ID: CLAMP-343 Signed-off-by: Krystian Kedron <k.kedron@partner.samsung.com>
-rw-r--r--src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java21
1 files changed, 7 insertions, 14 deletions
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 965c90f8..c8848919 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
@@ -434,18 +434,7 @@ public class PolicyClient {
* @return The response message from Policy
*/
public String deleteMicrosService(ModelProperties prop) {
- String deletePolicyResponse = "";
- try {
- String policyNamePrefix = refProp.getStringValue(POLICY_MS_NAME_PREFIX_PROPERTY_NAME);
- if (checkPolicyExists(prop, policyNamePrefix, null)) {
- String policyType = refProp.getStringValue(POLICY_MSTYPE_PROPERTY_NAME);
- deletePolicyResponse = deletePolicy(prop, policyType, null);
- }
- } catch (Exception e) {
- logger.error("Exception occurred during policy communication", e);
- throw new PolicyClientException("Exception while communicating with Policy", e);
- }
- return deletePolicyResponse;
+ return findAndDelete(prop, POLICY_MS_NAME_PREFIX_PROPERTY_NAME, POLICY_MSTYPE_PROPERTY_NAME);
}
/**
@@ -488,11 +477,15 @@ public class PolicyClient {
* @return The response message from policy
*/
public String deleteBrms(ModelProperties prop) {
+ return findAndDelete(prop, POLICY_OP_NAME_PREFIX_PROPERTY_NAME, POLICY_OP_TYPE_PROPERTY_NAME);
+ }
+
+ private String findAndDelete(ModelProperties prop, String policyPrefixProperty, String policyTypeProperty) {
String deletePolicyResponse = "";
try {
- String policyNamePrefix = refProp.getStringValue(POLICY_OP_NAME_PREFIX_PROPERTY_NAME);
+ String policyNamePrefix = refProp.getStringValue(policyPrefixProperty);
if (checkPolicyExists(prop, policyNamePrefix, null)) {
- String policyType = refProp.getStringValue(POLICY_OP_TYPE_PROPERTY_NAME);
+ String policyType = refProp.getStringValue(policyTypeProperty);
deletePolicyResponse = deletePolicy(prop, policyType, null);
}
} catch (Exception e) {