Search in sources :

Example 1 with ReportDistributionStep

use of org.xwiki.extension.distribution.internal.job.step.ReportDistributionStep in project xwiki-platform by xwiki.

the class AbstractDistributionJob method runInternal.

@Override
protected void runInternal() throws Exception {
    List<DistributionStep> steps = getStatus().getSteps();
    this.progressManager.pushLevelProgress(steps.size(), this);
    // Initialize steps
    WelcomeDistributionStep welcomeStep = (WelcomeDistributionStep) getStep(steps, WelcomeDistributionStep.ID);
    ReportDistributionStep reportStep = (ReportDistributionStep) getStep(steps, ReportDistributionStep.ID);
    for (DistributionStep step : steps) {
        step.initialize(this);
        // Enable Welcome step if one of the steps is enabled
        if (step.getState() == null) {
            if (welcomeStep != null) {
                welcomeStep.setState(null);
            }
            if (reportStep != null) {
                reportStep.setState(null);
            }
        }
    }
    // Execute steps
    try {
        for (int index = 0; index < steps.size(); ++index) {
            this.progressManager.startStep(this);
            getStatus().setCurrentStateIndex(index);
            DistributionStep step = steps.get(index);
            // Prepare step
            step.prepare();
            // Execute step
            if (step.getState() == null) {
                if (getRequest().isInteractive()) {
                    DistributionQuestion question = new DistributionQuestion(step);
                    // Waiting to start
                    signalReady();
                    getStatus().ask(question);
                    if (question.getAction() != null) {
                        switch(question.getAction()) {
                            case CANCEL:
                                for (; index < steps.size(); ++index) {
                                    steps.get(index).setState(DistributionStep.State.CANCELED);
                                }
                            case SKIP:
                                index = steps.size() - 1;
                                break;
                            default:
                                break;
                        }
                    }
                    // Save the status so that we remember the answer even if the DW is stopped before the end
                    this.store.storeAsync(this.status);
                } else {
                    step.executeNonInteractive();
                }
            }
            this.progressManager.endStep(this);
        }
    } finally {
        this.progressManager.popLevelProgress(this);
    }
}
Also used : WelcomeDistributionStep(org.xwiki.extension.distribution.internal.job.step.WelcomeDistributionStep) DistributionStep(org.xwiki.extension.distribution.internal.job.step.DistributionStep) ReportDistributionStep(org.xwiki.extension.distribution.internal.job.step.ReportDistributionStep) ReportDistributionStep(org.xwiki.extension.distribution.internal.job.step.ReportDistributionStep) WelcomeDistributionStep(org.xwiki.extension.distribution.internal.job.step.WelcomeDistributionStep)

Aggregations

DistributionStep (org.xwiki.extension.distribution.internal.job.step.DistributionStep)1 ReportDistributionStep (org.xwiki.extension.distribution.internal.job.step.ReportDistributionStep)1 WelcomeDistributionStep (org.xwiki.extension.distribution.internal.job.step.WelcomeDistributionStep)1