Expand my Community achievements bar.

SOLVED

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

Avatar

Level 1

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

1 Accepted Solution

Avatar

Correct answer by
Level 10

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. 

View solution in original post

3 Replies

Avatar

Level 10

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. 

Avatar

Level 1

Hi,

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

Cheers,

Tom

Avatar

Correct answer by
Level 10

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.