[jbpm-commits] JBoss JBPM SVN: r4559 - in jbpm4/branches/email/modules: pvm/.settings and 5 other directories.

do-not-reply at jboss.org do-not-reply at jboss.org
Thu Apr 16 04:17:49 EDT 2009


Author: alex.guizar at jboss.com
Date: 2009-04-16 04:17:49 -0400 (Thu, 16 Apr 2009)
New Revision: 4559

Added:
   jbpm4/branches/email/modules/pvm/.settings/org.eclipse.jdt.ui.prefs
   jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/GivenSpaceFamilyNameBuilder.java
   jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java
   jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailProducer.java
   jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/RecipientNameBuilder.java
Modified:
   jbpm4/branches/email/modules/api/src/main/java/org/jbpm/identity/User.java
   jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java
   jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplate.java
   jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/RecipientTemplate.java
   jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailSession.java
   jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/UserImpl.java
   jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java
   jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java
Log:
alternate proposal for mail producer which aggregates the mail template

Modified: jbpm4/branches/email/modules/api/src/main/java/org/jbpm/identity/User.java
===================================================================
--- jbpm4/branches/email/modules/api/src/main/java/org/jbpm/identity/User.java	2009-04-15 20:09:56 UTC (rev 4558)
+++ jbpm4/branches/email/modules/api/src/main/java/org/jbpm/identity/User.java	2009-04-16 08:17:49 UTC (rev 4559)
@@ -31,4 +31,6 @@
   
   String getGivenName();
   String getFamilyName();
+
+	String getEmailAddress();
 }

Added: jbpm4/branches/email/modules/pvm/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- jbpm4/branches/email/modules/pvm/.settings/org.eclipse.jdt.ui.prefs	                        (rev 0)
+++ jbpm4/branches/email/modules/pvm/.settings/org.eclipse.jdt.ui.prefs	2009-04-16 08:17:49 UTC (rev 4559)
@@ -0,0 +1,3 @@
+#Wed Apr 15 21:58:44 CDT 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/>

Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java	2009-04-15 20:09:56 UTC (rev 4558)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java	2009-04-16 08:17:49 UTC (rev 4559)
@@ -21,37 +21,57 @@
  */
 package org.jbpm.pvm.internal.email.impl;
 
+import java.net.URL;
+
 /**
  * @author Alejandro Guizar
  */
 public class AttachmentTemplate {
 
-  private String url;
-  private String resource;
-  private String file;
+	private String name;
+	private String description;
+	private String url;
+	private String resource;
+	private String file;
 
-  public String getUrl() {
-    return url;
-  }
+	public String getName() {
+		return name;
+	}
 
-  public void setUrl(String url) {
-    this.url = url;
-  }
+	public void setName(String name) {
+		this.name = name;
+	}
 
-  public String getResource() {
-    return resource;
-  }
+	public String getDescription() {
+		return description;
+	}
 
-  public void setResource(String resource) {
-    this.resource = resource;
-  }
+	public void setDescription(String description) {
+		this.description = description;
+	}
 
-  public String getFile() {
-    return file;
-  }
+	public String getUrl() {
+		return url;
+	}
 
-  public void setFile(String file) {
-    this.file = file;
-  }
+	public void setUrl(String url) {
+		this.url = url;
+	}
 
+	public String getResource() {
+		return resource;
+	}
+
+	public void setResource(String resource) {
+		this.resource = resource;
+	}
+
+	public String getFile() {
+		return file;
+	}
+
+	public void setFile(String file) {
+		this.file = file;
+	}
+
 }

Added: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/GivenSpaceFamilyNameBuilder.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/GivenSpaceFamilyNameBuilder.java	                        (rev 0)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/GivenSpaceFamilyNameBuilder.java	2009-04-16 08:17:49 UTC (rev 4559)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.email.impl;
+
+import org.jbpm.identity.User;
+import org.jbpm.pvm.internal.email.spi.RecipientNameBuilder;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class GivenSpaceFamilyNameBuilder implements RecipientNameBuilder {
+
+	public String buildName(User user) {
+		String givenName = user.getGivenName();
+		String familyName = user.getFamilyName();
+
+		return givenName != null ? familyName != null ? givenName + ' ' + familyName : givenName
+				: familyName;
+	}
+
+}

