Optimising Content Fragment And Variation Creation
Hi
Currently we have code to programmatically create a content fragment with variations.
The process is:
1. create content fragment
2. create content fragment variation and populate all the variation elements by calling the createVariation method below:
public static void createVariation(ContentFragment cf, JsonObject dp, String variationName, String variationTitle) throws ContentFragmentException, PersistenceException {
VariationTemplate vt = cf.createVariation(variationName, variationTitle, "");
Iterator<ContentElement> itr = cf.getElements();
while(itr.hasNext()) {
ContentElement cfElement = itr.next();
ContentVariation cv = cfElement.getVariation(vt.getName());
cv.setContent(dp.getString(cfElement.getName(), ""), "String");
}
}
We found that this code is slow and cumbersome. We would like to create a content fragment and its variations in one method call like https://experienceleague.adobe.com/docs/experience-manager-65/assets/extending/assets-api-content-fragments.html#create
but we don't want to be using a HTTP POST to do it. Is there AEM library we can use to do the same? com.adobe.cq.dam.cfm.ContentFragment package seems a bit limited for what we need.