aboutsummaryrefslogtreecommitdiffstats
path: root/participant/participant-impl/participant-impl-http
diff options
context:
space:
mode:
authorFrancescoFioraEst <francesco.fiora@est.tech>2024-02-14 16:30:56 +0000
committerFrancescoFioraEst <francesco.fiora@est.tech>2024-02-15 15:29:53 +0000
commite0a13196ebb34c84931df27ba00cd1778adbceb9 (patch)
tree64f1af69d7802ee41a08278ec1e84b21241c1fb5 /participant/participant-impl/participant-impl-http
parent665815fc5c91c3437a0b0459448994789464a391 (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-http')
-rw-r--r--participant/participant-impl/participant-impl-http/src/main/java/org/onap/policy/clamp/acm/participant/http/main/handler/AutomationCompositionElementHandler.java86
1 files changed, 8 insertions, 78 deletions
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 883b8a17b..752b8d938 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
@@ -1,6 +1,6 @@
/*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2021-2023 Nordix Foundation.
+ * Copyright (C) 2021-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,16 @@ package org.onap.policy.clamp.acm.participant.http.main.handler;
import jakarta.validation.Validation;
import jakarta.ws.rs.core.Response.Status;
import java.lang.invoke.MethodHandles;
-import java.util.List;
import java.util.Map;
import java.util.UUID;
-import lombok.RequiredArgsConstructor;
import org.onap.policy.clamp.acm.participant.http.main.models.ConfigRequest;
import org.onap.policy.clamp.acm.participant.http.main.webclient.AcHttpClient;
-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.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.clamp.models.acm.utils.AcmUtils;
import org.onap.policy.common.utils.coder.Coder;
import org.onap.policy.common.utils.coder.CoderException;
import org.onap.policy.common.utils.coder.StandardCoder;
@@ -52,17 +46,19 @@ 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 AcHttpClient acHttpClient;
+ public AutomationCompositionElementHandler(ParticipantIntermediaryApi intermediaryApi, AcHttpClient acHttpClient) {
+ super(intermediaryApi);
+ this.acHttpClient = acHttpClient;
+ }
+
/**
* Handle a automation composition element state change.
*
@@ -119,70 +115,4 @@ public class AutomationCompositionElementHandler implements AutomationCompositio
throw new AutomationCompositionException(Status.BAD_REQUEST, "Error extracting ConfigRequest ", e);
}
}
-
- @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)) {
- deploy(automationCompositionId, element, properties);
- return;
- }
- deployState = AcmUtils.deployCompleted(deployState);
- lockState = AcmUtils.lockCompleted(deployState, lockState);
- 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");
- }
}