Search in sources :

Example 41 with Job

use of org.xwiki.job.Job 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

Job (org.xwiki.job.Job)41 Test (org.junit.Test)11 JobStatus (org.xwiki.job.event.status.JobStatus)10 AbstractExtensionJob (org.xwiki.extension.job.internal.AbstractExtensionJob)8 InstallJob (org.xwiki.extension.job.internal.InstallJob)8 UninstallJob (org.xwiki.extension.job.internal.UninstallJob)8 JobException (org.xwiki.job.JobException)8 DocumentReference (org.xwiki.model.reference.DocumentReference)8 InstallRequest (org.xwiki.extension.job.InstallRequest)7 UpgradePlanJob (org.xwiki.extension.job.internal.UpgradePlanJob)7 InstallPlanJob (org.xwiki.extension.job.internal.InstallPlanJob)6 UninstallPlanJob (org.xwiki.extension.job.internal.UninstallPlanJob)6 XWikiException (com.xpn.xwiki.XWikiException)5 LogEvent (org.xwiki.logging.event.LogEvent)5 InstallException (org.xwiki.extension.InstallException)4 UninstallException (org.xwiki.extension.UninstallException)4 XarInstalledExtension (org.xwiki.extension.xar.internal.repository.XarInstalledExtension)4 EntityReference (org.xwiki.model.reference.EntityReference)4 WikiReference (org.xwiki.model.reference.WikiReference)4 IOException (java.io.IOException)3