6 Replies Latest reply on Nov 27, 2012 1:34 AM by kasq

    Does CQ provide a valid example of reverse replication for forms?

    Kevin-cq

      I am not talking about this:

      http://helpx.adobe.com/cq/kb/HowToUseReverseReplication.html

      and not this:

      http://mkalugin-cq.blogspot.com/2012/02/reverse-replication-woes-solved.html

       

      They work for polls and comments, but they don't seem to be working for forms. As far as I understand, the default servlet for forms creates a "sling:Folder" as a data container, under which all form values are set into properties. However, polls and comments are created as an entity(or node) under a container. A working example for comment is under "/content/usergenerated/content/geometrixx/en/blog/2009/02/shapecon_2009_inveg". All essential properties such as "cq:distribute", "cq:lastModified" are set correctly under this node. I tried to copy the idea of this example, but it never works for me.

       

      Here's how I did.

      1. I need to make a node as a "cq:Page", since reverse replication only works for this primary type. Let's name it "Page-1"

      2. Create a "jcr:content" node under this node, make it as "cq:PageContent". I also set resourceType and template in "jcr:content". I need to make "Page-1" as a content page.

      3. Create a data container under "cq:Page" node, make it "nt:unstructured". Let's name it "form_container". All form values are set into properties in this node. set "cq:lastModified", "cq:lastModifiedBy" and "cq:distribute" under this node.

      4. Create a "jcr:content" node under "form_container", make it "nt:structured", set "cq:lastModified", "cq:lastModifiedBy" and "cq:distribute" under this node.

       

      Obviously CQ doesn't know what I did and refuses to reverse replicate. Any help will greatly appreciate.

       

      A finished upload will look like this:

       

      /content

          /usergenerated

              /newsevent [cq:Page]

                  /1351359963325_1 [cq:Page]

                      |

                      + form_content [cq:PageContent, cq:distribute==>true, and all form values stored as properties]

                      |

                      -- jrc:content [cq:distribute==> true, cq:lastModified==>Date Instance, cq:lastModifiedBy==>admin]

       

      Kevin

        • 1. Re: Does CQ provide a valid example of reverse replication for forms?
          kasq Level 3

          Hi Kevin,

           

          First of all you need to be sure that you setup a reverse replication agent on author instance. If you are using two instances of publish you need to create two agents for both publishes and additional you need also create a workflow launcher which activates additional a content to the second publish in case when the content will be replicated from the first publish to the author instance as it is done for comments components (please check launcher for Comment moderation workflow)

           

          Second thing is that of you want to enable reverse replication for some nodes created under content/usergenerated you need to create proper structure of nodes there. Please check bellow link, in my case it helps me to understand how the nodes should be created:

           

          http://mkalugin-cq.blogspot.it/2012/02/reverse-replication-woes-solved.html

           

          In my company we are using reverse replication in the infrastructure where we have 2 author instances and 2 publish instance.

          This are two example structures which are created by our custom code for a forms in one repo:

           

          EXAMPLE 1

           

          /content

               /usergenereated

                    /content (sling:Folder)

                         /project_name (cq:Page)

                              /form1_data (cq:Page)

                                   /date_of_submit_form (cq:Page)

                                        /uniqe_id (cq:Page)

                                             /jcr:content (cq:PageContent + cq:distribute=true, cq:lastModified = Date Instance, cq:lastModifiedBy = admin,

                                                                 all form values stored as a properties)

           

          EXAMPLE 2

           

          /content

               /usergenereated

                    /content (sling:Folder)

                         /project_name (cq:Page)

                              /form2_data (cq:Page)

                                   /year_of_submit_form (cq:Page)

                                        /month_of_submit_form (cq:Page)

                                               /date_of_submit_form (cq:Page)

                                                       /uniqe_id (cq:Page)

                                                                 /jcr:content (cq:PageContent + cq:distribute=true, cq:lastModified = Date Instance, cq:lastModifiedBy                                                        = admin, all form values stored as a properties)

           

           

          Of course structure which you creates is depended from you and you should consider how many data will be stored in the repo. In case when you expect that there will be a hundreds of nodes there should be created more hierarchical structure (like in the EXAMPLE 2). In our case we created this both structure in the custom code (sling post servlet) and at the end the three additional properties like cq:disttibute are set before this structure is saved in the repository. Then if you want to verify if reverse replication is working fine you need after creating a node in publish check if node is also created in following path /var/replication/outbox from where data are replicated from publish to author.

           

          Another and the last thing is also to create a script attached to the workflow which on author remove from created by the form nodes those three additional attributes to avoid go in the endless loop in case when you are reactivating content from author to publish. For more details you can check also following link:

           

          https://helpx.adobe.com/cq/kb/HowToUseReverseReplication.html

              

          This is all from my side . I hope that this helps you somehow to solve your problems.

           

          Regards,

          kasq

          • 2. Re: Does CQ provide a valid example of reverse replication for forms?
            Kevin-cq Level 1

            Hi kasq,

             

            Thanks for your response. I believe our structure is roughly the same as yours, except that we don't have that many levels. The only difference here is that we do not have a script attached to the workflow to delete those 3 attributes. I still don't know how to do that since am really new to CQ. We also created those the structure and the related attributes via the customized forward.jsp. I like to know if we need to create a new workflow to manage the reverse replication. Speaking of the "/var/replication/outbox". I see some nodes were created underneath but there is no content associated with, as opposed to the geometrixx's. Please let me know what I miss here. Thank you very much!

             

            Kevin

            • 3. Re: Does CQ provide a valid example of reverse replication for forms?
              kasq Level 3

              Hi,

               

              Our script has been created under /etc/workflow/scripts/myproject/set-cq-distribute-false.ecma

              It is simple script which removes 3 additional attributes from the node which has been replicated from one publish instance to author and then which is activated by the launcher when it is activated to another pubslih

               

              This is script:

               

              var workflowData = workItem.getWorkflowData();

              if (workflowData.getPayloadType() == "JCR_PATH") {

                  var path = workflowData.getPayload().toString();

                  var node = workflowSession.getSession().getItem(path);

                  if(node.hasProperty("cq:distribute")) {

                      node.setProperty("cq:distribute", false);

                      node.save();

                  }

              }

               

              It is attached to a workflow used by the launcher in the Process Step (tab "Process" and selected from dropdown list). That's all. In case of reverse replication from publish to author you don't need any workflow, but you need configure a reverse replication agent on auhtors instance which transport content from /var/replication/outbox" to /conent/usergenerated/content path the same like in publish created by your customized forwad.jsp

              • 4. Re: Does CQ provide a valid example of reverse replication for forms?
                Kevin-cq Level 1

                Thanks for your script. Looks like we have a lot missing here. We haven't done anything besides coding our forward.jsp. Your post really helps. Thanks a lot!

                • 5. Re: Does CQ provide a valid example of reverse replication for forms?
                  Kevin-cq Level 1

                  Hi,

                  Is there any place I can see the workflow for the comment or blog reverse replication. Should it be an unset distribute process for it to avoid the endless loop as described in this post http://helpx.adobe.com/cq/kb/HowToUseReverseReplication.html ? I am still stuck here not being able to construct a workflow to automate the reverse replication.

                   

                  Thanks,

                   

                  Kevin

                  • 6. Re: Does CQ provide a valid example of reverse replication for forms?
                    kasq Level 3

                    Hi Kevin,

                     

                    For the comment there are two workflows pointed to usergenrated content:

                     

                    /etc/workflow/models/collab/comment_moderation.html

                    /etc/workflow/models/comment-activity-handler.html

                     

                    so you can check both.

                     

                    This are specific workflows for a commnets and they are contains some specific logic for a comment functionality. I suppose that there is also inside those workflows place which removes three additional attributes.

                     

                    In our case we are using very simple workflow defined in the author instance which like I wrote transports replicated content between all publish instances and avoiding a endless loop :

                     

                    worklow.jpg

                    Please check also logs from replication, there you should see if it is working or not. Just open in the author instance

                     

                    REPLICATION -> AGENTS ON AUTHOR -> and then agent created for reverse replication -> VIEW LOGS

                     

                    If you have more than one publish instance there should be created on author one reverse replication agent for each pubsllih instance. For more info please take a look into documentation:

                     

                    http://dev.day.com/docs/en/cq/current/deploying/configuring_cq.html#Replicating from Publish to Author

                    http://dev.day.com/docs/en/cq/current/deploying/configuring_cq.html#Configuring Reverse Replication

                     

                    Regards,

                    kasq