Thanks Justin.
Works well!
=8<=
@Override
public Resource decorate(Resource resource, HttpServletRequest request)
{
final String resourceType = resource.getResourceType();
if ("old/handler".equals(resourceType)) {
return new ResourceWrapper(resource) {
@Override
public String getResourceType() {
return "new/handler";
}
};
}
return resource;
}
=>8=
Is there a way to register my ResourceDecorator service for certain
resource types only instead of that if conditional above?
On Wed, Jun 27, 2012 at 3:06 PM, Justin Edelson <[email protected]>wrote:
> Hi Sam,
> ResoureDecorators must be registered add OSGi services.
>
> Justin
> On Jun 27, 2012 3:00 PM, "sam ”" <[email protected]> wrote:
>
> > Ah thanks.
> >
> > Is there a way to provide ResourceDecorator implementation in script
> (jsp)?
> > Or, do I have to provide OSGi bundle/component?
> >
> >
> > On Wed, Jun 27, 2012 at 2:34 PM, Justin Edelson <[email protected]
> > >wrote:
> >
> > > Hi Sam,
> > > You should be able to do this with a ResourceDecorator service to
> change
> > > the resource type at runtime.
> > >
> > > Regards,
> > > Justin
> > > On Jun 27, 2012 2:25 PM, "sam ”" <[email protected]> wrote:
> > >
> > > > Hey,
> > > >
> > > > I have a large number of resources with sling:resourceType =
> > old/handler
> > > >
> > > > I don't want to modify their sling:resourceType property. But, I
> want
> > to
> > > > have old/handler actually resolve to /apps/new/handler
> > > >
> > > > For example, given a resource:
> > > > /content/mypage
> > > > whose sling:resourceType = old/hander,
> > > >
> > > > GET /content/mypage.html
> > > > is handled by:
> > > > /apps/old/handler/html.jsp
> > > >
> > > >
> > > > Without modifying /content/mypage, can I have the same GET request
> be
> > > > handled by:
> > > > /apps/new/handler/html.jsp ?
> > > >
> > > > I tried /etc/maps/oldToNew
> > > > sling:internalRedirect = /apps/new/handler$1
> > > > sling:match = .*/apps/old/handler(.*)
> > > >
> > > > GET /apps/old/handler
> > > > does redirect to /apps/new/handler.
> > > > But, script resolution doesn't seem to use /etc/maps.
> > > >
> > >
> >
>