Search in sources :

Example 1 with ExtensionId

use of org.xwiki.extension.ExtensionId in project xwiki-platform by xwiki.

the class DefaultDistributionJob method createSteps.

@Override
protected List<DistributionStep> createSteps() {
    List<DistributionStep> steps = new ArrayList<>();
    boolean isMainWiki = isMainWiki();
    // Create admin user if needed
    if (isMainWiki) {
        try {
            steps.add(this.componentManager.<DistributionStep>getInstance(DistributionStep.class, FirstAdminUserStep.ID));
        } catch (ComponentLookupException e) {
            this.logger.error("Failed to get first admin step instance", e);
        }
    }
    // Install/upgrade main wiki UI
    addDefaultUIStep(steps, isMainWiki);
    // Upgrade other wikis
    if (isMainWiki) {
        ExtensionId wikiUI = this.distributionManager.getWikiUIExtensionId();
        if (wikiUI != null && StringUtils.isNotBlank(wikiUI.getId())) {
            // ... but only if the wiki extension ID is defined
            try {
                steps.add(this.componentManager.<DistributionStep>getInstance(DistributionStep.class, WikisDefaultUIDistributionStep.ID));
            } catch (ComponentLookupException e) {
                this.logger.error("Failed to get all in one default UI step instance", e);
            }
        } else {
        // TODO: Display the wikis flavor step
        }
    }
    // Upgrade outdated extensions
    try {
        steps.add(this.componentManager.<DistributionStep>getInstance(DistributionStep.class, OutdatedExtensionsDistributionStep.ID));
    } catch (ComponentLookupException e) {
        this.logger.error("Failed to get outdated extensions step instance", e);
    }
    return steps;
}
Also used : DistributionStep(org.xwiki.extension.distribution.internal.job.step.DistributionStep) WikisDefaultUIDistributionStep(org.xwiki.extension.distribution.internal.job.step.WikisDefaultUIDistributionStep) DefaultUIDistributionStep(org.xwiki.extension.distribution.internal.job.step.DefaultUIDistributionStep) FlavorDistributionStep(org.xwiki.extension.distribution.internal.job.step.FlavorDistributionStep) OutdatedExtensionsDistributionStep(org.xwiki.extension.distribution.internal.job.step.OutdatedExtensionsDistributionStep) ArrayList(java.util.ArrayList) ComponentLookupException(org.xwiki.component.manager.ComponentLookupException) ExtensionId(org.xwiki.extension.ExtensionId)

Example 2 with ExtensionId

use of org.xwiki.extension.ExtensionId in project xwiki-platform by xwiki.

the class WikisDefaultUIDistributionStep method prepare.

@Override
public void prepare() {
    if (getState() == null) {
        setState(State.COMPLETED);
        WikiDescriptorManager wikiDescriptorManager = this.wikiDescriptorManagerProvider.get();
        Collection<String> wikiIds;
        try {
            wikiIds = wikiDescriptorManager.getAllIds();
        } catch (WikiManagerException e) {
            this.logger.error("Failed to get the list of wikis", e);
            setState(null);
            return;
        }
        ExtensionId wikiExtensionUI = this.distributionManager.getWikiUIExtensionId();
        if (wikiExtensionUI != null) {
            for (String wikiId : wikiIds) {
                if (!wikiDescriptorManager.getMainWikiId().equals(wikiId)) {
                    String namespace = "wiki:" + wikiId;
                    // Only if the UI is not already installed
                    InstalledExtension installedExtension = this.installedRepository.getInstalledExtension(wikiExtensionUI.getId(), namespace);
                    if (installedExtension == null || !installedExtension.getId().getVersion().equals(wikiExtensionUI.getVersion())) {
                        setState(null);
                        return;
                    }
                }
            }
        }
    }
}
Also used : InstalledExtension(org.xwiki.extension.InstalledExtension) WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) WikiDescriptorManager(org.xwiki.wiki.descriptor.WikiDescriptorManager) ExtensionId(org.xwiki.extension.ExtensionId)

Example 3 with ExtensionId

use of org.xwiki.extension.ExtensionId in project xwiki-platform by xwiki.

the class WikisDefaultUIDistributionStep method executeNonInteractive.

