Search in sources :

Example 16 with JobStatus

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

the class XWiki method getCurrentInitializerJobStatus.

/**
 * @return the status of the job initializing the instance or the current wiki
 * @since 8.4RC1
 */
public JobStatus getCurrentInitializerJobStatus() {
    // Get XWiki initializer job
    JobStatus jobStatus = getJobStatus();
    if (jobStatus == null) {
        return null;
    }
    // The XWiki initialization is not done yet
    if (jobStatus.getState() != State.FINISHED) {
        return jobStatus;
    }
    // If XWiki initialization did not failed
    if (this.xwiki != null) {
        // Get current wiki initializer job
        Job wikiJob = this.xwiki.getWikiInitializerJob(this.context.getWikiId());
        jobStatus = wikiJob != null ? wikiJob.getStatus() : null;
    }
    return jobStatus;
}
Also used : JobStatus(org.xwiki.job.event.status.JobStatus) XWikiInitializerJobStatus(com.xpn.xwiki.internal.XWikiInitializerJobStatus) XWikiInitializerJob(com.xpn.xwiki.internal.XWikiInitializerJob) Job(org.xwiki.job.Job)

Example 17 with JobStatus

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

the class XWikiJobResource method getRealJobStatus.

protected JobStatus getRealJobStatus(String jobId) throws WebApplicationException {
    JobStatus jobStatus;
    String[] idArray = jobId.split("/");
    List<String> id = new ArrayList<>(idArray.length);
    // Unescape id sections
    for (String idElement : idArray) {
        try {
            id.add(URLDecoder.decode(idElement, "UTF8"));
        } catch (UnsupportedEncodingException e) {
            throw new WebApplicationException(e);
        }
    }
    // Search job
    Job job = this.jobExecutor.getJob(id);
    if (job == null) {
        jobStatus = this.jobStore.getJobStatus(id);
    } else {
        jobStatus = job.getStatus();
    }
    if (jobStatus == null) {
        throw new WebApplicationException(Response.Status.NOT_FOUND);
    }
    return jobStatus;
}
Also used : JobStatus(org.xwiki.job.event.status.JobStatus) WebApplicationException(javax.ws.rs.WebApplicationException) ArrayList(java.util.ArrayList) UnsupportedEncodingException(java.io.UnsupportedEncodingException) 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