Access Properties values set via WCM USE class

Avatar

Avatar

patK-ze1xYs

Avatar

patK-ze1xYs

patK-ze1xYs

07-02-2017

WCM USE class creates a MAP from backend Service.

 

resource.adaptTo(ModifiableValueMap.class).putAll(backendPropertyMAP); // Creates a MAP of all properties custom + authored

In HTML
 

<a   ng-class="${properties.key1fromResource}" ng-disabled="${properties.key2fromResource}"> TEXT </a>

 

Above snippet works fine when user who has all permissions views the page.

But when I view the page for a user who only has read access on ‘/content/page’ values don’t get printed and end result is

 <a> TEXT </a>

 

One way to handle is store values in JCR nodes which can be fetched in HTML, checking if there is a way to still read properties for a user with Read only access without saving in JCR node.

View Entire Topic

Avatar

Avatar

Gdubz-57m2mu

Avatar

Gdubz-57m2mu

Gdubz-57m2mu

07-02-2017

Hi ptK,

Firstly, WCMUse[1] is deprecated, use WCMUsePojo[2] instead. Secondly, is there any particular reason you're using a ModifiableValueMap[3] to READ values? You should really just be using a regular ValueMap[4] instead, if you can help it.

In the event that you can't help but use the ModifiableValueMap, you may need to utilize a Service Resolver[5] that has sufficient privileges to read and write content, in lieu of the user's (possibly unprivileged) ResourceResolver[6].

[1] https://docs.adobe.com/docs/en/aem/6-2/develop/ref/javadoc/com/adobe/cq/sightly/WCMUse.html
[2] https://docs.adobe.com/docs/en/aem/6-2/develop/ref/javadoc/com/adobe/cq/sightly/WCMUsePojo.html
[3] https://docs.adobe.com/docs/en/aem/6-2/develop/ref/javadoc/org/apache/sling/api/resource/ModifiableV...
[4] https://docs.adobe.com/docs/en/aem/6-2/develop/ref/javadoc/org/apache/sling/api/resource/ValueMap.ht...
[5] https://helpx.adobe.com/experience-manager/using/querying-experience-manager-sling.html
[6] https://docs.adobe.com/docs/en/aem/6-2/develop/ref/javadoc/org/apache/sling/api/resource/ResourceRes...