From d58c0ca04ae993702b2c399afd52b01e503ec0fe Mon Sep 17 00:00:00 2001 From: FrancescoFioraEst Date: Fri, 2 Jun 2023 12:36:45 +0100 Subject: Add Failure handling support in all ACM-participants MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In any transition (like deploy, undeploy,  lock, unlock, update, delete) a participant should respond with the final state of transition, a status indicator (stateChaneResult) indicating if error has occurred and a message. Issue-ID: POLICY-4706 Change-Id: I424bc6d620f476392baee8904e21d3a6c7aa8d6b Signed-off-by: FrancescoFioraEst --- .../AutomationCompositionElementHandler.java | 51 ++++++++++++++++++++-- 1 file changed, 47 insertions(+), 4 deletions(-) (limited to 'participant/participant-impl/participant-impl-http/src/main') diff --git a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java index f5fb03054..966aee971 100644 --- a/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java +++ b/participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java @@ -23,6 +23,7 @@ package org.onap.policy.clamp.acm.participant.http.main.handler; import java.io.Closeable; import java.io.IOException; import java.lang.invoke.MethodHandles; +import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; @@ -41,7 +42,11 @@ import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationComposit import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; import org.onap.policy.clamp.common.acm.exception.AutomationCompositionException; import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy; +import org.onap.policy.clamp.models.acm.concepts.AcTypeState; +import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition; import org.onap.policy.clamp.models.acm.concepts.DeployState; +import org.onap.policy.clamp.models.acm.concepts.LockState; +import org.onap.policy.clamp.models.acm.concepts.StateChangeResult; import org.onap.policy.common.utils.coder.Coder; import org.onap.policy.common.utils.coder.CoderException; import org.onap.policy.common.utils.coder.StandardCoder; @@ -78,7 +83,7 @@ public class AutomationCompositionElementHandler implements AutomationCompositio @Override public void undeploy(UUID automationCompositionId, UUID automationCompositionElementId) { intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, automationCompositionElementId, - DeployState.UNDEPLOYED, null, ""); + DeployState.UNDEPLOYED, null, StateChangeResult.NO_ERROR, ""); } /** @@ -100,14 +105,15 @@ public class AutomationCompositionElementHandler implements AutomationCompositio .collect(Collectors.toList()); if (failedResponseStatus.isEmpty()) { intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), - DeployState.DEPLOYED, null, "Deployed"); + DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Deployed"); } else { intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), - DeployState.UNDEPLOYED, null, "Error on Invoking the http request: " + failedResponseStatus); + DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, + "Error on Invoking the http request: " + failedResponseStatus); } } catch (AutomationCompositionException e) { intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), - DeployState.UNDEPLOYED, null, e.getMessage()); + DeployState.UNDEPLOYED, null, StateChangeResult.FAILED, e.getMessage()); } } @@ -149,6 +155,43 @@ public class AutomationCompositionElementHandler implements AutomationCompositio } } + @Override + public void lock(UUID instanceId, UUID elementId) throws PfModelException { + intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId, null, LockState.LOCKED, + StateChangeResult.NO_ERROR, "Locked"); + } + + @Override + public void unlock(UUID instanceId, UUID elementId) throws PfModelException { + intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId, null, LockState.UNLOCKED, + StateChangeResult.NO_ERROR, "Unlocked"); + } + + @Override + public void delete(UUID instanceId, UUID elementId) throws PfModelException { + intermediaryApi.updateAutomationCompositionElementState(instanceId, elementId, DeployState.DELETED, null, + StateChangeResult.NO_ERROR, "Deleted"); + } + + @Override + public void update(UUID instanceId, AcElementDeploy element, Map properties) + throws PfModelException { + intermediaryApi.updateAutomationCompositionElementState(instanceId, element.getId(), DeployState.DEPLOYED, null, + StateChangeResult.NO_ERROR, "Update not supported"); + } + + @Override + public void prime(UUID compositionId, List elementDefinitionList) + throws PfModelException { + intermediaryApi.updateCompositionState(compositionId, AcTypeState.PRIMED, StateChangeResult.NO_ERROR, "Primed"); + } + + @Override + public void deprime(UUID compositionId) throws PfModelException { + intermediaryApi.updateCompositionState(compositionId, AcTypeState.COMMISSIONED, StateChangeResult.NO_ERROR, + "Deprimed"); + } + /** * Closes this stream and releases any system resources associated * with it. If the stream is already closed then invoking this -- cgit 1.2.3-korg