@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();
  }