protected void autoCreateChildren ( Name primaryType , NodeTypes capabilities ) throws ItemExistsException , PathNotFoundException , VersionException , ConstraintViolationException , LockException , RepositoryException { Collection < JcrNodeDefinition > autoChildDefns = capabilities . getAutoCreatedChildNodeDefinitions ( primaryType ) ; if ( ! autoChildDefns . isEmpty ( ) ) { // There is at least one auto-created child under this node ... Set < Name > childNames = new HashSet < Name > ( ) ; for ( JcrNodeDefinition defn : autoChildDefns ) { // Residual definitions cannot be both auto-created and residual; // see Section 3.7.2.3.4 of the JCR 2.0 specfication" assert ! defn . isResidual ( ) ; if ( defn . isProtected ( ) ) { // Protected items are created by the implementation, so we'll not do these ... continue ; } Name childName = defn . getInternalName ( ) ; if ( ! childNames . contains ( childName ) ) { // We've not already created a child with this name ... JcrNodeType childPrimaryType = defn . getDefaultPrimaryType ( ) ; addChildNode ( childName , childPrimaryType . getInternalName ( ) , null , false , false ) ; } } } }
Create in this node any auto - created child nodes .