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

Taking the example from the guide 
(http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingComponents) I thought 
it would be something like the following, which won't compile for me due to the 
getLocalUser symbol not being found.


import org.xwiki.context.Execution;
import org.xwiki.context.ExecutionContext;
...
    @Inject
    private Execution execution;
    
    @Override
    public String sayHello()
    {
        ExecutionContext context = execution.getContext();
        
        String user = context.getLocalUser();
        return "Hello " + user;
        
    }

I note that in 
http://nexus.xwiki.org/nexus/service/local/repositories/releases/archive/org/xwiki/platform/xwiki-platform-oldcore/6.3/xwiki-platform-oldcore-6.3-javadoc.jar/!/com/xpn/xwiki/XWikiContext.html#getLocalUser%28%29
 the getLocalUser() method is deprecated in lieu of getUserReference() but I'd 
really rather deal with a String if at all possible.
_______________________________________________
users mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to