diff options
author | FrancescoFioraEst <francesco.fiora@est.tech> | 2024-02-14 16:30:56 +0000 |
---|---|---|
committer | FrancescoFioraEst <francesco.fiora@est.tech> | 2024-02-15 15:29:53 +0000 |
commit | e0a13196ebb34c84931df27ba00cd1778adbceb9 (patch) | |
tree | 64f1af69d7802ee41a08278ec1e84b21241c1fb5 /participant/participant-impl/participant-impl-a1pms | |
parent | 665815fc5c91c3437a0b0459448994789464a391 (diff) |
Add old properties and new properties support
Add old/new properties support in migrate and update,
and add Java code backward compatibility.
Issue-ID: POLICY-4930
Change-Id: I640bc2a858969168b13fe6cdbb557ebf920bafd5
Signed-off-by: FrancescoFioraEst <francesco.fiora@est.tech>
Diffstat (limited to 'participant/participant-impl/participant-impl-a1pms')
-rw-r--r-- | participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java | 72 |
1 files changed, 9 insertions, 63 deletions
diff --git a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java index 02697facc..75f3edb0a 100644 --- a/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java +++ b/participant/participant-impl/participant-impl-a1pms/src/main/java/org/onap/policy/clamp/acm/participant/a1pms/handler/AutomationCompositionElementHandler.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2022-2023 Nordix Foundation. + * Copyright (C) 2022-2024 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,22 +23,18 @@ package org.onap.policy.clamp.acm.participant.a1pms.handler; import jakarta.validation.Validation; import jakarta.validation.ValidationException; import java.lang.invoke.MethodHandles; -import java.util.List; import java.util.Map; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import lombok.AccessLevel; import lombok.Getter; -import lombok.RequiredArgsConstructor; import org.apache.http.HttpStatus; import org.onap.policy.clamp.acm.participant.a1pms.exception.A1PolicyServiceException; import org.onap.policy.clamp.acm.participant.a1pms.models.ConfigurationEntity; import org.onap.policy.clamp.acm.participant.a1pms.webclient.AcA1PmsClient; -import org.onap.policy.clamp.acm.participant.intermediary.api.AutomationCompositionElementListener; import org.onap.policy.clamp.acm.participant.intermediary.api.ParticipantIntermediaryApi; +import org.onap.policy.clamp.acm.participant.intermediary.api.impl.AcElementListenerV1; 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; @@ -55,21 +51,24 @@ import org.springframework.stereotype.Component; * This class handles implementation of automationCompositionElement updates. */ @Component -@RequiredArgsConstructor -public class AutomationCompositionElementHandler implements AutomationCompositionElementListener { +public class AutomationCompositionElementHandler extends AcElementListenerV1 { private static final Coder CODER = new StandardCoder(); private static final Logger LOGGER = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass()); - private final ParticipantIntermediaryApi intermediaryApi; - private final AcA1PmsClient acA1PmsClient; // Map of acElement Id and A1PMS services @Getter(AccessLevel.PACKAGE) private final Map<UUID, ConfigurationEntity> configRequestMap = new ConcurrentHashMap<>(); + public AutomationCompositionElementHandler(ParticipantIntermediaryApi intermediaryApi, + AcA1PmsClient acA1PmsClient) { + super(intermediaryApi); + this.acA1PmsClient = acA1PmsClient; + } + /** * Handle a automation composition element state change. * @@ -128,52 +127,6 @@ 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<String, Object> properties) - throws PfModelException { - intermediaryApi.updateAutomationCompositionElementState(instanceId, element.getId(), DeployState.DEPLOYED, null, - StateChangeResult.NO_ERROR, "Update not supported"); - } - - @Override - public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> 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"); - } - - @Override - public void handleRestartComposition(UUID compositionId, - List<AutomationCompositionElementDefinition> elementDefinitionList, AcTypeState state) - throws PfModelException { - var finalState = AcTypeState.PRIMED.equals(state) || AcTypeState.PRIMING.equals(state) ? AcTypeState.PRIMED - : AcTypeState.COMMISSIONED; - intermediaryApi.updateCompositionState(compositionId, finalState, StateChangeResult.NO_ERROR, "Restarted"); - } - - @Override public void handleRestartInstance(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties, DeployState deployState, LockState lockState) throws PfModelException { if (DeployState.DEPLOYING.equals(deployState)) { @@ -198,11 +151,4 @@ public class AutomationCompositionElementHandler implements AutomationCompositio intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), deployState, lockState, StateChangeResult.NO_ERROR, "Restarted"); } - - @Override - public void migrate(UUID automationCompositionId, AcElementDeploy element, UUID compositionTargetId, - Map<String, Object> properties) throws PfModelException { - intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), - DeployState.DEPLOYED, null, StateChangeResult.NO_ERROR, "Migrated"); - } } |