Trying to create CF programmatically
I am trying to create CF programmatically using a servlet. But, I do not see them being generated after servlet completion.
Resource parentRsc = resolver.getResource("<parent-path>");
Resource templateOrModelRsc = request.getResourceResolver().getResource("<cf-model-path>");
FragmentTemplate tpl = templateOrModelRsc.adaptTo(FragmentTemplate.class);
try {
ContentFragment newFragment = tpl.createFragment(parentRsc, "test", "A fragment description.");
} catch (ContentFragmentException e) {
logger.error(e.getMessage(),e);
}
Any pointers would be appreciated.
