Wiki source code of XWiki API Reference

Version 458.1 by Vincent Massol on 2015/03/16

Hide last authors
Vincent Massol 346.1 1 {{velocity}}
Guillaume Delhumeau 453.1 2 #set($versionStable = "6.4.2")
Marius Dumitru Florea 454.1 3 #set($versionDev = "7.0-milestone-2")
Vincent Massol 452.1 4 ##set($versionOldStable = "5.4.7")
Vincent Massol 346.1 5 {{/velocity}}
Thomas Mortagne 305.1 6
Vincent Massol 346.1 7 XWiki's APIs are the methods that the XWiki development team consider safe for you to use (i.e. for which backward compatibility is guaranteed). They can be called from Java or directly from your wiki pages [[using a scripting language>>DevGuide.Scripting]] (Velocity, Groovy, Python, Ruby, etc).
8
Vincent Massol 390.1 9 {{info}}
10 As users of the XWiki API you need to be aware of some important points:
11 * You should never use a class having ##internal## in its package. It means this class is not a public API and XWiki developers can change it at any time. If you depend on such a class you're on your own and the XWiki Development Team doesn't guarantee its stability.
12 * You should pay attention to the ##@Unstable## annotation. When you see code marked with this annotation it means it's a new public API that it still considered unstable and that can change at any time too. See [[Unstable Annotation>>dev:Community.DevelopmentPractices||anchor="H40UnstableAnnotation"]] for more details.
13 {{/info}}
14
Ludovic Dubost 381.1 15 == Scripting Reference Documentation ==
Ludovic Dubost 371.1 16
Vincent Massol 455.1 17 * For XWiki versions >= 6.2.5+ you should install the [[Scripting Documentation Application>>extensions:Extension.Scripting Documentation Application]] in your wiki. You can [[browse a version of it installed on xwiki.org>>ScriptingDocumentation.WebHome]] (but beware, it'll show the Scripting API available on the XWiki version installed for xwiki.org, which may differ from your locally installed XWiki version).
Vincent Massol 455.2 18 * For XWiki versions <= 5.0.x you can browse the old [[Scripting Reference Documentation>>SRD.Navigation||queryString="xpage=embed"]] (a.k.a SRD).
Ludovic Dubost 381.1 19
Thomas Mortagne 419.1 20 == How to find a class ==
21
Thomas Mortagne 446.1 22 You can get the maven module where to find a Java class by using [[XWiki Nexus Search page>>http://nexus.xwiki.org/nexus/index.html#nexus-search;classname~~]]. Put the complete class name and you will get all modules containing it. Nexus also allows you to see what's in those artifacts and read the javadoc.
Thomas Mortagne 419.1 23
Vincent Massol 456.1 24 == JavaDoc ==
Ludovic Dubost 371.1 25
Vincent Massol 457.1 26 XWiki is made of various extensions/modules and each module offers API for both developers coding in Java and for Scripts written in wiki pages. In the future our goal is to have Javadoc links directly from each extension page located in the [[Extensions Wiki>>extensions:Main.WebHome]]. Right now we're listing below the Javadocs for all modules.
Silvia Macovei 239.1 27
Vincent Massol 346.1 28 {{velocity}}
Vincent Massol 457.1 29 #if ("$!request.versionId" != '')
30 #set ($versionId = $request.versionId)
31 #set ($versionName = $request.versionName)
32 #else
33 #set ($versionId = $versionStable)
34 #set ($versionName = "stable")
35 #end
Vincent Massol 458.1 36 #set ($discard = $xcontext.put('javadocVersion', $versionId))
Vincent Massol 457.1 37
Vincent Massol 457.3 38 Javadoc for version $versionId ($versionName) ([[stable: $versionStable>>||anchor="HJavaDoc" queryString="versionId=$versionStable&versionName=stable"]]#if ($versionDev), [[dev: $versionDev>>||anchor="HJavaDoc" queryString="versionId=$versionDev&versionName=dev"]]#{end}#if ($versionOldStable), [[super stable: $versionOldStable>>||anchor="HJavaDoc" queryString="versionId=$versionOldStable&versionName='super stable'"]]#{end}):
Vincent Massol 346.1 39 {{/velocity}}
Thomas Mortagne 420.1 40
Vincent Massol 457.1 41 {{groovy}}
42 import groovy.xml.*
43 import org.apache.commons.lang3.*
44
Vincent Massol 457.4 45 def offset = 0
46 def count = 200
47 def shouldContinue = true
Vincent Massol 457.1 48
Vincent Massol 457.4 49 while (shouldContinue) {
Vincent Massol 458.1 50 def url = "http://nexus.xwiki.org/nexus/service/local/lucene/search?g=org.xwiki.*&v=${xcontext.javadocVersion}&p=jar&c=javadoc&from=${offset}&count=${count}".toURL().text
Vincent Massol 457.4 51 def root = new XmlSlurper().parseText(url)
52
53 offset += count
54 def total = Integer.parseInt(root.totalCount.text())
55 shouldContinue = total > offset ? true : false
56
57 root.data.artifact.each { artifact ->
58 // Extract the last part of the group id and consider it's the repo short name
59 def groupId = artifact.groupId.text()
60 def repo = StringUtils.substringAfterLast(groupId, ".")
61 def artifactId = artifact.artifactId
62 def version = artifact.version
63 def javadocURL = "http://nexus.xwiki.org/nexus/service/local/repositories/releases/archive/org/xwiki/${repo}/${artifactId}/${version}/${artifactId}-${version}-javadoc.jar/!/index.html"
64 println "* [[${artifactId}>>url:${javadocURL}]]"
65 }
Vincent Massol 457.1 66 }
67 {{/groovy}}
68
Vincent Massol 456.1 69 The [[full Javadoc>>http://maven.xwiki.org/site/docs/]] is also available ({{info}}but only for old versions, we need to fix this{{/info}}).
Thomas Mortagne 189.1 70
Manuel Smeria 376.2 71 Older Javadocs of XWiki can be found in our [[Maven Release repository>>http://maven.xwiki.org/releases/]]. For example for XWiki Platform Core Javadocs, check the files suffixed by ##javadoc## for the version you wish under [[this directory>>http://maven.xwiki.org/releases/org/xwiki/platform/xwiki-platform-oldcore/]].

Get Connected