Event targets: past, present and future

Hi everyone,

I’m opening this brainstorming to ensure we’re all on the same page regarding a problem with org.xwiki.eventstream.Event#getTarget and the related org.xwiki.eventstream.TargetableEvent#getTarget. Right now those API are returning set of String, and it’s only specified that it can users or groups, but the format is never specified.

@lucaa found recently while debugging that right now (since XWiki 12.x at least) only absolute serialized references are supported.
However some clues like xwiki-platform/xwiki-platform-core/xwiki-platform-extension/xwiki-platform-extension-versioncheck/src/main/java/org/xwiki/extension/versioncheck/NewExtensionVersionAvailableEvent.java at master · xwiki/xwiki-platform · GitHub tends to show that in the past, maybe relative serialized references were supported: I’m using conditional here since this code was never really used, and the code of Notifications changed a lot.

So maybe we have a regression here, but fixing it in order to ensure that any target could be a relative might be time consuming and I’m not sure it worth it. Especially since we never had any report of this until now, and we know that those TargetableEvent were not very used until recently. Instead it seems more interesting to only provide a better documentation about what getTarget should return.

On the contrary, IMO we should focus on the future on deprecating those APIs using Set of String, in favor of an API with proper references: but for that we first need an abstraction for having both GroupReference and UserReference (which is planned).

So here my proposal would be:

  1. we don’t fix the possible regression but instead we properly document what Event#getTargets and TargetableEvent#getTarget should return
  2. on the future, we try to deprecate those APIs to have proper APIs returning references instead of String



I think it’s reasonable to expect that only absolute references would be manipulated by event targets, it’s not even sure it was ever supported.


+1 Thanks