diff options
author | Xue Gao <xg353y@intl.att.com> | 2019-04-16 11:44:11 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2019-04-16 11:44:11 +0000 |
commit | 6aabe34a66cfc4eca0152a873161461322f1adb4 (patch) | |
tree | 9621650d69072eef100c9d84df1b6747e561dbd4 /src/main | |
parent | d5f36a1f874e7045abec81dac2e249aa5e5be051 (diff) | |
parent | 5eabd030a88d8e44f384f582f4c402fda2ac6a03 (diff) |
Merge "Removed code duplication in PolicyClient"
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/onap/clamp/clds/client/req/policy/PolicyClient.java | 21 |
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 965c90f89..c88489190 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) { |