javaxwiki

XWiki extension : detect event space creation


Based on the documentation here we can see that in a xwiki java extension, we can intercept the event UserCreation like that :

https://extensions.xwiki.org/xwiki/bin/view/Extension/Observation%20Module%20Local#HWritinganEventListenerinVelocityinaWikipage

public void onEvent(Event event, Object source, Object data)
{
    XWikiDocument document = (XWikiDocument) source;
    String wikiName = document.getDocumentReference().getWikiReference().getName();
    DocumentReference userClass = new DocumentReference(wikiName, "XWiki", "XWikiUsers");

    if (document.getXObject(userClass) != null) {
}

I want the same thing, but I want to detect the event space creation ( so basically when you add a space( basically a space is the main root page of an article ) in your wiki. But I didn't found any class like XWikiUsers for the space or the page.

It don't want to do it with velocity or groovy but in pure java extension and I have no clue, the doc is very huge but it's hard to found what I' looking for.


Solution

  • Technically, a "space" gets created whenever a page is created under it (either terminal page or WebHome).

    So you could either: