Wiki source code of Import an Extension
Last modified by Thomas Mortagne on 2026/01/13 16:42
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{include reference="ExtensionCode.RepositoryCode"/}} | ||
| 2 | |||
| 3 | Import an extension coming from an another repository. It's generally used to add complete documentation or search capability for extension in a repository not supporting it. It can also be used to create a repository with a limited selection of extensions coming from a more complete repository. | ||
| 4 | |||
| 5 | If an extension already exist with the provided id in the wiki the extension will be updated. | ||
| 6 | |||
| 7 | Example of extension id: ##org.xwiki.contrib:application-filemanager## | ||
| 8 | |||
| 9 | {{velocity}} | ||
| 10 | #if ($request.importExtension == 'true') | ||
| 11 | #set($extensionDocumentReference = $repositoryManager.importExtension($request.extensionId, $request.repositoryId)) | ||
| 12 | #if (!$extensionDocumentReference) | ||
| 13 | {{error}}Failed to import extension: #printThrowable($repositoryManager.lastError){{/error}} | ||
| 14 | #else | ||
| 15 | {{success}}Redirect to $response.sendRedirect($xwiki.getURL($extensionDocumentReference)){{/success}} | ||
| 16 | #end | ||
| 17 | #else | ||
| 18 | {{html}} | ||
| 19 | #if ($isGuest) | ||
| 20 | You need first to <a href="${escapetool.xml($xwiki.getURL("Main.WebHome", "login", "xredirect=$doc.externalURL"))}">log in</a> or <a href="${escapetool.xml($xwiki.getURL("xwiki:Main.WebHome", "register", "xredirect=$doc.externalURL"))}">register</a>. | ||
| 21 | #else | ||
| 22 | <form action="$doc.getURL()" id="importextension"> | ||
| 23 | <input type="hidden" name="parent" value="Extension.WebHome" /> | ||
| 24 | <input type="hidden" name="template" value="ExtensionCode.ExtensionTemplate" /> | ||
| 25 | <input type="hidden" name="importExtension" value="true" /> | ||
| 26 | <input type="text" name="extensionId" placeholder="extension id..." size="25" id="importExtensionIdInput"/> | ||
| 27 | <select name="repositoryId" id="importRepositoryIdInput"> | ||
| 28 | #foreach($repository in $extensionManager.repositories) | ||
| 29 | #if ($repository.descriptor.type != 'xwiki') | ||
| 30 | <option value="$escapetool.xml($repository.descriptor.id)">$escapetool.html($repository.descriptor.id)</option> | ||
| 31 | #end | ||
| 32 | #end | ||
| 33 | </select> | ||
| 34 | <span class="buttonwrapper"> | ||
| 35 | <input class="button" type="submit" value="Import" id="importSubmit"/> | ||
| 36 | </span> | ||
| 37 | </form> | ||
| 38 | #end | ||
| 39 | {{/html}} | ||
| 40 | #end | ||
| 41 | {{/velocity}} |