Added: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java	                        (rev 0)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailProducerImpl.java	2009-04-16 08:17:49 UTC (rev 4559)
@@ -0,0 +1,251 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.email.impl;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.mail.Email;
+import org.apache.commons.mail.EmailAttachment;
+import org.apache.commons.mail.EmailException;
+import org.apache.commons.mail.HtmlEmail;
+import org.apache.commons.mail.MultiPartEmail;
+import org.apache.commons.mail.SimpleEmail;
+import org.jbpm.JbpmException;
+import org.jbpm.env.Environment;
+import org.jbpm.identity.Group;
+import org.jbpm.identity.User;
+import org.jbpm.model.OpenExecution;
+import org.jbpm.pvm.internal.email.spi.MailProducer;
+import org.jbpm.pvm.internal.email.spi.RecipientNameBuilder;
+import org.jbpm.pvm.internal.identity.spi.IdentitySession;
+import org.jbpm.pvm.internal.script.ScriptManager;
+
+/**
+ * Default mail producer.
+ * 
+ * @author Alejandro Guizar
+ */
+public class MailProducerImpl implements MailProducer {
+
+	private MailTemplate template;
+
+	public MailTemplate getTemplate() {
+		return template;
+	}
+
+	public void setTemplate(MailTemplate template) {
+		this.template = template;
+	}
+
+	public Email produce(OpenExecution execution) {
+		try {
+			Email email = instantiateEmail(template);
+			fillRecipients(template, execution, email);
+			fillSubject(execution, email);
+			fillBody(execution, email);
+			return email;
+		}
+		catch (EmailException e) {
+			throw new JbpmException("could not produce email", e);
+		}
+	}
+
+	protected Email instantiateEmail(MailTemplate template) {
+		return template.getHtml() != null ? new HtmlEmail() : template
+				.getAttachmentTemplates()
+				.isEmpty() ? new MultiPartEmail() : new SimpleEmail();
+	}
+
+	protected void fillRecipients(MailTemplate template, OpenExecution execution, Email email)
+			throws EmailException {
+		Environment environment = Environment.getCurrent();
+		IdentitySession identitySession = environment.get(IdentitySession.class);
+		RecipientNameBuilder recipientNameBuilder = environment.get(RecipientNameBuilder.class);
+
+		// to
+		RecipientTemplate to = template.getTo();
+		if (to != null) {
+			for (String address : evaluateRecipients(to.getAddresses(), execution)) {
+				email.addTo(address);
+			}
+			for (String actorId : evaluateRecipients(to.getActors(), execution)) {
+				Collection<User> users = resolveUsers(identitySession, actorId);
+				for (User user : users) {
+					email.addTo(user.getEmailAddress(), recipientNameBuilder.buildName(user));
+				}
+			}
+		}
+
+		// cc
+		RecipientTemplate cc = template.getCc();
+		if (cc != null) {
+			for (String address : evaluateRecipients(cc.getAddresses(), execution)) {
+				email.addCc(address);
+			}
+			for (String actorId : evaluateRecipients(cc.getActors(), execution)) {
+				Collection<User> users = resolveUsers(identitySession, actorId);
+				for (User user : users) {
+					email.addCc(user.getEmailAddress(), recipientNameBuilder.buildName(user));
+				}
+			}
+		}
+
+		// bcc
+		RecipientTemplate bcc = template.getBcc();
+		if (bcc != null) {
+			for (String address : evaluateRecipients(bcc.getAddresses(), execution)) {
+				email.addBcc(address);
+			}
+			for (String actorId : evaluateRecipients(bcc.getActors(), execution)) {
+				Collection<User> users = resolveUsers(identitySession, actorId);
+				for (User user : users) {
+					email.addBcc(user.getEmailAddress(), recipientNameBuilder.buildName(user));
+				}
+			}
+		}
+	}
+
+	private String evaluateExpression(String expression, OpenExecution execution) {
+		ScriptManager scriptManager = Environment.getFromCurrent(ScriptManager.class);
+		return scriptManager
+				.evaluateExpression(expression, execution, template.getLanguage())
+				.toString();
+	}
+
+	private String[] evaluateRecipients(String recipients, OpenExecution execution) {
+		return evaluateExpression(recipients, execution).split("[,|\\s]+");
+	}
+
+	private static Collection<User> resolveUsers(IdentitySession identitySession, String actorId) {
+		// first, try to resolve actorId as user
+		User user = identitySession.findUserById(actorId);
+		if (user != null)
+			return Collections.singleton(user);
+
+		// next, try to resolve as group
+		Group group = identitySession.findGroupById(actorId);
+		if (group != null)
+			return identitySession.findUsersByGroup(actorId);
+
+		// give up
+		return Collections.emptySet();
+	}
+
+	protected void fillSubject(OpenExecution execution, Email email) {
+		email.setSubject(evaluateExpression(template.getSubject(), execution));
+	}
+
+	protected void fillBody(OpenExecution execution, Email email) throws EmailException {
+		if (template.getHtml() == null) {
+			email.setMsg(evaluateExpression(template.getText(), execution));
+		}
+		else {
+			HtmlEmail htmlEmail = (HtmlEmail) email;
+			htmlEmail.setHtmlMsg(evaluateExpression(template.getHtml(), execution));
+			htmlEmail.setTextMsg(evaluateExpression(template.getText(), execution));
+		}
+	}
+
+	protected void addAttachments(OpenExecution execution, Email email) throws EmailException {
+		List<AttachmentTemplate> attachmentTemplates = template.getAttachmentTemplates();
+		if (attachmentTemplates.isEmpty())
+			return;
+
+		MultiPartEmail multiPartEmail = (MultiPartEmail) email;
+		for (AttachmentTemplate attachmentTemplate : attachmentTemplates) {
+			EmailAttachment attachment = new EmailAttachment();
+			attachment.setDisposition(EmailAttachment.ATTACHMENT);
+
+			// name
+			String name = attachmentTemplate.getName();
+			if (name != null)
+				attachment.setName(evaluateExpression(name, execution));
+
+			// description
+			String description = attachmentTemplate.getDescription();
+			if (description != null)
+				attachment.setDescription(evaluateExpression(description, execution));
+
+			// file
+			String file = attachmentTemplate.getFile();
+			if (file != null) {
+				File targetFile = new File(evaluateExpression(file, execution));
+				if (!targetFile.isFile()) {
+					throw new EmailException("could not fetch attachment from " + targetFile);
+				}
+				attachment.setPath(targetFile.getPath());
+				// extract attachment name from file
+				if (name == null)
+					attachment.setName(targetFile.getName());
+			}
+			else {
+				URL targetUrl;
+				// url
+				String url = attachmentTemplate.getUrl();
+				if (url != null) {
+					try {
+						targetUrl = new URL(evaluateExpression(url, execution));
+					}
+					catch (MalformedURLException e) {
+						throw new EmailException("could not fetch attachment from " + url, e);
+					}
+				}
+				// resource
+				else {
+					String resource = attachmentTemplate.getResource();
+					targetUrl =
+							Environment.getCurrent().getClassLoader().getResource(
+									evaluateExpression(resource, execution));
+					if (targetUrl == null) {
+						throw new EmailException("could not fetch attachment from " + resource);
+					}
+				}
+				attachment.setURL(targetUrl);
+				// extract attachment name from url
+				if (name == null) {
+					String resourceName = extractResourceName(targetUrl);
+					attachment.setName(resourceName);
+				}
+			}
+
+			multiPartEmail.attach(attachment);
+		}
+	}
+
+	private static String extractResourceName(URL url) {
+		String path = url.getPath();
+		if (path == null || path.length() == 0)
+			return null;
+
+		// skip trailing slash
+		int sepIndex = path.lastIndexOf('/', path.length() - 1);
+		if (sepIndex == -1)
+			return null;
+
+		return path.substring(sepIndex);
+	}
+}

Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplate.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplate.java	2009-04-15 20:09:56 UTC (rev 4558)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplate.java	2009-04-16 08:17:49 UTC (rev 4559)
@@ -37,11 +37,11 @@
 
   private String name;
   private String language;
