I wrote:
> > What's the right way to get the current user from the execution 
> > context within a Java component?

Thomas Mortagne replied:
> For what you need the simplest in a component is usually to use
> org.xwiki.bridge.DocumentAccessBridge component (from
> xwiki-platform-bridge module) until a proper user manager api is
> introduced.

OK, so I should not use ExecutionContext at all? It looks the the approach 
you're suggesting is:

1) Inject a DocumentAccessBridge instead of an Execution, e.g.:
@Inject
private DocumentAccessBridge bridge;

2) Get a reference to the current user
(According to  
http://maven.xwiki.org/site/docs/xwiki-javadoc-5.0.x/org/xwiki/bridge/DocumentAccessBridge.html
 which might be out of date but I can't find a more recent API doc)

DocumentReference userDoc = bridge.getCurrentUserReference();

3) Presumably the document reference captures the full location of the user's 
profile page. The DocumentReference API doesn't appear to have a page name 
accessor, so presumably to extract the user name I need to pull it out of 
userDoc.toString().

Is this right? Conceptually I find this less intuitive than using a context 
object, so it's a pity if that's been deprecated.

Thanks,

Bryn


_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to