[jbpm-commits] JBoss JBPM SVN: r4544 - in jbpm4/branches/email/modules: pvm and 7 other directories.
do-not-reply at jboss.org
do-not-reply at jboss.org
Tue Apr 14 03:13:56 EDT 2009
Author: alex.guizar at jboss.com
Date: 2009-04-14 03:13:56 -0400 (Tue, 14 Apr 2009)
New Revision: 4544
Added:
jbpm4/branches/email/modules/pvm/.settings/org.eclipse.jdt.core.prefs
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/wire/binding/MailTemplateBinding.java
jbpm4/branches/email/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailTemplateWireTest.java
Removed:
jbpm4/branches/email/modules/pvm/.settings/org.eclipse.jdt.ui.prefs
Modified:
jbpm4/branches/email/modules/api/.project
jbpm4/branches/email/modules/pvm/.project
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/DomBuilder.java
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parser.java
jbpm4/branches/email/modules/pvm/src/test/resources/jbpm.wire.bindings.xml
Log:
bind mail template
Modified: jbpm4/branches/email/modules/api/.project
===================================================================
--- jbpm4/branches/email/modules/api/.project 2009-04-13 11:01:01 UTC (rev 4543)
+++ jbpm4/branches/email/modules/api/.project 2009-04-14 07:13:56 UTC (rev 4544)
@@ -1,18 +1,23 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>api</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.maven.ide.eclipse.maven2Nature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>jbpm-api</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
Modified: jbpm4/branches/email/modules/pvm/.project
===================================================================
--- jbpm4/branches/email/modules/pvm/.project 2009-04-13 11:01:01 UTC (rev 4543)
+++ jbpm4/branches/email/modules/pvm/.project 2009-04-14 07:13:56 UTC (rev 4544)
@@ -1,18 +1,23 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>pvm</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- <nature>org.maven.ide.eclipse.maven2Nature</nature>
- </natures>
-</projectDescription>
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>jbpm-pvm</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.maven.ide.eclipse.maven2Builder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ <nature>org.maven.ide.eclipse.maven2Nature</nature>
+ </natures>
+</projectDescription>
Added: jbpm4/branches/email/modules/pvm/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- jbpm4/branches/email/modules/pvm/.settings/org.eclipse.jdt.core.prefs (rev 0)
+++ jbpm4/branches/email/modules/pvm/.settings/org.eclipse.jdt.core.prefs 2009-04-14 07:13:56 UTC (rev 4544)
@@ -0,0 +1,5 @@
+#Tue Apr 14 00:52:21 CDT 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.source=1.5
Deleted: jbpm4/branches/email/modules/pvm/.settings/org.eclipse.jdt.ui.prefs
===================================================================
--- jbpm4/branches/email/modules/pvm/.settings/org.eclipse.jdt.ui.prefs 2009-04-13 11:01:01 UTC (rev 4543)
+++ jbpm4/branches/email/modules/pvm/.settings/org.eclipse.jdt.ui.prefs 2009-04-14 07:13:56 UTC (rev 4544)
@@ -1,3 +0,0 @@
-#Mon Apr 06 21:23:03 CDT 2009
-eclipse.preferences.version=1
-org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates/>
Added: 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 (rev 0)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AttachmentTemplate.java 2009-04-14 07:13:56 UTC (rev 4544)
@@ -0,0 +1,57 @@
+/*
+ * 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;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class AttachmentTemplate {
+
+ private String url;
+ private String resource;
+ private String file;
+
+ public String getUrl() {
+ return url;
+ }
+
+ 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/MailTemplate.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplate.java (rev 0)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailTemplate.java 2009-04-14 07:13:56 UTC (rev 4544)
@@ -0,0 +1,134 @@
+/*
+ * 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.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.mail.Message.RecipientType;
+
+/**
+ * Template for electronic mail, complete with recipients, subject, content and attachments.
+ *
+ * @author Alejandro Guizar
+ */
+public class MailTemplate {
+
+ private String name;
+ private String language;
+ private Map<RecipientType, RecipientTemplate> recipientTemplates;
+ private String subject;
+ private String text;
+ private String html;
+ private List<AttachmentTemplate> attachmentTemplates;
+
+ /**
+ * Name of this template, useful for referencing it from mail activities.
+ */
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ /**
+ * Templating engine meant to produce dynamic content.
+ */
+ public String getLanguage() {
+ return language;
+ }
+
+ public void setLanguage(String language) {
+ this.language = language;
+ }
+
+ public RecipientTemplate getRecipientTemplate(RecipientType recipientType) {
+ return recipientTemplates != null ? recipientTemplates.get(recipientType) : null;
+ }
+
+ public void setRecipientTemplate(RecipientType recipientType, RecipientTemplate recipientTemplate) {
+ if (recipientTemplates == null)
+ recipientTemplates = new HashMap<RecipientType, RecipientTemplate>();
+ recipientTemplates.put(recipientType, recipientTemplate);
+ }
+
+ public RecipientTemplate getTo() {
+ return getRecipientTemplate(RecipientType.TO);
+ }
+
+ public void setTo(RecipientTemplate to) {
+ setRecipientTemplate(RecipientType.TO, to);
+ }
+
+ public RecipientTemplate getCc() {
+ return getRecipientTemplate(RecipientType.CC);
+ }
+
+ public void setCc(RecipientTemplate cc) {
+ setRecipientTemplate(RecipientType.CC, cc);
+ }
+
+ public RecipientTemplate getBcc() {
+ return getRecipientTemplate(RecipientType.BCC);
+ }
+
+ public void setBcc(RecipientTemplate bcc) {
+ setRecipientTemplate(RecipientType.BCC, bcc);
+ }
+
+ public String getSubject() {
+ return subject;
+ }
+
+ public void setSubject(String subject) {
+ this.subject = subject;
+ }
+
+ public String getText() {
+ return text;
+ }
+
+ public void setText(String text) {
+ this.text = text;
+ }
+
+ public String getHtml() {
+ return html;
+ }
+
+ public void setHtml(String html) {
+ this.html = html;
+ }
+
+ public List<AttachmentTemplate> getAttachmentTemplates() {
+ return attachmentTemplates;
+ }
+
+ public void addAttachmentTemplate(AttachmentTemplate attachmentTemplate) {
+ if (attachmentTemplates == null) attachmentTemplates = new ArrayList<AttachmentTemplate>();
+ attachmentTemplates.add(attachmentTemplate);
+ }
+}
Added: 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 (rev 0)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/RecipientTemplate.java 2009-04-14 07:13:56 UTC (rev 4544)
@@ -0,0 +1,54 @@
+/*
+ * 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.util.ArrayList;
+import java.util.List;
+
+/**
+ * Template for email recipients, either addresses or actors.
+ *
+ * @author Alejandro Guizar
+ */
+public class RecipientTemplate {
+
+ private List<String> addresses;
+ private List<String> actors;
+
+ public List<String> getAddresses() {
+ return addresses;
+ }
+
+ public void addAddress(String address) {
+ if (addresses == null) addresses = new ArrayList<String>();
+ addresses.add(address);
+ }
+
+ public List<String> getActors() {
+ return actors;
+ }
+
+ public void addActor(String actor) {
+ if (actors == null) actors = new ArrayList<String>();
+ actors.add(actor);
+ }
+}
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java 2009-04-13 11:01:01 UTC (rev 4543)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/util/XmlUtil.java 2009-04-14 07:13:56 UTC (rev 4544)
@@ -21,7 +21,6 @@
*/
package org.jbpm.pvm.internal.util;
-import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Collections;
@@ -34,8 +33,6 @@
import org.jbpm.pvm.internal.xml.Parse;
import javax.xml.namespace.QName;
-import javax.xml.transform.Result;
-import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
@@ -225,23 +222,15 @@
return "null";
}
- Source source = new DOMSource(element);
-
StringWriter stringWriter = new StringWriter();
- PrintWriter printWriter = new PrintWriter(stringWriter);
- Result result = new StreamResult(printWriter);
-
try {
TransformerFactory transformerFactory = TransformerFactory.newInstance();
Transformer transformer = transformerFactory.newTransformer();
- transformer.transform(source, result);
+ transformer.transform(new DOMSource(element), new StreamResult(stringWriter));
} catch (Exception e) {
log.error("couldn't transform dom element into string representation");
return "<" + element.getTagName() + " ... >...</" + element.getTagName() + ">";
}
-
- printWriter.close();
-
return stringWriter.toString();
}
Added: 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 (rev 0)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailTemplateBinding.java 2009-04-14 07:13:56 UTC (rev 4544)
@@ -0,0 +1,163 @@
+/*
+ * 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.wire.binding;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.jbpm.pvm.internal.email.impl.AttachmentTemplate;
+import org.jbpm.pvm.internal.email.impl.MailTemplate;
+import org.jbpm.pvm.internal.email.impl.RecipientTemplate;
+import org.jbpm.pvm.internal.util.XmlUtil;
+import org.jbpm.pvm.internal.wire.Descriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ListDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
+import org.jbpm.pvm.internal.wire.descriptor.StringDescriptor;
+import org.jbpm.pvm.internal.wire.operation.PropertyOperation;
+import org.jbpm.pvm.internal.xml.Parse;
+import org.jbpm.pvm.internal.xml.Parser;
+import org.w3c.dom.Element;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class MailTemplateBinding extends WireDescriptorBinding {
+
+ public MailTemplateBinding() {
+ super("mail-template");
+ }
+
+ public Object parse(Element element, Parse parse, Parser parser) {
+ ObjectDescriptor templateDescriptor = new ObjectDescriptor(MailTemplate.class);
+ // name
+ String name = element.getAttribute("name");
+ if (name != null) {
+ templateDescriptor.addInjection("name", new StringDescriptor(name));
+ }
+ else {
+ parse.addProblem("template has no name");
+ }
+ // language
+ String language = XmlUtil.attribute(element, "language");
+ if (language != null) {
+ templateDescriptor.addInjection("language", new StringDescriptor(language));
+ }
+ // to
+ Element toElement = XmlUtil.element(element, "to");
+ if (toElement != null) {
+ Descriptor toDescriptor = parseRecipientTemplate(toElement, parse, parser);
+ addPropertyInjection(templateDescriptor, "to", toDescriptor);
+ }
+ else {
+ parse.addProblem("template '" + name + "' has no 'to' recipients");
+ }
+ // cc
+ Element ccElement = XmlUtil.element(element, "cc");
+ if (ccElement != null) {
+ Descriptor ccDescriptor = parseRecipientTemplate(ccElement, parse, parser);
+ addPropertyInjection(templateDescriptor, "cc", ccDescriptor);
+ }
+ // bcc
+ Element bccElement = XmlUtil.element(element, "bcc");
+ if (bccElement != null) {
+ Descriptor bccDescriptor = parseRecipientTemplate(bccElement, parse, parser);
+ addPropertyInjection(templateDescriptor, "bcc", bccDescriptor);
+ }
+ // subject
+ Element subjectElement = XmlUtil.element(element, "subject");
+ if (subjectElement != null) {
+ StringDescriptor subjectDescriptor =
+ new StringDescriptor(XmlUtil.getContentText(subjectElement));
+ templateDescriptor.addInjection("subject", subjectDescriptor);
+ }
+ else {
+ parse.addProblem("template '" + name + "' has no subject");
+ }
+ // text
+ Element textElement = XmlUtil.element(element, "text");
+ if (textElement != null) {
+ StringDescriptor textDescriptor = new StringDescriptor(XmlUtil.getContentText(textElement));
+ templateDescriptor.addInjection("text", textDescriptor);
+ }
+ // html
+ Element htmlElement = XmlUtil.element(element, "html");
+ if (htmlElement != null) {
+ StringDescriptor htmlDescriptor = new StringDescriptor(XmlUtil.toString(htmlElement));
+ templateDescriptor.addInjection("html", htmlDescriptor);
+ }
+ // attachments
+ Element attachmentsElement = XmlUtil.element(element, "attachments");
+ if (attachmentsElement != null) {
+ List<Descriptor> attachmentDescriptors = new ArrayList<Descriptor>();
+ for (Element attachmentElement : XmlUtil.elements(attachmentsElement, "attachment")) {
+ ObjectDescriptor attachmentDescriptor = new ObjectDescriptor(AttachmentTemplate.class);
+ attachmentDescriptors.add(attachmentDescriptor);
+ // url
+ String url = XmlUtil.attribute(attachmentElement, "url");
+ if (url != null) attachmentDescriptor.addInjection("url", new StringDescriptor(url));
+ // resource
+ String resource = XmlUtil.attribute(attachmentElement, "resource");
+ if (resource != null)
+ attachmentDescriptor.addInjection("resource", new StringDescriptor(resource));
+ // file
+ String file = XmlUtil.attribute(attachmentElement, "file");
+ if (file != null) attachmentDescriptor.addInjection("file", new StringDescriptor(file));
+ }
+
+ ListDescriptor attachmentsDescriptor = new ListDescriptor();
+ attachmentsDescriptor.setValueDescriptors(attachmentDescriptors);
+ templateDescriptor.addInjection("attachmentTemplates", attachmentsDescriptor);
+ }
+ return templateDescriptor;
+ }
+
+ private static void addPropertyInjection(ObjectDescriptor objectDescriptor, String propertyName,
+ Descriptor valueDescriptor) {
+ PropertyOperation operation = new PropertyOperation();
+ operation.setPropertyName(propertyName);
+ operation.setDescriptor(valueDescriptor);
+ objectDescriptor.addOperation(operation);
+ }
+
+ protected Descriptor parseRecipientTemplate(Element element, Parse parse, Parser parser) {
+ ObjectDescriptor recipientDescriptor = new ObjectDescriptor(RecipientTemplate.class);
+
+ String addresses = XmlUtil.attribute(element, "addresses");
+ if (addresses != null) recipientDescriptor.addInjection("addresses", parseTokens(addresses));
+
+ String actors = XmlUtil.attribute(element, "actors");
+ if (actors != null) recipientDescriptor.addInjection("actors", parseTokens(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;
+ }
+
+}
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/DomBuilder.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/DomBuilder.java 2009-04-13 11:01:01 UTC (rev 4543)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/DomBuilder.java 2009-04-14 07:13:56 UTC (rev 4544)
@@ -29,6 +29,7 @@
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.Text;
+import org.w3c.dom.UserDataHandler;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.Locator;
@@ -41,7 +42,6 @@
public Document document;
- protected String debugNamespace = null;
protected String lineAttributeName = "line";
protected String columnAttributeName = null;
@@ -315,23 +315,12 @@
int lineNumber = locator.getLineNumber();
int columnNumber = locator.getColumnNumber();
- if (debugNamespace==null) {
- if (lineAttributeName!=null) {
- elem.setAttribute(lineAttributeName, Integer.toString(lineNumber));
- }
- if (columnAttributeName!=null) {
- elem.setAttribute(columnAttributeName, Integer.toString(columnNumber));
- }
-
- } else {
- if (lineAttributeName!=null) {
- elem.setAttributeNS(debugNamespace, lineAttributeName, Integer.toString(lineNumber));
- }
- if (columnAttributeName!=null) {
- elem.setAttributeNS(debugNamespace, columnAttributeName, Integer.toString(columnNumber));
- }
-
+ if (lineAttributeName!=null) {
+ elem.setUserData(lineAttributeName, lineNumber, null);
}
+ if (columnAttributeName!=null) {
+ elem.setUserData(columnAttributeName, columnNumber, null);
+ }
}
@@ -824,18 +813,12 @@
return true;
}
- public void setDebugNamespace(String debugNamespace) {
- this.debugNamespace = debugNamespace;
- }
public void setLineAttributeName(String lineAttributeName) {
this.lineAttributeName = lineAttributeName;
}
public void setColumnAttributeName(String columnAttributeName) {
this.columnAttributeName = columnAttributeName;
}
- public String getDebugNamespace() {
- return debugNamespace;
- }
public String getLineAttributeName() {
return lineAttributeName;
}
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parser.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parser.java 2009-04-13 11:01:01 UTC (rev 4543)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parser.java 2009-04-14 07:13:56 UTC (rev 4544)
@@ -394,6 +394,7 @@
parseDocument(parse.document, parse);
} catch (Exception e) {
+ e.printStackTrace();
parse.addProblem("couldn't interpret the dom model: "+e.getMessage(), e);
}
}
@@ -437,7 +438,7 @@
}
DocumentBuilder documentBuilder = createDocumentBuilder(parse);
- document = documentBuilder.newDocument();
+ document = documentBuilder.getDOMImplementation().createDocument(null, null, null);
parse.setDocument(document);
DomBuilder domBuilder = new DomBuilder();
Added: jbpm4/branches/email/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailTemplateWireTest.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailTemplateWireTest.java (rev 0)
+++ jbpm4/branches/email/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailTemplateWireTest.java 2009-04-14 07:13:56 UTC (rev 4544)
@@ -0,0 +1,174 @@
+/*
+ * 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.wire;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.jbpm.pvm.internal.email.impl.AttachmentTemplate;
+import org.jbpm.pvm.internal.email.impl.MailTemplate;
+
+/**
+ * @author Alejandro Guizar
+ */
+public class MailTemplateWireTest extends WireTestCase {
+
+ public void testName() {
+ WireContext wireContext =
+ createWireContext("<objects>"
+ + "<mail-template name='plate'>"
+ + " <to addresses='dilbert at office, alice at work, dogbert at house'/>"
+ + " <subject>bureaucracy</subject>"
+ + "</mail-template>"
+ + "</objects>");
+
+ MailTemplate template = wireContext.get(MailTemplate.class);
+ assertEquals("plate", template.getName());
+ }
+
+ public void testLanguage() {
+ WireContext wireContext =
+ createWireContext("<objects>"
+ + "<mail-template name='plate' language='juel'>"
+ + " <to addresses='dilbert at office, alice at work, dogbert at house'/>"
+ + " <subject>bureaucracy</subject>"
+ + "</mail-template>"
+ + "</objects>");
+
+ MailTemplate template = wireContext.get(MailTemplate.class);
+ assertEquals("juel", template.getLanguage());
+ }
+
+ public void testTo() {
+ WireContext wireContext =
+ createWireContext("<objects>"
+ + "<mail-template name='plate'>"
+ + " <to addresses='dilbert at office, alice at work, dogbert at house'/>"
+ + " <subject>bureaucracy</subject>"
+ + "</mail-template>"
+ + "</objects>");
+
+ MailTemplate template = wireContext.get(MailTemplate.class);
+ assertEquals(Arrays.asList("dilbert at office", "alice at work", "dogbert at house"), template
+ .getTo()
+ .getAddresses());
+ }
+
+ public void testCc() {
+ WireContext wireContext =
+ createWireContext("<objects>"
+ + "<mail-template name='plate'>"
+ + " <to addresses='dilbert at office, alice at work, dogbert at house'/>"
+ + " <cc actors='theboss, hrpolicymaker'/>"
+ + " <subject>bureaucracy</subject>"
+ + "</mail-template>"
+ + "</objects>");
+
+ MailTemplate template = wireContext.get(MailTemplate.class);
+ assertEquals(Arrays.asList("theboss", "hrpolicymaker"), template.getCc().getActors());
+ }
+
+ public void testBcc() {
+ WireContext wireContext =
+ createWireContext("<objects>"
+ + "<mail-template name='plate'>"
+ + " <to addresses='dilbert at office, alice at work, dogbert at house'/>"
+ + " <bcc actors='thoughtpolice'/>"
+ + " <subject>bureaucracy</subject>"
+ + "</mail-template>"
+ + "</objects>");
+
+ MailTemplate template = wireContext.get(MailTemplate.class);
+ assertEquals(Collections.singletonList("thoughtpolice"), template.getBcc().getActors());
+ }
+
+ public void testSubject() {
+ WireContext wireContext =
+ createWireContext("<objects>"
+ + "<mail-template name='plate'>"
+ + " <to addresses='dilbert at office, alice at work, dogbert at house'/>"
+ + " <subject>bureaucracy</subject>"
+ + "</mail-template>"
+ + "</objects>");
+
+ MailTemplate template = wireContext.get(MailTemplate.class);
+ assertEquals("bureaucracy", template.getSubject());
+ }
+
+ public void testText() {
+ WireContext wireContext =
+ createWireContext("<objects>"
+ + "<mail-template name='plate'>"
+ + " <to addresses='dilbert at office, alice at work, dogbert at house'/>"
+ + " <subject>bureaucracy</subject>"
+ + " <text>plain text content</text>"
+ + "</mail-template>"
+ + "</objects>");
+
+ MailTemplate template = wireContext.get(MailTemplate.class);
+ assertEquals("plain text content", template.getText());
+ }
+
+ public void testHtml() {
+ WireContext wireContext =
+ createWireContext("<objects>"
+ + "<mail-template name='plate'>"
+ + " <to addresses='dilbert at office, alice at work, dogbert at house'/>"
+ + " <subject>bureaucracy</subject>"
+ + " <html><strong>rich</strong> content</html>"
+ + "</mail-template>"
+ + "</objects>");
+
+ MailTemplate template = wireContext.get(MailTemplate.class);
+ System.out.println(template.getHtml());
+ assertEquals("<html>\n<strong>rich</strong> content</html>\n", template.getHtml());
+ }
+
+ public void testAttachments() {
+ WireContext wireContext =
+ createWireContext("<objects>"
+ + "<mail-template name='plate'>"
+ + " <to addresses='dilbert at office, alice at work, dogbert at house'/>"
+ + " <subject>bureaucracy</subject>"
+ + " <attachments>"
+ + " <attachment url='http://en.wikipedia.org/wiki/File:Dilbert-20050910.png'/>"
+ + " <attachment resource='org/example/pic.jpg'/>"
+ + " <attachment file='${user.home}/.face'/>"
+ + " </attachments>"
+ + "</mail-template>"
+ + "</objects>");
+
+ MailTemplate template = wireContext.get(MailTemplate.class);
+ List<AttachmentTemplate> attachmentTemplates = template.getAttachmentTemplates();
+ assertEquals(3, attachmentTemplates.size());
+ // url
+ AttachmentTemplate attachmentTemplate = attachmentTemplates.get(0);
+ assertEquals("http://en.wikipedia.org/wiki/File:Dilbert-20050910.png", attachmentTemplate.getUrl());
+ // resource
+ attachmentTemplate = attachmentTemplates.get(1);
+ assertEquals("org/example/pic.jpg", attachmentTemplate.getResource());
+ // file
+ attachmentTemplate = attachmentTemplates.get(2);
+ assertEquals("${user.home}/.face", attachmentTemplate.getFile());
+ }
+}
Modified: jbpm4/branches/email/modules/pvm/src/test/resources/jbpm.wire.bindings.xml
===================================================================
--- jbpm4/branches/email/modules/pvm/src/test/resources/jbpm.wire.bindings.xml 2009-04-13 11:01:01 UTC (rev 4543)
+++ jbpm4/branches/email/modules/pvm/src/test/resources/jbpm.wire.bindings.xml 2009-04-14 07:13:56 UTC (rev 4544)
@@ -39,6 +39,7 @@
<binding class="org.jbpm.pvm.internal.wire.binding.BusinessCalendarBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.IdGeneratorBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.AuthenticationBinding" />
+ <binding class="org.jbpm.pvm.internal.wire.binding.MailTemplateBinding" />
<!-- hibernate bindings -->
<binding class="org.jbpm.pvm.internal.wire.binding.HibernateConfigurationBinding" />
<binding class="org.jbpm.pvm.internal.wire.binding.SeamHibernateSessionBinding" />
More information about the jbpm-commits
mailing list