JBoss JBPM SVN: r4514 - jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl.
by do-not-reply@jboss.org
Author: bradsdavis
Date: 2009-04-09 10:25:18 -0400 (Thu, 09 Apr 2009)
New Revision: 4514
Modified:
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java
Log:
Added check for addressFilter being null.
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java 2009-04-09 10:11:42 UTC (rev 4513)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java 2009-04-09 14:25:18 UTC (rev 4514)
@@ -32,19 +32,25 @@
// Need to apply filter.
try {
- Collection<InternetAddress> toFiltered = addressFilter.filter(to);
- Collection<InternetAddress> ccFiltered = addressFilter.filter(cc);
- Collection<InternetAddress> bccFiltered = addressFilter.filter(bcc);
-
- // Set the email with the new filtered addresses.
- email.setTo(toFiltered);
- email.setCc(ccFiltered);
- email.setBcc(bccFiltered);
-
- // If there is someone to send it to, then send it.
- if (!(toFiltered.isEmpty() && ccFiltered.isEmpty() && bccFiltered.isEmpty())) {
- email.send();
+ if(addressFilter!=null) {
+ Collection<InternetAddress> toFiltered = addressFilter.filter(to);
+ Collection<InternetAddress> ccFiltered = addressFilter.filter(cc);
+ Collection<InternetAddress> bccFiltered = addressFilter.filter(bcc);
+
+ // Set the email with the new filtered addresses.
+ email.setTo(toFiltered);
+ email.setCc(ccFiltered);
+ email.setBcc(bccFiltered);
+
+ // If there is someone to send it to, then send it.
+ if (!(toFiltered.isEmpty() && ccFiltered.isEmpty() && bccFiltered.isEmpty())) {
+ email.send();
+ }
}
+ else {
+ //If no filter is set, then accept all.
+ email.send();
+ }
}
catch (EmailException e) {
log.error("An exception occurred while sending email.", e);
17 years
JBoss JBPM SVN: r4512 - jbpm4/trunk/modules/userguide/src/main/docbook/en/modules.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-04-09 06:04:21 -0400 (Thu, 09 Apr 2009)
New Revision: 4512
Removed:
jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml
Log:
removed ch04-Jpdl.xml. it was renamed to ch05-... before
Deleted: jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml
===================================================================
--- jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml 2009-04-09 09:56:43 UTC (rev 4511)
+++ jbpm4/trunk/modules/userguide/src/main/docbook/en/modules/ch04-Jpdl.xml 2009-04-09 10:04:21 UTC (rev 4512)
@@ -1,896 +0,0 @@
-<chapter id="jpdl">
- <title>jPDL</title>
-
- <para>This chapter will explain the jPDL file format for describing
- process definitions. The schemadocs can also serve as a quick reference for this
- information.
- </para>
- <para>An example jPDL process file looks like this:
- </para>
- <programlisting><?xml version="1.0" encoding="UTF-8"?>
-
-<process name="Purchase order" xmlns="http://jbpm.org/4/jpdl">
-
- <start>
- <transition to="Verify supplier" />
- </start>
-
- <state name="Verify supplier">
- <transition name="Supplier ok" to="Check supplier data" />
- <transition name="Supplier not ok" to="Error" />
- </state>
-
- <exclusive name="Check supplier data">
- <transition name="nok" to="Error" />
- <transition name="ok" to="Completed" />
- </exclusive>
-
- <end name="Completed" />
-
- <end name="Error" />
-
-</process></programlisting>
-
- <section id="process">
- <title><literal>process</literal></title>
- <para>The top level element representing one process definition.
- </para>
- <table><title><literal>process</literal> attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>name</literal></entry>
- <entry>any text</entry>
- <entry></entry>
- <entry><emphasis role="bold">required</emphasis></entry>
- <entry>name or label of the process used to display to the process
- name in user interactions.
- </entry>
- </row>
- <row>
- <entry><literal>key</literal></entry>
- <entry>alpha numeric characters and underscores</entry>
- <entry>if omitted, the key will be generated based on the name by replacing
- all non-alpha-numeric characters with underscores</entry>
- <entry>optional</entry>
- <entry>identification to distinct different process definitions.
- Multiple versions of a process with the same key can be deployed.
- The key:name combination must remain exactly the same for all
- deployed versions.
- </entry>
- </row>
- <row>
- <entry><literal>version</literal></entry>
- <entry>integer</entry>
- <entry>one higher then highest version number starting with 1 if no other process
- is deployed with the same name/key.
- </entry>
- <entry>optional</entry>
- <entry>version number of this process</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <table><title><literal>process</literal> elements:</title>
- <tgroup cols="3" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Element</entry>
- <entry>Multiplicity</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>description</literal></entry>
- <entry>0..1</entry>
- <entry>description text</entry>
- </row>
- <row>
- <entry><link linkend="activities">activities</link></entry>
- <entry>1..*</entry>
- <entry>a list of any activity type can be placed here. At least
- one <literal>start</literal> activity must be present.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
-
- <section id="activities">
- <title>Activities</title>
- <para>(BPMN note: when we mention activities here, we are not only refering to BPMN
- activities, but also to BPMN events and BPMN gateways.)
- </para>
-
- <section id="start">
- <title><literal>start</literal></title>
- <para>Indicates where an execution for this process starts. Typically there is
- exactly one start activity in a process. A process has to have at least one start
- activity. A start activity must have exactly one outgoing transition and that transition
- is taken when a process execution starts.
- </para>
- <table><title><literal>start</literal> attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>name</literal></entry>
- <entry>any text</entry>
- <entry></entry>
- <entry>optional</entry>
- <entry>name of the activity. Since a start activity
- cannot have incoming transitions, the name is optional.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table><title><literal>start</literal> elements:</title>
- <tgroup cols="3" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Element</entry>
- <entry>Multiplicity</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>transition</literal></entry>
- <entry>1</entry>
- <entry>the outgoing transition</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
-
- <section id="state">
- <title><literal>state</literal></title>
- <para>A wait state. Process execution will wait until an external trigger is
- provided through the API. Apart from the <link linkend="commonactivitycontent">
- common activity content</link>, <literal>state</literal> doesn't have any extra
- attributes or elements.
- </para>
- <section id="statesequence">
- <title><literal>state</literal> sequence</title>
- <para>Let's look at an example which shows states connected with transitions
- as a sequence</para>
- <figure id="state.sequence">
- <title>A sequence of states</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/state.sequence.png"/></imageobject></mediaobject>
- </figure>
- <programlisting><process name="StateSequence" xmlns="http://jbpm.org/4/jpdl">
-
- <start>
- <transition to="a" />
- </start>
-
- <state name="a">
- <transition to="b" />
- </state>
-
- <state name="b">
- <transition to="c" />
- </state>
-
- <state name="c" />
-
-</process></programlisting>
- <para>After you start an execution like this:</para>
- <programlisting>Execution execution = executionService.startProcessInstanceByKey("StateSequence");</programlisting>
- <para>the created process instance will be positioned in
- state <literal>a</literal>. Providing an external trigger can
- be done with the <literal>signalExecution</literal> methods.</para>
- <programlisting>String executionId = execution.getId();
-execution = executionService.signalExecutionById(executionId);</programlisting>
- </section>
- <section id="statechoice">
- <title><literal>state</literal> choice</title>
- <para>In this second example with states, we'll show how you can use a
- <literal>state</literal> can be used to feed in an external choice of
- the path to take.
- </para>
- <figure id="state.choice">
- <title>A choice between state</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/state.choice.png"/></imageobject></mediaobject>
- </figure>
- <programlisting><process name="StateChoice" xmlns="http://jbpm.org/4/jpdl">
-
- <start>
- <transition to="wait for response" />
- </start>
-
- <state name="wait for response">
- <transition name="accept" to="submit document" />
- <transition name="reject" to="try again" />
- </state>
-
- <state name="submit document" />
-
- <state name="try again" />
-
-</process></programlisting>
- <para>Let's start a new process instance for this process definition:</para>
- <programlisting>Execution execution = executionService.startProcessInstanceByKey("StateSequence");</programlisting>
- <para>Now, the execution is arrived in the <literal>wait for response</literal>.
- The execution will wait there until an external trigger is given. In case
- a <literal>state</literal> has multiple outgoing transitions, the signalName given
- in the external trigger will be matched against the name of the outgoing transition
- to take. So when we provide signalName <literal>accept</literal> like this:
- </para>
- <programlisting>executionService.signalExecutionById(executionId, "accept");</programlisting>
- <para>Then the execution will continue over the outgoing transition named
- <literal>accept</literal>. Analogue, when signalName <literal>reject</literal>
- is given in the signalExecutionXxx methods, the execution will continue over
- the outgoing transition named reject.
- </para>
- </section>
- </section>
-
- <section id="java">
- <title><literal>java</literal></title>
- <para>The Java task. A process execution will execute the method of the class that is configured
- in this task.</para>
- <table><title><literal>java</literal> attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>class</literal></entry>
- <entry></entry>
- <entry></entry>
- <entry></entry>
- <entry></entry>
- </row>
- <row>
- <entry><literal>method</literal></entry>
- <entry></entry>
- <entry></entry>
- <entry></entry>
- <entry></entry>
- </row>
- <row>
- <entry><literal>var</literal></entry>
- <entry></entry>
- <entry></entry>
- <entry></entry>
- <entry></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table><title><literal>java</literal> elements:</title>
- <tgroup cols="3" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Element</entry>
- <entry>Multiplicity</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>field</literal></entry>
- <entry></entry>
- <entry></entry>
- </row>
- <row>
- <entry><literal>arg</literal></entry>
- <entry></entry>
- <entry></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>Consider the following example.</para>
- <figure id="java">
- <title>A java task</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/java.png"/></imageobject></mediaobject>
- </figure>
- <programlisting><process name="Java" xmlns="http://jbpm.org/4/jpdl">
-
- <start>
- <transition to="invoke java method" />
- </start>
-
- <java name="invoke java method"
- class="org.jbpm.examples.java.JohnDoe"
- method="hello"
- var="answer">
-
- <field name="state"><string value="fine"/></field>
- <field name="session"><env type="org.hibernate.Session"/></field>
-
- <arg><string value="Hi, how are you?"/></arg>
-
- <transition to="wait" />
- </java>
-
- <state name="wait">
-
-</process>
- </programlisting>
- <para>The java task specifies that during its execution an instance of the class <literal>org.jbpm.examples.java.JohnDoe</literal>
- will be instantiated and the method <literal>hello</literal> of this class will be invoked on the resulting object. The variable named
- <literal>answer</literal> will contain the result of the invocation. Let's look at the class <literal>JohnDoe</literal> below.
- </para>
- <programlisting>package org.jbpm.examples.java;
-
-import org.hibernate.Session;
-
-public class JohnDoe {
-
- String state;
- Session session;
-
- public String hello(String msg) {
- if ( (msg.indexOf("how are you?")!=-1)
- && (session.isOpen())
- ) {
- return "I'm "+state+", thank you.";
- }
- return null;
- }
-}
- </programlisting>
- <para>The class above reveals that it contains two fields named <literal>state</literal> and <literal>session</literal>
- and that the method <literal>hello</literal> accepts one argument. During the execution the values specified in the
- <literal>field</literal> and <literal>arg</literal> configuration elements will be used. The expected result of creating
- a process instance is that the process variable <literal>answer</literal> contains the string
- <literal>I'm fine, thank you.</literal>.
- </para>
- </section>
-
- <section id="script">
- <title><literal>script</literal></title>
- <para>The Script task. A process execution will execute a script that is specified by this task. The script can be
- specified by either the <literal>expr</literal> attribute or by the inclusion of the <literal>text</literal> nested
- element. The result of the evaluation
- </para>
- <table><title><literal>script</literal> attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>expr</literal></entry>
- <entry></entry>
- <entry></entry>
- <entry></entry>
- <entry></entry>
- </row>
- <row>
- <entry><literal>var</literal></entry>
- <entry></entry>
- <entry></entry>
- <entry></entry>
- <entry></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table><title><literal>script</literal> elements:</title>
- <tgroup cols="3" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Element</entry>
- <entry>Multiplicity</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>text</literal></entry>
- <entry></entry>
- <entry></entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>Consider the following example.</para>
- <figure id="script">
- <title>A script task</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/script.png"/></imageobject></mediaobject>
- </figure>
- <programlisting><process name="ScriptExpression" xmlns="http://jbpm.org/4/jpdl">
-
- <start>
- <transition to="invoke script" />
- </start>
-
- <script name="invoke script"
- expr="Send packet to #{person.address}"
- var="text">
-
- <transition to="wait" />
- </script>
-
- <state name="wait"/>
-
-</process></programlisting>
- </section>
-
- <section id="esb">
- <title><literal>esb</literal></title>
- </section>
-
- <section id="sql">
- <title><literal>sql</literal></title>
- </section>
-
- <section id="hql">
- <title><literal>hql</literal></title>
- </section>
-
- <section id="task">
- <title><literal>task</literal></title>
- </section>
-
- <section id="exclusive">
- <title><literal>exclusive</literal></title>
- <para>Takes one path of many alternatives. Also known as a decision. An exclusive
- activity has multiple outgoing transitions and when an execution arrives in an exclusive
- activity, an automatic evaluation will decide which outgoing transition is taken.
- </para>
- <para>An exclusive activity should be configured in one of the three following ways:
- </para>
-
- <section id="exclusiveconditions">
- <title>Exclusive conditions</title>
- <para>An exclusive with conditions on the transitions evaluates the condition in each transition.
- The first transition for which the nested condition expression resolves to true or which does
- not have a condition is taken.
- </para>
- <table><title><literal>exclusive.transition.condition</literal> attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>expr</literal></entry>
- <entry>expression</entry>
- <entry></entry>
- <entry><emphasis role="bold">required</emphasis></entry>
- <entry>script that will be evaluated in the specified
- expression language.
- </entry>
- </row>
- <row>
- <entry><literal>lang</literal></entry>
- <entry>expression language</entry>
- <entry>the <literal>default-expression-language</literal> taken from the <link linkend="scripting"><literal>script-manager</literal> configuration</link></entry>
- <entry>optional</entry>
- <entry>the language in which <literal>expr</literal> is
- to be evaluated.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>Example:
- </para>
- <figure id="exclusive">
- <title>The exclusive gateway</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/exclusive.png"/></imageobject></mediaobject>
- </figure>
- <programlisting><process name="ExclusiveConditions" >
-
- <start>
- <transition to="evaluate document" />
- </start>
-
- <exclusive name="evaluate document">
- <transition to="submit document">
- <emphasis role="bold"><condition expr="#{content=="good"}" /></emphasis>
- </transition>
- <transition to="try again">
- <emphasis role="bold"><condition expr="#{content=="not so good"}" /></emphasis>
- </transition>
- <transition to="give up" />
- </exclusive>
-
- <state name="submit document" />
-
- <state name="try again" />
-
- <state name="give up" />
-
-</process></programlisting>
- </section>
-
- <section id="exclusiveexpression">
- <title>Exclusive expression</title>
- <para>An exclusive expression evaluates to a String representing the name of
- an outgoing transition.
- </para>
- <table><title><literal>exclusive</literal> attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>expr</literal></entry>
- <entry>expression</entry>
- <entry></entry>
- <entry><emphasis role="bold">required</emphasis></entry>
- <entry>script that will be evaluated in the specified
- expression language.
- </entry>
- </row>
- <row>
- <entry><literal>lang</literal></entry>
- <entry>expression language</entry>
- <entry>the <literal>default-expression-language</literal> taken from the <link linkend="scripting"><literal>script-manager</literal> configuration</link></entry>
- <entry>optional</entry>
- <entry>the language in which <literal>expr</literal> is
- to be evaluated.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>Example:
- </para>
- <para>Same picture as <link linkend="exclusive">above</link>.
- </para>
- <programlisting><process name="Poolcar">
- <start>
- <transition to="How far?" />
- </start>
- <exclusive name="How far?" <emphasis role="bold">expr="#{distance}"</emphasis>>
- <transition name="far" to="Big car" />
- <transition name="nearby" to="Small car" />
- </exclusive>
- <state name="Big car" />
- <state name="Small car" />
-</process></programlisting>
- <para>When you start an new process instance like this
- </para>
- <programlisting>Map<String, Object> variables = new HashMap<String, Object>();
-variables.put("distance", "far");
-Execution execution = executionService.startProcessInstanceByKey("Poolcar", variables);</programlisting>
- <para>then the new execution will go to activity <literal>Big car</literal>.</para>
- </section>
-
- <section id="exclusivehandler">
- <title>Exclusive handler</title>
- <para>An exclusive handler is a java class that implements the
- <literal>ExclusiveHandler</literal> interface. The exclusive handler
- will be responsible for selecting the name of the outgoing transition.
- </para>
- <programlisting>public interface ExclusiveHandler {
- String select(OpenExecution execution);
-}</programlisting>
- <para>The handler is specified as a sub element of the exclusive</para>
- <table><title><literal>exclusive.handler</literal> attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>class</literal></entry>
- <entry>classname</entry>
- <entry></entry>
- <entry><emphasis role="bold">required</emphasis></entry>
- <entry>fully qualified classname of the handler implementation class.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <para>Here's an example process of an exclusive using an ExclusiveHandler:</para>
- <para>Same picture as <link linkend="exclusive">above</link>.
- </para>
- <programlisting><process name="ExclusiveHandler">
-
- <start>
- <transition to="evaluate document" />
- </start>
-
- <exclusive name="evaluate document">
- <handler class="org.jbpm.examples.exclusive.handler.ContentEvaluation" />
- <transition name="good" to="submit document" />
- <transition name="bad" to="try again" />
- <transition name="ugly" to="give up" />
- </exclusive>
-
- <state name="submit document" />
-
- <state name="try again" />
-
- <state name="give up" />
-
-</process></programlisting>
- <para>The ContentEvaluation class looks like this</para>
- <programlisting>public class ContentEvaluation implements ExclusiveHandler {
-
- public String select(OpenExecution execution) {
- String content = (String) execution.getVariable("content");
- if (content.equals("you're great")) {
- return "good";
- }
- if (content.equals("you gotta improve")) {
- return "bad";
- }
- return "ugly";
- }
-}</programlisting>
- <para>Now, when we start a process instance and supply value
- <literal>you're great</literal> for variable content, then the
- ContentEvaluation will return String <literal>good</literal> and
- the process instance will arrive in activity <literal>Submit document</literal>.
- </para>
- </section>
-
- </section>
-
- <section id="end">
- <title><literal>end</literal></title>
- <para>Ends the execution.
- </para>
- <section id="endprocessinstance">
- <title><literal>end</literal> process instance</title>
- <para>By default, an end activity will end the complete
- process instance. In case multiple concurrent executions
- are still active within the same process instance, all of
- them will be ended.
- </para>
- <figure id="end.processinstance">
- <title>The end event</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/end.processinstance.png"/></imageobject></mediaobject>
- </figure>
- <programlisting><process name="EndProcessInstance" xmlns="http://jbpm.org/4/jpdl">
-
- <start>
- <transition to="end" />
- </start>
-
- <end name="end" />
-
-</process></programlisting>
- <para>When a new process instance is created, it immediately ends.</para>
- </section>
- <section id="endexecution">
- <title><literal>end</literal> execution</title>
- <para>Only the execution that arrives in the
- end activity will be ended and other concurrent executions
- should be left active. To get this behaviour, set
- attribute <literal>ends="execution"</literal>
- </para>
- <table><title><literal>end</literal> execution attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>ends</literal></entry>
- <entry>{processinstance|execution}</entry>
- <entry>processinstance</entry>
- <entry>optional</entry>
- <entry>specifies if the whole process instance should be ended or
- just the path of execution that arrives in the end activity.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
- <section id="endmultiple">
- <title><literal>end</literal> multiple</title>
- <para>A process can have multiple end events. This can be handy to indicate
- different outcomes of a process instance. For example
- </para>
- <figure id="end.multiple">
- <title>Multiple end events</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/end.multiple.png"/></imageobject></mediaobject>
- </figure>
- <programlisting><process name="EndMultiple" xmlns="http://;jbpm.org/4/jpdl">
-
- <start>
- <transition to="get return code" />
- <start>
-
- <state name="get return code">
- <transition name="200" to="ok"/>
- <transition name="400" to="bad request"/>
- <transition name="500" to="internal server error"/>
- </state>
-
- <end name="ok"/>
- <end name="bad request"/>
- <end name="internal server error"/>
-
-</process>
- </programlisting>
- <para>Now if we would start an execution and signal it to move out of the <literal>get return code</literal> wait state with the
- following code, the execution would end with the <literal>bad request</literal> end event.</para>
- <programlisting>Execution execution = executionService.startProcessInstanceByKey("EndMultiple");
-String executionId = execution.getId();
-execution = executionService.signalExecutionById(executionId, "400");
- </programlisting>
- <para>Likewise, using the value <literal>200</literal> or <literal>500</literal> would cause the execution
- to end with the <literal>ok</literal> or with the <literal>internal server error</literal> end events
- respectively.</para>
- </section>
-
- <section id="endstate">
- <title><literal>end</literal> state</title>
- <para>An execution can also end with different states. It is another way to specify the outcome of a process.
- It is indicated by the <literal>state</literal> attribute of the end event or by the <literal>end-cancel</literal>
- and <literal>end-error</literal> shortcut notations.
- </para>
-
- <table><title><literal>end</literal> execution attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>state</literal></entry>
- <entry>String</entry>
- <entry></entry>
- <entry>optional</entry>
- <entry>the state assigned to the execution.
- </entry>
- </row>
- </tbody>
- </tgroup>
- </table>
-
- <para>Take for example the following process.
- </para>
- <figure id="end.state">
- <title>Different end states</title>
- <mediaobject><imageobject><imagedata align="center" fileref="images/end.state.png"/></imageobject></mediaobject>
- </figure>
- <programlisting><process name="EndState" xmlns="http://jbpm.org/4/jpdl">
-
- <start>
- <transition to="get return code"/>
- </start>
-
- <state name="get return code">
- <transition name="200" to="ok"/>
- <transition name="400" to="bad request" />
- <transition name="500" to="internal server error"/>
- </state>
-
- <end name="ok" state="completed"/>
- <end-cancel name="bad request"/>
- <end-error name="internal server error"/>
-
-</process>
- </programlisting>
- <para>This time, if we would start an execution and signal it to move out of the <literal>get return code</literal> wait state with the
- following code, the execution would end with the <literal>cancel</literal> state.</para>
- <programlisting>Execution execution = executionService.startProcessInstanceByKey("EndState");
-String executionId = execution.getId();
-execution = executionService.signalExecutionById(executionId, "400");
- </programlisting>
- <para>Similarly as above, using the value <literal>200</literal> or <literal>500</literal> would cause the execution
- to end with the <literal>completed</literal> or with the <literal>error</literal> states
- respectively.</para>
-
- </section>
- </section>
-
- <section id="commonactivitycontents">
- <title>Common activity contents</title>
- <para>Unless specified otherwise above, all activities also include this
- content model:
- </para>
- <table><title>Common activity attributes:</title>
- <tgroup cols="5" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Attribute</entry>
- <entry>Type</entry>
- <entry>Default</entry>
- <entry>Required?</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>name</literal></entry>
- <entry>any text</entry>
- <entry></entry>
- <entry><emphasis role="bold">required</emphasis></entry>
- <entry>name of the activity</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- <table><title>Common activity elements:</title>
- <tgroup cols="3" rowsep="1" colsep="1">
- <thead>
- <row>
- <entry>Element</entry>
- <entry>Multiplicity</entry>
- <entry>Description</entry>
- </row>
- </thead>
- <tbody>
- <row>
- <entry><literal>transition</literal></entry>
- <entry>0..*</entry>
- <entry>the outgoing transitions</entry>
- </row>
- </tbody>
- </tgroup>
- </table>
- </section>
- </section>
-
-</chapter>
17 years
JBoss JBPM SVN: r4511 - jbpm4/tags/jbpm-4.0.0.Beta1/modules/userguide/src/main/docbook/en/modules.
by do-not-reply@jboss.org
Author: tom.baeyens(a)jboss.com
Date: 2009-04-09 05:56:43 -0400 (Thu, 09 Apr 2009)
New Revision: 4511
Modified:
jbpm4/tags/jbpm-4.0.0.Beta1/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml
Log:
fixed task swimlane image reference in userguide docs
Modified: jbpm4/tags/jbpm-4.0.0.Beta1/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml
===================================================================
--- jbpm4/tags/jbpm-4.0.0.Beta1/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml 2009-04-09 08:33:46 UTC (rev 4510)
+++ jbpm4/tags/jbpm-4.0.0.Beta1/modules/userguide/src/main/docbook/en/modules/ch05-Jpdl.xml 2009-04-09 09:56:43 UTC (rev 4511)
@@ -1167,12 +1167,7 @@
</table>
<figure id="process.task.swimlane">
<title>The task swimlane example process</title>
-
- <!-- KOEN: volgende image moet aangepast worden naar
- images/process.task.swimlane.png
- nadat je die hebt toegevoegd aan de images directory -->
-
- <mediaobject><imageobject><imagedata align="center" fileref="images/process.task.png"/></imageobject></mediaobject>
+ <mediaobject><imageobject><imagedata align="center" fileref="images/process.task.swimlane.png"/></imageobject></mediaobject>
</figure>
<para>The task swimlane example has the following process file :</para>
<programlisting><process name="TaskSwimlane" xmlns="http://jbpm.org/4/jpdl">
17 years
JBoss JBPM SVN: r4510 - jbpm4/tags.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-04-09 04:33:46 -0400 (Thu, 09 Apr 2009)
New Revision: 4510
Added:
jbpm4/tags/jbpm-4.0.0.Beta1/
Log:
Beta1 release tag
Copied: jbpm4/tags/jbpm-4.0.0.Beta1 (from rev 4509, jbpm4/branches/jbpm-4.0.0.Beta1)
17 years
JBoss JBPM SVN: r4509 - jbpm4/branches/jbpm-4.0.0.Beta1.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-04-09 04:27:55 -0400 (Thu, 09 Apr 2009)
New Revision: 4509
Modified:
jbpm4/branches/jbpm-4.0.0.Beta1/pom.xml
Log:
Fix JBPM-2146: Release gwt-console-1.0.0.Beta3M2
Modified: jbpm4/branches/jbpm-4.0.0.Beta1/pom.xml
===================================================================
--- jbpm4/branches/jbpm-4.0.0.Beta1/pom.xml 2009-04-09 07:39:22 UTC (rev 4508)
+++ jbpm4/branches/jbpm-4.0.0.Beta1/pom.xml 2009-04-09 08:27:55 UTC (rev 4509)
@@ -47,7 +47,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<apache.ant.version>1.7.0</apache.ant.version>
<cactus.version>13-1.7.1</cactus.version>
- <gwt.console.version>1.0.0-SNAPSHOT</gwt.console.version>
+ <gwt.console.version>1.0.0.Beta3M2</gwt.console.version>
<hibernate.version>3.2.6.ga</hibernate.version>
<hibernate.annotations.version>3.3.1.GA</hibernate.annotations.version>
<hsqldb.version>1.8.0.7</hsqldb.version>
17 years
JBoss JBPM SVN: r4508 - projects/gwt-console/tags.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-04-09 03:39:22 -0400 (Thu, 09 Apr 2009)
New Revision: 4508
Added:
projects/gwt-console/tags/gwt-console-1.0.0.Beta3M2/
Log:
Create Beta3M2 tag
Copied: projects/gwt-console/tags/gwt-console-1.0.0.Beta3M2 (from rev 4507, projects/gwt-console/trunk)
17 years
JBoss JBPM SVN: r4507 - jbpm4/tags.
by do-not-reply@jboss.org
Author: heiko.braun(a)jboss.com
Date: 2009-04-09 03:36:54 -0400 (Thu, 09 Apr 2009)
New Revision: 4507
Removed:
jbpm4/tags/jbpm-4.0.0.Beta1/
Log:
Recreate tag
17 years
JBoss JBPM SVN: r4506 - in jbpm4/branches/email/modules/pvm/src: main/java/org/jbpm/pvm/internal/wire/binding and 1 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-04-09 01:28:08 -0400 (Thu, 09 Apr 2009)
New Revision: 4506
Added:
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java
Removed:
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/SyncMailSession.java
Modified:
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailSessionBinding.java
jbpm4/branches/email/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailSessionWireTest.java
Log:
rename SyncMailSession to MailSessionImpl as no other implementation seems to be necessary
Copied: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java (from rev 4505, jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/SyncMailSession.java)
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java (rev 0)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailSessionImpl.java 2009-04-09 05:28:08 UTC (rev 4506)
@@ -0,0 +1,65 @@
+package org.jbpm.pvm.internal.email.impl;
+
+import java.util.Collection;
+import java.util.List;
+
+import javax.mail.Session;
+import javax.mail.internet.InternetAddress;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.commons.mail.Email;
+import org.apache.commons.mail.EmailException;
+import org.jbpm.pvm.internal.email.spi.MailSession;
+
+public class MailSessionImpl implements MailSession {
+
+ private List<MailServer> mailServers;
+
+ private static final Log log = LogFactory.getLog(MailSessionImpl.class);
+
+ public void send(Collection<Email> emails) {
+ // Emails need to have the sessions populated.
+ for (Email email : emails) {
+ Collection<InternetAddress> to = email.getToAddresses();
+ Collection<InternetAddress> cc = email.getCcAddresses();
+ Collection<InternetAddress> bcc = email.getBccAddresses();
+
+ for (MailServer mailServer : mailServers) {
+ AddressFilter addressFilter = mailServer.getAddressFilter();
+ Session mailSession = mailServer.createMailSession();
+ email.setMailSession(mailSession);
+
+ // Need to apply filter.
+ try {
+ Collection<InternetAddress> toFiltered = addressFilter.filter(to);
+ Collection<InternetAddress> ccFiltered = addressFilter.filter(cc);
+ Collection<InternetAddress> bccFiltered = addressFilter.filter(bcc);
+
+ // Set the email with the new filtered addresses.
+ email.setTo(toFiltered);
+ email.setCc(ccFiltered);
+ email.setBcc(bccFiltered);
+
+ // If there is someone to send it to, then send it.
+ if (!(toFiltered.isEmpty() && ccFiltered.isEmpty() && bccFiltered.isEmpty())) {
+ email.send();
+ }
+ }
+ catch (EmailException e) {
+ log.error("An exception occurred while sending email.", e);
+ // TODO: Does anything else need to occur here?
+ }
+ }
+ }
+ }
+
+ public List<MailServer> getMailServers() {
+ return mailServers;
+ }
+
+ protected void setMailServers(List<MailServer> mailServers) {
+ this.mailServers = mailServers;
+ }
+
+}
Deleted: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/SyncMailSession.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/SyncMailSession.java 2009-04-09 05:23:54 UTC (rev 4505)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/SyncMailSession.java 2009-04-09 05:28:08 UTC (rev 4506)
@@ -1,65 +0,0 @@
-package org.jbpm.pvm.internal.email.impl;
-
-import java.util.Collection;
-import java.util.List;
-
-import javax.mail.Session;
-import javax.mail.internet.InternetAddress;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.commons.mail.Email;
-import org.apache.commons.mail.EmailException;
-import org.jbpm.pvm.internal.email.spi.MailSession;
-
-public class SyncMailSession implements MailSession {
-
- private List<MailServer> mailServers;
-
- private static final Log log = LogFactory.getLog(SyncMailSession.class);
-
- public void send(Collection<Email> emails) {
- // Emails need to have the sessions populated.
- for (Email email : emails) {
- Collection<InternetAddress> to = email.getToAddresses();
- Collection<InternetAddress> cc = email.getCcAddresses();
- Collection<InternetAddress> bcc = email.getBccAddresses();
-
- for (MailServer mailServer : mailServers) {
- AddressFilter addressFilter = mailServer.getAddressFilter();
- Session mailSession = mailServer.createMailSession();
- email.setMailSession(mailSession);
-
- // Need to apply filter.
- try {
- Collection<InternetAddress> toFiltered = addressFilter.filter(to);
- Collection<InternetAddress> ccFiltered = addressFilter.filter(cc);
- Collection<InternetAddress> bccFiltered = addressFilter.filter(bcc);
-
- // Set the email with the new filtered addresses.
- email.setTo(toFiltered);
- email.setCc(ccFiltered);
- email.setBcc(bccFiltered);
-
- // If there is someone to send it to, then send it.
- if (!(toFiltered.isEmpty() && ccFiltered.isEmpty() && bccFiltered.isEmpty())) {
- email.send();
- }
- }
- catch (EmailException e) {
- log.error("An exception occurred while sending email.", e);
- // TODO: Does anything else need to occur here?
- }
- }
- }
- }
-
- public List<MailServer> getMailServers() {
- return mailServers;
- }
-
- protected void setMailServers(List<MailServer> mailServers) {
- this.mailServers = mailServers;
- }
-
-}
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailSessionBinding.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailSessionBinding.java 2009-04-09 05:23:54 UTC (rev 4505)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailSessionBinding.java 2009-04-09 05:28:08 UTC (rev 4506)
@@ -25,7 +25,7 @@
import java.util.List;
import org.jbpm.pvm.internal.email.impl.MailServer;
-import org.jbpm.pvm.internal.email.impl.SyncMailSession;
+import org.jbpm.pvm.internal.email.impl.MailSessionImpl;
import org.jbpm.pvm.internal.email.impl.AddressFilter;
import org.jbpm.pvm.internal.email.spi.MailSession;
import org.jbpm.pvm.internal.util.XmlUtil;
@@ -111,7 +111,7 @@
serversDescriptor.setValueDescriptors(serverDescriptors);
// mail session
- ObjectDescriptor sessionDescriptor = new ObjectDescriptor(SyncMailSession.class);
+ ObjectDescriptor sessionDescriptor = new ObjectDescriptor(MailSessionImpl.class);
sessionDescriptor.addInjection("mailServers", serversDescriptor);
return sessionDescriptor;
}
Modified: jbpm4/branches/email/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailSessionWireTest.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailSessionWireTest.java 2009-04-09 05:23:54 UTC (rev 4505)
+++ jbpm4/branches/email/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailSessionWireTest.java 2009-04-09 05:28:08 UTC (rev 4506)
@@ -30,9 +30,8 @@
import org.jbpm.JbpmException;
import org.jbpm.pvm.internal.email.impl.MailServer;
-import org.jbpm.pvm.internal.email.impl.SyncMailSession;
+import org.jbpm.pvm.internal.email.impl.MailSessionImpl;
import org.jbpm.pvm.internal.email.impl.AddressFilter;
-import org.jbpm.pvm.internal.email.spi.MailSession;
/**
* @author Alejandro Guizar
@@ -53,11 +52,8 @@
+ " </mail-session>"
+ "</objects>");
- MailSession mailSession = wireContext.get(MailSession.class);
- assertTrue("expected sync mail session", mailSession instanceof SyncMailSession);
-
- SyncMailSession syncMailSession = (SyncMailSession) mailSession;
- List<MailServer> mailServers = syncMailSession.getMailServers();
+ MailSessionImpl mailSession = wireContext.get(MailSessionImpl.class);
+ List<MailServer> mailServers = mailSession.getMailServers();
assertEquals(1, mailServers.size());
MailServer mailServer = mailServers.get(0);
@@ -68,6 +64,20 @@
assertEquals("noreply(a)jbpm.org", properties.getProperty("mail.from"));
}
+ public void testNoSessionProperties() {
+ try {
+ createWireContext("<objects>"
+ + " <mail-session>"
+ + " <mail-server />"
+ + " </mail-session>"
+ + "</objects>");
+ fail("expected wire context creation to puke");
+ }
+ catch (JbpmException e) {
+ // session properties are mandatory
+ }
+ }
+
public static class MyAuthenticator extends Authenticator {
@Override
protected PasswordAuthentication getPasswordAuthentication() {
@@ -87,31 +97,15 @@
" </mail-server>" +
" </mail-session>" +
"</objects>");
- MailSession mailSession = wireContext.get(MailSession.class);
- assertTrue("expected sync mail session", mailSession instanceof SyncMailSession);
- SyncMailSession syncMailSession = (SyncMailSession) mailSession;
- List<MailServer> mailServers = syncMailSession.getMailServers();
+ MailSessionImpl mailSession = wireContext.get(MailSessionImpl.class);
+ List<MailServer> mailServers = mailSession.getMailServers();
assertEquals(1, mailServers.size());
MailServer mailServer = mailServers.get(0);
assertSame(MyAuthenticator.class, mailServer.getAuthenticator().getClass());
}
- public void testNoSessionProperties() {
- try {
- createWireContext("<objects>"
- + " <mail-session>"
- + " <mail-server />"
- + " </mail-session>"
- + "</objects>");
- fail("expected wire context creation to puke");
- }
- catch (JbpmException e) {
- // session properties are mandatory
- }
- }
-
public void testAddressFilter() {
WireContext wireContext =
createWireContext("<objects>"
@@ -126,11 +120,9 @@
+ " </mail-server>"
+ " </mail-session>"
+ "</objects>");
- MailSession mailSession = wireContext.get(MailSession.class);
- assertTrue("expected sync mail session", mailSession instanceof SyncMailSession);
- SyncMailSession syncMailSession = (SyncMailSession) mailSession;
- List<MailServer> mailServers = syncMailSession.getMailServers();
+ MailSessionImpl mailSession = wireContext.get(MailSessionImpl.class);
+ List<MailServer> mailServers = mailSession.getMailServers();
assertEquals(1, mailServers.size());
MailServer mailServer = mailServers.get(0);
@@ -157,11 +149,9 @@
+ " </mail-server>"
+ " </mail-session>"
+ "</objects>");
- MailSession mailSession = wireContext.get(MailSession.class);
- assertTrue("expected sync mail session", mailSession instanceof SyncMailSession);
- SyncMailSession syncMailSession = (SyncMailSession) mailSession;
- List<MailServer> mailServers = syncMailSession.getMailServers();
+ MailSessionImpl mailSession = wireContext.get(MailSessionImpl.class);
+ List<MailServer> mailServers = mailSession.getMailServers();
assertEquals(1, mailServers.size());
MailServer mailServer = mailServers.get(0);
@@ -184,11 +174,9 @@
+ " </mail-server>"
+ " </mail-session>"
+ "</objects>");
- MailSession mailSession = wireContext.get(MailSession.class);
- assertTrue("expected sync mail session", mailSession instanceof SyncMailSession);
- SyncMailSession syncMailSession = (SyncMailSession) mailSession;
- List<MailServer> mailServers = syncMailSession.getMailServers();
+ MailSessionImpl mailSession = wireContext.get(MailSessionImpl.class);
+ List<MailServer> mailServers = mailSession.getMailServers();
assertEquals(3, mailServers.size());
}
}
17 years
JBoss JBPM SVN: r4505 - in jbpm4/branches/email/modules/pvm/src: main/java/org/jbpm/pvm/internal/email/producer/impl and 3 other directories.
by do-not-reply@jboss.org
Author: alex.guizar(a)jboss.com
Date: 2009-04-09 01:23:54 -0400 (Thu, 09 Apr 2009)
New Revision: 4505
Modified:
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AddressFilter.java
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailServer.java
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/SyncMailSession.java
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailSessionBinding.java
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PropertiesBinding.java
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java
jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java
jbpm4/branches/email/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailSessionWireTest.java
Log:
support authenticator for mail session
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AddressFilter.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AddressFilter.java 2009-04-08 20:27:20 UTC (rev 4504)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/AddressFilter.java 2009-04-09 05:23:54 UTC (rev 4505)
@@ -3,6 +3,7 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
+import java.util.List;
import java.util.regex.Pattern;
import javax.mail.internet.InternetAddress;
@@ -15,86 +16,86 @@
*/
public class AddressFilter {
- /**
- * patterns of addresses to be included. all addresses are included when omitted.
- */
- private Collection<Pattern> includePatterns;
- /**
- * patterns of addresses to be excluded. no addresses are excluded when omitted.
- */
- private Collection<Pattern> excludePatterns;
+ /**
+ * patterns of addresses to be included. all addresses are included when omitted.
+ */
+ private List<Pattern> includePatterns;
+ /**
+ * patterns of addresses to be excluded. no addresses are excluded when omitted.
+ */
+ private List<Pattern> excludePatterns;
- public Collection<InternetAddress> filter(final Collection<InternetAddress> addresses) {
- Collection<InternetAddress> filteredAddresses = new HashSet<InternetAddress>();
- if (addresses != null) {
- // Loop over for addresses to decide what to keep.
- for (InternetAddress address : addresses) {
- if (keepAddress(address)) {
- filteredAddresses.add(address);
- }
- }
- }
- return filteredAddresses;
- }
+ public Collection<InternetAddress> filter(final Collection<InternetAddress> addresses) {
+ Collection<InternetAddress> filteredAddresses = new HashSet<InternetAddress>();
+ if (addresses != null) {
+ // Loop over for addresses to decide what to keep.
+ for (InternetAddress address : addresses) {
+ if (keepAddress(address)) {
+ filteredAddresses.add(address);
+ }
+ }
+ }
+ return filteredAddresses;
+ }
- /***
- * Determine in a given address is included or excluded based on regex.
- *
- * @param address Email Address to validate against regex.
- * @return If the includes is provided, and the address matches an include pattern, returns true,
- * false otherwise.
- */
- protected boolean keepAddress(InternetAddress address) {
- return includeAddress(address) && !excludeAddress(address);
- }
+ /***
+ * Determine in a given address is included or excluded based on regex.
+ *
+ * @param address Email Address to validate against regex.
+ * @return If the includes is provided, and the address matches an include pattern, returns true,
+ * false otherwise.
+ */
+ protected boolean keepAddress(InternetAddress address) {
+ return includeAddress(address) && !excludeAddress(address);
+ }
- protected boolean includeAddress(InternetAddress address) {
- if (includePatterns == null || includePatterns.isEmpty()) return true;
+ protected boolean includeAddress(InternetAddress address) {
+ if (includePatterns == null || includePatterns.isEmpty()) return true;
- for (Pattern pattern : includePatterns) {
- if (pattern.matcher(address.toString()).matches()) return true;
- }
- return false;
- }
+ for (Pattern pattern : includePatterns) {
+ if (pattern.matcher(address.toString()).matches()) return true;
+ }
+ return false;
+ }
- protected boolean excludeAddress(InternetAddress address) {
- if (excludePatterns == null || excludePatterns.isEmpty()) return false;
+ protected boolean excludeAddress(InternetAddress address) {
+ if (excludePatterns == null || excludePatterns.isEmpty()) return false;
- for (Pattern pattern : excludePatterns) {
- if (pattern.matcher(address.toString()).matches()) return true;
- }
- return false;
- }
+ for (Pattern pattern : excludePatterns) {
+ if (pattern.matcher(address.toString()).matches()) return true;
+ }
+ return false;
+ }
- /**
- * Gets the patterns of addresses to be included. All addresses are included when omitted.
- */
- public Collection<Pattern> getIncludePatterns() {
- return includePatterns;
- }
+ /**
+ * Gets the patterns of addresses to be included. All addresses are included when omitted.
+ */
+ public List<Pattern> getIncludePatterns() {
+ return includePatterns;
+ }
- public void addIncludePattern(Pattern includePattern) {
- if (includePatterns == null) includePatterns = new ArrayList<Pattern>();
- includePatterns.add(includePattern);
- }
+ public void addIncludePattern(Pattern includePattern) {
+ if (includePatterns == null) includePatterns = new ArrayList<Pattern>();
+ includePatterns.add(includePattern);
+ }
- protected void setIncludePatterns(Collection<Pattern> includePatterns) {
- this.includePatterns = includePatterns;
- }
+ protected void setIncludePatterns(List<Pattern> includePatterns) {
+ this.includePatterns = includePatterns;
+ }
- /**
- * Gets the patterns of addresses to be excluded. No addresses are excluded when omitted.
- */
- public Collection<Pattern> getExcludePatterns() {
- return excludePatterns;
- }
+ /**
+ * Gets the patterns of addresses to be excluded. No addresses are excluded when omitted.
+ */
+ public List<Pattern> getExcludePatterns() {
+ return excludePatterns;
+ }
- public void addExcludePattern(Pattern excludePattern) {
- if (excludePatterns == null) excludePatterns = new ArrayList<Pattern>();
- excludePatterns.add(excludePattern);
- }
+ public void addExcludePattern(Pattern excludePattern) {
+ if (excludePatterns == null) excludePatterns = new ArrayList<Pattern>();
+ excludePatterns.add(excludePattern);
+ }
- protected void setExcludePatterns(Collection<Pattern> excludePatterns) {
- this.excludePatterns = excludePatterns;
- }
+ protected void setExcludePatterns(List<Pattern> excludePatterns) {
+ this.excludePatterns = excludePatterns;
+ }
}
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailServer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailServer.java 2009-04-08 20:27:20 UTC (rev 4504)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/MailServer.java 2009-04-09 05:23:54 UTC (rev 4505)
@@ -2,6 +2,7 @@
import java.util.Properties;
+import javax.mail.Authenticator;
import javax.mail.Session;
/**
@@ -11,26 +12,35 @@
*/
public class MailServer {
- private AddressFilter addressFilter;
- private Properties sessionProperties;
+ private AddressFilter addressFilter;
+ private Properties sessionProperties;
+ private Authenticator authenticator;
- public AddressFilter getAddressFilter() {
- return addressFilter;
- }
+ public AddressFilter getAddressFilter() {
+ return addressFilter;
+ }
- protected void setAddressFilter(AddressFilter filter) {
- this.addressFilter = filter;
- }
+ protected void setAddressFilter(AddressFilter filter) {
+ this.addressFilter = filter;
+ }
- public Properties getSessionProperties() {
- return sessionProperties;
- }
+ public Properties getSessionProperties() {
+ return sessionProperties;
+ }
- protected void setSessionProperties(Properties sessionProperties) {
- this.sessionProperties = sessionProperties;
- }
+ protected void setSessionProperties(Properties sessionProperties) {
+ this.sessionProperties = sessionProperties;
+ }
- public Session createMailSession() {
- return Session.getDefaultInstance(sessionProperties, null);
- }
+ public Authenticator getAuthenticator() {
+ return authenticator;
+ }
+
+ protected void setAuthenticator(Authenticator authenticator) {
+ this.authenticator = authenticator;
+ }
+
+ public Session createMailSession() {
+ return Session.getDefaultInstance(sessionProperties, authenticator);
+ }
}
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/SyncMailSession.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/SyncMailSession.java 2009-04-08 20:27:20 UTC (rev 4504)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/impl/SyncMailSession.java 2009-04-09 05:23:54 UTC (rev 4505)
@@ -1,6 +1,7 @@
package org.jbpm.pvm.internal.email.impl;
import java.util.Collection;
+import java.util.List;
import javax.mail.Session;
import javax.mail.internet.InternetAddress;
@@ -13,53 +14,52 @@
public class SyncMailSession implements MailSession {
- private Collection<MailServer> mailServers;
+ private List<MailServer> mailServers;
- private static final Log log = LogFactory.getLog(SyncMailSession.class);
+ private static final Log log = LogFactory.getLog(SyncMailSession.class);
- public void send(Collection<Email> emails) {
+ public void send(Collection<Email> emails) {
+ // Emails need to have the sessions populated.
+ for (Email email : emails) {
+ Collection<InternetAddress> to = email.getToAddresses();
+ Collection<InternetAddress> cc = email.getCcAddresses();
+ Collection<InternetAddress> bcc = email.getBccAddresses();
- // Emails need to have the sessions populated.
- for (Email email : emails) {
- Collection<InternetAddress> to = email.getToAddresses();
- Collection<InternetAddress> cc = email.getCcAddresses();
- Collection<InternetAddress> bcc = email.getBccAddresses();
+ for (MailServer mailServer : mailServers) {
+ AddressFilter addressFilter = mailServer.getAddressFilter();
+ Session mailSession = mailServer.createMailSession();
+ email.setMailSession(mailSession);
- for (MailServer mailServer : mailServers) {
- AddressFilter addressFilter = mailServer.getAddressFilter();
- Session mailSession = mailServer.createMailSession();
- email.setMailSession(mailSession);
+ // Need to apply filter.
+ try {
+ Collection<InternetAddress> toFiltered = addressFilter.filter(to);
+ Collection<InternetAddress> ccFiltered = addressFilter.filter(cc);
+ Collection<InternetAddress> bccFiltered = addressFilter.filter(bcc);
- // Need to apply filter.
- try {
- Collection<InternetAddress> toFiltered = addressFilter.filter(to);
- Collection<InternetAddress> ccFiltered = addressFilter.filter(cc);
- Collection<InternetAddress> bccFiltered = addressFilter.filter(bcc);
+ // Set the email with the new filtered addresses.
+ email.setTo(toFiltered);
+ email.setCc(ccFiltered);
+ email.setBcc(bccFiltered);
- // Set the email with the new filtered addresses.
- email.setTo(toFiltered);
- email.setCc(ccFiltered);
- email.setBcc(bccFiltered);
+ // If there is someone to send it to, then send it.
+ if (!(toFiltered.isEmpty() && ccFiltered.isEmpty() && bccFiltered.isEmpty())) {
+ email.send();
+ }
+ }
+ catch (EmailException e) {
+ log.error("An exception occurred while sending email.", e);
+ // TODO: Does anything else need to occur here?
+ }
+ }
+ }
+ }
- // If there is someone to send it to, then send it.
- if (!(toFiltered.isEmpty() && ccFiltered.isEmpty() && bccFiltered.isEmpty())) {
- email.send();
- }
- }
- catch (EmailException e) {
- log.error("An exception occurred while sending email.", e);
- // TODO: Does anything else need to occur here?
- }
- }
- }
- }
+ public List<MailServer> getMailServers() {
+ return mailServers;
+ }
- public Collection<MailServer> getMailServers() {
- return mailServers;
- }
+ protected void setMailServers(List<MailServer> mailServers) {
+ this.mailServers = mailServers;
+ }
- protected void setMailServers(Collection<MailServer> mailServers) {
- this.mailServers = mailServers;
- }
-
}
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java 2009-04-08 20:27:20 UTC (rev 4504)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/email/producer/impl/HtmlScriptMailProducer.java 2009-04-09 05:23:54 UTC (rev 4505)
@@ -111,7 +111,7 @@
public String embedImage(HtmlEmail email, String imageSrc)
{
- if(imageSrc==null||imageSrc.isEmpty())
+ if(imageSrc==null||imageSrc.length()==0)
{
return null;
}
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailSessionBinding.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailSessionBinding.java 2009-04-08 20:27:20 UTC (rev 4504)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/MailSessionBinding.java 2009-04-09 05:23:54 UTC (rev 4505)
@@ -30,11 +30,9 @@
import org.jbpm.pvm.internal.email.spi.MailSession;
import org.jbpm.pvm.internal.util.XmlUtil;
import org.jbpm.pvm.internal.wire.Descriptor;
-import org.jbpm.pvm.internal.wire.descriptor.CollectionDescriptor;
import org.jbpm.pvm.internal.wire.descriptor.ListDescriptor;
import org.jbpm.pvm.internal.wire.descriptor.ObjectDescriptor;
import org.jbpm.pvm.internal.wire.descriptor.PatternDescriptor;
-import org.jbpm.pvm.internal.wire.descriptor.PropertiesDescriptor;
import org.jbpm.pvm.internal.xml.Parse;
import org.jbpm.pvm.internal.xml.Parser;
import org.w3c.dom.Element;
@@ -46,60 +44,76 @@
*/
public class MailSessionBinding extends WireDescriptorBinding {
- private static final PropertiesBinding propertiesBinding = new PropertiesBinding();
+ private static final PropertiesBinding propertiesBinding = new PropertiesBinding();
+ private static final ObjectBinding objectBinding = new ObjectBinding();
- public MailSessionBinding() {
- super("mail-session");
- }
+ public MailSessionBinding() {
+ super("mail-session");
+ }
- public Object parse(Element element, Parse parse, Parser parser) {
- // mail servers
- List<Descriptor> serverDescriptors = new ArrayList<Descriptor>();
- for (Element serverElement : XmlUtil.elements(element, "mail-server")) {
- // mail session properties
- Element smtpElement = XmlUtil.element(serverElement, "session-properties");
- PropertiesDescriptor propertiesDescriptor = propertiesBinding.parse(smtpElement, parse,
- parser);
+ public Object parse(Element element, Parse parse, Parser parser) {
+ // mail servers
+ List<Descriptor> serverDescriptors = new ArrayList<Descriptor>();
+ for (Element serverElement : XmlUtil.elements(element, "mail-server")) {
+ // mail server
+ ObjectDescriptor serverDescriptor = new ObjectDescriptor(MailServer.class);
+ serverDescriptors.add(serverDescriptor);
- // address filter
- Element filterElement = XmlUtil.element(serverElement, "address-filter");
+ // address filter
+ Element filterElement = XmlUtil.element(serverElement, "address-filter");
+ if (filterElement != null) {
+ // includes
+ List<Descriptor> includeDescriptors = new ArrayList<Descriptor>();
+ for (Element includeElement : XmlUtil.elements(filterElement, "include")) {
+ includeDescriptors.add(new PatternDescriptor(XmlUtil.getContentText(includeElement), 0));
+ }
+ ListDescriptor includesDescriptor = new ListDescriptor();
+ includesDescriptor.setValueDescriptors(includeDescriptors);
- // includes
- List<Descriptor> includeDescriptors = new ArrayList<Descriptor>();
- for (Element includeElement : XmlUtil.elements(filterElement, "include")) {
- includeDescriptors.add(new PatternDescriptor(XmlUtil.getContentText(includeElement), 0));
- }
- CollectionDescriptor includesDescriptor = new ListDescriptor();
- includesDescriptor.setValueDescriptors(includeDescriptors);
+ // excludes
+ List<Descriptor> excludeDescriptors = new ArrayList<Descriptor>();
+ for (Element excludeElement : XmlUtil.elements(filterElement, "exclude")) {
+ excludeDescriptors.add(new PatternDescriptor(XmlUtil.getContentText(excludeElement), 0));
+ }
+ ListDescriptor excludesDescriptor = new ListDescriptor();
+ excludesDescriptor.setValueDescriptors(excludeDescriptors);
- // excludes
- List<Descriptor> excludeDescriptors = new ArrayList<Descriptor>();
- for (Element excludeElement : XmlUtil.elements(filterElement, "exclude")) {
- excludeDescriptors.add(new PatternDescriptor(XmlUtil.getContentText(excludeElement), 0));
- }
- CollectionDescriptor excludesDescriptor = new ListDescriptor();
- excludesDescriptor.setValueDescriptors(excludeDescriptors);
+ // address filter
+ ObjectDescriptor filterDescriptor = new ObjectDescriptor(AddressFilter.class);
+ filterDescriptor.addInjection("includePatterns", includesDescriptor);
+ filterDescriptor.addInjection("excludePatterns", excludesDescriptor);
- // address filter
- ObjectDescriptor filterDescriptor = new ObjectDescriptor(AddressFilter.class);
- filterDescriptor.addInjection("includePatterns", includesDescriptor);
- filterDescriptor.addInjection("excludePatterns", excludesDescriptor);
+ serverDescriptor.addInjection("addressFilter", filterDescriptor);
+ }
- // mail server
- ObjectDescriptor serverDescriptor = new ObjectDescriptor(MailServer.class);
- serverDescriptor.addInjection("addressFilter", filterDescriptor);
- serverDescriptor.addInjection("sessionProperties", propertiesDescriptor);
- serverDescriptors.add(serverDescriptor);
- }
+ // mail session properties
+ Element propertiesElement = XmlUtil.element(serverElement, "session-properties");
+ if (propertiesElement != null) {
+ Descriptor propertiesDescriptor =
+ (Descriptor) propertiesBinding.parse(propertiesElement, parse, parser);
+ serverDescriptor.addInjection("sessionProperties", propertiesDescriptor);
+ }
+ else {
+ parse.addProblem("missing mail session properties");
+ }
- // mail servers
- CollectionDescriptor serversDescriptor = new ListDescriptor();
- serversDescriptor.setValueDescriptors(serverDescriptors);
+ // authenticator
+ Element authenticatorElement = XmlUtil.element(serverElement, "authenticator");
+ if (authenticatorElement != null) {
+ Descriptor authenticatorDescriptor =
+ (Descriptor) objectBinding.parse(authenticatorElement, parse, parser);
+ serverDescriptor.addInjection("authenticator", authenticatorDescriptor);
+ }
+ }
- // mail session
- ObjectDescriptor sessionDescriptor = new ObjectDescriptor(SyncMailSession.class);
- sessionDescriptor.addInjection("mailServers", serversDescriptor);
- return sessionDescriptor;
- }
+ // mail servers
+ ListDescriptor serversDescriptor = new ListDescriptor();
+ serversDescriptor.setValueDescriptors(serverDescriptors);
+ // mail session
+ ObjectDescriptor sessionDescriptor = new ObjectDescriptor(SyncMailSession.class);
+ sessionDescriptor.addInjection("mailServers", serversDescriptor);
+ return sessionDescriptor;
+ }
+
}
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PropertiesBinding.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PropertiesBinding.java 2009-04-08 20:27:20 UTC (rev 4504)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/wire/binding/PropertiesBinding.java 2009-04-09 05:23:54 UTC (rev 4505)
@@ -44,7 +44,7 @@
super("properties");
}
- public PropertiesDescriptor parse(Element element, Parse parse, Parser parser) {
+ public Object parse(Element element, Parse parse, Parser parser) {
PropertiesDescriptor descriptor = new PropertiesDescriptor();
if (element.hasAttribute("file")) {
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java 2009-04-08 20:27:20 UTC (rev 4504)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/Parse.java 2009-04-09 05:23:54 UTC (rev 4505)
@@ -24,7 +24,6 @@
import java.io.File;
import java.io.InputStream;
-import java.io.Serializable;
import java.net.URL;
import java.util.ListIterator;
import java.util.Stack;
@@ -32,7 +31,6 @@
import javax.xml.parsers.DocumentBuilder;
import org.jbpm.JbpmException;
-import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.stream.FileStreamInput;
import org.jbpm.pvm.internal.stream.InputStreamInput;
import org.jbpm.pvm.internal.stream.ResourceStreamInput;
@@ -49,9 +47,8 @@
*
* @author Tom Baeyens
*/
-public class Parse extends ProblemList implements Serializable, ErrorHandler {
+public class Parse extends ProblemList implements ErrorHandler {
- private static Log log = Log.getLog(Parse.class.getName());
private static final long serialVersionUID = 1L;
protected Parser parser;
@@ -190,11 +187,8 @@
* 'warning'. */
public Parse checkProblems(String description) {
if (hasProblems()) {
- String errorMsg = "problems during parse of "+description+":"+getProblemsText();
- log.info(errorMsg);
- if (errorMsg!=null) {
- throw new JbpmException(errorMsg);
- }
+ String errorMsg = "problems during parse of "+description+NEWLINE+getProblemsText();
+ throw new JbpmException(errorMsg);
}
return this;
}
@@ -234,13 +228,10 @@
ListIterator<Object> listIter = objectStack.listIterator(objectStack.size());
while (listIter.hasPrevious()) {
Object object = listIter.previous();
- if (object!=null) {
- if (clazz.isAssignableFrom(object.getClass())) {
- return (T) object;
- }
+ if (clazz.isInstance(object)) {
+ return clazz.cast(object);
}
}
- return null;
}
return null;
}
Modified: jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java 2009-04-08 20:27:20 UTC (rev 4504)
+++ jbpm4/branches/email/modules/pvm/src/main/java/org/jbpm/pvm/internal/xml/ProblemList.java 2009-04-09 05:23:54 UTC (rev 4505)
@@ -27,10 +27,8 @@
import java.util.List;
import org.jbpm.Problem;
-import org.jbpm.internal.log.Log;
import org.jbpm.pvm.internal.repository.DeploymentImpl;
-
/** list of problems. Base class for {@link Parse}
* and {@link DeploymentImpl}.
*
@@ -40,16 +38,14 @@
private static final long serialVersionUID = 1L;
- private static final String NEWLINE = System.getProperty("line.separator");
+ static final String NEWLINE = System.getProperty("line.separator");
- private static final Log log = Log.getLog(ProblemList.class.getName());
-
protected List<ProblemImpl> problems;
/** all problems encountered */
public List<Problem> getProblems() {
if (problems==null) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
return (List) problems;
}
Modified: jbpm4/branches/email/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailSessionWireTest.java
===================================================================
--- jbpm4/branches/email/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailSessionWireTest.java 2009-04-08 20:27:20 UTC (rev 4504)
+++ jbpm4/branches/email/modules/pvm/src/test/java/org/jbpm/pvm/internal/wire/MailSessionWireTest.java 2009-04-09 05:23:54 UTC (rev 4505)
@@ -21,10 +21,14 @@
*/
package org.jbpm.pvm.internal.wire;
-import java.util.Collection;
+import java.util.List;
import java.util.Properties;
import java.util.regex.Pattern;
+import javax.mail.Authenticator;
+import javax.mail.PasswordAuthentication;
+
+import org.jbpm.JbpmException;
import org.jbpm.pvm.internal.email.impl.MailServer;
import org.jbpm.pvm.internal.email.impl.SyncMailSession;
import org.jbpm.pvm.internal.email.impl.AddressFilter;
@@ -35,47 +39,156 @@
*/
public class MailSessionWireTest extends WireTestCase {
- public void testMailSession() {
- WireContext wireContext = createWireContext(
- "<objects>" +
- " <mail-session>" +
- " <mail-server>" +
- " <address-filter>" +
- " <include>.+(a)jbpm.org</include>" +
- " <exclude>.+(a)jboss.com</exclude>" +
- " </address-filter>" +
- " <session-properties>" +
- " <property name='mail.host' value='localhost' />" +
- " <property name='mail.user' value='aguizar' />" +
- " <property name='mail.from' value='noreply(a)jbpm.org' />" +
- " </session-properties>" +
- " </mail-server>" +
- " </mail-session>" +
- "</objects>"
- );
+ public void testSessionProperties() {
+ WireContext wireContext =
+ createWireContext("<objects>"
+ + " <mail-session>"
+ + " <mail-server>"
+ + " <session-properties>"
+ + " <property name='mail.host' value='localhost' />"
+ + " <property name='mail.user' value='aguizar' />"
+ + " <property name='mail.from' value='noreply(a)jbpm.org' />"
+ + " </session-properties>"
+ + " </mail-server>"
+ + " </mail-session>"
+ + "</objects>");
- MailSession mailService = wireContext.get(MailSession.class);
- assertTrue("expected sync mail service", mailService instanceof SyncMailSession);
+ MailSession mailSession = wireContext.get(MailSession.class);
+ assertTrue("expected sync mail session", mailSession instanceof SyncMailSession);
- SyncMailSession syncMailService = (SyncMailSession) mailService;
- Collection<MailServer> serverConfigs = syncMailService.getMailServers();
- assertEquals(1, serverConfigs.size());
+ SyncMailSession syncMailSession = (SyncMailSession) mailSession;
+ List<MailServer> mailServers = syncMailSession.getMailServers();
+ assertEquals(1, mailServers.size());
- MailServer serverConfig = serverConfigs.iterator().next();
- AddressFilter addressFilter = serverConfig.getAddressFilter();
-
- Collection<Pattern> includePatterns = addressFilter.getIncludePatterns();
- assertEquals(1, includePatterns.size());
- assertEquals(".+(a)jbpm.org", includePatterns.iterator().next().toString());
-
- Collection<Pattern> excludePatterns = addressFilter.getExcludePatterns();
- assertEquals(1, excludePatterns.size());
- assertEquals(".+(a)jboss.com", excludePatterns.iterator().next().toString());
-
- Properties properties = serverConfig.getSessionProperties();
+ MailServer mailServer = mailServers.get(0);
+ Properties properties = mailServer.getSessionProperties();
assertEquals(3, properties.size());
assertEquals("localhost", properties.getProperty("mail.host"));
assertEquals("aguizar", properties.getProperty("mail.user"));
assertEquals("noreply(a)jbpm.org", properties.getProperty("mail.from"));
- }
+ }
+
+ public static class MyAuthenticator extends Authenticator {
+ @Override
+ protected PasswordAuthentication getPasswordAuthentication() {
+ return new PasswordAuthentication("aguizar", "wontsay");
+ }
+ }
+
+ public void testAuthenticator() {
+ WireContext wireContext =
+ createWireContext("<objects>" +
+ " <mail-session>" +
+ " <mail-server>" +
+ " <session-properties />" +
+ " <authenticator class='" +
+ MyAuthenticator.class.getName() +
+ "' />" +
+ " </mail-server>" +
+ " </mail-session>" +
+ "</objects>");
+ MailSession mailSession = wireContext.get(MailSession.class);
+ assertTrue("expected sync mail session", mailSession instanceof SyncMailSession);
+
+ SyncMailSession syncMailSession = (SyncMailSession) mailSession;
+ List<MailServer> mailServers = syncMailSession.getMailServers();
+ assertEquals(1, mailServers.size());
+
+ MailServer mailServer = mailServers.get(0);
+ assertSame(MyAuthenticator.class, mailServer.getAuthenticator().getClass());
+ }
+
+ public void testNoSessionProperties() {
+ try {
+ createWireContext("<objects>"
+ + " <mail-session>"
+ + " <mail-server />"
+ + " </mail-session>"
+ + "</objects>");
+ fail("expected wire context creation to puke");
+ }
+ catch (JbpmException e) {
+ // session properties are mandatory
+ }
+ }
+
+ public void testAddressFilter() {
+ WireContext wireContext =
+ createWireContext("<objects>"
+ + " <mail-session>"
+ + " <mail-server>"
+ + " <address-filter>"
+ + " <include>.+(a)jbpm.org</include>"
+ + " <exclude>.+(a)jboss.com</exclude>"
+ + " <exclude>.+(a)redhat.com</exclude>"
+ + " </address-filter>"
+ + " <session-properties />"
+ + " </mail-server>"
+ + " </mail-session>"
+ + "</objects>");
+ MailSession mailSession = wireContext.get(MailSession.class);
+ assertTrue("expected sync mail session", mailSession instanceof SyncMailSession);
+
+ SyncMailSession syncMailSession = (SyncMailSession) mailSession;
+ List<MailServer> mailServers = syncMailSession.getMailServers();
+ assertEquals(1, mailServers.size());
+
+ MailServer mailServer = mailServers.get(0);
+ AddressFilter addressFilter = mailServer.getAddressFilter();
+
+ List<Pattern> includePatterns = addressFilter.getIncludePatterns();
+ assertEquals(1, includePatterns.size());
+ assertEquals(".+(a)jbpm.org", includePatterns.get(0).toString());
+
+ List<Pattern> excludePatterns = addressFilter.getExcludePatterns();
+ assertEquals(2, excludePatterns.size());
+ assertEquals(".+(a)jboss.com", excludePatterns.get(0).toString());
+ assertEquals(".+(a)redhat.com", excludePatterns.get(1).toString());
+
+ assertEquals(0, mailServer.getSessionProperties().size());
+ }
+
+ public void testNoAddressFilter() {
+ WireContext wireContext =
+ createWireContext("<objects>"
+ + " <mail-session>"
+ + " <mail-server>"
+ + " <session-properties />"
+ + " </mail-server>"
+ + " </mail-session>"
+ + "</objects>");
+ MailSession mailSession = wireContext.get(MailSession.class);
+ assertTrue("expected sync mail session", mailSession instanceof SyncMailSession);
+
+ SyncMailSession syncMailSession = (SyncMailSession) mailSession;
+ List<MailServer> mailServers = syncMailSession.getMailServers();
+ assertEquals(1, mailServers.size());
+
+ MailServer mailServer = mailServers.get(0);
+ assertNull("expected no address filter", mailServer.getAddressFilter());
+ assertEquals(0, mailServer.getSessionProperties().size());
+ }
+
+ public void testMultipleMailServers() {
+ WireContext wireContext =
+ createWireContext("<objects>"
+ + " <mail-session>"
+ + " <mail-server>"
+ + " <session-properties />"
+ + " </mail-server>"
+ + " <mail-server>"
+ + " <session-properties />"
+ + " </mail-server>"
+ + " <mail-server>"
+ + " <session-properties />"
+ + " </mail-server>"
+ + " </mail-session>"
+ + "</objects>");
+ MailSession mailSession = wireContext.get(MailSession.class);
+ assertTrue("expected sync mail session", mailSession instanceof SyncMailSession);
+
+ SyncMailSession syncMailSession = (SyncMailSession) mailSession;
+ List<MailServer> mailServers = syncMailSession.getMailServers();
+ assertEquals(3, mailServers.size());
+ }
}
17 years