use of alien4cloud.paas.wf.exception.BadWorkflowOperationException in project alien4cloud by alien4cloud.
the class AbstractWorkflowBuilder method removeStep.
void removeStep(Workflow wf, String stepId, boolean force) {
WorkflowStep step = wf.getSteps().remove(stepId);
if (step == null) {
throw new InconsistentWorkflowException(String.format("Inconsistent workflow: a step nammed '%s' can not be found while it's referenced else where ...", stepId));
}
if (!force && step.getActivity() instanceof DelegateWorkflowActivity) {
throw new BadWorkflowOperationException("Native steps can not be removed from workflow");
}
if (step.getPrecedingSteps() != null) {
if (step.getOnSuccess() != null) {
// connect all preceding to all following
for (String precedingId : step.getPrecedingSteps()) {
WorkflowStep preceding = wf.getSteps().get(precedingId);
for (String followingId : step.getOnSuccess()) {
WorkflowStep following = wf.getSteps().get(followingId);
WorkflowUtils.linkSteps(preceding, following);
}
}
}
for (Object precedingId : step.getPrecedingSteps().toArray()) {
WorkflowStep preceding = wf.getSteps().get(precedingId);
unlinkSteps(preceding, step);
}
}
if (step.getOnSuccess() != null) {
for (Object followingId : step.getOnSuccess().toArray()) {
WorkflowStep following = wf.getSteps().get(followingId);
unlinkSteps(step, following);
}
}
}
use of alien4cloud.paas.wf.exception.BadWorkflowOperationException in project alien4cloud by alien4cloud.
the class RemoveWorkflowProcessor method processWorkflowOperation.
@Override
protected void processWorkflowOperation(Csar csar, Topology topology, RemoveWorkflowOperation operation, Workflow workflow) {
ensureNotStandard(workflow, "standard workflow <" + workflow.getName() + "> can not be removed");
log.debug("removing workflow [ {} ] from topology [ {} ]", operation.getWorkflowName(), topology.getId());
topology.getWorkflows().remove(operation.getWorkflowName());
topology.getWorkflows().values().forEach(wf -> wf.getSteps().values().forEach(step -> {
if (step.getActivity() instanceof InlineWorkflowActivity) {
InlineWorkflowActivity inlineWorkflowActivity = (InlineWorkflowActivity) step.getActivity();
if (inlineWorkflowActivity.getInline().equals(workflow.getName())) {
throw new BadWorkflowOperationException("Workflow " + inlineWorkflowActivity.getInline() + " is inlined in workflow " + wf.getName() + " in step " + step.getName());
}
}
}));
}
use of alien4cloud.paas.wf.exception.BadWorkflowOperationException in project alien4cloud by alien4cloud.
the class WorkflowsBuilderService method reinitWorkflow.
public void reinitWorkflow(String workflowName, TopologyContext topologyContext, boolean simplify) {
Workflow wf = topologyContext.getTopology().getWorkflows().get(workflowName);
if (wf == null) {
throw new NotFoundException(String.format("The workflow '%s' can not be found", workflowName));
}
if (!wf.isStandard()) {
throw new BadWorkflowOperationException(String.format("Reinit can not be performed on non standard workflow '%s'", workflowName));
}
AbstractWorkflowBuilder builder = getWorkflowBuilder(topologyContext.getDSLVersion(), wf);
wf = builder.reinit(wf, topologyContext);
WorkflowUtils.fillHostId(wf, topologyContext);
if (simplify) {
postProcessTopologyWorkflows(topologyContext);
}
}
Aggregations