diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-02-10 12:54:14 +0000 |
---|---|---|
committer | Francesco Fiora <francesco.fiora@est.tech> | 2023-02-10 14:50:05 +0000 |
commit | d65aa6abc70ad9dff9c74984f2a600607892f831 (patch) | |
tree | 8e02a91bbf1076910e8f4029acb2b7427e8beafc /runtime-acm/src/main | |
parent | c1fce9211058bf91b40415022a819d3b410f711e (diff) |
Initial support for Implement recording of Operational State
Remove AutomationCompositionState and AutomationCompositionOrderedState
in Jpa classes
add validation to not update deployed instances
Issue-ID: POLICY-4550
Change-Id: If18915a4be6b67dda83ff3ca5457ed52d0e8ddf2
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'runtime-acm/src/main')
-rw-r--r-- | runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java index 62a769fdb..02e5b1ac6 100644 --- a/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java +++ b/runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java @@ -29,8 +29,8 @@ import lombok.AllArgsConstructor; import org.onap.policy.clamp.acm.runtime.supervision.SupervisionAcHandler; import org.onap.policy.clamp.models.acm.concepts.AcTypeState; import org.onap.policy.clamp.models.acm.concepts.AutomationComposition; -import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionState; import org.onap.policy.clamp.models.acm.concepts.AutomationCompositions; +import org.onap.policy.clamp.models.acm.concepts.DeployState; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.AcInstanceStateUpdate; import org.onap.policy.clamp.models.acm.messages.rest.instantiation.InstantiationResponse; import org.onap.policy.clamp.models.acm.persistence.provider.AcDefinitionProvider; @@ -106,6 +106,10 @@ public class AutomationCompositionInstantiationProvider { throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, automationComposition.getCompositionId() + DO_NOT_MATCH + compositionId); } + if (!DeployState.UNDEPLOYED.equals(acToUpdate.getDeployState())) { + throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, + "Not allow to update for state in " + acToUpdate.getDeployState()); + } acToUpdate.setElements(automationComposition.getElements()); acToUpdate.setName(automationComposition.getName()); acToUpdate.setVersion(automationComposition.getVersion()); @@ -139,8 +143,8 @@ public class AutomationCompositionInstantiationProvider { return result; } if (!AcTypeState.PRIMED.equals(acDefinitionOpt.get().getState())) { - result.addResult(new ObjectValidationResult("ServiceTemplate", "", ValidationStatus.INVALID, - "Commissioned automation composition definition not primed")); + result.addResult(new ObjectValidationResult("ServiceTemplate", acDefinitionOpt.get().getState(), + ValidationStatus.INVALID, "Commissioned automation composition definition not primed")); return result; } result.addResult(AcmUtils.validateAutomationComposition(automationComposition, @@ -169,7 +173,7 @@ public class AutomationCompositionInstantiationProvider { var automationComposition = automationCompositionProvider.getAutomationComposition(instanceId); if (!automationComposition.getCompositionId().equals(compositionId)) { throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, - "Composition Id " + compositionId + DO_NOT_MATCH + automationComposition.getCompositionId()); + automationComposition.getCompositionId() + DO_NOT_MATCH + compositionId); } return automationComposition; } @@ -187,9 +191,9 @@ public class AutomationCompositionInstantiationProvider { throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, automationComposition.getCompositionId() + DO_NOT_MATCH + compositionId); } - if (!AutomationCompositionState.UNINITIALISED.equals(automationComposition.getState())) { + if (!DeployState.UNDEPLOYED.equals(automationComposition.getDeployState())) { throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, - "Automation composition state is still " + automationComposition.getState()); + "Automation composition state is still " + automationComposition.getDeployState()); } var response = new InstantiationResponse(); automationComposition = |