Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Content Sync #3151

Merged

Conversation

YegorKozlov
Copy link
Contributor

Purpose

Incrementally synchronize content between AEM Author instances.

ACS Content Sync is yet another solution aiming to overcome the shortcomings of using CRX Package Manager / VLT RCP to copy content between AEM environments.

How does Content Sync Work?

Content Sync uses JSON Export/Import between Sling GET/POST servlets. The tool fetches a catalog of resources from the source instance, e.g.

/content/path1  lastModified1
/content/path2  lastModified2
/content/path3  lastModified3

then it compares it with the local state, computes the delta and synchronizes it via JSON Export/Import.

How many HTTP calls does Content Sync make?

The ballpark estimation is O(N) where N is the number of content resources (cq:Page, dam:Asset, etc.) being sync-ed.
For example, it takes an HTTP call to sync a cq:Page resource, so to sync a tree of N cq:Page nodes the tool will make minimum N HTTP calls. To sync a dam:Asset node the tool will make an HTTP call to grab the jcr:content and sub-nodes, and an HTTP call to grab binary data for each rendition.

What can I sync?

In general - any content resources, like

  • Pages
  • Assets
  • Experience Fragments
  • Content Fragments
  • Tags

How to Use

In order to use the Content Sync tool, you need the latest version of ACS Commons installed on the source and target AEM instances.

Configure Sling Get Servlet

Create an OSGi configuration for PID org.apache.sling.servlets.get.DefaultGetServlet and make sure that:

  • JSON Renderer is enabled
  • JSON Max Results parameter is set to at least 1000
  • Legacy ECMA date format is unchecked

image

Configure the host(s) to synchronize from

Navigate to the Content Sync tool (http://localhost:4502/apps/acs-commons/content/contentsync.html) and click the Configure button in top right corner. Then click Add Host

image
image
The contentsync-user user needs read permissions on the content you are going to sync.

Run the Content Sync tool

Navigate to the Content Sync tool http://localhost:4502/apps/acs-commons/content/contentsync.html and select a path to synchronize.
The default mode is Incremental, which means only new or modified resources will be downloaded. If the Incremental option is unchecked then the tool will do full sync and download the entire content tree.

The 'On-complete' workflow option allows you to define a custom post-update action. For example, you can define a workflow to clear properties like cq:replicationStatus, or automatically publish a resource if it is published in the source environment.

image

Pluggable Update Strategy

The strategy to select incremental delta is pluggable.
The default algorithm is based on the cq:lastModified/jcr:lastModified timestamp.
As an example, Content Sync ships with another strategy which synchronizes dam:Asset nodes based on the dam:sha1 checksum in the asset metadata. Users can plug-in their custom strategies by implementing com.adobe.acs.commons.contentsync.UpdateStrategy interface;

@codecov
Copy link

codecov bot commented Aug 5, 2023

Codecov Report

Merging #3151 (11655b6) into master (ad10e45) will increase coverage by 0.11%.
Report is 3 commits behind head on master.
The diff coverage is 62.79%.

@@             Coverage Diff              @@
##             master    #3151      +/-   ##
============================================
+ Coverage     55.25%   55.37%   +0.11%     
- Complexity     5435     5527      +92     
============================================
  Files           713      723      +10     
  Lines         29109    29574     +465     
  Branches       3767     3842      +75     
============================================
+ Hits          16084    16376     +292     
- Misses        11512    11675     +163     
- Partials       1513     1523      +10     
Files Changed Coverage Δ
...be/acs/commons/contentsync/ConfigurationUtils.java 0.00% <0.00%> (ø)
.../adobe/acs/commons/contentsync/ContentCatalog.java 0.00% <0.00%> (ø)
...ommons/contentsync/impl/AssetChecksumStrategy.java 0.00% <0.00%> (ø)
.../adobe/acs/commons/contentsync/RemoteInstance.java 40.32% <40.32%> (ø)
...commons/contentsync/impl/LastModifiedStrategy.java 71.00% <71.00%> (ø)
...acs/commons/contentsync/SyncHostConfiguration.java 75.00% <75.00%> (ø)
...com/adobe/acs/commons/contentsync/ContentSync.java 78.50% <78.50%> (ø)
...ons/contentsync/servlet/ContentCatalogServlet.java 88.23% <88.23%> (ø)
...com/adobe/acs/commons/contentsync/CatalogItem.java 100.00% <100.00%> (ø)
...m/adobe/acs/commons/contentsync/ContentReader.java 100.00% <100.00%> (ø)

@davidjgonzalez davidjgonzalez marked this pull request as draft August 8, 2023 17:59
@davidjgonzalez davidjgonzalez added this to the 6.1.0 milestone Aug 30, 2023
@davidjgonzalez
Copy link
Contributor

@YegorKozlov is this read for review?

@davidjgonzalez davidjgonzalez modified the milestones: 6.1.0, 6.2.0 Sep 8, 2023
@YegorKozlov
Copy link
Contributor Author

@YegorKozlov is this read for review?

yes @davidjgonzalez . it's ready for review

@davidjgonzalez davidjgonzalez marked this pull request as ready for review September 11, 2023 17:23
@davidjgonzalez davidjgonzalez merged commit 04dd367 into Adobe-Consulting-Services:master Sep 14, 2023
9 of 10 checks passed
@AntonValadzko
Copy link

Hi @YegorKozlov, Is it possible to sync only root page without child pages below it? Like only this path /content/site/en/home/jcr:content

@YegorKozlov
Copy link
Contributor Author

Hi @YegorKozlov, Is it possible to sync only root page without child pages below it? Like only this path /content/site/en/home/jcr:content

In the current implementation it's not possible. I'm thinking of adding a new Query strategy, so that instead of a path user would pass a jcr query. This way you will have a finer control what to sync.

YegorKozlov added a commit to YegorKozlov/acs-aem-commons that referenced this pull request Oct 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants