diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2023-12-13 14:12:25 +0000 |
---|---|---|
committer | FrancescoFioraEst <francesco.fiora@est.tech> | 2024-01-02 09:43:57 +0000 |
commit | 664af40d4c073404d6c067731e25fc44dab3f2c2 (patch) | |
tree | a37c1821e6e200d79f036398d06d1c37bd58c594 /runtime-acm/src/main | |
parent | 7189a95de7687a8c37a05d40306e743df5fdf5b3 (diff) |
Add validation in AC instance elements Id in update
Issue-ID: POLICY-4905
Change-Id: If49a7829fa8acfe375cf7bb1d7ed6859f8a3f190
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'runtime-acm/src/main')
-rwxr-xr-x | runtime-acm/src/main/java/org/onap/policy/clamp/acm/runtime/instantiation/AutomationCompositionInstantiationProvider.java | 18 |
1 files changed, 9 insertions, 9 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 9f126406b..84920dd03 100755 --- 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 @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2021-2023 Nordix Foundation. + * Copyright (C) 2021-2024 Nordix Foundation. * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); @@ -134,7 +134,7 @@ public class AutomationCompositionInstantiationProvider { } else if ((DeployState.DEPLOYED.equals(acToUpdate.getDeployState()) || DeployState.UPDATING.equals(acToUpdate.getDeployState())) && LockState.LOCKED.equals(acToUpdate.getLockState())) { - return updateDeployedAutomationComposition(compositionId, automationComposition, acToUpdate); + return updateDeployedAutomationComposition(automationComposition, acToUpdate); } throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, "Not allowed to update in the state " + acToUpdate.getDeployState()); @@ -143,12 +143,11 @@ public class AutomationCompositionInstantiationProvider { /** * Update deployed AC Element properties. * - * @param compositionId The UUID of the automation composition definition * @param automationComposition the automation composition * @param acToBeUpdated the composition to be updated * @return the result of the update */ - public InstantiationResponse updateDeployedAutomationComposition(UUID compositionId, + public InstantiationResponse updateDeployedAutomationComposition( AutomationComposition automationComposition, AutomationComposition acToBeUpdated) { if (automationComposition.getCompositionTargetId() != null @@ -158,12 +157,13 @@ public class AutomationCompositionInstantiationProvider { } // Iterate and update the element property values - for (var dbAcElement : acToBeUpdated.getElements().entrySet()) { - var elementId = dbAcElement.getKey(); - if (automationComposition.getElements().containsKey(elementId)) { - dbAcElement.getValue().getProperties() - .putAll(automationComposition.getElements().get(elementId).getProperties()); + for (var element : automationComposition.getElements().entrySet()) { + var elementId = element.getKey(); + var dbAcElement = acToBeUpdated.getElements().get(elementId); + if (dbAcElement == null) { + throw new PfModelRuntimeException(Response.Status.BAD_REQUEST, "Element id not present " + elementId); } + dbAcElement.getProperties().putAll(element.getValue().getProperties()); } if (automationComposition.getRestarting() != null) { throw new PfModelRuntimeException(Status.BAD_REQUEST, "There is a restarting process, Update not allowed"); |