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?