Search in sources :

Example 1 with JobStatus

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

the class DefaultDistributionManager method getPreviousFarmJobStatus.

@Override
public DistributionJobStatus getPreviousFarmJobStatus() {
    JobStatus jobStatus = this.jobStore.getJobStatus(getFarmJobId());
    DistributionJobStatus farmJobStatus;
    if (jobStatus != null) {
        if (jobStatus instanceof DistributionJobStatus) {
            farmJobStatus = (DistributionJobStatus) jobStatus;
        } else {
            // RETRO-COMPATIBILITY: the status used to be a DistributionJobStatus
            farmJobStatus = new DistributionJobStatus(jobStatus, this.observationManagerProvider.get(), this.loggerManagerProvider.get());
        }
    } else {
        farmJobStatus = null;
    }
    return farmJobStatus;
}
Also used : JobStatus(org.xwiki.job.event.status.JobStatus) DistributionJobStatus(org.xwiki.extension.distribution.internal.job.DistributionJobStatus) DistributionJobStatus(org.xwiki.extension.distribution.internal.job.DistributionJobStatus)

Example 2 with JobStatus

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

the class WikiTemplateManagerScriptTest method getWikiProvisioningJobStatusWithBadId.

@Test
public void getWikiProvisioningJobStatusWithBadId() throws Exception {
    List<String> jobId = new ArrayList<String>();
    JobStatus result = mocker.getComponentUnderTest().getWikiProvisioningJobStatus(jobId);
    assertEquals(null, result);
}
Also used : JobStatus(org.xwiki.job.event.status.JobStatus) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 3 with JobStatus

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

the class WikiTemplateManagerScriptTest method getWikiProvisioningJobStatus.

@Test
public void getWikiProvisioningJobStatus() throws Exception {
    WikiProvisioningJob job = mock(WikiProvisioningJob.class);
    when(wikiTemplateManager.getWikiProvisioningJob(anyList())).thenReturn(job);
    JobStatus status = mock(JobStatus.class);
    when(job.getStatus()).thenReturn(status);
    List<String> jobId = new ArrayList<String>();
    JobStatus result = mocker.getComponentUnderTest().getWikiProvisioningJobStatus(jobId);
    assertEquals(status, result);
}
Also used : JobStatus(org.xwiki.job.event.status.JobStatus) ArrayList(java.util.ArrayList) WikiProvisioningJob(org.xwiki.wiki.provisioning.WikiProvisioningJob) Test(org.junit.Test)

Example 4 with JobStatus

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

the class WikiTemplateManagerScriptTest method getWikiProvisioningJobStatusWithException.

@Test
public void getWikiProvisioningJobStatusWithException() throws Exception {
    Exception exception = new WikiTemplateManagerException("test");
    when(wikiTemplateManager.getWikiProvisioningJob(anyList())).thenThrow(exception);
    List<String> jobId = new ArrayList<String>();
    JobStatus result = mocker.getComponentUnderTest().getWikiProvisioningJobStatus(jobId);
    assertEquals(null, result);
    assertEquals(exception, mocker.getComponentUnderTest().getLastError());
    verify(mocker.getMockedLogger()).error("Failed to get tge wiki provisioning job.", exception);
}
Also used : JobStatus(org.xwiki.job.event.status.JobStatus) ArrayList(java.util.ArrayList) WikiTemplateManagerException(org.xwiki.wiki.template.WikiTemplateManagerException) WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException) WikiTemplateManagerException(org.xwiki.wiki.template.WikiTemplateManagerException) Test(org.junit.Test)

Example 5 with JobStatus

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

the class ExtensionManagerScriptService method getCurrentJobStatus.

/**
 * Get the status of the currently executing job, if any.
 *
 * @return status of the currently executing job, or {@code null} if no job is being executed
 */
public JobStatus getCurrentJobStatus() {
    Job job = getCurrentJobInternal();
    JobStatus jobStatus;
    if (job != null) {
        jobStatus = job.getStatus();
        if (!this.authorization.hasAccess(Right.PROGRAM)) {
            jobStatus = safe(jobStatus);
        }
    } else {
        jobStatus = null;
    }
    return jobStatus;
}
Also used : JobStatus(org.xwiki.job.event.status.JobStatus) UpgradePlanJob(org.xwiki.extension.job.internal.UpgradePlanJob) UninstallPlanJob(org.xwiki.extension.job.internal.UninstallPlanJob) UninstallJob(org.xwiki.extension.job.internal.UninstallJob) InstallJob(org.xwiki.extension.job.internal.InstallJob) Job(org.xwiki.job.Job) InstallPlanJob(org.xwiki.extension.job.internal.InstallPlanJob) AbstractExtensionJob(org.xwiki.extension.job.internal.AbstractExtensionJob)

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