On Mar 25, 2011, at 2:19 PM, Thomas Mortagne wrote:
Hi devs,
I'm currently working on
http://jira.xwiki.org/jira/browse/XWIKI-6103
which has two aspects:
1) stored the user as a DocumentReference in the context so that we
stop loosing the user all the time when switching databases
2) provide a DocumentReference oriented API to deal with the current user
For 2 I would like to propose some change in the way to see not logged
in user: I would like to make getUserReference return null when there
is no user logged in instead of some DocumentReference containing
<currentwiki>:XWiki.XWikiGuest. I understand that when dealing with
string "XWikiGuest" hack appear but null when there is actually no
context user makes much more sense at Java level IMO. Make safer to
distinguish between no logged in user and logged in user and you don't
really care what has been chosen as virtual name for not logged in
users at this level.
+1for now.
For the future we might want to consider that user references doesn't have to match
document references and that users may be stored anywhere (and not always in the wiki).
I'd be for having a User object and have a getUser() that returns it rather than
manipulating references.
Then we can have a GuestUser and do things like:
if (getUser().equals(User.GuestUser)) {....}
More specifically IMO we should stop using code that knows that the user reference is a
reference to a document and instead go through a dedicated User API. It's that User
API implementation that will know (for ex) that users are stored in wiki pages.
For example instead of writing the following to know if a user exists:
dab.exists(getUserReference())
Instead write:
UserManager.exists(String username)
But I agree this is a change for a bit later.
Thanks
-Vincent
That will not impact anything which already exist and
is just for code
that will use the new API of course but I think it deserve some debate
first since that's another way to see things and well it's an API.
WDYT ?
--
Thomas Mortagne
_______________________________________________
devs mailing list
devs(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/devs