use of org.xwiki.extension.InstalledExtension 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;
}
}
}
}
}
}
use of org.xwiki.extension.InstalledExtension 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);
}
use of org.xwiki.extension.InstalledExtension 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);
}
}
}
}
use of org.xwiki.extension.InstalledExtension in project xwiki-platform by xwiki.
the class WikiCopiedEventListenerTest method testCopyOneExtension.
@Test
public void testCopyOneExtension() throws InstallException {
InstalledExtension extensionDependency1 = this.installedExtensionRepository.installExtension(this.localExtensionDependency1, "wiki:source", false);
InstalledExtension extension1 = this.installedExtensionRepository.installExtension(this.localExtension1, "wiki:source", false);
Assert.assertFalse(extension1.isInstalled("wiki:target"));
Assert.assertFalse(extensionDependency1.isInstalled("wiki:target"));
this.observation.notify(new WikiCopiedEvent("source", "target"), null, null);
Assert.assertTrue(extension1.isInstalled("wiki:target"));
Assert.assertTrue(extensionDependency1.isInstalled("wiki:target"));
}
use of org.xwiki.extension.InstalledExtension in project xwiki-platform by xwiki.
the class DiffXarJob method diff.
private void diff(String feature, String namespace, Set<LocalDocumentReference> alreadydone) {
if (this.comparedFeatures.contains(feature)) {
// We already looked at this feature.
return;
}
this.comparedFeatures.add(feature);
InstalledExtension installedExtension = this.installedExtensionRepository.getInstalledExtension(feature, namespace);
if (installedExtension != null) {
diff(installedExtension, namespace, alreadydone);
Collection<? extends ExtensionDependency> dependencies = installedExtension.getDependencies();
this.progressManager.pushLevelProgress(dependencies.size(), this);
try {
for (ExtensionDependency dependency : dependencies) {
this.progressManager.startStep(this);
diff(dependency.getId(), namespace, new HashSet<>(alreadydone));
}
} finally {
this.progressManager.popLevelProgress(this);
}
}
}
Aggregations