Based on the documentation here we can see that in a xwiki java extension, we can intercept the event UserCreation like that :
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.
Technically, a "space" gets created whenever a page is created under it (either terminal page or WebHome
).
So you could either:
DocumentCreatingEvent
, so not yet DocumentCreatedEvent
) and then do a query (see https://extensions.xwiki.org/xwiki/bin/view/Extension/Query%20Module) to see if the space (matching the new document's space reference) matches an existing one or a deeper nested one inside the database... orDocumentCreatedEvent
) has the name WebHome
which would be much better in terms of performance, but it will not work if you are working with terminal documents (i.e. other documents than 'WebHome' ones, see https://www.xwiki.org/xwiki/bin/view/Documentation/UserGuide/Features/ContentOrganization/#HTerminology