Call an action when a node is created or published

  Written by The Jahia Team
 
Developers
  rules
   Estimated reading time:
7.1.2

A customer would like to know a way to call a Java Method when a Node is created or published.

Answer

A way to call a Java Method is with a rule, you can call an action when a node is created or published
===============================

  1. You can set a name to the action inside the spring xml file, something like this:
    <bean class="com.mae.bureau.actualite.SendActualiteNotificationAction" name="actualiteNotificationAction">
        <property name="name" value="actualiteNotificationAction"/>
    </bean>

     

  2.  With the name of the action specified in the spring file, you can call it in the drools file, and use this consequence:
    rule "Send notification when created actualite"
    .........
    then
    Log "----- Before send notification when created an actualite" + node.getName()
    Execute the action "actualiteNotificationAction" now on the node
    Log "----- After send notification when created an actualite: " + node.getName()
    end
    ===============================