Search in sources :

Example 1 with BadWorkflowOperationException

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);
        }
    }
}
Also used : InconsistentWorkflowException(alien4cloud.paas.wf.exception.InconsistentWorkflowException) NodeWorkflowStep(org.alien4cloud.tosca.model.workflow.NodeWorkflowStep) RelationshipWorkflowStep(org.alien4cloud.tosca.model.workflow.RelationshipWorkflowStep) WorkflowStep(org.alien4cloud.tosca.model.workflow.WorkflowStep) BadWorkflowOperationException(alien4cloud.paas.wf.exception.BadWorkflowOperationException) DelegateWorkflowActivity(org.alien4cloud.tosca.model.workflow.activities.DelegateWorkflowActivity)

Example 2 with BadWorkflowOperationException

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());
            }
        }
    }));
}
Also used : Component(org.springframework.stereotype.Component) Slf4j(lombok.extern.slf4j.Slf4j) RemoveWorkflowOperation(org.alien4cloud.tosca.editor.operations.workflow.RemoveWorkflowOperation) Csar(org.alien4cloud.tosca.model.Csar) InlineWorkflowActivity(org.alien4cloud.tosca.model.workflow.activities.InlineWorkflowActivity) Workflow(org.alien4cloud.tosca.model.workflow.Workflow) BadWorkflowOperationException(alien4cloud.paas.wf.exception.BadWorkflowOperationException) EditionContextManager(org.alien4cloud.tosca.editor.EditionContextManager) Topology(org.alien4cloud.tosca.model.templates.Topology) InlineWorkflowActivity(org.alien4cloud.tosca.model.workflow.activities.InlineWorkflowActivity) BadWorkflowOperationException(alien4cloud.paas.wf.exception.BadWorkflowOperationException)

Example 3 with BadWorkflowOperationException

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);
    }
}
Also used : Workflow(org.alien4cloud.tosca.model.workflow.Workflow) NotFoundException(alien4cloud.exception.NotFoundException) BadWorkflowOperationException(alien4cloud.paas.wf.exception.BadWorkflowOperationException)

Aggregations

BadWorkflowOperationException (alien4cloud.paas.wf.exception.BadWorkflowOperationException)3 Workflow (org.alien4cloud.tosca.model.workflow.Workflow)2 NotFoundException (alien4cloud.exception.NotFoundException)1 InconsistentWorkflowException (alien4cloud.paas.wf.exception.InconsistentWorkflowException)1 Slf4j (lombok.extern.slf4j.Slf4j)1 EditionContextManager (org.alien4cloud.tosca.editor.EditionContextManager)1 RemoveWorkflowOperation (org.alien4cloud.tosca.editor.operations.workflow.RemoveWorkflowOperation)1 Csar (org.alien4cloud.tosca.model.Csar)1 Topology (org.alien4cloud.tosca.model.templates.Topology)1 NodeWorkflowStep (org.alien4cloud.tosca.model.workflow.NodeWorkflowStep)1 RelationshipWorkflowStep (org.alien4cloud.tosca.model.workflow.RelationshipWorkflowStep)1 WorkflowStep (org.alien4cloud.tosca.model.workflow.WorkflowStep)1 DelegateWorkflowActivity (org.alien4cloud.tosca.model.workflow.activities.DelegateWorkflowActivity)1 InlineWorkflowActivity (org.alien4cloud.tosca.model.workflow.activities.InlineWorkflowActivity)1 Component (org.springframework.stereotype.Component)1