Expand my Community achievements bar.

SOLVED

Restrict wcm.io CA Configuration based on content path

Avatar

Community Advisor

I configured Context Aware Config using wcm.io. When I edit a CA Config page, I saw my custom configurations which I wrote via @Configuration annotation. Till now everything is fine.
But in the list of the configuration UI page, I saw all the configurations. Is there any way to restrict the configuration visible based on the content path?

For example, For my_project_1 I wrote 2 configurations. config_A, config_B. And for my_project_2 I wrote config_X, config_Y, and config_Z.
In the wcm.io page editor, I saw all the configurations, config_A, config_B, config_X, config_Y, and config_Z.
But I want to see the configs based on their content path.
For /content/my_project_1/master -> config_A, config_B
and /content/my_project_2/master -> config_X, config_Y,  config_Z

Sady_Rifat_0-1666256138045.png

Sady_Rifat_1-1666256336646.png

 

 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi,

This is not possible to segregate context aware config in UI based on project.

 

The json returns the config names

http://localhost:4502/content/mysite/config/jcr:content.configNames.json 

You can write one more servlet to get the valid config and remove rest from the dropdown or change at /apps/wcm-io/caconfig/editor/clientlibs/io.wcm.caconfig.editor/js/modals/add-collection-item.controller.js



Arun Patidar

View solution in original post

5 Replies

Avatar

Correct answer by
Community Advisor

Hi,

This is not possible to segregate context aware config in UI based on project.

 

The json returns the config names

http://localhost:4502/content/mysite/config/jcr:content.configNames.json 

You can write one more servlet to get the valid config and remove rest from the dropdown or change at /apps/wcm-io/caconfig/editor/clientlibs/io.wcm.caconfig.editor/js/modals/add-collection-item.controller.js



Arun Patidar

Avatar

Level 1

Since I was looking for something similar, I did some deep diving into the code and found out it is technically possible to do it. What you need is the following:

 

* Ensure you have io.wcm.sling.commons loaded

* Create an OSGi service that implements io.wcm.caconfig.editor.ConfigurationEditorFilter and in the @component annotation, you configure the "property" property to something like Wcmio-CAService-ContextPathRegex=<insert regex here>

* In the subsequent allowAdd method you need to implement, you only allow true on the configs you want. 

 

Keep in mind that the regex is used to match the jcr:content resource of the CA config page itself, so your regex should be something like /content/<your_site_and_path>/<config page name>/jcr:content$

Avatar

Community Advisor

@dylanreniers ,

Many thanks for your sharing. I will try the method.