20 import com.nokia.helium.core.EmailDataSender; |
20 import com.nokia.helium.core.EmailDataSender; |
21 |
21 |
22 import com.nokia.helium.core.EmailSendException; |
22 import com.nokia.helium.core.EmailSendException; |
23 import com.nokia.helium.core.PropertiesSource; |
23 import com.nokia.helium.core.PropertiesSource; |
24 import com.nokia.helium.core.TemplateInputSource; |
24 import com.nokia.helium.core.TemplateInputSource; |
25 import com.nokia.helium.signal.Notifier; |
25 import com.nokia.helium.signal.ant.Notifier; |
26 import com.nokia.helium.core.TemplateProcessor; |
26 import com.nokia.helium.core.TemplateProcessor; |
|
27 import com.nokia.helium.core.ant.ResourceCollectionUtils; |
|
28 |
27 import java.util.List; |
29 import java.util.List; |
28 import java.util.Hashtable; |
30 import java.util.Hashtable; |
29 import java.util.ArrayList; |
31 import java.util.ArrayList; |
30 import java.io.IOException; |
32 import java.io.IOException; |
31 |
33 |
32 import org.apache.tools.ant.BuildException; |
34 import org.apache.tools.ant.BuildException; |
33 import org.apache.tools.ant.Project; |
35 import org.apache.tools.ant.Project; |
34 import org.apache.tools.ant.types.DataType; |
36 import org.apache.tools.ant.types.DataType; |
|
37 import org.apache.tools.ant.types.ResourceCollection; |
|
38 |
35 import java.io.File; |
39 import java.io.File; |
36 |
40 |
37 /** |
41 /** |
38 * The emailNotifier provides you an easy way to send a you and email containing |
42 * The emailNotifier provides you an easy way to send a you and email containing |
39 * the summary of a build failure. |
43 * the summary of a build failure. |
51 private String notifyWhen = "never"; |
55 private String notifyWhen = "never"; |
52 private String from; |
56 private String from; |
53 private String additionalRecipients; |
57 private String additionalRecipients; |
54 |
58 |
55 /** |
59 /** |
56 * Rendering the template, and sending the result through email. |
60 * {@inheritDoc} |
57 * |
61 */ |
58 * @param signalName |
|
59 * - is the name of the signal that has been raised. |
|
60 * @param failStatus |
|
61 * - indicates whether to fail the build or not |
|
62 * @param notifierInput |
|
63 * - contains signal notifier info |
|
64 * @param message |
|
65 * - is the message from the signal that has been raised. |
|
66 */ |
|
67 |
|
68 @SuppressWarnings("unchecked") |
62 @SuppressWarnings("unchecked") |
69 public void sendData(String signalName, boolean failStatus, |
63 public void sendData(String signalName, boolean failStatus, |
70 NotifierInput notifierInput, String message) { |
64 ResourceCollection notifierInput, String message) { |
71 if (notifyWhen != null |
65 if (notifyWhen != null |
72 && (notifyWhen.equals("always") |
66 && (notifyWhen.equals("always") |
73 || (notifyWhen.equals("fail") && failStatus) || (notifyWhen |
67 || (notifyWhen.equals("fail") && failStatus) || (notifyWhen |
74 .equals("pass") && !failStatus))) { |
68 .equals("pass") && !failStatus))) { |
75 if (title == null) { |
69 if (title == null) { |
94 subProject.setProperty("signal.message", "" + message); |
88 subProject.setProperty("signal.message", "" + message); |
95 try { |
89 try { |
96 |
90 |
97 File fileToSend = null; |
91 File fileToSend = null; |
98 if (notifierInput != null) { |
92 if (notifierInput != null) { |
99 fileToSend = notifierInput.getFile(".*.html"); |
93 fileToSend = ResourceCollectionUtils.getFile(notifierInput, ".*.html"); |
100 } |
94 } |
101 if (fileToSend == null) { |
95 if (fileToSend == null) { |
102 if (defaultTemplate != null && defaultTemplate.exists()) { |
96 if (defaultTemplate != null && defaultTemplate.exists()) { |
103 File emailOutputFile; |
97 File emailOutputFile; |
104 try { |
98 try { |