Hide annotate or delete buttons for user group based on asset path | Community
Skip to main content
Level 2
January 7, 2022
Solved

Hide annotate or delete buttons for user group based on asset path

  • January 7, 2022
  • 1 reply
  • 1026 views

Let's say I have "my-project" group. I need to assign permissions for this group in such a way that annotate or delete buttons in AEM assets toolbar should be visible on /content/dam/my-project/folder-a. However, annotate or delete buttons should not be visible on /content/dam/my-project/folder-b

Can anyone help me on how can I assign permissions for user group which varies on asset content path. 

Any help is really appreciated!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Anmol_Bhardwaj

I don't think AEM has any OOTB permission for this particular use-case.

But, you can always add a custom JS file and include it in the asseteditor.

Categories of that file would be "cq.dam.asseteditor.v2".

 

  • In that file , you can hide ( display:none) , the required buttons based on the URL ( window.location ). 
  • To make sure they only run for a particular user group, you can call a servlet from the JS file.
  • This servlet can send a boolean value in the response based on whether the user logged in belongs to a certain group for which this function should work.

Getting User Groups in Java: 

ResourceResolver resourceResolver = getResourceResolver(); session = resourceResolver.adaptTo(Session.class); UserManager userManager = ((JackrabbitSession) session).getUserManager(); Iterator < Authorizable > groupIterator = userManager.findAuthorizables("jcr:primaryType", "rep:Group");

 

1 reply

Anmol_Bhardwaj
Community Advisor
Anmol_BhardwajCommunity AdvisorAccepted solution
Community Advisor
January 7, 2022

I don't think AEM has any OOTB permission for this particular use-case.

But, you can always add a custom JS file and include it in the asseteditor.

Categories of that file would be "cq.dam.asseteditor.v2".

 

  • In that file , you can hide ( display:none) , the required buttons based on the URL ( window.location ). 
  • To make sure they only run for a particular user group, you can call a servlet from the JS file.
  • This servlet can send a boolean value in the response based on whether the user logged in belongs to a certain group for which this function should work.

Getting User Groups in Java: 

ResourceResolver resourceResolver = getResourceResolver(); session = resourceResolver.adaptTo(Session.class); UserManager userManager = ((JackrabbitSession) session).getUserManager(); Iterator < Authorizable > groupIterator = userManager.findAuthorizables("jcr:primaryType", "rep:Group");