cancel
Showing results for 
Search instead for 
Did you mean: 

Custom MailActionExecuter

castgroupteam
Champ in-the-making
Champ in-the-making
Hi all,
I'm trying to write my custom MailActionExcuter to send email notifications using freemarker templates stored in data dictionary. I need to write my own custom Action Executer because I need some bheavior not implementend on the standard one. Looking at the out of the box spring beans configurations I've noticed that smtp outbound configuration is kept in a separate subsystem (email). Tring to define my custom new bean on this subsystem confilcts with the standard MailActionExecuter, defining it in the main context I have no problem.
So, what is the reason for which the outbound config is kept in a separate subsystem?

Thanks in advance
8 REPLIES 8

niketapatel
Star Contributor
Star Contributor
Can you define location where you are defining your custom mail action executor bean!

And why subsystem has been introduced you can check here - https://wiki.alfresco.com/wiki/Alfresco_Subsystems

"In Alfresco terminology, a subsystem is a configurable module responsible for a sub-part of Alfresco functionality. Typically, a subsystem wraps an optional functional area such as IMAP binding, or one with several alternative implementations, such as authentication.
A subsystem can be thought of as miniature Alfresco server embedded within the main one, in that
it can be started, stopped and configured independently
it has its own isolated Spring Application Context and configuration."

Thank for your reply.
I've tried to put my spring -context.xml files here:
<ALFRESCO_TOMCAT_DIR>/shared/classes/alfresco/extension/subsystems/email/OutboundSMTP/outbound/
and here:
<ALFRESCO_TOMCAT_DIR>/webapps/alfresco/WEB-INF/classes/alfresco/subsystems/email/OutboundSMTP/

but it doesn't work (and then does not work either the original mail action based on bean wit id="mail");
I've got the error:
"Don't know where to route call to method public abstract org.alfresco.service.cmr.action.ActionDefinition org.alfresco.repo.action.executer.ActionExecuter.getActionDefinition()"
I've tried to debug and the error is generated at the line 135 of the class defined in ChainingSubsystemProxyFactory.java
but it's not easy at all to debug. It seems that 2 ActionExecuter can't exist on the same subsystem but has not sense.

However, then simply deployng the context file into the normal extension folder:
<ALFRESCO_TOMCAT_DIR>/shared/classes/alfresco/extension
does it work but I don't know the possibles side effects.

The Alfresco version I'm working with is the CE 4.2.e

Thank you again.

niketapatel
Star Contributor
Star Contributor
Your path looks OK - /shared/classes/alfresco/extension/subsystems/email/OutboundSMTP/outbound/

Can you post your spring custom context file. And also can you make sure you have not modified any other OOB context file!

Yes I'm sure to have not modified other OOB context file.
This is my spring context xml:


<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
   <bean id="mail2" class="it.netsphere.alfresco.repo.action.executer.MailExtendedActionExecuter" parent="action-executer">
        <property name="queueName" value="outboundMail2"/>
        <property name="mailService">
            <ref bean="mailService"></ref>
        </property>
        <property name="templateService">
            <ref bean="templateService"></ref>
        </property>
        <property name="personService">
            <ref bean="personService"></ref>
        </property>
        <property name="authenticationService">
            <ref bean="authenticationService"></ref>
        </property>
        <property name="nodeService">
            <ref bean="nodeService"></ref>
        </property>
        <property name="tenantService">
            <ref bean="tenantService"></ref>
        </property>
        <property name="authorityService">
            <ref bean="authorityService"></ref>
        </property>
        <property name="preferenceService">
            <ref bean="preferenceService"></ref>
        </property>
        <property name="serviceRegistry">
            <ref bean="ServiceRegistry"></ref>
        </property>
        <property name="imageResolver" ref="defaultImageResolver" />
        <property name="headerEncoding">
            <value>${mail.header}</value>
        </property>
        <property name="validateAddresses">
            <value>false</value>
      </property>
      <property name="fromAddress">
         <value>${mail.from.default}</value>
      </property>
      <property name="fromEnabled">
         <value>false</value>
        </property>
        <property name="sysAdminParams">
            <ref bean="sysAdminParams"></ref>
      </property>
      <property name="sendTestMessage">
         <value>false</value>
      </property>
      <property name="testMessageTo">
         <value>${mail.testmessage.to}</value>
      </property>
      <property name="testMessageSubject">
         <value>${mail.testmessage.subject}</value>
      </property>
      <property name="testMessageText">
         <value>${mail.testmessage.text}</value>
      </property>
       
        <!– For dev/test only - emails sent to test email, irrespective of intended recipient –>
        <property name="testModeRecipient" value="${dev.email.recipient.address}"/>
       
        <!– For dev/test only - if true, emails are not actually sent –>
        <property name="testMode" value="false"/>
       
   </bean>

</beans>




Thank you very much.
Daniele




niketapatel
Star Contributor
Star Contributor
Can you try with bean id="mail"


<beans>

   <bean id="mail" class="it.netsphere.alfresco.repo.action.executer.MailExtendedActionExecuter" parent="action-executer">
—–
—–

Yes, but in this way I can just replace the standard MailActionExecuter.
The goal for me is to keep both actions: the standard one and the custom one.

Thank you.
Daniele

mrogers
Star Contributor
Star Contributor
Then you also need to add the mail2 action.   There's an action and an actionExecuer which actually does the work for the action.


Take a look at action-services.context.xml where the various actions are defined.  If memory serves you just need to define the executer with an approprate name (mail2) in your case and it will register itself.  You will see that the mail action is a little bit special since it defines a proxy bean for the outboundSMTP subsystem.

No, does not work even adding the "mail2" bean on action-services-context.xml.
Looking at source codes it seems that the reason is something like that:
2 implementations of the ActionExecuter interface cannot exists on the outboundSMTP subsystem because of  the line 135 of the class defined in ChainingSubsystemProxyFactory.java

However if I define my bean outside the subsystem, the new action works fine.
Thanks