How alter SlingHttpServletRequest with different Resource?
I am struggling with some generic piece of code:
Resource resource = dynamicallyFindNeededResource(res);
Class<?> someModel = pickUpSomeSlingModelClass();
return resource.adaptTo(someModel);
The problem is I want to expand this type of adapting to request as well:
Adaptable adaptable = checkIfModelAdaptableByRequest(someModel) ? changeRequestResourceToCurrentOne(request, resource) : resource;
return adaptable.adaptTo(someModel);
What comes to my mind is the changeRequestResourceToCurrentOne method has to use SlingRequestWrapper which would be kind of lame solution. Any other ides how to alter that request with resource without wrapping it with new resoruce? Thanks in advance.