mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (4.3/Cloud) to HEAD (4.3/Cloud)
59881: Merged V4.2-BUG-FIX (4.2.2) to HEAD-BUG-FIX (Cloud/4.3) 59606: Merged DEV to V4.2-BUG-FIX 58106: Fixed formatting in MailActionExecuter found during investigations 58107: Fixed formatting issues in ActionExecuterAbstractBase found during investigations 58108: Further detection of transaction state in the base action code (MNT-9806) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@62197 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -24,6 +24,8 @@ import java.util.Set;
|
||||
import org.alfresco.repo.action.ActionDefinitionImpl;
|
||||
import org.alfresco.repo.action.ParameterizedItemAbstractBase;
|
||||
import org.alfresco.repo.lock.LockUtils;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport.TxnReadState;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ActionDefinition;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
@@ -77,10 +79,10 @@ public abstract class ActionExecuterAbstractBase extends ParameterizedItemAbstra
|
||||
|
||||
public void setMlAwareNodeService(NodeService mlAwareNodeService)
|
||||
{
|
||||
this.mlAwareNodeService = mlAwareNodeService;
|
||||
}
|
||||
this.mlAwareNodeService = mlAwareNodeService;
|
||||
}
|
||||
|
||||
public void setLockService(LockService lockService)
|
||||
public void setLockService(LockService lockService)
|
||||
{
|
||||
this.lockService = lockService;
|
||||
}
|
||||
@@ -235,7 +237,12 @@ public abstract class ActionExecuterAbstractBase extends ParameterizedItemAbstra
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void execute(Action action, NodeRef actionedUponNodeRef)
|
||||
{
|
||||
{
|
||||
if (AlfrescoTransactionSupport.getTransactionReadState() == TxnReadState.TXN_NONE)
|
||||
{
|
||||
throw new IllegalStateException("Actions invariably access the repository. Doing so without a transaction is not recommended.");
|
||||
}
|
||||
|
||||
// Check the mandatory properties
|
||||
checkMandatoryProperties(action, getActionDefinition());
|
||||
|
||||
|
@@ -230,7 +230,7 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
|
||||
|
||||
public void setPreferenceService(PreferenceService preferenceService)
|
||||
{
|
||||
this.preferenceService = preferenceService;
|
||||
this.preferenceService = preferenceService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -400,11 +400,11 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
|
||||
@Override
|
||||
public void init()
|
||||
{
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Init called, testMessageTo=" + testMessageTo);
|
||||
}
|
||||
|
||||
if(logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("Init called, testMessageTo=" + testMessageTo);
|
||||
}
|
||||
|
||||
numberSuccessfulSends.set(0);
|
||||
numberFailedSends.set(0);
|
||||
|
||||
@@ -451,17 +451,17 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
|
||||
final NodeRef actionedUponNodeRef)
|
||||
{
|
||||
|
||||
//Prepare our messages before the commit, in-case of deletes
|
||||
MimeMessageHelper[] messages = null;
|
||||
if (validNodeRefIfPresent(actionedUponNodeRef))
|
||||
//Prepare our messages before the commit, in-case of deletes
|
||||
MimeMessageHelper[] messages = null;
|
||||
if (validNodeRefIfPresent(actionedUponNodeRef))
|
||||
{
|
||||
messages = prepareEmails(ruleAction, actionedUponNodeRef);
|
||||
messages = prepareEmails(ruleAction, actionedUponNodeRef);
|
||||
}
|
||||
final MimeMessageHelper[] finalMessages = messages;
|
||||
|
||||
//Send out messages
|
||||
if(finalMessages!=null){
|
||||
if (sendAfterCommit(ruleAction))
|
||||
final MimeMessageHelper[] finalMessages = messages;
|
||||
|
||||
//Send out messages
|
||||
if(finalMessages!=null){
|
||||
if (sendAfterCommit(ruleAction))
|
||||
{
|
||||
AlfrescoTransactionSupport.bindListener(new TransactionListenerAdapter()
|
||||
{
|
||||
@@ -474,9 +474,9 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
|
||||
@Override
|
||||
public Void execute() throws Throwable
|
||||
{
|
||||
for (MimeMessageHelper message : finalMessages) {
|
||||
sendEmail(ruleAction, message);
|
||||
}
|
||||
for (MimeMessageHelper message : finalMessages) {
|
||||
sendEmail(ruleAction, message);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -486,11 +486,11 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
|
||||
}
|
||||
else
|
||||
{
|
||||
for (MimeMessageHelper message : finalMessages) {
|
||||
sendEmail(ruleAction, message);
|
||||
}
|
||||
for (MimeMessageHelper message : finalMessages) {
|
||||
sendEmail(ruleAction, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -838,7 +838,7 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
|
||||
}
|
||||
if (locale == null)
|
||||
{
|
||||
locale = sender.getSecond();
|
||||
locale = sender.getSecond();
|
||||
}
|
||||
|
||||
// set subject line
|
||||
@@ -847,13 +847,13 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
|
||||
String localizedSubject = getLocalizedSubject(subject, subjectParams, locale);
|
||||
if (locale == null)
|
||||
{
|
||||
// process the template against the model
|
||||
// process the template against the model
|
||||
text = templateService.processTemplate("freemarker", templateRef, model);
|
||||
}
|
||||
else
|
||||
{
|
||||
// process the template against the model
|
||||
text = templateService.processTemplate("freemarker", templateRef, model, locale);
|
||||
// process the template against the model
|
||||
text = templateService.processTemplate("freemarker", templateRef, model, locale);
|
||||
}
|
||||
if ((testModeRecipient != null) && (testModeRecipient.length() > 0) && (! testModeRecipient.equals("${dev.email.recipient.address}")))
|
||||
{
|
||||
@@ -974,23 +974,23 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
|
||||
*/
|
||||
private String getLocalizedSubject(String subject, Object[] params, Locale locale)
|
||||
{
|
||||
String localizedSubject = null;
|
||||
String localizedSubject = null;
|
||||
if (locale == null)
|
||||
{
|
||||
localizedSubject = I18NUtil.getMessage(subject, params);
|
||||
localizedSubject = I18NUtil.getMessage(subject, params);
|
||||
}
|
||||
else
|
||||
{
|
||||
localizedSubject = I18NUtil.getMessage(subject, locale, params);
|
||||
localizedSubject = I18NUtil.getMessage(subject, locale, params);
|
||||
}
|
||||
|
||||
if (localizedSubject == null)
|
||||
{
|
||||
return subject;
|
||||
return subject;
|
||||
}
|
||||
else
|
||||
{
|
||||
return localizedSubject;
|
||||
return localizedSubject;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1036,11 +1036,11 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
|
||||
{
|
||||
try
|
||||
{
|
||||
address = new InternetAddress(from, fromPersonalName);
|
||||
address = new InternetAddress(from, fromPersonalName);
|
||||
}
|
||||
catch (UnsupportedEncodingException error)
|
||||
{
|
||||
address = new InternetAddress(from);
|
||||
address = new InternetAddress(from);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1101,19 +1101,19 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Pair<String, Locale>> getRecipients(Action ruleAction)
|
||||
{
|
||||
|
||||
List<Pair<String, Locale>> recipients = new LinkedList<Pair<String,Locale>>();
|
||||
|
||||
|
||||
List<Pair<String, Locale>> recipients = new LinkedList<Pair<String,Locale>>();
|
||||
|
||||
// set recipient
|
||||
String to = (String)ruleAction.getParameterValue(PARAM_TO);
|
||||
if (to != null && to.length() != 0)
|
||||
{
|
||||
Locale locale = null;
|
||||
if (personExists(to))
|
||||
{
|
||||
locale = getLocaleForUser(to);
|
||||
}
|
||||
recipients.add(new Pair<String, Locale>(to, locale));
|
||||
Locale locale = null;
|
||||
if (personExists(to))
|
||||
{
|
||||
locale = getLocaleForUser(to);
|
||||
}
|
||||
recipients.add(new Pair<String, Locale>(to, locale));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1241,13 +1241,13 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
|
||||
String domain = tenantService.getPrimaryDomain(user); // get primary tenant
|
||||
if (domain != null)
|
||||
{
|
||||
exists = TenantUtil.runAsTenant(new TenantRunAsWork<Boolean>()
|
||||
{
|
||||
public Boolean doWork() throws Exception
|
||||
{
|
||||
return personService.personExists(user);
|
||||
}
|
||||
}, domain);
|
||||
exists = TenantUtil.runAsTenant(new TenantRunAsWork<Boolean>()
|
||||
{
|
||||
public Boolean doWork() throws Exception
|
||||
{
|
||||
return personService.personExists(user);
|
||||
}
|
||||
}, domain);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1262,13 +1262,13 @@ public class MailActionExecuter extends ActionExecuterAbstractBase
|
||||
String domain = tenantService.getPrimaryDomain(user); // get primary tenant
|
||||
if (domain != null)
|
||||
{
|
||||
person = TenantUtil.runAsTenant(new TenantRunAsWork<NodeRef>()
|
||||
{
|
||||
public NodeRef doWork() throws Exception
|
||||
{
|
||||
return personService.getPerson(user);
|
||||
}
|
||||
}, domain);
|
||||
person = TenantUtil.runAsTenant(new TenantRunAsWork<NodeRef>()
|
||||
{
|
||||
public NodeRef doWork() throws Exception
|
||||
{
|
||||
return personService.getPerson(user);
|
||||
}
|
||||
}, domain);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Reference in New Issue
Block a user