-  private Map<RecipientType, RecipientTemplate> recipientTemplates;
+  private Map<RecipientType, RecipientTemplate> recipientTemplates = new HashMap<RecipientType, RecipientTemplate>();
   private String subject;
   private String text;
   private String html;
-  private List<AttachmentTemplate> attachmentTemplates;
+  private List<AttachmentTemplate> attachmentTemplates = new ArrayList<AttachmentTemplate>();
 
   /**
    * Name of this template, useful for referencing it from mail activities.
@@ -66,12 +66,10 @@
   }
 
   public RecipientTemplate getRecipientTemplate(RecipientType recipientType) {
-    return recipientTemplates != null ? recipientTemplates.get(recipientType) : null;
+    return recipientTemplates.get(recipientType);
   }
 
   public void setRecipientTemplate(RecipientType recipientType, RecipientTemplate recipientTemplate) {
-    if (recipientTemplates == null)
-      recipientTemplates = new HashMap<RecipientType, RecipientTemplate>();
     recipientTemplates.put(recipientType, recipientTemplate);
   }
 
@@ -128,7 +126,6 @@
   }
 
   public void addAttachmentTemplate(AttachmentTemplate attachmentTemplate) {
-    if (attachmentTemplates == null) attachmentTemplates = new ArrayList<AttachmentTemplate>();
     attachmentTemplates.add(attachmentTemplate);
   }
 }

Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/RecipientTemplate.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/RecipientTemplate.java	2009-04-15 20:09:56 UTC (rev 4558)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/RecipientTemplate.java	2009-04-16 08:17:49 UTC (rev 4559)
@@ -21,9 +21,6 @@
  */
 package org.jbpm.pvm.internal.email.impl;
 
