Re: Script resolution newbie question
Hi Alex! But what if I have a few millions or so of those tiny little resources and no differences at all in acls (anonymous can read, authenticated users can write) or even their categorization (an article is an article is an article)... Then a way to dispatch a different set of rendering templates based on the host/path and keep the rendering code/deployment separate would be useful... Cheers! Alessandro > On Oct 31, 2013, at 7:17 PM, Alexander Klimetschek wrote: > > Hi Alessandro! > >> On 31.10.2013, at 07:28, Alessandro Bologna >> wrote: >> >> For requests that have a specific header, say "Host:otherapp", I want >> instead to use scripts located at /apps/myotherapp/page. >> >> Short of duplicating the resource, what's the best practice to implement >> this? > > I would say the best practice actually IS to have a separate resource tree > for another host/tenant. As soon as ACLs or other little differences between > hosts come into play, this is the best approach. Otherwise you'll start > reimplementing a lot of what the repository and sling gives you already. > > Cheers, > Alex >
Re: Script resolution newbie question
Hi Alessandro! On 31.10.2013, at 07:28, Alessandro Bologna wrote: > For requests that have a specific header, say "Host:otherapp", I want > instead to use scripts located at /apps/myotherapp/page. > > Short of duplicating the resource, what's the best practice to implement this? I would say the best practice actually IS to have a separate resource tree for another host/tenant. As soon as ACLs or other little differences between hosts come into play, this is the best approach. Otherwise you'll start reimplementing a lot of what the repository and sling gives you already. Cheers, Alex
Re: Script resolution newbie question
Hi Alessandro, Unfortunately, no. BindingsValuesProvider are executed much too late for this. Whatever you do has to be done *before* the script/servlet is resolved. Justin On Thu, Oct 31, 2013 at 12:56 PM, Alessandro Bologna wrote: > Justin, > thank you, I may very well go with your approach, which I guess would mean > to override the getResourceType and getResourceSuperType in a > MyAppResourceWrapper based on the current request (to which I have no > access to in the my ResourceDecorator, when using the single > decorate(Resource) method). > Instead of using a ThreadLocal, could I implement a BindingsValuesProvider > and get the request object from the bindings and inject them in the wrapped > resource? Any major problem doing so? > > > Thanks a lot to all. > Alessandro > > > > On Thu, Oct 31, 2013 at 12:05 PM, Justin Edelson > wrote: > >> Hi Alessandro, >> What you could also do is to have a ResourceDecorator which changes up >> the resource type. HOWEVER, you might be templted to use the >> two-argument method. This doesn't actually work (and now documented as >> such). So you'd need to combine this with some ThreadLocal-based >> filter to store the current request. >> >> HTH, >> Justin >> >> On Thu, Oct 31, 2013 at 11:53 AM, Alessandro Bologna >> wrote: >> > Thanks Paul and Bertrand, >> > So, if I have two development teams working on two different presentation >> > apps that I want to keep completely separate I would need to partition >> all >> > the selectors space to that for instance >> > >> > /content/shared.team1.html uses /apps/myapp/team1/html.jsp >> > /content/shared.team1.header.html uses /apps/myapp/team1/header/html.jsp >> > and similarly for team2 etc >> > >> > How about the config folder, for logging, rewriters etc, wouldn't that >> have >> > to be necessarily shared between the two teams? >> > >> > Thanks again, >> > Alessandro >> > >> > >> > >> > >> > On Thu, Oct 31, 2013 at 11:15 AM, Bertrand Delacretaz < >> > bdelacre...@apache.org> wrote: >> > >> >> On Thu, Oct 31, 2013 at 4:07 PM, Paul McMahon wrote: >> >> > ...You'd probably want to perhaps using a selector instead of a header >> >> value (or using a >> >> > rewrite rule to turn the header value into a selector) and then use >> >> selector specific scripts >> >> > to meet your requirements... >> >> >> >> I was going to suggest just that, and instead of an external rewrite >> >> rule you could also use a Sling Filter. >> >> >> >> -Bertrand >> >> >>
Re: Script resolution newbie question
Justin, thank you, I may very well go with your approach, which I guess would mean to override the getResourceType and getResourceSuperType in a MyAppResourceWrapper based on the current request (to which I have no access to in the my ResourceDecorator, when using the single decorate(Resource) method). Instead of using a ThreadLocal, could I implement a BindingsValuesProvider and get the request object from the bindings and inject them in the wrapped resource? Any major problem doing so? Thanks a lot to all. Alessandro On Thu, Oct 31, 2013 at 12:05 PM, Justin Edelson wrote: > Hi Alessandro, > What you could also do is to have a ResourceDecorator which changes up > the resource type. HOWEVER, you might be templted to use the > two-argument method. This doesn't actually work (and now documented as > such). So you'd need to combine this with some ThreadLocal-based > filter to store the current request. > > HTH, > Justin > > On Thu, Oct 31, 2013 at 11:53 AM, Alessandro Bologna > wrote: > > Thanks Paul and Bertrand, > > So, if I have two development teams working on two different presentation > > apps that I want to keep completely separate I would need to partition > all > > the selectors space to that for instance > > > > /content/shared.team1.html uses /apps/myapp/team1/html.jsp > > /content/shared.team1.header.html uses /apps/myapp/team1/header/html.jsp > > and similarly for team2 etc > > > > How about the config folder, for logging, rewriters etc, wouldn't that > have > > to be necessarily shared between the two teams? > > > > Thanks again, > > Alessandro > > > > > > > > > > On Thu, Oct 31, 2013 at 11:15 AM, Bertrand Delacretaz < > > bdelacre...@apache.org> wrote: > > > >> On Thu, Oct 31, 2013 at 4:07 PM, Paul McMahon wrote: > >> > ...You'd probably want to perhaps using a selector instead of a header > >> value (or using a > >> > rewrite rule to turn the header value into a selector) and then use > >> selector specific scripts > >> > to meet your requirements... > >> > >> I was going to suggest just that, and instead of an external rewrite > >> rule you could also use a Sling Filter. > >> > >> -Bertrand > >> >
Re: Script resolution newbie question
Hi Alessandro, What you could also do is to have a ResourceDecorator which changes up the resource type. HOWEVER, you might be templted to use the two-argument method. This doesn't actually work (and now documented as such). So you'd need to combine this with some ThreadLocal-based filter to store the current request. HTH, Justin On Thu, Oct 31, 2013 at 11:53 AM, Alessandro Bologna wrote: > Thanks Paul and Bertrand, > So, if I have two development teams working on two different presentation > apps that I want to keep completely separate I would need to partition all > the selectors space to that for instance > > /content/shared.team1.html uses /apps/myapp/team1/html.jsp > /content/shared.team1.header.html uses /apps/myapp/team1/header/html.jsp > and similarly for team2 etc > > How about the config folder, for logging, rewriters etc, wouldn't that have > to be necessarily shared between the two teams? > > Thanks again, > Alessandro > > > > > On Thu, Oct 31, 2013 at 11:15 AM, Bertrand Delacretaz < > bdelacre...@apache.org> wrote: > >> On Thu, Oct 31, 2013 at 4:07 PM, Paul McMahon wrote: >> > ...You'd probably want to perhaps using a selector instead of a header >> value (or using a >> > rewrite rule to turn the header value into a selector) and then use >> selector specific scripts >> > to meet your requirements... >> >> I was going to suggest just that, and instead of an external rewrite >> rule you could also use a Sling Filter. >> >> -Bertrand >>
Re: Script resolution newbie question
Thanks Paul and Bertrand, So, if I have two development teams working on two different presentation apps that I want to keep completely separate I would need to partition all the selectors space to that for instance /content/shared.team1.html uses /apps/myapp/team1/html.jsp /content/shared.team1.header.html uses /apps/myapp/team1/header/html.jsp and similarly for team2 etc How about the config folder, for logging, rewriters etc, wouldn't that have to be necessarily shared between the two teams? Thanks again, Alessandro On Thu, Oct 31, 2013 at 11:15 AM, Bertrand Delacretaz < bdelacre...@apache.org> wrote: > On Thu, Oct 31, 2013 at 4:07 PM, Paul McMahon wrote: > > ...You'd probably want to perhaps using a selector instead of a header > value (or using a > > rewrite rule to turn the header value into a selector) and then use > selector specific scripts > > to meet your requirements... > > I was going to suggest just that, and instead of an external rewrite > rule you could also use a Sling Filter. > > -Bertrand >
Re: Script resolution newbie question
On Thu, Oct 31, 2013 at 4:07 PM, Paul McMahon wrote: > ...You'd probably want to perhaps using a selector instead of a header value > (or using a > rewrite rule to turn the header value into a selector) and then use selector > specific scripts > to meet your requirements... I was going to suggest just that, and instead of an external rewrite rule you could also use a Sling Filter. -Bertrand
Re: Script resolution newbie question
The documentation you are referencing is for resolving a request to a resource in the repository, not for script resolution. The script resolution documentation is at http://sling.apache.org/documentation/the-sling-engine/url-to-script-resolution.html. To my knowledge the API doesn't support modifying the resource type based on a header value. You'd probably want to perhaps using a selector instead of a header value (or using a rewrite rule to turn the header value into a selector) and then use selector specific scripts to meet your requirements. Paul McMahon Acquity Group - Part of Accenture Interactive On Thursday, October 31, 2013 10:32 AM, Alessandro Bologna wrote: Hi, I am pretty sure that the answer is simple enough, but somehow I couldn't find it in the documentation. Say that I have a resource /content/shared/foo with sling:resourceType myapp/page, which will cause a request to invoke scripts at /apps/myapp/page. For requests that have a specific header, say "Host:otherapp", I want instead to use scripts located at /apps/myotherapp/page. Short of duplicating the resource, what's the best practice to implement this? It doesn't seem that the mapping at[1] would help be because in the end I need to change the base path of the resourceType... Thanks Alessandro [1] https://cwiki.apache.org/confluence/display/SLING/Flexible+Resource+Resolution
Script resolution newbie question
Hi, I am pretty sure that the answer is simple enough, but somehow I couldn't find it in the documentation. Say that I have a resource /content/shared/foo with sling:resourceType myapp/page, which will cause a request to invoke scripts at /apps/myapp/page. For requests that have a specific header, say "Host:otherapp", I want instead to use scripts located at /apps/myotherapp/page. Short of duplicating the resource, what's the best practice to implement this? It doesn't seem that the mapping at[1] would help be because in the end I need to change the base path of the resourceType... Thanks Alessandro [1] https://cwiki.apache.org/confluence/display/SLING/Flexible+Resource+Resolution