Merged DEV to HEAD

48848: ALF-18520: Mails subsystem fails with Nullpointer during initialization
          If option is set to send test message on mail subsystem init then do it on behalf of System user.
          During getFrom field calculation if there is no current user then send mail from default address
          like it is System user. Case to unit test was added. 
   Reformatted MailActionExecuterTest


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@48866 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2013-04-05 10:57:33 +00:00
parent d542afaa5c
commit 0bc61d6d35
2 changed files with 204 additions and 175 deletions

View File

@@ -38,6 +38,8 @@ import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.action.ParameterDefinitionImpl;
import org.alfresco.repo.admin.SysAdminParams;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.template.DateCompareMethod;
import org.alfresco.repo.template.HasAspectMethod;
import org.alfresco.repo.template.I18NMessageMethod;
@@ -389,13 +391,20 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
super.init();
if (sendTestMessage && testMessageTo != null)
{
Map<String, Serializable> params = new HashMap<String, Serializable>();
params.put(PARAM_TO, testMessageTo);
params.put(PARAM_SUBJECT, testMessageSubject);
params.put(PARAM_TEXT, testMessageText);
Action ruleAction = serviceRegistry.getActionService().createAction(NAME, params);
executeImpl(ruleAction, null);
AuthenticationUtil.runAs(new RunAsWork<Object>()
{
public Object doWork() throws Exception
{
Map<String, Serializable> params = new HashMap<String, Serializable>();
params.put(PARAM_TO, testMessageTo);
params.put(PARAM_SUBJECT, testMessageSubject);
params.put(PARAM_TEXT, testMessageText);
Action ruleAction = serviceRegistry.getActionService().createAction(NAME, params);
executeImpl(ruleAction, null);
return null;
}
}, AuthenticationUtil.getSystemUserName());
}
}
@@ -926,7 +935,7 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
if (! authService.isCurrentUserTheSystemUser())
{
String currentUserName = authService.getCurrentUserName();
if (personExists(currentUserName))
if (currentUserName != null && personExists(currentUserName))
{
fromPersonName = currentUserName;
locale = getLocaleForUser(fromPersonName);