How to activate a program page in cq5 workflow

I am trying to activate some pages from code. I created a workflow that will change the page when any content is changed on some other pages that have a link to this page. I tried to do this by setting activation properties, for example:

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

Although this property gets every time. But activation does not occur in the publication instance. How to activate a software ally in a user workflow?

+6
source share
2 answers

Use the OSGi Replicator Service:

 @Component public class MyComponent { @Reference private Replicator replicator; private void activatePage(Session session) { //... replicator.replicate(session, ReplicationActionType.ACTIVATE, pathToPage); //... } } 

You do not need to set any properties.

+7
source

If you do not have a component, you can enter the service as -

 Replicator replicator = getSling().getService(Replicator.class); 
0
source

Source: https://habr.com/ru/post/954401/


All Articles