Wiki source code of Extensions Index

Last modified by Thomas Mortagne on 2022/05/16 14:41

Show last authors
1 Since XWiki 12.10 Extension Manager comes with a local index of available extensions.
2
3 It's used by default in the Extension Manager UI when searching for extension to install. Aside from gathering all the extensions availables on the configured searchable repositories (including if they are recommended and their ratings) it also add the following metadata:
4
5 * validate each extension on each namespace and store the result, this info is used in the Extesion Manager UI to search by default only compatible extensions for the current namespace (and the root namespace on main wiki)
6 * {{version since="13.3"}}the extension index contains metadata to help filter extensions by components{{/version}}. It's possible to directly filter extension in Extension Manager search UI using the syntax ##components~_~_org.xwiki.my.package.Role:hint## or shortcuts for some well known components roles:
7 ** ##components~_~_org.xwiki.rendering.macro.Macro## -> ##component_macro##
8 ** ##components~_~_org.xwiki.script.service.ScriptService## -> ##component_scriptservice##
9 ** ##components~_~_org.xwiki.rendering.parser.Parser## -> ##component_parser##
10 ** ##components~_~_org.xwiki.rendering.renderer.PrintRendererFactory## -> ##component_renderer##
11 ** ##components~_~_org.xwiki.rendering.renderer.BlockRenderer## -> ##component_blockrenderer##
12 ** ##components~_~_org.xwiki.filter.input.InputFilterStreamFactory## -> ##component_inputFilter##
13 ** ##components~_~_org.xwiki.filter.output.OutputFilterStreamFactory## -> ##component_outputFilter##
14
15 The main entry point is the ##org.xwiki.extension.index.ExtensionIndex## component and extensions returned by the index implement the ##org.xwiki.extension.index.IndexedExtension## interface which provide some information specific to the extension stored in the index (like whether or not it's compatible with a specific namespace).
16
17 == Script API ==
18
19 The main entry point to manipulate the extensions index from a script is the ##extension.index## script service. It mostly a way to acces a safe version of the ##org.xwiki.extension.index.ExtensionIndex##.
20
21 {{code language="velocity"}}
22 ## Create a new query to use with the extension index
23 #set($extensionQuery = $services.extension.index.newQuery("$!request.search"))
24
25 ## We want extension starting with an id containing "org.xwiki.contrib"
26 #set ($discard = $extensionQuery.addFilter('org.xwiki.contrib', '', 'MATCH'))
27
28 ## We only want extension compatible with current and root namespaces
29 #set ($discard = $extensionQuery.setCompatible(true, '', "wiki:$xcontext.database"))
30
31 ## Execute the query
32 #set ($extensions = $services.extension.index.repository.search($extensionQuery))
33 {{/code}}

Get Connected