On 3 Jun 2009, at 10:14, Felix Meschberger wrote:
Hi,
Each ResourceProvider is responsible for setting up resources
themselves, including setting the resource type. For example the
BundleResourceProvider sets the resource type to nt:file or nt:folder
depending on whether the resource is a file or folder.
The JcrResourceProvider now uses the ResourceTypeProvider service to
enhance its resource type resolution:
(1) check sling:resourceType property
(2) check ResourceTypeProvider services
(3) take primary node type
Ok, that makes sense, clearly changing ResourceTypeProvider would be
the wrong thing to do
thank you.
Your (remaining) problem probably is the resource type of non-existing
resources which is currently hard coded to sling:nonexisting and it is
also defined in the API that a non existing resource has the
sling:nonexisting resource type.
It might be conceivable though to set the resourceSuperType of such
non-existing resources to something configurable. To do this I would
suggest to introduce a new service interface, which would be called
when
the ResourceResolver is about to create the NonExistingResource.
Ok, I will give that a go, sounds like a far better than a
ResourceProvider place to put this stuff.
Thanks
Ian
Regards
Felix
Ian Boston schrieb:
On 3 Jun 2009, at 09:26, Felix Meschberger wrote:
Not in the sense of "inheriting the resource type from the parent
node
if none is set".
But: We have a ResourceTypeProvider service interface, which you may
implement. This provider is called by the JcrResourceProvider if a
node
has no sling:resourceType property.
In a custom resource provider, you could find a sling:resourceType
property up the ancestors of the node to build inheritance this way.
HTH
Felix,
Yes It does to a degree
I had a look at that interface and it works if there is a Node, but
URL
does not directly map to the JCR path either because the JCR path
doesnt
exist yet, or because there is mapping between the URL and the JCR
path,
then there is no Node, so the JcrResourceType doesnt get called.
What *would* work is something like
/**
* Provide a resource type for resource paths which do not have
* resourceType.
*/
public interface ResourceTypeProvider {
/**
* Return the resource type to use for the node.
* @param absPath The node.
* @return The resource type to use or null.
*/
String getResourceTypeForPath(String absPath) throws
RepositoryException;
}
That would also get rid of the need for my patch local on
ResourceProvider registrations (classifier)
Ian
Regards
Felix