From 583ddc80eed2ec562d5578ca08a9eb2d8b1a5d73 Mon Sep 17 00:00:00 2001 From: Mark Rogers Date: Fri, 1 Mar 2013 17:46:13 +0000 Subject: [PATCH] Outbound email - protected against testMessageTo being null git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@47456 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- config/alfresco/messages/email-service.properties | 4 ++++ .../repo/action/executer/MailActionExecuter.java | 14 +++++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/config/alfresco/messages/email-service.properties b/config/alfresco/messages/email-service.properties index 326b7a7fe1..95003ec12d 100644 --- a/config/alfresco/messages/email-service.properties +++ b/config/alfresco/messages/email-service.properties @@ -25,3 +25,7 @@ email.server.err.failed_to_read_content_stream=Failed to read the message part c email.server.err.incorrect_message_part=Incorrect message part: {0} email.outbound.err.send.failed=Failed to send email to: {0} cause {1} + +email.outbound.err.test.no.to=Unable to send test message 'testMessageTo' is empty +email.outbound.err.test.no.subject=Unable to send test message 'subject' is empty +email.outbound.err.test.no.text=Unable to send test message 'text' is empty diff --git a/source/java/org/alfresco/repo/action/executer/MailActionExecuter.java b/source/java/org/alfresco/repo/action/executer/MailActionExecuter.java index 8effd3a334..18c556c5ad 100644 --- a/source/java/org/alfresco/repo/action/executer/MailActionExecuter.java +++ b/source/java/org/alfresco/repo/action/executer/MailActionExecuter.java @@ -271,6 +271,18 @@ public class MailActionExecuter extends ActionExecuterAbstractBase */ public boolean sendTestMessage() { + if(testMessageTo == null || testMessageTo.length() == 0) + { + throw new AlfrescoRuntimeException("email.outbound.err.test.no.to"); + } + if(testMessageSubject == null || testMessageSubject.length() == 0) + { + throw new AlfrescoRuntimeException("email.outbound.err.test.no.subject"); + } + if(testMessageText == null || testMessageText.length() == 0) + { + throw new AlfrescoRuntimeException("email.outbound.err.test.no.text"); + } Map params = new HashMap(); params.put(PARAM_TO, testMessageTo); params.put(PARAM_SUBJECT, testMessageSubject); @@ -314,7 +326,7 @@ public class MailActionExecuter extends ActionExecuterAbstractBase numberFailedSends.set(0); super.init(); - if (sendTestMessage) + if (sendTestMessage && testMessageTo != null) { Map params = new HashMap(); params.put(PARAM_TO, testMessageTo);