Search in sources :

Example 1 with ExtensionPlan

use of org.xwiki.extension.job.plan.ExtensionPlan in project xwiki-platform by xwiki.

the class OutdatedExtensionsDistributionStep method createRepairPlan.

private ExtensionPlan createRepairPlan(ExtensionId invalidExtension, String namespace) throws JobException, InterruptedException {
    // Install the default UI
    InstallRequest installRequest = new InstallRequest();
    installRequest.setId(ExtensionRequest.getJobId(ExtensionRequest.JOBID_PLAN_PREFIX, invalidExtension.getId(), namespace));
    installRequest.addExtension(invalidExtension);
    installRequest.addNamespace(namespace);
    // Don't take any risk
    installRequest.setUninstallAllowed(false);
    // Indicate if it's allowed to do modification on root namespace
    installRequest.setRootModificationsAllowed(true);
    installRequest.setInteractive(false);
    // Set user to use as author (for example) to be superadmin
    installRequest.setExtensionProperty(AbstractExtensionValidator.PROPERTY_USERREFERENCE, XWikiRightService.SUPERADMIN_USER_FULLNAME);
    Job job = this.jobExecutor.execute(UpgradePlanJob.JOBTYPE, installRequest);
    job.join();
    return (ExtensionPlan) job.getStatus();
}
Also used : ExtensionPlan(org.xwiki.extension.job.plan.ExtensionPlan) InstallRequest(org.xwiki.extension.job.InstallRequest) Job(org.xwiki.job.Job) UpgradePlanJob(org.xwiki.extension.job.internal.UpgradePlanJob)

Example 2 with ExtensionPlan

use of org.xwiki.extension.job.plan.ExtensionPlan in project xwiki-platform by xwiki.

the class OutdatedExtensionsDistributionStep method repair.

private void repair(ExtensionId invalidExtension, String namespace) throws JobException, InterruptedException {
    // Find valid extension version
    ExtensionPlan plan = createRepairPlan(invalidExtension, namespace);
    // Install valid extension version
    if (plan.getTree().size() > 0) {
        ExtensionPlanAction action = plan.getTree().iterator().next().getAction();
        install(action.getExtension().getId(), namespace, false);
    }
}
Also used : ExtensionPlan(org.xwiki.extension.job.plan.ExtensionPlan) ExtensionPlanAction(org.xwiki.extension.job.plan.ExtensionPlanAction)

Aggregations

ExtensionPlan (org.xwiki.extension.job.plan.ExtensionPlan)2 InstallRequest (org.xwiki.extension.job.InstallRequest)1 UpgradePlanJob (org.xwiki.extension.job.internal.UpgradePlanJob)1 ExtensionPlanAction (org.xwiki.extension.job.plan.ExtensionPlanAction)1 Job (org.xwiki.job.Job)1