Sitemap

RepoInit In AEM (Part II)

2 min readNov 14, 2022

--

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 kinjal

OR

create user kinjal with path /home/users/a

Create user with password

create user kinjal with password mypassword

Create service user

create service user myserviceuser

Create a group

create group testGroup
create group testGroup with path /home/groups/a

Create 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
end

Notice 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
end

Add User to Group

add kinjal to group testGroup

Set ACL for groups

set ACL for testGroup
allow jcr:read on /content
end

Delete user

delete service user myserviceuser
delete user kinjal

Delete group

delete group testGroup

Set 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/*
end

In Next blog we will understand rep:glob.

Reference : https://sling.apache.org/documentation/bundles/repository-initialization.html

--

--

Kinjal P Darji
Kinjal P Darji

Written by Kinjal P Darji

Hi, I'm an AEM Architect and AWS Certified Developer. I also hold PG certificate in AIML by IIIT Hyderabad.