Expand my Community achievements bar.

SOLVED

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

Avatar

Level 2

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!

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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");

 

View solution in original post

1 Reply

Avatar

Correct answer by
Community Advisor

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");