Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to activate programmatically a page in cq5 workflow

Tags:

aem

I am trying to activate some pages from code. I have made a workflow that will modify a page whenever some content is modified in some other pages that have a reference to this page. I was trying to do this by setting properties of activation like:

parentpage.setProperty("cq:lastModified", Calendar.getInstance());
parentpage.setProperty("cq:lastModifiedBy", session.getUserID());

Although this property is getting set each time. But activation is not happening in the publish instance. How do we activate programmatic ally in custom workflow itself?

like image 876
Param1414086 Avatar asked Sep 23 '13 09:09

Param1414086


1 Answers

Use Replicator OSGi service:

@Component
public class MyComponent {

    @Reference
    private Replicator replicator;

    private void activatePage(Session session) {
    //...
        replicator.replicate(session, ReplicationActionType.ACTIVATE, pathToPage);
    //...
    }
}

You don't need to set any properties.

like image 113
Tomek Rękawek Avatar answered Sep 30 '22 13:09

Tomek Rękawek