From 2b82696ea09c21cf5b47cedf08fe294622a6c4e6 Mon Sep 17 00:00:00 2001 From: "kris.jinka" Date: Tue, 13 Nov 2018 09:10:52 +0900 Subject: Use parameter obj for policy results Policy result method uses more params than allowed Use parameter object for setting params instead Issue-ID: POLICY-1251 Change-Id: I6bf1f20896dc5176811bc363a390c682faa06ca4 Signed-off-by: kris.jinka --- .../policy/builder/ControlLoopPolicyBuilder.java | 12 ++--------- .../builder/impl/ControlLoopPolicyBuilderImpl.java | 24 ++++++++++------------ 2 files changed, 13 insertions(+), 23 deletions(-) (limited to 'controlloop/common/policy-yaml/src/main') diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java index 123fe2fa1..3c43756c3 100644 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java +++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/ControlLoopPolicyBuilder.java @@ -177,20 +177,12 @@ public interface ControlLoopPolicyBuilder { /** * Creates a policy that is chained to the result of another Policy. * - * @param name name - * @param description description - * @param actor actor - * @param target target - * @param recipe recipe - * @param retries retries - * @param timeout timeout - * @param policyId id + * @param policyParam policy parameters object * @param results results * @return Policy that was set * @throws BuilderException builder exception */ - public Policy setPolicyForPolicyResult(String name, String description, String actor, Target target, String recipe, - Map payload, Integer retries, Integer timeout, String policyId, PolicyResult... results) + public Policy setPolicyForPolicyResult(PolicyParam policyParam, PolicyResult... results) throws BuilderException; diff --git a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java index 6950523cb..bd3939886 100644 --- a/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java +++ b/controlloop/common/policy-yaml/src/main/java/org/onap/policy/controlloop/policy/builder/impl/ControlLoopPolicyBuilderImpl.java @@ -228,30 +228,28 @@ public class ControlLoopPolicyBuilderImpl implements ControlLoopPolicyBuilder { } @Override - public Policy setPolicyForPolicyResult(String name, String description, String actor, Target target, String recipe, - Map payload, Integer retries, Integer timeout, - String policyId, PolicyResult... results) + public Policy setPolicyForPolicyResult(PolicyParam policyParam, PolicyResult... results) throws BuilderException { // // Find the existing policy // - Policy existingPolicy = this.findPolicy(policyId); + Policy existingPolicy = this.findPolicy(policyParam.getId()); if (existingPolicy == null) { - throw new BuilderException(UNKNOWN_POLICY + policyId); + throw new BuilderException(UNKNOWN_POLICY + policyParam.getId()); } // // Create the new Policy // Policy newPolicy = new Policy( PolicyParam.builder().id(UUID.randomUUID().toString()) - .name(name) - .description(description) - .actor(actor) - .payload(payload) - .target(target) - .recipe(recipe) - .retries(retries) - .timeout(timeout) + .name(policyParam.getName()) + .description(policyParam.getDescription()) + .actor(policyParam.getActor()) + .payload(policyParam.getPayload()) + .target(policyParam.getTarget()) + .recipe(policyParam.getRecipe()) + .retries(policyParam.getRetries()) + .timeout(policyParam.getTimeout()) .build()); // // Connect the results -- cgit 1.2.3-korg