OK, I solved it. I also had to wrap the pipeline into a auth-protect block, as well as using the following to get the component manager

public String getUserId() throws Exception{
org.apache.avalon.framework.component.ComponentManager cm= CocoonComponentManager.getSitemapComponentManager();
SessionManager sessionManager = (SessionManager)cm.lookup(
org.apache.cocoon.webapps.session.SessionManager.ROLE);
String userLogin = sessionManager.getContextFragment( "authentication",
"/authentication/ID").getFirstChild().getNodeValue();
return userLogin;
}


Steinar Rune Eriksen wrote:
Laurent Trillaud wrote:

Hi
Try this :

var sessionManager = cocoon.getComponent(
Packages.org.apache.cocoon.webapps.session.SessionManager.ROLE);
var userLogin = sessionManager.getContextFragment( "authentication",
"/authentication/ID").getFirstChild().getNodeValue();

Laurent Trillaud



Great, this seems to be more or less what I need. One problem remains however - I would really like to do the same inside a pure Java class rather than through a flow script.

I have come as far as follows, but am not sure how to obtain the root ComponentManager?

public String getUserId() throws Exception{
ComponentManager cm= ??
SessionManager sessionManager = (SessionManager)cm.lookup(
org.apache.cocoon.webapps.session.SessionManager.ROLE);
String userLogin = sessionManager.getContextFragment( "authentication",
"/authentication/ID").getFirstChild().getNodeValue();
return userLogin;
}





I have seen some use of a compose method, but I am not sure how that works

    protected ComponentManager manager;
    public void compose(ComponentManager cm)
    {
        this.manager = cm;
    }


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to