Search in sources :

Example 1 with UninstallJob

use of org.xwiki.extension.job.internal.UninstallJob in project xwiki-platform by xwiki.

the class XarExtensionHandlerTest method uninstall.

private void uninstall(ExtensionId extensionId, String wiki) throws Throwable {
    UninstallRequest uninstallRequest = new UninstallRequest();
    uninstallRequest.setProperty("user.reference", getXWikiContext().getUserReference());
    uninstallRequest.setProperty("checkrights", true);
    uninstallRequest.addExtension(extensionId);
    if (wiki != null) {
        uninstallRequest.addNamespace("wiki:" + wiki);
    }
    Job uninstallJob = this.jobExecutor.execute(UninstallJob.JOBTYPE, uninstallRequest);
    uninstallJob.join();
    List<LogEvent> errors = uninstallJob.getStatus().getLog().getLogsFrom(LogLevel.WARN);
    if (!errors.isEmpty()) {
        if (errors.get(0).getThrowable() != null) {
            throw errors.get(0).getThrowable();
        } else {
            throw new Exception(errors.get(0).getFormattedMessage());
        }
    }
}
Also used : LogEvent(org.xwiki.logging.event.LogEvent) UninstallJob(org.xwiki.extension.job.internal.UninstallJob) InstallJob(org.xwiki.extension.job.internal.InstallJob) Job(org.xwiki.job.Job) UninstallException(org.xwiki.extension.UninstallException) AccessDeniedException(org.xwiki.security.authorization.AccessDeniedException) InstallException(org.xwiki.extension.InstallException) UninstallRequest(org.xwiki.extension.job.UninstallRequest)

Aggregations

InstallException (org.xwiki.extension.InstallException)1 UninstallException (org.xwiki.extension.UninstallException)1 UninstallRequest (org.xwiki.extension.job.UninstallRequest)1 InstallJob (org.xwiki.extension.job.internal.InstallJob)1 UninstallJob (org.xwiki.extension.job.internal.UninstallJob)1 Job (org.xwiki.job.Job)1 LogEvent (org.xwiki.logging.event.LogEvent)1 AccessDeniedException (org.xwiki.security.authorization.AccessDeniedException)1