@Override
public void executeNonInteractive() throws Exception {
    WikiDescriptorManager wikiDescriptorManager = this.wikiDescriptorManagerProvider.get();
    Collection<String> wikiIds;
    try {
        wikiIds = wikiDescriptorManager.getAllIds();
    } catch (WikiManagerException e) {
        this.logger.error("Failed to get the list of wikis", e);
        setState(null);
        return;
    }
    ExtensionId wikiExtensionUI = this.distributionManager.getWikiUIExtensionId();
    for (String wikiId : wikiIds) {
        if (!wikiDescriptorManager.getMainWikiId().equals(wikiId)) {
            String namespace = new Namespace("wiki", wikiId).toString();
            // Only if the UI is not already installed
            if (wikiExtensionUI != null) {
                InstalledExtension installedExtension = this.installedRepository.getInstalledExtension(wikiExtensionUI.getId(), namespace);
                if (installedExtension == null || !installedExtension.getId().getVersion().equals(wikiExtensionUI.getVersion())) {
                    install(wikiExtensionUI, namespace, false);
                }
            }
        }
    }
    // Complete task
    setState(State.COMPLETED);
}
Also used : InstalledExtension(org.xwiki.extension.InstalledExtension) WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) WikiDescriptorManager(org.xwiki.wiki.descriptor.WikiDescriptorManager) ExtensionId(org.xwiki.extension.ExtensionId) Namespace(org.xwiki.component.namespace.Namespace)

Example 4 with ExtensionId

use of org.xwiki.extension.ExtensionId in project xwiki-platform by xwiki.

the class WikisFlavorDistributionStep method prepare.

@Override
public void prepare() {
    if (getState() == null) {
        setState(State.COMPLETED);
        if (!isMainWiki()) {
            return;
        }
        WikiDescriptorManager wikiDescriptorManager = this.wikiDescriptorManagerProvider.get();
        Collection<String> wikiIds;
        try {
            wikiIds = wikiDescriptorManager.getAllIds();
        } catch (WikiManagerException e) {
            this.logger.error("Failed to get the list of wikis", e);
            setState(null);
            return;
        }
        String mainWiki = wikiDescriptorManager.getMainWikiId();
        // Enable if any of the wikis has no valid top level flavor extension
        for (String wikiId : wikiIds) {
            if (mainWiki.equals(wikiId)) {
                continue;
            }
            String namespace = "wiki:" + wikiId;
            ExtensionId flavor = flavorManager.getFlavorOfWiki(getWiki());
            if (flavor == null || !installedRepository.getInstalledExtension(flavor).isValid(namespace)) {
                setState(null);
                return;
            }
        }
    }
}
Also used : WikiManagerException(org.xwiki.wiki.manager.WikiManagerException) WikiDescriptorManager(org.xwiki.wiki.descriptor.WikiDescriptorManager) ExtensionId(org.xwiki.extension.ExtensionId)

Example 5 with ExtensionId

use of org.xwiki.extension.ExtensionId in project xwiki-platform by xwiki.

the class DefaultUIDistributionStep method prepare.

@Override
public void prepare() {
    if (getState() == null) {
        setState(State.COMPLETED);
        Namespace namespace = getNamespace();
        ExtensionId extensionUI = this.distributionJob.getStatus().getDistributionExtensionUI();
        // Only if the UI is not already installed
        if (extensionUI != null) {
            InstalledExtension installedExtension = this.installedRepository.getInstalledExtension(extensionUI.getId(), namespace.toString());
            if (installedExtension == null || !installedExtension.getId().getVersion().equals(extensionUI.getVersion())) {
                setState(null);
            }
        }
    }
}
Also used : InstalledExtension(org.xwiki.extension.InstalledExtension) ExtensionId(org.xwiki.extension.ExtensionId) Namespace(org.xwiki.component.namespace.Namespace)

Aggregations

ExtensionId (org.xwiki.extension.ExtensionId)67 Test (org.junit.Test)37 InstalledExtension (org.xwiki.extension.InstalledExtension)13 ExtensionAdministrationPage (org.xwiki.extension.test.po.ExtensionAdministrationPage)11 TestExtension (org.xwiki.repository.test.TestExtension)11 ExtensionPane (org.xwiki.extension.test.po.ExtensionPane)9 DocumentReference (org.xwiki.model.reference.DocumentReference)9 InstalledExtensionRepository (org.xwiki.extension.repository.InstalledExtensionRepository)8 Extension (org.xwiki.extension.Extension)7 InstallRequest (org.xwiki.extension.job.InstallRequest)6 DefaultVersionConstraint (org.xwiki.extension.version.internal.DefaultVersionConstraint)6 WikiDescriptorManager (org.xwiki.wiki.descriptor.WikiDescriptorManager)6 IOException (java.io.IOException)5 DefaultExtensionDependency (org.xwiki.extension.DefaultExtensionDependency)5 SearchResultsPane (org.xwiki.extension.test.po.SearchResultsPane)5 ViewPage (org.xwiki.test.ui.po.ViewPage)5 XWikiContext (com.xpn.xwiki.XWikiContext)4 ResolveException (org.xwiki.extension.ResolveException)4 DependencyPane (org.xwiki.extension.test.po.DependencyPane)4 LogItemPane (org.xwiki.extension.test.po.LogItemPane)4