It doesn't work as the wrapper uses the original resource metadata object.
I could create a wrapper for the resource metadata as well and remove
the lock check. This way I would need to dublicate all resource metadata
methods in the resource metadata wrapper for the delegation. But every
signature change in the evolution of the ResourceMetadata class would
have to be synchronized with its wrapper. This seems to be a very tight
dependency. Is this really the way to go?
Best,
Sandro
Am 08.10.14 19:39, schrieb Carsten Ziegeler:
Your resource is already resolved, so you should rather create a resource
wrapper and return that
Carsten
2014-10-08 15:51 GMT+02:00 Sandro Boehme <[email protected]>:
The problem might be related to SLING-2780 [1]. But I still don't know how
to get around it.
[1] - https://issues.apache.org/jira/browse/SLING-2780
Best,
Sandro
Am 08.10.14 15:40, schrieb Sandro Boehme:
Hello,
when I call a resource using my custom ResourceProvider [1] I get a
server error (500) saying "java.lang.UnsupportedOperationException:
JcrNodeResourceMetadata is locked" [3]. At the moment I don't see a way
to get around that and it would be great if someone has a hint on what
to do.
In my ResEditorResourceProvider.java:61 [1] I return a resource that I
get from a ResourceResolver. While resolving, the
'ResourceDecoratorTracker.decorate(Resource)' method
'result.getResourceMetadata().lock()' is called and after I returned my
resource 'ResourceResolverImpl.getAbsoluteResourceInternal(String path,
boolean isResolve)' calls
'resource.getResourceMetadata().setResolutionPath(path)' which triggers
the exception. You can see that in the stack trace [3].
++ Background ++
I'm working on a custom ResourceProvider [1] for the Sling Resource
Editor [2] that returns a wrapped resource for every Sling resource.
This wrapped resource will later get the resource type for the Resource
Editor set. That way the Resource Editor script would get called for all
resources.
[1] -
https://github.com/sandroboehme/resourceeditor/
blob/master/src/main/java/org/apache/sling/reseditor/
ResEditorResourceProvider.java
[2] - https://issues.apache.org/jira/browse/SLING-4001
[3] -
java.lang.UnsupportedOperationException: JcrNodeResourceMetadata is
locked
at
org.apache.sling.api.resource.ResourceMetadata.checkReadOnly(
ResourceMetadata.java:310)
at
org.apache.sling.api.resource.ResourceMetadata.put(
ResourceMetadata.java:322)
at
org.apache.sling.api.resource.ResourceMetadata.setResolutionPath(
ResourceMetadata.java:254)
at
org.apache.sling.resourceresolver.impl.ResourceResolverImpl.
getAbsoluteResourceInternal(ResourceResolverImpl.java:955)
at
org.apache.sling.resourceresolver.impl.ResourceResolverImpl.
resolveInternal(ResourceResolverImpl.java:810)
at
org.apache.sling.resourceresolver.impl.ResourceResolverImpl.
resolveInternal(ResourceResolverImpl.java:327)
at
org.apache.sling.resourceresolver.impl.ResourceResolverImpl.resolve(
ResourceResolverImpl.java:225)
at
org.apache.sling.engine.impl.request.RequestData.
initResource(RequestData.java:223)
at
org.apache.sling.engine.impl.SlingRequestProcessorImpl.doProcessRequest(
SlingRequestProcessorImpl.java:142)
at
org.apache.sling.engine.impl.SlingMainServlet.service(
SlingMainServlet.java:217)
Thanks!
Sandro