[ 
https://issues.apache.org/jira/browse/SLING-2782?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13599812#comment-13599812
 ] 

Felix Meschberger commented on SLING-2782:
------------------------------------------

I think the "killer" case is that the Resource API deals with Resources which 
have resource types. So its more about the conceptual stringency than about 
killer use cases.... So after sleeping over it I think Carsten's idea is 
actually compelling: I always had a hard time thinking of setting the 
jcr:primaryType property to create a new resource. It kind of breaks the 
abstraction. 

How about this formulation:

1. We document the suggestion to set the resource type
2. The JCRResourceProvider (while of course still supporting jcr:primaryType) 
is enhanced to support sling:resourceType: If the resource type is a valid node 
type, it is used as the jcr:primaryType. There is *no* mapping involved. Thus a 
resource type of the form "app/page" is never used as a node type. On the other 
hand, it IMHO makes sense to "use" the resource type "sling:Folder" as the 
primary node type.

If the resource type cannot be used as the primary node type (and no 
jcr:primaryType is defined), the default from the repository is used by just 
using the single-argument Node.addNode(String) method.
                
> Try to use sling:resourceType as a node type for node creation
> --------------------------------------------------------------
>
>                 Key: SLING-2782
>                 URL: https://issues.apache.org/jira/browse/SLING-2782
>             Project: Sling
>          Issue Type: Improvement
>          Components: JCR
>    Affects Versions: JCR Resource 2.2.4
>            Reporter: Carsten Ziegeler
>             Fix For: JCR Resource 2.2.6
>
>
> Right now, creating resources through the resource API 
> (ResourceResolver#create) still requires some knowledge about the underlying 
> storage especially in the case of JCR - in many cases you need to provide the 
> primary node type.
> We could relax this and use the sling:resourceType as the node - but only if 
> jcr:primaryType is not specified and sling:resourceType contains a valid node 
> type name.
> This is in line with the implementation of the resource type handling for jcr 
> resources: if the node does not have a sling:resourceType, the node type is 
> returned.
> In addition, we defined that e.g. for files all resource providers should 
> return nt:file as the resource type and nt:folder for folders. So making this 
> work the other way round, fits into this.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to