-import java.util.ArrayList;
-import java.util.List;
-
 /**
  * Template for email recipients, either addresses or actors.
  * 
@@ -31,24 +28,23 @@
  */
 public class RecipientTemplate {
 
-  private List<String> addresses;
-  private List<String> actors;
+	private String addresses;
+	private String actors;
 
-  public List<String> getAddresses() {
-    return addresses;
-  }
+	public String getAddresses() {
+		return addresses;
+	}
 
-  public void addAddress(String address) {
-    if (addresses == null) addresses = new ArrayList<String>();
-    addresses.add(address);
-  }
+	public void setAddresses(String addresses) {
+		this.addresses = addresses;
+	}
 
-  public List<String> getActors() {
-    return actors;
-  }
+	public String getActors() {
+		return actors;
+	}
 
-  public void addActor(String actor) {
-    if (actors == null) actors = new ArrayList<String>(); 
-    actors.add(actor);
-  }
+	public void setActors(String actors) {
+		this.actors = actors;
+	}
+
 }

Added: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailProducer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailProducer.java	                        (rev 0)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailProducer.java	2009-04-16 08:17:49 UTC (rev 4559)
@@ -0,0 +1,37 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.email.spi;
+
+import org.apache.commons.mail.Email;
+import org.jbpm.model.OpenExecution;
+
+/**
+ * Pluggable control object for creating emails from templates.
+ * 
+ * @author Brad Davis
+ * @author Alejandro Guizar
+ */
+public interface MailProducer {
+
+  Email produce(OpenExecution execution);
+
+}

Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailSession.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailSession.java	2009-04-15 20:09:56 UTC (rev 4558)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/MailSession.java	2009-04-16 08:17:49 UTC (rev 4559)
@@ -4,6 +4,13 @@
 
 import org.apache.commons.mail.Email;
 
+/**
+ * Pluggable control object for sending emails.
+ * 
+ * @author Brad Davis
+ */
 public interface MailSession {
-	public void send(Collection<Email> emails);
+
+  void send(Collection<Email> emails);
+
 }

