On Mon, Dec 21, 2009 at 18:10, Asiri Rathnayake
<asiri.rathnayake(a)gmail.com> wrote:
On Mon, Dec 21, 2009 at 2:59 PM, Vincent Massol
<vincent(a)massol.net> wrote:
Hi devs,
I'm still working on the Model Reference domain. We've brainstormed
with Thomas and we'd like to propose replacing the current
ModelContext.getCurrentDocumentName() by
ModelContext.getCurrentEntityReference() (which returns an
EntityReference).
The idea is that a URL could target a document but also a wiki only
(e.g the REST API odes that), or a given space only, or even an object
or a property. This would mean we would need to have
getCurrentDocumentReference() in addition to all the others:
getCurrentWikiReference(), getCurrentSpaceReference(). It would also
mean a lot of them would be set to null. Last it would mean different
ways to access the same information (e.g.
getCurrentDocumentReference.getWikiReference() vs
getCurrentWikiReference()).
We would also add a EntityReference.extractReference(EntityType type)
method in order to make it easy to extract information from the a
reference path.
For example to extract the Wiki from an entity reference:
WikiReference wikiRef =
context.getCurrentEntityReference(EntityType.WIKI);
if (wikiRef != null) ....
+1
May be we can avoid the enum type by using generics?
<T extends EntityReference> T getCurrentEntityReference();
Not sure if this is a good practice though.
Generic does not exist in the bytecode so impossible to know that you
want the EntityType.WIKI if you don't explicitly ask for it.
- Asiri
WDYT?
Thanks
-Vincent
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs