RepoInit In AEM (Part II)
Repoinit configuration file is usually placed inside /apps/yourproject/osgiconfig/<environmentspecificconfig>. for author, publisher or environment (runmodes) the configuration may differ. Repoinit file can be config file or json file. For example
org.apache.sling.jcr.repoinit.RepositoryInitializer~yourproject.cfg.json
(Notice the ~ sign)
Script statements can be written in this file as below.
{
"scripts": [
"create path (sling:OrderedFolder) /content/dam/yourproject",
"create path (nt:unstructured) /content/dam/yourproject/jcr:content",
]
}Or
org.apache.sling.jcr.repoinit.RepositoryInitializer-yourproject.config
(Notice the hifen sign)
Script statements can be written in this file as below.
scripts=[
"
create path (sling:OrderedFolder) /content/dam/yourproject
create path (nt:unstructured) /content/dam/yourproject/jcr:content
"
]Let’s look at some example statements
Create user
create user kinjalOR
create user kinjal with path /home/users/aCreate user with password
create user kinjal with password mypasswordCreate service user
create service user myserviceuserCreate a group
create group testGroup
create group testGroup with path /home/groups/aCreate path
create path /one/two/three
create path /three/four(nt:folk)/five(nt:jazz)/six
create path (nt:x) /seven/eight/nine
create path /one(mixin nt:art)/step(mixin nt:dance)/two/steps
create path (nt:foxtrot) /one/step(mixin nt:dance)/two/steps
create path /one/step(mixin nt:dance,nt:art)/two/steps
create path /one/step(nt:foxtrot mixin nt:dance)/two/steps
create path /one/step(nt:foxtrot mixin nt:dance,nt:art)/two/steps
create path /one:and/step/two:and/steps
create path /one@home/step/two@home/steps
create path /one+tap/step/two+tap/steps
Create Path with Properties
create path (sling:Folder) /var/discovery(nt:unstructured)/somefolder2 with properties
set sling:ResourceType{String} to /x/y/z
set cq:allowedTemplates to /d/e/f/*, m/n/*
default someInteger{Long} to 42
endNotice the “end” statement.
Set ACL for users
set ACL for kinjal
remove * on /libs,/apps
allow jcr:read on /content
deny jcr:write on /apps
endAdd User to Group
add kinjal to group testGroupSet ACL for groups
set ACL for testGroup
allow jcr:read on /content
endDelete user
delete service user myserviceuser
delete user kinjalDelete group
delete group testGroupSet properties on path
set properties on /pathA, /path/B
set sling:ResourceType{String} to /x/y/z
set cq:allowedTemplates to /d/e/f/*, m/n/*
endIn Next blog we will understand rep:glob.
Reference : https://sling.apache.org/documentation/bundles/repository-initialization.html
