...
Old implementation:
Code Block |
---|
language | java |
---|
title | AcElementListenerV2 |
---|
|
@Override
public void handleRestartInstance(CompositionElementDto compositionElement, InstanceElementDto instanceElement,
DeployState deployState, LockState lockState) throws PfModelException {
if (DeployState.DEPLOYING.equals(deployState)) {
deploy(compositionElement, instanceElement);
return;
}
if (DeployState.UNDEPLOYING.equals(deployState)) {
undeploy(compositionElement, instanceElement);
return;
}
if (DeployState.UPDATING.equals(deployState)) {
update(compositionElement, instanceElement, instanceElement);
return;
}
if (DeployState.DELETING.equals(deployState)) {
delete(compositionElement, instanceElement);
return;
}
if (LockState.LOCKING.equals(lockState)) {
lock(compositionElement, instanceElement);
return;
}
if (LockState.UNLOCKING.equals(lockState)) {
unlock(compositionElement, instanceElement);
return;
}
intermediaryApi.updateAutomationCompositionElementState(instanceElement.instanceId(),
instanceElement.elementId(), deployState, lockState, StateChangeResult.NO_ERROR, "Restarted");
}
|
...
Refactored:
Code Block |
---|
language | java |
---|
title | AcElementListenerV2 |
---|
|
@Override
public void handleRestartInstance(CompositionElementDto compositionElement, InstanceElementDto instanceElement,
DeployState deployState, LockState lockState) throws PfModelException {
} |
Policy participant:
Code Block |
---|
language | java |
---|
title | AcElementListenerV2 |
---|
|
@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;
}
if (DeployState.UNDEPLOYING.equals(deployState) || DeployState.DEPLOYED.equals(deployState)
|| DeployState.UPDATING.equals(deployState)) {
var automationCompositionDefinition = element.getToscaServiceTemplateFragment();
serviceTemplateMap.put(element.getId(), automationCompositionDefinition);
}
if (DeployState.UNDEPLOYING.equals(deployState)) {
undeploy(automationCompositionId, element.getId());
return;
}
deployState = AcmUtils.deployCompleted(deployState);
lockState = AcmUtils.lockCompleted(deployState, lockState);
intermediaryApi.updateAutomationCompositionElementState(automationCompositionId, element.getId(), deployState,
lockState, StateChangeResult.NO_ERROR, "Restarted");
} |
Policy participant refactored:
Code Block |
---|
language | java |
---|
title | AcElementListenerV2 |
---|
|
@Override
public void handleRestartInstance(UUID automationCompositionId, AcElementDeploy element,
Map<String, Object> properties, DeployState deployState, LockState lockState) throws PfModelException {
var automationCompositionDefinition = element.getToscaServiceTemplateFragment();
serviceTemplateMap.put(element.getId(), automationCompositionDefinition);
} |