Open HitmanInWis opened 4 years ago
ChildResourceFromRequestInjector
, unless there was some communicated intent somewhere. That said in the context of OverridePathSlingRequestWrapper
it might not be so clear.OverridePathSlingRequestWrapperTheSequel
(better name of course ;)) and fix it there, and leave the current OverridePathSlingRequestWrapper
alone?For 3 we certainly could, and deprecate the old one. Feels a bit messy given we'll have 3 versions (2 in ACS Commons, and 1 in Sling). However, so be it :)
I guess my question would be whether we think its more appropriate to fix both the same way, or if we think there's good argument to fix 2 directly and 3 via a new class.
@HitmanInWis I run into problems wrapping or creating synthetic sling requests/responses more often than you'd imagine, and its a real PITA when you have to. I'm not sure if Sling's servlet helpers[1] could help here [1] .. though we'd have a dependency on a "third party" library, which is ~against ACS Commons tenants.. which is problematic.
Agree it's not the most elegant solution, but our hands feel a bit tied with that specific class being a Sling impl, and ACS Commons not shipping w/ 3rd party libs (sling servlet helpers, which may not even do the trick).
We can see what others think tho, for sure
[1] https://sling.apache.org/documentation/bundles/servlet-helpers.html
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This is still on my list...just gotta get to it...
Turns out I dont need to deprecate the old OverridePathSlingRequestWrapper
necessarily, since it may still be used in cases where you're not adapting to a sling model. I've added a new ctor to OverridePathSlingRequestWrapper
to allow for the additional sling model bindings, and updated @ChildResourceFromRequest
to use the new ctor.
@ChildResourceFromRequestInjector
leverages a request wrapper classcom.adobe.acs.commons.util.OverridePathSlingRequestWrapper
in order to inject child resources as sling models, leveraging a Request object rather than only a Resource (since many sling models require a request). However, the sling bindings provided byOverridePathSlingRequestWrapper
are incomplete. As an example, thecurrentStyle
binding will be that of the parent resource (the original resource of the original request) rather than the child resource being adapted, which breaks functionality that depends on design (editable template) configs.Looking at the sling version included with AEM 6.4+, a very similar class to
OverridePathSlingRequestWrapper
has been implemented atorg.apache.sling.models.impl.ResourceOverridingRequestWrapper
which has more complete sling bindings support. This class is internal, and cannot be directly referenced, but it can be leveraged viaorg.apache.sling.models.impl.ModelAdapterFactory#getModelFromWrappedRequest
which we could then use from@ChildResourceFromRequest
.However, I'm struggling on best path forward on this, due to the following factors:
ModelAdapterFactory#getModelFromWrappedRequest
is not available to AEM 6.3, which ACS Commons still supports.@ChildResourceFromRequest
. In some ways this can be considered a bug fix, but there might be existing code that depends on that bug.OverridePathSlingRequestWrapper
We can solve issue 1 by either copying the code in the new sling class to
OverridePathSlingRequestWrapper
or by waiting until ACS Commons drops support of AEM 6.3. However, that still leaves issues 2 and 3 above.Any thoughts on the appropriate solve?