Reverse replication in custom file upload component not works | Community
Skip to main content
igor_sheremetov
New Participant
October 16, 2015
Solved

Reverse replication in custom file upload component not works

  • October 16, 2015
  • 3 replies
  • 1008 views

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.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

3 replies

smacdonald2008
New Participant
October 16, 2015

Here is an older community thread with a similar issue:

http://forums.adobe.com/message/4904901

New Participant
October 16, 2015

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"; } }
Sham_HC
Sham_HCAccepted solution
New Participant
October 16, 2015