summaryrefslogtreecommitdiffstats
path: root/participant/participant-intermediary/src/main/java/org
diff options
context:
space:
mode:
Diffstat (limited to 'participant/participant-intermediary/src/main/java/org')
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java28
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java8
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java14
-rw-r--r--participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java43
4 files changed, 46 insertions, 47 deletions
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java
index c8fd91d69..6ca4d3cc7 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/AutomationCompositionElementListener.java
@@ -20,9 +20,11 @@
package org.onap.policy.clamp.acm.participant.intermediary.api;
+import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.onap.policy.clamp.models.acm.concepts.AcElementDeploy;
+import org.onap.policy.clamp.models.acm.concepts.AutomationCompositionElementDefinition;
import org.onap.policy.models.base.PfModelException;
/**
@@ -48,23 +50,17 @@ public interface AutomationCompositionElementListener {
public void deploy(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties)
throws PfModelException;
- public default void lock(UUID automationCompositionId, UUID automationCompositionElementId)
- throws PfModelException {
- // default Lock Operation
- }
+ public void lock(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException;
- public default void unlock(UUID automationCompositionId, UUID automationCompositionElementId)
- throws PfModelException {
- // default Unlock Operation
- }
+ public void unlock(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException;
- public default void delete(UUID automationCompositionId, UUID automationCompositionElementId)
- throws PfModelException {
- // default Delete Operation
- }
+ public void delete(UUID automationCompositionId, UUID automationCompositionElementId) throws PfModelException;
- public default void update(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties)
- throws PfModelException {
- // default update Operation
- }
+ public void update(UUID automationCompositionId, AcElementDeploy element, Map<String, Object> properties)
+ throws PfModelException;
+
+ public void prime(UUID compositionId, List<AutomationCompositionElementDefinition> elementDefinitionList)
+ throws PfModelException;
+
+ public void deprime(UUID compositionId) throws PfModelException;
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java
index 550ac37c5..1677f5486 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/ParticipantIntermediaryApi.java
@@ -23,9 +23,11 @@ package org.onap.policy.clamp.acm.participant.intermediary.api;
import java.util.Map;
import java.util.UUID;
+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.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
+import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
/**
* This interface is used by participant implementations to use the participant intermediary.
@@ -47,10 +49,11 @@ public interface ParticipantIntermediaryApi {
* @param id the ID of the automation composition element to update the state on
* @param deployState the Deploy State of the automation composition element
* @param lockState the Lock State of the automation composition element
+ * @param stateChangeResult the indicator if error occurs
* @param message the message
*/
void updateAutomationCompositionElementState(UUID automationCompositionId, UUID id, DeployState deployState,
- LockState lockState, String message);
+ LockState lockState, StateChangeResult stateChangeResult, String message);
/**
* Get AutomationCompositions.
@@ -70,4 +73,7 @@ public interface ParticipantIntermediaryApi {
*/
void sendAcElementInfo(UUID automationCompositionId, UUID id, String useState, String operationalState,
Map<String, Object> outProperties);
+
+ void updateCompositionState(UUID compositionId, AcTypeState state, StateChangeResult stateChangeResult,
+ String message);
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
index 1bc3e5e72..14a653113 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/api/impl/ParticipantIntermediaryApiImpl.java
@@ -26,9 +26,11 @@ import java.util.UUID;
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.handler.AutomationCompositionHandler;
+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.DeployState;
import org.onap.policy.clamp.models.acm.concepts.LockState;
+import org.onap.policy.clamp.models.acm.concepts.StateChangeResult;
import org.onap.policy.models.base.PfUtils;
import org.springframework.stereotype.Component;
@@ -57,9 +59,9 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp
}
@Override
- public void updateAutomationCompositionElementState(UUID automationCompositionId, UUID id, DeployState newState,
- LockState lockState, String message) {
- automationCompositionHandler.updateAutomationCompositionElementState(automationCompositionId, id, newState,
+ public void updateAutomationCompositionElementState(UUID automationCompositionId, UUID id, DeployState deployState,
+ LockState lockState, StateChangeResult stateChangeResult, String message) {
+ automationCompositionHandler.updateAutomationCompositionElementState(automationCompositionId, id, deployState,
lockState, message);
}
@@ -74,4 +76,10 @@ public class ParticipantIntermediaryApiImpl implements ParticipantIntermediaryAp
public Map<UUID, AutomationComposition> getAutomationCompositions() {
return PfUtils.mapMap(automationCompositionHandler.getAutomationCompositionMap(), AutomationComposition::new);
}
+
+ @Override
+ public void updateCompositionState(UUID compositionId, AcTypeState state, StateChangeResult stateChangeResult,
+ String message) {
+ // Auto-generated method stub
+ }
}
diff --git a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java
index 514bc655f..045677704 100644
--- a/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java
+++ b/participant/participant-intermediary/src/main/java/org/onap/policy/clamp/acm/participant/intermediary/handler/AutomationCompositionHandler.java
@@ -137,6 +137,10 @@ public class AutomationCompositionHandler {
if (checkOpt.isEmpty()) {
automationComposition.setDeployState(deployState);
automationComposition.setLockState(element.getLockState());
+
+ if (DeployState.DELETED.equals(deployState)) {
+ automationCompositionMap.remove(automationComposition.getInstanceId());
+ }
}
}
if (lockState != null) {
@@ -272,7 +276,7 @@ public class AutomationCompositionHandler {
* @param acElementDefinitions the list of AutomationCompositionElementDefinition
*/
public void handleAcPropertyUpdate(PropertiesUpdate updateMsg,
- List<AutomationCompositionElementDefinition> acElementDefinitions) {
+ List<AutomationCompositionElementDefinition> acElementDefinitions) {
if (updateMsg.getParticipantUpdatesList().isEmpty()) {
LOGGER.warn("No AutomationCompositionElement updates in message {}",
@@ -283,8 +287,8 @@ public class AutomationCompositionHandler {
for (var participantDeploy : updateMsg.getParticipantUpdatesList()) {
if (participantId.equals(participantDeploy.getParticipantId())) {
- initializeDeploy(updateMsg.getMessageId(), updateMsg.getAutomationCompositionId(),
- participantDeploy, DeployState.UPDATING);
+ initializeDeploy(updateMsg.getMessageId(), updateMsg.getAutomationCompositionId(), participantDeploy,
+ DeployState.UPDATING);
callParticipantUpdateProperty(participantDeploy.getAcElementList(), acElementDefinitions,
updateMsg.getAutomationCompositionId());
@@ -320,7 +324,7 @@ public class AutomationCompositionHandler {
}
private void initializeDeploy(UUID messageId, UUID instanceId, ParticipantDeploy participantDeploy,
- DeployState deployState) {
+ DeployState deployState) {
if (automationCompositionMap.containsKey(instanceId)) {
updateExistingElementsOnThisParticipant(instanceId, participantDeploy, deployState);
} else {
@@ -333,12 +337,11 @@ public class AutomationCompositionHandler {
}
private void callParticipantDeploy(List<AcElementDeploy> acElements,
- List<AutomationCompositionElementDefinition> acElementDefinitions,
- Integer startPhaseMsg, UUID automationCompositionId) {
+ List<AutomationCompositionElementDefinition> acElementDefinitions, Integer startPhaseMsg,
+ UUID automationCompositionId) {
try {
for (var element : acElements) {
- var acElementNodeTemplate = getAcElementNodeTemplate(acElementDefinitions,
- element.getDefinition());
+ var acElementNodeTemplate = getAcElementNodeTemplate(acElementDefinitions, element.getDefinition());
if (acElementNodeTemplate != null) {
int startPhase = ParticipantUtils.findStartPhase(acElementNodeTemplate.getProperties());
if (startPhaseMsg.equals(startPhase)) {
@@ -357,12 +360,10 @@ public class AutomationCompositionHandler {
}
private void callParticipantUpdateProperty(List<AcElementDeploy> acElements,
- List<AutomationCompositionElementDefinition> acElementDefinitions,
- UUID automationCompositionId) {
+ List<AutomationCompositionElementDefinition> acElementDefinitions, UUID automationCompositionId) {
try {
for (var element : acElements) {
- var acElementNodeTemplate = getAcElementNodeTemplate(acElementDefinitions,
- element.getDefinition());
+ var acElementNodeTemplate = getAcElementNodeTemplate(acElementDefinitions, element.getDefinition());
if (acElementNodeTemplate != null) {
for (var acElementListener : listeners) {
var map = new HashMap<>(acElementNodeTemplate.getProperties());
@@ -389,7 +390,7 @@ public class AutomationCompositionHandler {
}
private List<AutomationCompositionElement> storeElementsOnThisParticipant(ParticipantDeploy participantDeploy,
- DeployState deployState) {
+ DeployState deployState) {
List<AutomationCompositionElement> acElementList = new ArrayList<>();
for (var element : participantDeploy.getAcElementList()) {
var acElement = new AutomationCompositionElement();
@@ -403,8 +404,8 @@ public class AutomationCompositionHandler {
return acElementList;
}
- private void updateExistingElementsOnThisParticipant(
- UUID instanceId, ParticipantDeploy participantDeploy, DeployState deployState) {
+ private void updateExistingElementsOnThisParticipant(UUID instanceId, ParticipantDeploy participantDeploy,
+ DeployState deployState) {
Map<UUID, AutomationCompositionElement> elementList = automationCompositionMap.get(instanceId).getElements();
for (var element : participantDeploy.getAcElementList()) {
@@ -443,12 +444,6 @@ public class AutomationCompositionHandler {
automationComposition.getElements().values().stream()
.forEach(acElement -> automationCompositionElementDelete(automationComposition.getInstanceId(),
acElement, startPhaseMsg, acElementDefinitions));
-
- boolean isAllUninitialised = automationComposition.getElements().values().stream()
- .filter(element -> !DeployState.DELETED.equals(element.getDeployState())).findAny().isEmpty();
- if (isAllUninitialised) {
- automationCompositionMap.remove(automationComposition.getInstanceId());
- }
}
/**
@@ -488,8 +483,6 @@ public class AutomationCompositionHandler {
for (var acElementListener : listeners) {
try {
acElementListener.lock(instanceId, acElement.getId());
- updateAutomationCompositionElementState(instanceId, acElement.getId(), null, LockState.LOCKED,
- "Locked");
} catch (PfModelException e) {
LOGGER.error("Automation composition element lock failed {}", instanceId);
}
@@ -507,8 +500,6 @@ public class AutomationCompositionHandler {
for (var acElementListener : listeners) {
try {
acElementListener.unlock(instanceId, acElement.getId());
- updateAutomationCompositionElementState(instanceId, acElement.getId(), null, LockState.UNLOCKED,
- "Unlocked");
} catch (PfModelException e) {
LOGGER.error("Automation composition element unlock failed {}", instanceId);
}
@@ -537,8 +528,6 @@ public class AutomationCompositionHandler {
for (var acElementListener : listeners) {
try {
acElementListener.delete(instanceId, acElement.getId());
- updateAutomationCompositionElementState(instanceId, acElement.getId(), DeployState.DELETED,
- null, "Deleted");
} catch (PfModelException e) {
LOGGER.error("Automation composition element unlock failed {}", instanceId);
}