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;
}
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;
}
}
}
}
}
}
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);
}
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;
}
}
}
}
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);
}
}
}
}
Aggregations