@Override public ExtensionId getUIExtensionId(String wiki) { XWikiContext xcontext = this.xcontextProvider.get(); // If it is the main wiki, return the main UI. if (xcontext.isMainWiki(wiki)) { return this.distributionManager.getMainUIExtensionId(); } try { // Get the wiki document DocumentReference wikiDocumentRef = documentReferenceResolver.resolve( xcontext.getMainXWiki() + ":" + XWiki.getServerWikiPage(wiki)); XWikiDocument wikiDocument = xcontext.getWiki().getDocument(wikiDocumentRef, xcontext); // Let see if the wiki document has an Workspace object DocumentReference workspaceClassRef = new DocumentReference(xcontext.getMainXWiki(), "WorkspaceManager", "WorkspaceClass"); // If there is an object, then it's a "workspace" if (wikiDocument.getXObject(workspaceClassRef) != null) { CoreExtension distributionExtension = this.coreExtensionRepository.getEnvironmentExtension(); // Get the maven model Model mavenModel = (Model) distributionExtension.getProperty(MavenCoreExtension.PKEY_MAVEN_MODEL); // Get the UI Id String wikiUIId = mavenModel.getProperties().getProperty("xwiki.extension.distribution.workspaceui"); return new ExtensionId(wikiUIId, distributionExtension.getId().getVersion()); } } catch (XWikiException e) { logger.error("Failed to get wiki descriptor for wiki [{}]", wiki, e); } // Other case, it is a "normal" subwiki return this.distributionManager.getWikiUIExtensionId(); }
private boolean checkCoreExtension( ExtensionDependency extensionDependency, List<ModifableExtensionPlanNode> parentBranch) throws InstallException { CoreExtension coreExtension = this.coreExtensionRepository.getCoreExtension(extensionDependency.getId()); if (coreExtension != null) { if (!extensionDependency .getVersionConstraint() .isCompatible(coreExtension.getId().getVersion())) { throw new InstallException( "Dependency [" + extensionDependency + "] is not compatible with core extension [" + coreExtension + "]"); } else { if (getRequest().isVerbose()) { this.logger.debug( "There is already a core extension [{}] covering extension dependency [{}]", coreExtension.getId(), extensionDependency); } ModifableExtensionPlanNode node = new ModifableExtensionPlanNode( extensionDependency, extensionDependency.getVersionConstraint()); node.setAction( new DefaultExtensionPlanAction(coreExtension, null, Action.NONE, null, true)); parentBranch.add(node); return true; } } return false; }