Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Repoinit script

Avatar

Level 4

I've created a Repoinit script using an OSGi Service Factory Configuration. I've successfully deployed the OSGi configuration containing the Repoinit script and I can see it under /system/console/configMgr, but the rep:policy isn't created in the DAM as expected. Can someone please provide guidance?

 

<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
          xmlns:jcr="http://www.jcp.org/jcr/1.0"
          xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
          jcr:primaryType="sling:OsgiConfig"
          repoinit.content='{
        "scripts": [
            "set ACL for path /content/dam/advisor/ deny jcr:all on granted group everyone",
            "set ACL for path /content/dam/advisor/ allow jcr:read on granted group jhi-employee",
   
        ]
    }'/>

 

 

 

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 4

This was the correct syntax after some more testing (in AEM 6.5.18):

 

scripts=["
set ACL for employee
allow jcr:read on /content/dam/advisor
end

"]

View solution in original post

6 Replies

Avatar

Community Advisor

what is the error you are getting?

 

did you add all dependencies in POM ?

 

<dependencies>
<!-- Apache Sling Repository Initialization -->
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.repoinit</artifactId>
<version>1.1.46</version>
</dependency>
<!-- Apache Sling JCR API -->
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.jcr.api</artifactId>
<version>2.4.0</version>
</dependency>
<!-- Apache Sling RepoInit Parser -->
<dependency>
<groupId>org.apache.sling</groupId>
<artifactId>org.apache.sling.repoinit.parser</artifactId>
<version>1.6.4</version>
</dependency>
</dependencies>

Avatar

Community Advisor

You need to explicitly create the folders on which you are setting the ACLs 

  1. Add repoinit statements to the script property of the config. The syntax and options are documented in Sling documentation. There should be explicit creation of a parent folder before their child folders. For example, an explicit creation of /content before /content/myfolder, before /content/myfolder/mysubfolder. For ACLs being set on low-level structures, it is recommended to set them on a higher level and work with a rep:glob restriction. For example, (allow jcr:read on /apps restriction(rep:glob,/msm/wcm/rolloutconfigs)).

https://experienceleague.adobe.com/docs/experience-manager-cloud-service/content/implementing/deploy...

and if you are working on aem cloud your repoint file should be in json formats. A sample repoinit file is always created if you create a project based on new maven archetype 

Avatar

Employee Advisor

try this:

{
  "scripts": [
      "create path /content/dam/advisor",      
      "set ACL for everyone\n\tdeny jcr:all on /content/dam/advisor\nend",
      "set ACL for jhi-employee\n\tallow jcr:read on /content/dam/advisor\nend"
  ]
}

Avatar

Correct answer by
Level 4

This was the correct syntax after some more testing (in AEM 6.5.18):

 

scripts=["
set ACL for employee
allow jcr:read on /content/dam/advisor
end

"]

Avatar

Administrator

@stiegjo22 Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni