Not able to Add OOTB groups to newly created groups via repoinit script | Community
Skip to main content
khamat_bn
Level 4
Mar 27, 2021 1:32 PM UTC
Solved

Not able to Add OOTB groups to newly created groups via repoinit script

We have written a repoinit script to add OOTB groups to custom groups but getting the error in script while deploying to AEM cloud.(working fine in local) 

That is because of script is running earlier than the OOTB group creation. Its failing while building image in cloud. 

So we want to add OOTB groups to custom groups automatically instead of manually. 

Is there any way instead of manual work ?

 

Below are logs for build image execution in AEM cloud pipeline.

 

 

27.01.2021 06:19:54.906 *INFO* [Apache Sling Repository Startup Thread #1] org.apache.sling.jcr.repoinit.impl.GroupMembershipVisitor Adding members '[global-librarian, asset-consumers]' to group 'contributor' 

27.01.2021 06:19:54.911 *ERROR* [Apache Sling Repository Startup Thread #1] com.adobe.granite.repository.impl.SlingRepositoryManager Exception in a SlingRepositoryInitializer, SlingRepository service registration aborted 

java.lang.RuntimeException: contributor is not a group 

at org.apache.sling.jcr.repoinit.impl.GroupMembershipVisitor.visitAddGroupMembers(GroupMembershipVisitor.java:52) [org.apache.sling.jcr.repoinit:1.1.28] 

at org.apache.sling.repoinit.parser.operations.AddGroupMembers.accept(AddGroupMembers.java:40) [org.apache.sling.repoinit.parser:1.6.2] 

at org.apache.sling.jcr.repoinit.impl.JcrRepoInitOpsProcessorImpl.apply(JcrRepoInitOpsProcessorImpl.java:56) [org.apache.sling.jcr.repoinit:1.1.28] 

at org.apache.sling.jcr.repoinit.impl.RepositoryInitializerFactory.processRepository(RepositoryInitializerFactory.java:126) [org.apache.sling.jcr.repoinit:1.1.28] 

at org.apache.sling.jcr.base.AbstractSlingRepositoryManager.executeRepositoryInitializers(AbstractSlingRepositoryManager.java:610) [org.apache.sling.jcr.base:3.1.6] 

at org.apache.sling.jcr.base.AbstractSlingRepositoryManager.initializeAndRegisterRepositoryService(AbstractSlingRepositoryManager.java:558) [org.apache.sling.jcr.base:3.1.6] 

at org.apache.sling.jcr.base.AbstractSlingRepositoryManager.access$300(AbstractSlingRepositoryManager.java:92) [org.apache.sling.jcr.base:3.1.6] 

at org.apache.sling.jcr.base.AbstractSlingRepositoryManager$4.run(AbstractSlingRepositoryManager.java:527) [org.apache.sling.jcr.base:3.1.6] 

27.01.2021 06:19:54.918 *INFO* [Apache Sling Repository Startup Thread #1] com.adobe.granite.repository.impl.SlingRepositoryManager Stop requested 

 

Contributor group is creating after running repoinit script 

 

27.01.2021 06:20:07.751 *INFO* [Apache Sling Repository Startup Thread #1] com.adobe.granite.security.user.internal.audit.AuditAuthorizableAction Group 'contributor' was created 

27.01.2021 06:20:07.780 *WARN* [Apache Sling Repository Startup Thread #1] org.apache.jackrabbit.oak.security.user.UserImporter New member of Group 'contributor': No such authorizable (NodeID = 429bbd5b-46a6-3c3d-808b-5fd4219d5c4d) 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
user05162Accepted solution
Employee
Mar 29, 2021 12:52 PM UTC

Repoint does initialize before any content[1] is loaded to the repo. So, you will have to find an alternate approach to add the OOTB group to the custom group.

 

One approach I could think of is to do it via custom code when your code initializes for the first time after AEM restart 

 

[1] https://experienceleague.adobe.com/docs/experience-manager-cloud-service/implementing/deploying/overview.html?lang=en#repoinit

 

4 replies

New Participant
Jun 16, 2021 5:39 PM UTC

So as to add OOTB groups to newly created groups via repoinit script follow below steps:

 

1. Create OOTB group via repoinit script

2. ADD  OOTB group to newly created custom group

3. Once AEM loads, OOTB groups permission will be automatically taken care off.

 

scripts=[
"
create group contributor

create group new-custom-group
add new-custom-group to group contributor
"
]

 

Translate
kautuk_sahni
Employee
Jun 17, 2021 11:17 AM UTC
@ashwinkumar_gupta, Thank you for sharing the answer with AEM community. Keep it up.
Translate
Kautuk Sahni
user05162Accepted solution
Employee
Mar 29, 2021 12:52 PM UTC

Repoint does initialize before any content[1] is loaded to the repo. So, you will have to find an alternate approach to add the OOTB group to the custom group.

 

One approach I could think of is to do it via custom code when your code initializes for the first time after AEM restart 

 

[1] https://experienceleague.adobe.com/docs/experience-manager-cloud-service/implementing/deploying/overview.html?lang=en#repoinit

 

Translate
arunpatidar
New Participant
Mar 28, 2021 8:15 PM UTC

you can write this logic in your bundle as well, on bundle activator class.

As soon s the bundle is activated, it will add a custom group to the contributor group.

Translate
Arun Patidar