The solution appears to be to prevent the JcrResourceResolver2 from
resetting the ResourcePathInfo on an already resolved Resource.
I have a working "AbstractVirtualResourceProvider" which currently
does what I need with no changes required in Sling itself.
Code is at [1], but it probably contains bugs, later versions will be
navigable from [2]
Ian
[1]
http://github.com/ieb/open-experiments/tree/3c1a92784b8f3e0856e6e4aae623d52343f150c7/slingtests/osgikernel/bundles/virtual
[2] http://github.com/ieb/open-experiments/
On 22 May 2009, at 01:19, Ian Boston wrote:
Hi,
Further on this.
Where the url does not contain an extension (eg /_user/private/
test1 ) the internal redirect/proxy works, So it works perfectly for a
curl -F"test=newnode" -u admin
http://localhost:8080/_user/private/test1/asdasd/asdasd/asdasd
resulting in creating a node at /_private/D0/33/E2/admin/test1/
asdasd/asdasd and setting the property test.
However, if the url contains an extension, then a 302 is generated
from a streaming servlet, as the target node /_private/D0/33/E2/
admin/test1/asdasd/asdasd doesnt have content subnode... so cant
stream.
I think the problem is as a result of the JcrResourceResolver2
resolution process (when combined with my incorrect impl), which
sets the ResourcePathInfo to the "" as the resolver path is the same
as the request path (ie no path info).... so no extension....hence
the streaming servlet.
in my ResourceProvider I am doing.
public Resource getResource(ResourceResolver resourceResolver,
String path) {
// path is /_user/private/test1/asdasd/asdasd/asdasd.html
if (path.startsWith(getBasePath())) {
Session session = resourceResolver.adaptTo(Session.class);
String userId = session.getUserID();
String resourcePath = getResourcePath(userId, path);
// eg /_private/D0/33/E2/admin/test1/asdasd/asdasd
if (resourcePath != null) {
Resource resource = resourceResolver.resolve(resourcePath);
// a JcrNodeResource with metadata sling.resolutionPath=/
_private/D0/33/E2/admin/test1/asdasd/asdasd/asdasd,
sling.resolutionPathInfo=.html
return resource;
}
} else {
LOGGER.info("Base Path doesnt match ");
}
return null;
}
Although all of this looks correct to me, I suspect I just should
not be doing it this way... any suggestions ?
Ian
On 21 May 2009, at 16:03, Ian Boston wrote:
Hi,
Is it possible to internally Proxy an existing Sling Resource from
another ResourceProvider ?
eg
I have a PrivateResourceProvider that matches /_user/private
From that it builds a path based on the logged in user and the rest
of the url
eg
/_private/A3/D0/33/admin
eg
/_user/private/test1.html
results in
/_private/A3/D0/33/admin/test1.html
at that point I would like to internally get hold of the resource
for /_private/A3/D0/33/admin/test1.html and return with that from
the PrivateResourceProvider so that it handles everything. But, I
get an external redirect (302) to _private/A3/D0/33/admin/test1.html
Ian