Hi everyone,
this proposal is about making official the support of the following serialized syntax for entity references:
entityType:serializedEntityReference
Example: OBJECT:xwiki:Main.WebHome^XWiki.StyleSheetExtension[0]
I’m talking about “making official” here because I discovered by accident that it’s already partially supported:
- our
EntityReferenceConverter
supports it both to parse a String and to serialize an EntityReference as a String - our javascript
XWiki.Model.resolve()
API supports it since 12.0RC1 (see: https://github.com/xwiki/xwiki-platform/commit/f581a50db4dc1dcd2fee5c2b5a62f904db83a6de)
So IMO there’s several levels for making it official, and that would be different part of the proposal.
Proposal 1.
Document this syntax in https://extensions.xwiki.org/xwiki/bin/view/Extension/Model%20Module and maybe in https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/FrontendResources/JavaScriptAPI/#HWorkwithEntityReferences
Proposal 2.
Create the dedicated script services methods in ModelScriptServices to allow using $services.model.resolve("OBJECT:xwiki:Main.WebHome^XWiki.StyleSheetExtension[0]")
and to allow getting a serialization from it (see proposal 3 for implementation details).
Proposal 3.
Create the dedicated serializer and resolver component to be able to use that syntax directly in those components. For the serializer it would be easy to just create a serializer that would prefix the entity reference.
For the resolver it’s a bit more complicated since currently our EntityReferenceResolver
interface contains the following signature:
EntityReference resolve(T entityReferenceRepresentation, EntityType type, Object... parameters);
I can see three solutions:
- 3a. We provide a serializer but no resolver and we document to rely on the converter for this resolver
- 3b. We add a new default method in the interface taking only the representation and the parameters, without the EntityType. And the default would be to throw an exception (maybe
NotImplementedException
or something more appropriate) unless we manage to provide an implem for all existing components. - 3c. We add a new resolver interface specifically for that representation.
Personally I’m in favor of 3b. And in favor of 1 and 2 of course.
WDYT?