Requirement:
Currently, the Sling Distribution Forward Agents utilize the Apache Sling Distribution Packaging – Vault Package Builder Factory to export packages. However, I want to configure a custom Package Builder that can export or replicate files in their native format instead of using the Vault packaging mechanism.
In other words, the goal is to export the content as-is — for example:
If the file is a JSON, it should be exported as a JSON file.
If it’s an HTML file, export it as HTML.
If it’s an image, export it as an image.
At present, the default Vault packaging exports the data in a binary (vault) format, which is not desirable for this use case.
I would like to understand whether this can be achieved through configuration or if it requires a custom code implementation, so I can proceed accordingly.
Currently using the default vault packaging in my forward agent :
Views
Replies
Total Likes
Do we have something like JSON package Builder? I was going through https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/issue-is-sling-content-dis... which says
So is there a JSON package builder available? If so - where is it and how to configure the same?
@VishalKa5 - Can you let me know if there's any such thing?
As of now I just want to focus on JSON only - any insights with the above use-case would be very helpful.
Thanks!
Views
Replies
Total Likes
Hi @ac4320,
Short answer - No, Sling Distribution doesn’t include a JSON package builder. The default “Vault Package Builder Factory” always exports in FileVault format. If you want the content to be distributed as raw JSON, HTML, or binary files (instead of zipped JCR content), you’ll need to implement a custom DistributionPackageBuilder.
Here are the details:
The default builder PID is:
org.apache.sling.distribution.serialization.impl.vlt.VaultDistributionPackageBuilderFactory
You can create your own builder by implementing the interface
org.apache.sling.distribution.packaging.DistributionPackageBuilder.
Inside your implementation, you can:
Read resources under the given paths (DistributionRequest)
Serialize them directly as JSON (using Sling’s ResourceResolver + JsonRenderer)
Write them to an output stream or a temporary file
Then register it as an OSGi component (e.g. name=json) and update your Forward Agent config to reference it:
Example use case:
If your content under /content/data/*.json should be replicated as JSON files, your builder could simply export those nodes via Sling’s JSON exporter instead of creating a Vault package.
References:
Views
Replies
Total Likes
@SantoshSai - Can you please help me with the code?
Views
Replies
Total Likes
Views
Likes
Replies