Search in sources :

Example 11 with JobStatus

use of org.xwiki.job.event.status.JobStatus in project xwiki-platform by xwiki.

the class DocumentsDeletingListenerTest method testWhenNonInteractive.

@Test
public void testWhenNonInteractive() throws Exception {
    Request request = mock(Request.class);
    Job job = mock(Job.class);
    when(job.getRequest()).thenReturn(request);
    when(request.isInteractive()).thenReturn(false);
    JobStatus status = mock(JobStatus.class);
    when(job.getStatus()).thenReturn(status);
    // Test
    DocumentsDeletingEvent event = new DocumentsDeletingEvent();
    mocker.getComponentUnderTest().onEvent(event, job, null);
    // Verify
    verify(mocker.getMockedLogger()).warn("XAR Extension Documents Deleting Listener will not check the document in non-interactive mode.");
    verifyZeroInteractions(status);
    verifyZeroInteractions(repository);
}
Also used : JobStatus(org.xwiki.job.event.status.JobStatus) Request(org.xwiki.job.Request) Job(org.xwiki.job.Job) DocumentsDeletingEvent(org.xwiki.bridge.event.DocumentsDeletingEvent) Test(org.junit.Test)

Example 12 with JobStatus

use of org.xwiki.job.event.status.JobStatus in project xwiki-platform by xwiki.

the class DistributionInternalScriptService method renderCurrentStepToXHTML.

public String renderCurrentStepToXHTML(String transformationId) {
    DistributionJob job = this.distributionManager.getCurrentDistributionJob();
    if (job != null) {
        JobStatus jobStatus = job.getStatus();
        if (jobStatus != null) {
            State jobState = jobStatus.getState();
            if (jobState == State.RUNNING || jobState == State.WAITING) {
                Block block = job.getCurrentStep().executeInteractive();
                WikiPrinter printer = new DefaultWikiPrinter();
                this.xhtmlRenderer.render(block, printer);
                return printer.toString();
            }
        }
    }
    return null;
}
Also used : JobStatus(org.xwiki.job.event.status.JobStatus) DistributionJobStatus(org.xwiki.extension.distribution.internal.job.DistributionJobStatus) DefaultWikiPrinter(org.xwiki.rendering.renderer.printer.DefaultWikiPrinter) DistributionJob(org.xwiki.extension.distribution.internal.job.DistributionJob) DistributionState(org.xwiki.extension.distribution.internal.DistributionManager.DistributionState) State(org.xwiki.job.event.status.JobStatus.State) Block(org.xwiki.rendering.block.Block) WikiPrinter(org.xwiki.rendering.renderer.printer.WikiPrinter) DefaultWikiPrinter(org.xwiki.rendering.renderer.printer.DefaultWikiPrinter)

Example 13 with JobStatus

use of org.xwiki.job.event.status.JobStatus in project xwiki-platform by xwiki.

the class FlavorSearchJob method createNewStatus.

@Override
protected DefaultFlavorSearchStatus createNewStatus(FlavorSearchRequest request) {
    Job currentJob = this.jobContext.getCurrentJob();
    JobStatus currentJobStatus = currentJob != null ? currentJob.getStatus() : null;
    return new DefaultFlavorSearchStatus(request, this.observationManager, this.loggerManager, this.foundFlavors, currentJobStatus);
}
Also used : JobStatus(org.xwiki.job.event.status.JobStatus) AbstractInstallPlanJob(org.xwiki.extension.job.internal.AbstractInstallPlanJob) Job(org.xwiki.job.Job)

Example 14 with JobStatus

use of org.xwiki.job.event.status.JobStatus in project xwiki-platform by xwiki.

the class JobScriptService method getJobStatus.

/**
 * @param jobId the job id
 * @return the status of the specified job, {@code null} if the status cannot be found
 */
public JobStatus getJobStatus(List<String> jobId) {
    JobStatus jobStatus;
    Job job = this.jobExecutor.getJob(jobId);
    if (job == null) {
        jobStatus = this.jobStore.getJobStatus(jobId);
    } else {
        jobStatus = job.getStatus();
    }
    if (jobStatus != null && !this.authorization.hasAccess(Right.PROGRAM)) {
        jobStatus = safe(jobStatus);
    }
    return jobStatus;
}
Also used : JobStatus(org.xwiki.job.event.status.JobStatus) Job(org.xwiki.job.Job)

Example 15 with JobStatus

use of org.xwiki.job.event.status.JobStatus in project xwiki-platform by xwiki.

the class JobScriptService method getCurrentJobStatus.

/**
 * Get the status of the currently executing job in the specified group job, if any.
 *
 * @param path specifies the job group where to look for a running job
 * @return status of the currently executing job in the specified group, or {@code null} if no job is being executed
 */
public JobStatus getCurrentJobStatus(Collection<String> path) {
    Job job = this.jobExecutor.getCurrentJob(new JobGroupPath(path));
    JobStatus jobStatus = null;
    if (job != null) {
        jobStatus = job.getStatus();
        if (!this.authorization.hasAccess(Right.PROGRAM)) {
            jobStatus = safe(jobStatus);
        }
    }
    return jobStatus;
}
Also used : JobStatus(org.xwiki.job.event.status.JobStatus) JobGroupPath(org.xwiki.job.JobGroupPath) Job(org.xwiki.job.Job)

Aggregations

JobStatus (org.xwiki.job.event.status.JobStatus)17 Job (org.xwiki.job.Job)10 Test (org.junit.Test)8 ArrayList (java.util.ArrayList)4 DocumentsDeletingEvent (org.xwiki.bridge.event.DocumentsDeletingEvent)3 Request (org.xwiki.job.Request)3 HashMap (java.util.HashMap)2 ExtensionId (org.xwiki.extension.ExtensionId)2 DistributionJobStatus (org.xwiki.extension.distribution.internal.job.DistributionJobStatus)2 XarInstalledExtension (org.xwiki.extension.xar.internal.repository.XarInstalledExtension)2 DocumentReference (org.xwiki.model.reference.DocumentReference)2 EntityReference (org.xwiki.model.reference.EntityReference)2 EntitySelection (org.xwiki.refactoring.job.question.EntitySelection)2 XWikiInitializerJob (com.xpn.xwiki.internal.XWikiInitializerJob)1 XWikiInitializerJobStatus (com.xpn.xwiki.internal.XWikiInitializerJobStatus)1 IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 WebApplicationException (javax.ws.rs.WebApplicationException)1 DistributionState (org.xwiki.extension.distribution.internal.DistributionManager.DistributionState)1 DistributionJob (org.xwiki.extension.distribution.internal.job.DistributionJob)1