ADOBE CQ 5.5 Reverse Replication (Publisher -> Author) triggering by code, but not running at all

StackOverflow https://stackoverflow.com/questions/21887189

  •  13-10-2022
  •  | 
  •  

Question

I did quite some research on how to do so, and finally come to this:

Session session = resourceResolver.adaptTo(Session.class);
Node formRootNode = resourceResolver.getResource("/content/usergenerated/content/XXX").adaptTo(Node.class);
String id = incrementId(formRootNode);
Node formNode = formRootNode.addNode("data" + id, "nt:unstructured");
formNode.setProperty("id", id);
formNode.setProperty("name", "John");
session.save();
formNode.setProperty("cq:distribute", true);
formNode.setProperty("cq:lastModified", Calendar.getInstance());
formNode.setProperty("cq:lastModifiedBy", session.getUserID());
session.save();

For the XXX, it's type of cq:Page. When I try out this code in Publisher, new nodes did get inserted into Publisher (eg: /content/usergenerated/content/XXX/data1), just that it's not replicated to Author.

I have gathered any possible know-hows on how to do this over the Internet:

Unfortunately still didn't manage to get it working after studying above advises/examples, anyone could please kindly shed some light?

Was it helpful?

Solution

  1. Create a separate cq:Page for each piece of user-generated content.
  2. cq:distribute property should be set on the jcr:content resource.

Example:

Session session = resourceResolver.adaptTo(Session.class);
Node formRootNode = JcrUtil.createPath("/content/usergenerated/content/formPage", true, "sling:Folder", "cq:Page", session, false);
Node formNode = formRootNode.addNode("jcr:content", "cq:PageContent");
formNode.setProperty("name", "John");
session.save();
formNode.setProperty("cq:distribute", true);
formNode.setProperty("cq:lastModified", Calendar.getInstance());
formNode.setProperty("cq:lastModifiedBy", session.getUserID());
session.save();

Example uses JcrUtil.createPath to create unique node under /content/usergenerated/content.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top