Search in sources :

Example 1 with ScriptExtensionRewriter

use of org.xwiki.extension.script.ScriptExtensionRewriter in project xwiki-platform by xwiki.

the class AbstractExtensionDistributionStep method install.

protected void install(ExtensionId extensionId, String namespace, boolean jarOnRoot) throws JobException, InterruptedException {
    // Install the default UI
    InstallRequest installRequest = new InstallRequest();
    installRequest.setId(ExtensionRequest.getJobId(ExtensionRequest.JOBID_ACTION_PREFIX, extensionId.getId(), namespace));
    installRequest.addExtension(extensionId);
    installRequest.addNamespace(namespace);
    // Indicate it's allowed to do modification on root namespace
    installRequest.setRootModificationsAllowed(true);
    // Make sure the job is no interactive
    installRequest.setInteractive(false);
    if (jarOnRoot) {
        // Make sure jars are installed on root
        // TODO: use a less script oriented class
        ScriptExtensionRewriter rewriter = new ScriptExtensionRewriter();
        rewriter.installExtensionTypeOnRootNamespace("jar");
        rewriter.installExtensionTypeOnRootNamespace("webjar");
        installRequest.setRewriter(rewriter);
    }
    // Set the author to use
    installRequest.setProperty(AbstractExtensionValidator.PROPERTY_USERREFERENCE, new DocumentReference("xwiki", "XWiki", XWikiRightService.SUPERADMIN_USER));
    installRequest.setExtensionProperty(AbstractExtensionValidator.PROPERTY_USERREFERENCE, XWikiRightService.SUPERADMIN_USER_FULLNAME);
    this.jobExecutor.execute(InstallJob.JOBTYPE, installRequest).join();
}
Also used : ScriptExtensionRewriter(org.xwiki.extension.script.ScriptExtensionRewriter) InstallRequest(org.xwiki.extension.job.InstallRequest) DocumentReference(org.xwiki.model.reference.DocumentReference)

Example 2 with ScriptExtensionRewriter

use of org.xwiki.extension.script.ScriptExtensionRewriter in project xwiki-platform by xwiki.

the class DataMojo method executeInternal.

@Override
public void executeInternal() throws MojoExecutionException {
    InstallRequest installRequest = new InstallRequest();
    // Allow modifying root namespace
    installRequest.setRootModificationsAllowed(true);
    // Make sure jars are installed on root
    // TODO: use a less script oriented class
    ScriptExtensionRewriter rewriter = new ScriptExtensionRewriter();
    rewriter.installExtensionTypeOnRootNamespace("jar");
    rewriter.installExtensionTypeOnRootNamespace("webjar");
    installRequest.setRewriter(rewriter);
    // Use superadmin as pages author
    installRequest.setProperty(AbstractExtensionValidator.PROPERTY_USERREFERENCE, new DocumentReference("xwiki", "XWiki", XWikiRightService.SUPERADMIN_USER));
    this.extensionHelper.install(this.includes, installRequest, "wiki:xwiki", null);
}
Also used : ScriptExtensionRewriter(org.xwiki.extension.script.ScriptExtensionRewriter) InstallRequest(org.xwiki.extension.job.InstallRequest) DocumentReference(org.xwiki.model.reference.DocumentReference)

Aggregations

InstallRequest (org.xwiki.extension.job.InstallRequest)2 ScriptExtensionRewriter (org.xwiki.extension.script.ScriptExtensionRewriter)2 DocumentReference (org.xwiki.model.reference.DocumentReference)2