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

Bertrand Delacretaz commented on SLING-10740:
---------------------------------------------

{quote}...we might need to review that and optimize to call save() only where 
really needed.
{quote}
In the meantime I ran [some experiments with large numbers of repoinit 
statements|https://gist.github.com/bdelacretaz/5ece181782206c0c9f820a78e6baaeef],
 and not calling save() at all might be problematic in such cases, in terms of 
performance. I _think_ if the Oak transient space gets too big that can be 
problematic - but I'm not sure.

This speaks for the second option that you suggested, extending the {{create 
path}} syntax to allow for setting properties.

As create path accepts a single path I think the following syntax will work for 
that:
{code:java}
create path (sling:Folder) /var/discovery(nt:unstructured)/somefolder with 
properties
  # same syntax as "set properties", and use the same code to set them
  # (maybe simply generate two Operations and make sure there's no save() in 
between?)
  set sling:ResourceType{String} to /x/y/z
  set cq:allowedTemplates to /d/e/f/*, m/n/*
  default someInteger{Long} to 42
end
{code}
That doesn't preclude removing any extraneous save() calls, but I think this 
solution is cleaner and also better in terms of keeping things together.

> Repoinit create path statement fails for node types with a mandatory property
> -----------------------------------------------------------------------------
>
>                 Key: SLING-10740
>                 URL: https://issues.apache.org/jira/browse/SLING-10740
>             Project: Sling
>          Issue Type: Bug
>          Components: Repoinit
>            Reporter: Eric Norman
>            Assignee: Eric Norman
>            Priority: Major
>             Fix For: Repoinit JCR 1.1.38
>
>
> The processing of the "create path" statement calls save() at the end which 
> will cause a constraint violation if the nodetype of the created path 
> contains any properties that are declared as mandatory (and not autocreated). 
>  No processing of "set properties" statements happens before the save() call 
> in AclVisitor#visitCreatePath so it does not seem to be possible to define 
> any mandatory properties using the current repoinit grammar.
> I could see this solved in a couple ways:
>  # The AclVisitor#visitCreatePath could possibly pre-process any "set 
> properties" statements that are applicable to the created path before calling 
> save and then skip those same items when NodePropertiesVisitor visits the 
> same.
>  # Or, the "create path" grammar could be extended to allow defining 
> properties to be set at the same time as the create (with a syntax that is 
> similar to the "set properties" statement?)
>  # Or, perhaps calling save in AclVisitor#visitCreatePath is not necessary?  
> I'm not sure of the historical reasons why save() is done there.
>  # Or, maybe something else I haven't thought of
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to