Added: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/RecipientNameBuilder.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/RecipientNameBuilder.java	                        (rev 0)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/spi/RecipientNameBuilder.java	2009-04-16 08:17:49 UTC (rev 4559)
@@ -0,0 +1,40 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jbpm.pvm.internal.email.spi;
+
+import org.jbpm.identity.User;
+
+/**
+ * Function to create email recipient names from {@linkplain User user} entities. The following two
+ * strategies are representative.
+ * <ul>
+ * <li>Albert Einstein (given name + ' ' + family name)</li>
+ * <li>Einstein, Albert (family name + ", " + given name)</li>
+ * </ul>
+ * 
+ * @author Alejandro Guizar
+ */
+public interface RecipientNameBuilder {
+
+	String buildName(User user);
+
+}

Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/UserImpl.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/UserImpl.java	2009-04-15 20:09:56 UTC (rev 4558)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/identity/impl/UserImpl.java	2009-04-16 08:17:49 UTC (rev 4559)
@@ -37,9 +37,10 @@
   protected int dbversion;
 
   protected String id;
-  protected String password;
   protected String givenName;
   protected String familyName;
+  protected String emailAddress;
+  protected String password;
 
   public UserImpl() {
   }
@@ -59,8 +60,11 @@
   public String getFamilyName() {
     return familyName;
   }
-  
-  public String toString() {
+  public String getEmailAddress() {
+  	return emailAddress;
+	}
+
+	public String toString() {
     if ( (givenName!=null)
          && (familyName!=null)
        ) {
@@ -78,7 +82,10 @@
   public void setFamilyName(String familyName) {
     this.familyName = familyName;
   }
-  public String getPassword() {
+  public void setEmailAddress(String emailAddress) {
+		this.emailAddress = emailAddress;
+	}
+	public String getPassword() {
     return password;
   }
   public void setPassword(String password) {

Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java	2009-04-15 20:09:56 UTC (rev 4558)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/WireContext.java	2009-04-16 08:17:49 UTC (rev 4559)
@@ -32,7 +32,6 @@
 import org.jbpm.activity.ActivityBehaviour;
 import org.jbpm.env.Context;
 import org.jbpm.env.Environment;
-import org.jbpm.env.EnvironmentFactory;
 import org.jbpm.internal.log.Log;
 import org.jbpm.pvm.internal.cfg.JbpmConfiguration;
 import org.jbpm.pvm.internal.model.ProcessElementImpl;
@@ -703,7 +702,7 @@
     if (wireDefinition!=null) {
       String name = wireDefinition.getDescriptorName(type);
       if (name!=null) {
-        return (T) get(name);
+        return type.cast(get(name));
       } 
     }
     return null;

Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java	2009-04-15 20:09:56 UTC (rev 4558)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java	2009-04-16 08:17:49 UTC (rev 4559)
@@ -142,22 +142,12 @@
     ObjectDescriptor recipientDescriptor = new ObjectDescriptor(RecipientTemplate.class);
 
     String addresses = XmlUtil.attribute(element, "addresses");
-    if (addresses != null) recipientDescriptor.addInjection("addresses", parseTokens(addresses));
+    if (addresses != null) recipientDescriptor.addInjection("addresses", new StringDescriptor(addresses));
 
     String actors = XmlUtil.attribute(element, "actors");
-    if (actors != null) recipientDescriptor.addInjection("actors", parseTokens(actors));
+    if (actors != null) recipientDescriptor.addInjection("actors", new StringDescriptor(actors));
 
     return recipientDescriptor;
   }
 
-  private static ListDescriptor parseTokens(String tokens) {
-    List<Descriptor> tokenDescriptors = new ArrayList<Descriptor>();
-    for (String token : tokens.split("[,|\\s]+")) {
-      tokenDescriptors.add(new StringDescriptor(token));
-    }
-    ListDescriptor listDescriptor = new ListDescriptor();
-    listDescriptor.setValueDescriptors(tokenDescriptors);
-    return listDescriptor;
-  }
-
 }




More information about the jbpm-commits mailing list