Wednesday, October 7, 2015

How to extend Replication Page Process for workflow in AEM

Use Case: You want to extend existing replication page process and add your own logic during workflow step. Some of common use case could be,
1) Activate Asset as soon as it is uploaded to DAM

Solution:

Here is sample code you can use for this,

What this code is doing is trying to find DAM asset path from workflow item and then activating DAM asset instead of activating just original node when OOTB activate page workflow is used.



Once you add your code, you can add this as workflow step in your workflow. If you are extending model.xml for workflow then it will look something like this,

        <node
            jcr:primaryType="cq:WorkflowNode"
            description="A process to activate a page or asset"
            title="Activate Original Asset"
            type="PROCESS">
            <metaData
                jcr:primaryType="nt:unstructured"
                PROCESS="com.wemblog.ActivateAssetFromOriginalProcess"
                PROCESS_AUTO_ADVANCE="true"/>
        </node>

Also you have to make sure that you have right dependency in your pom.xml. If you are using AEM6.1 then you need to use

<dependency>
    <groupId>com.adobe.aem</groupId>
    <artifactId>uber-jar</artifactId>
    <version>6.1.0</version>
    <classifier>apis</classifier>
    <scope>provided</scope>
</dependency>

As usual if you have any question or comment please let me know.