diff options
author | Jim Hahn <jrh3@att.com> | 2020-02-29 22:48:59 -0500 |
---|---|---|
committer | Jim Hahn <jrh3@att.com> | 2020-02-29 22:48:59 -0500 |
commit | dcaa906f72630669f958f2fd3291a1e77be50d1c (patch) | |
tree | f3e630c1a387110a9352c9738dfa9b36790fd727 /controlloop/common/eventmanager/src/main/java/org | |
parent | 6d284bc693b5103ad27ff533957ec2a51fa61f42 (diff) |
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 <jrh3@att.com>
Change-Id: I05d746ee9c8ace263c7b33a245221c5eb71b612c
Diffstat (limited to 'controlloop/common/eventmanager/src/main/java/org')
-rw-r--r-- | controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/processor/ControlLoopProcessor.java | 39 |
1 files changed, 27 insertions, 12 deletions
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. */ |