From dcaa906f72630669f958f2fd3291a1e77be50d1c Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Sat, 29 Feb 2020 22:48:59 -0500 Subject: Tosca policies missing "final_xxx" fields The code that makes Tosca policies backward compatible was not copying the final_xxx fields (e.g., final_failure_retries). Added code to copy the fields. Issue-ID: POLICY-2376 Signed-off-by: Jim Hahn Change-Id: I05d746ee9c8ace263c7b33a245221c5eb71b612c --- .../processor/ControlLoopProcessor.java | 39 +++++++++++++++------- 1 file changed, 27 insertions(+), 12 deletions(-) (limited to 'controlloop/common/eventmanager') diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/processor/ControlLoopProcessor.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/processor/ControlLoopProcessor.java index 0015e4dd7..4ef1f75c9 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/processor/ControlLoopProcessor.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/processor/ControlLoopProcessor.java @@ -40,6 +40,7 @@ import org.onap.policy.controlloop.policy.Target; import org.onap.policy.controlloop.policy.TargetType; import org.onap.policy.drools.domain.models.DroolsPolicy; import org.onap.policy.drools.models.domain.legacy.LegacyPolicy; +import org.onap.policy.drools.models.domain.operational.Operation; import org.onap.policy.drools.models.domain.operational.OperationalPolicy; import org.onap.policy.drools.models.domain.operational.OperationalTarget; import org.onap.policy.drools.system.PolicyEngineConstants; @@ -131,18 +132,7 @@ public class ControlLoopProcessor implements Serializable { // @formatter:off backwardsCompatiblePolicy.setPolicies( - domainPolicy.getProperties().getOperations().stream().map(operation -> new Policy( - PolicyParam.builder() - .id(operation.getId()) - .name(operation.getActorOperation().getOperation()) - .description(operation.getDescription()) - .actor(operation.getActorOperation().getActor()) - .payload(operation.getActorOperation().getPayload()) - .recipe(operation.getActorOperation().getOperation()) - .retries(operation.getRetries()) - .timeout(operation.getTimeout()) - .target(toStandardTarget(operation.getActorOperation().getTarget())) - .build())) + domainPolicy.getProperties().getOperations().stream().map(this::convertPolicy) .collect(Collectors.toList())); // @formatter:on @@ -158,6 +148,31 @@ public class ControlLoopProcessor implements Serializable { return backwardsCompatiblePolicy; } + private Policy convertPolicy(Operation operation) { + // @formatter:off + Policy newPolicy = new Policy(PolicyParam.builder() + .id(operation.getId()) + .name(operation.getActorOperation().getOperation()) + .description(operation.getDescription()) + .actor(operation.getActorOperation().getActor()) + .payload(operation.getActorOperation().getPayload()) + .recipe(operation.getActorOperation().getOperation()) + .retries(operation.getRetries()) + .timeout(operation.getTimeout()) + .target(toStandardTarget(operation.getActorOperation().getTarget())) + .build()); + // @formatter:on + + newPolicy.setSuccess(operation.getSuccess()); + newPolicy.setFailure(operation.getFailure()); + newPolicy.setFailure_exception(operation.getFailureException()); + newPolicy.setFailure_guard(operation.getFailureGuard()); + newPolicy.setFailure_retries(operation.getFailureRetries()); + newPolicy.setFailure_timeout(operation.getFailureTimeout()); + + return newPolicy; + } + /** * Get ControlLoopParams. */ -- cgit 1.2.3-korg