You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@lenya.apache.org by Johannes Goerke <jo...@wsi-gris.uni-tuebingen.de> on 2006/01/10 11:32:57 UTC

Getting user's email in a Workflow Action

Hello,

I'm just trying to get the email address from a user in a Workflow
Action.
I have the userID (I extended the Workflow - AbstractAction-execute -
method a little bit so that I have the situation available), but for now
I don't see how to get the email address of the user.

For now, I try something like:
public class HelloWorld extends AbstractAction {

 public void execute(Situation situation, WorkflowInstance instance)
throws WorkflowException {
	    System.out.println("HelloWorld: Hello World");
	    System.out.println("HelloWorld: Parameter: " + params);
	    System.out.println("HelloWorld: User: " +
((CMSSituation)situation).getUserId());

		// now get the user's email address
	    try {
		PublicationAccessControllerResolver pacr = new
PublicationAccessControllerResolver();
	    	DefaultAccessController dac =
DefaultAccessController)(pacr.doResolveAccessController("/default/index.
html"));
		AccreditableManager am =
(AccreditableManager)dac.getAccreditableManager();
	        UserManager um = am.getUserManager();
	        User u =
um.getUser(((CMSSituation)situation).getUserId());
	    
    	        System.out.println("HelloWorld: User - email: " +
u.getEmail());
	    } catch (Exception e){
		System.out.println("Hello World: no email! ");
		e.printStackTrace();
 	    }
}
}

Unfortunately, I get an exception from
PublicationAccessControllerResolver, because this class cannot open the
logging (NullPointerException) in the method
doResolveAccessController().

Does anybody kow how to get the user's email?

Thank you in advance!

Johannes



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org


Re: Getting user's email in a Workflow Action

Posted by Andreas Hartmann <an...@apache.org>.
Johannes Goerke wrote:
> Hello,
> 
> I'm just trying to get the email address from a user in a Workflow
> Action.
> I have the userID (I extended the Workflow - AbstractAction-execute -
> method a little bit so that I have the situation available), but for now
> I don't see how to get the email address of the user.

[...]

> Unfortunately, I get an exception from
> PublicationAccessControllerResolver, because this class cannot open the
> logging (NullPointerException) in the method
> doResolveAccessController().

Your approach would basically be correct, but unfortunately it is not
possible to implement this.

The access control components use the Avalon framework, they can only
be obtained by Avalon components. The workflow action is not based
on Avalon, therefore you can't access these components.

You could implement a dirty solution by accessing the user XML files
directly, but of course that will cause trouble when the implementation
changes, or you use LDAP, or other changes occur.

-- Andreas


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@lenya.apache.org
For additional commands, e-mail: user-help@lenya.apache.org