Hi, folks! In my project I have a requirement to be able to send emails with attachments. I know that there is a sample implementation of custom action "Send-As-Email", but I needed to override standard "mail" action in such a way that it could send documents as attachents.
Ok, "mail" action is described as a proxy bean in action-services-context.xml. Actual "mail" bean is described in outboundSMTP-context.xml.
What I did in Alfresco 5.1 is just overrided outboundSMTP subsystem whith my own implementation of "mail" bean. Everything worked as I expected untill I migrated to Alfresco 6.1.
In Alfresco 6.1 the same approach produced an unexpected behaviour. There was no errors on startup and context initialization, but when I tried to create a "Send email" rule Repo-tier thrown an exception during rule saving:
2019-11-22 14:50:00,932 ERROR [org.springframework.extensions.webscripts.AbstractRuntime] [http-nio-9090-exec-7] Exception from executeScript: 10220002 Wrapped Exception (with status template): object is not an instance of declaring class
After a debugging session and digging into Alfresco source code I've figured out the only difference between 5.1 and 6.1 in regard of Repo-tier "mail" action defenition is in action-services-context.xml:
Alfresco 5.1:
<!-- Import mail action executor from the OutboundSMTP subsystem -->
<bean id="mail" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
<property name="sourceApplicationContextFactory">
<ref bean="OutboundSMTP" />
</property>
<property name="interfaces">
<list>
<value>org.alfresco.repo.action.executer.ActionExecuter</value>
<value>org.alfresco.repo.action.executer.TestModeable</value>
</list>
</property>
</bean>
In Alfresco 6.1:
<!-- Import mail action executor from the OutboundSMTP subsystem -->
<bean id="mail" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
<property name="sourceApplicationContextFactory">
<ref bean="OutboundSMTP" />
</property>
<property name="sourceBeanName">
<value>mail</value>
</property>
<property name="interfaces">
<list>
<value>org.alfresco.repo.action.executer.ActionExecuter</value>
<value>org.alfresco.repo.action.executer.TestModeable</value>
</list>
</property>
</bean>
As you see in Alfresco 6.1 they've added sourceBeanName property (actually it is optional). Somehow this broke my code. To fix it I had to additionally override that proxy "mail" bean from action-services-context.xml in a way it was in Alfresco 5.1 (without sourceBeanName property). And everything worked fine again.
Can someone explain me this wierd behaviuor?
OOTB MailExecutorAction doesn't allow sending the attachment with emails. Refer this post, rjohnson has an example of overriden action to handle attachement.
Yes, I know that Alfresco doesn't support attachments OOTB. And I was able to override OOTB "mail" action in 5.1 by just overriding "mail" bean in outboundSMTP-context.xml. But in 6.1 it was not enough to make it work, I had to additionaly override proxy-bean from action-services-context.xml.
My point was that it looks odd that one need to additionaly override proxy-bean to make overriden action work.
Anyway, thanks!
I would suggest to extend the mail executor action instead of overriding the context files unless there is something you are not able to achieve by extending mail executor action. I shared a sample in my last reply. You may consider looking into that as well.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.