How to replicate jcr content that is not part of a page. | Community
Skip to main content
tomnz1
October 16, 2015
Solved

How to replicate jcr content that is not part of a page.

  • October 16, 2015
  • 3 replies
  • 1022 views

Hi There.

I've written a component that stores data in the following location.  /content/applicationName/jcr:content/data/forms/ .  When my component saves information here I want to automatically push this out to the publish instance.  I can do this manually by clicking the replicate button against the node. 

Could anyone please let me know how to do this automatically?

Thanks in advance,

Tom

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

Another option that you can do that is from an event handler - invoke a custom Java Servlet on Publish. Send the data (to store at /content/applicationName/jcr:content/data/forms/ ) using the Servlet. Then use the JCR API on the Servlet to persist the data. Use Java APIs located in the  org.apache.http.client.methods.* package to invoke the Servlet. 

Also - look at this:

http://www.slideshare.net/teofili/data-replication-in-sling

talks about data replication using sling. 

3 replies

smacdonald2008
Level 10
October 16, 2015

One way to perform this use case is to use the JCR API to do it programmatically. You can write an event handler that responds to that JCR path. When a new node is added on Author, call a service that opens up a session to the Pub instance and then add a new node there with the data. 

tomnz1
tomnz1Author
October 16, 2015

Hi,

Thanks for your answer.  I'll give this a go.

Cheers,

Tom

smacdonald2008
smacdonald2008Accepted solution
Level 10
October 16, 2015

Another option that you can do that is from an event handler - invoke a custom Java Servlet on Publish. Send the data (to store at /content/applicationName/jcr:content/data/forms/ ) using the Servlet. Then use the JCR API on the Servlet to persist the data. Use Java APIs located in the  org.apache.http.client.methods.* package to invoke the Servlet. 

Also - look at this:

http://www.slideshare.net/teofili/data-replication-in-sling

talks about data replication using sling.