I'm trying to write custom file upload component for CQ5.6, but I meet the problem with reverse replication. Node created in Publish instance, but not replicated to Author instance. After replicator call, next line appears in error.log:
com.day.cq.replication.impl.ReplicatorImpl Replication triggered, but no agent found or selected.
Replication agents are turned on. In other cases, userforms for example, replication works successfully, so I'm think the problem is somewhere in my code. There is the code I use in the servlet:
Node node = session.getNode(path); ValueFactory valueFactory = session.getValueFactory(); Binary contentValue = valueFactory.createBinary(is); Node parent = node.addNode(fileName, "nt:unstructured"); parent.setProperty(DELETED, false); parent.setProperty(DESCRIPTION, description); Node fileNode = parent.addNode(fileName, "nt:file"); fileNode.addMixin("mix:referenceable"); Node resNode = fileNode.addNode("jcr:content", "nt:resource"); resNode.setProperty(Property.JCR_DATA, contentValue); Calendar lastModified = Calendar.getInstance(); lastModified.setTimeInMillis(lastModified.getTimeInMillis()); resNode.setProperty(Property.JCR_LAST_MODIFIED, lastModified); parent.setProperty("cq:distribute", true); parent.setProperty("cq:lastModified", Calendar.getInstance()); parent.setProperty("cq:lastModifiedBy", session.getUserID()); session.save(); replicator.replicate(session, ReplicationActionType.ACTIVATE, parent.getPath()); session.logout();
What should I do to make reverse replication works for this nodes I create in servlet?
P.S. I've spent hours reading documentation, but not found any solution.
Solved! Go to Solution.
Views
Replies
Total Likes
Views
Replies
Total Likes
Here is an older community thread with a similar issue:
Views
Replies
Total Likes
Igor,
Please check CQ-Actions library: https://github.com/Cognifide/CQ-Actions. Reverse-replication is just a four liner there and you've got already an entry point for author-processing (like replication to other publishers). You can of course skip processing path leaving just reverse-replication helper.
@Reference ActionRegistryService actionRegistryService; ... Node node = actionRegistryService.createActionNode(session, relPath, "my-action"); node.setProperty(name, value); session.save();
@Service @Component public class MyAction implements Action { private final static LOGGER = LoggerFactory.getLogger(MyAction.class); @Override public void perform(Page page) throws Exception { LOGGER.info("performing action"); } public String getType() { return "my-action"; } }
Views
Replies
Total Likes
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies