01: package org.jbpm.identity.mail;
02:
03: import org.jbpm.JbpmContext;
04: import org.jbpm.identity.User;
05: import org.jbpm.identity.hibernate.IdentitySession;
06: import org.jbpm.mail.AddressResolver;
07: import org.jbpm.svc.Service;
08: import org.jbpm.svc.ServiceFactory;
09:
10: /**
11: * translates actorIds into email addresses with the jBPM identity module.
12: * Only user actorIds are resolved to their email addresses. Group actorIds return null.
13: */
14: public class IdentityAddressResolver implements AddressResolver,
15: ServiceFactory, Service {
16:
17: private static final long serialVersionUID = 1L;
18:
19: public Object resolveAddress(String actorId) {
20: String emailAddress = null;
21: IdentitySession identitySession = new IdentitySession(
22: JbpmContext.getCurrentJbpmContext().getSession());
23: User user = identitySession.getUserByName(actorId);
24: if (user != null) {
25: emailAddress = user.getEmail();
26: }
27: return emailAddress;
28: }
29:
30: public Service openService() {
31: return this ;
32: }
33:
34: public void close() {
35: }
36: }
|