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

Avatar

Avatar
Ignite 1
Level 3
khamat_bn
Level 3

Likes

31 likes

Total Posts

55 posts

Correct reply

12 solutions
Top badges earned
Ignite 1
Give Back 3
Give Back
Boost 5
Boost 3
View profile

Avatar
Ignite 1
Level 3
khamat_bn
Level 3

Likes

31 likes

Total Posts

55 posts

Correct reply

12 solutions
Top badges earned
Ignite 1
Give Back 3
Give Back
Boost 5
Boost 3
View profile
khamat_bn
Level 3

27-03-2021

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) 

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Coach
Employee
jbrar
Employee

Likes

389 likes

Total Posts

869 posts

Correct reply

283 solutions
Top badges earned
Coach
Establish
Give Back 50
Give Back 5
Give Back 3
View profile

Avatar
Coach
Employee
jbrar
Employee

Likes

389 likes

Total Posts

869 posts

Correct reply

283 solutions
Top badges earned
Coach
Establish
Give Back 50
Give Back 5
Give Back 3
View profile
jbrar
Employee

29-03-2021

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/over...

 

Answers (2)

Answers (2)

Avatar

Avatar
Boost 1
Level 1
ashwinkumar_gupta
Level 1

Like

1 like

Total Posts

1 post

Correct reply

0 solutions
Top badges earned
Boost 1
View profile

Avatar
Boost 1
Level 1
ashwinkumar_gupta
Level 1

Like

1 like

Total Posts

1 post

Correct reply

0 solutions
Top badges earned
Boost 1
View profile
ashwinkumar_gupta
Level 1

16-06-2021

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
"
]

 

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,442 likes

Total Posts

3,322 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,442 likes

Total Posts

3,322 posts

Correct reply

941 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

28-03-2021

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.