Getting Sling Model for a page by JcrNodeResource
Hi,
I am building a REST endpoint which
1.) should execute some QueryBuilder queries based on the parameters passed to the endpoint,
2.) return the Sling models for the resources found by the QueryBuilder.
Point 1. is simple.
I have some concerns around point 2., where the hits returned by the QueryBuilder are JcrNodeResources and I would like to get Sling models for those resources (e.g. for a cq:Page with type "core/wcm/components/page/v3/page"). I have the idea to use the org.apache.sling.models.factory.ModelFactory -> getModelFromWrappedRequest method for this purpose like
Page page = modelFactory.getModelFromWrappedRequest(request, createSyntheticResource(resource), Page.class);.
The method createSyntheticResource should create a ValueMapResource with the arguments for the Page to be created.
Does this make sense or is there an easier way to call Sling model exporter for a given JcrNodeResource?
Thanks,
Peter





