Search in sources :

Example 1 with WikiProvisioningJobException

use of org.xwiki.wiki.provisioning.WikiProvisioningJobException in project xwiki-platform by xwiki.

the class DefaultWikiProvisioningJobExecutor method createAndExecuteJob.

@Override
public WikiProvisioningJob createAndExecuteJob(String wikiId, String provisioningJobName, Object parameter) throws WikiProvisioningJobException {
    try {
        // Get the context
        XWikiContext xcontext = xcontextProvider.get();
        // Create the job
        WikiProvisioningJob job = componentManager.getInstance(Job.class, provisioningJobName);
        // Id of the new job
        List<String> jobId = new ArrayList<String>();
        jobId.add("wiki");
        jobId.add("provisioning");
        jobId.add(provisioningJobName);
        jobId.add(wikiId);
        // Initialize it
        job.initialize(new WikiProvisioningJobRequest(jobId, wikiId, parameter, xcontext.getUserReference()));
        // Add it to the list of jobs
        jobs.put(jobId, job);
        // Pass it to the executor
        jobExecutor.execute(job);
        // Return the job
        return job;
    } catch (ComponentLookupException e) {
        throw new WikiProvisioningJobException(String.format("Failed to lookup provisioning job component for role [%s]", provisioningJobName), e);
    }
}
Also used : WikiProvisioningJobException(org.xwiki.wiki.provisioning.WikiProvisioningJobException) ArrayList(java.util.ArrayList) XWikiContext(com.xpn.xwiki.XWikiContext) WikiProvisioningJobRequest(org.xwiki.wiki.provisioning.WikiProvisioningJobRequest) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) WikiProvisioningJob(org.xwiki.wiki.provisioning.WikiProvisioningJob)

Aggregations

XWikiContext (com.xpn.xwiki.XWikiContext)1 ArrayList (java.util.ArrayList)1 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)1 WikiProvisioningJob (org.xwiki.wiki.provisioning.WikiProvisioningJob)1 WikiProvisioningJobException (org.xwiki.wiki.provisioning.WikiProvisioningJobException)1 WikiProvisioningJobRequest (org.xwiki.wiki.provisioning.WikiProvisioningJobRequest)1