cancel
Showing results for 
Search instead for 
Did you mean: 

Behaviour associated to update permissions

eljuaner
Confirmed Champ
Confirmed Champ

I want to execute some code (Java if it's possible or Javascript if it isn't) when an user manages permissions in Alfresco Share and he saves changes, which is the best way to do this? I can't find a behaviour or similar to listen on this event.

Thanks in advance!

1 ACCEPTED ANSWER

You can try using PermissionServicePolicies.

https://github.com/Alfresco/alfresco-repository/blob/master/src/main/java/org/alfresco/repo/security...

  • OnGrantLocalPermission > onGrantLocalPermission
  • OnRevokeLocalPermission > onRevokeLocalPermission
  • OnInheritPermissionsEnabled > onInheritPermissionsEnabled
  • OnInheritPermissionsDisabled > onInheritPermissionsDisabled

https://github.com/Alfresco/alfresco-repository/blob/master/src/main/java/org/alfresco/repo/security...

Hyland Developer Evangelist

View answer in original post

7 REPLIES 7

EddieMay
World-Class Innovator
World-Class Innovator

Hi @eljuaner,

Do you mean permissions on a document? If so, this tutorial on implementing custom behaviours might prove useful. 

Digital Community Manager, Alfresco Software.
Problem solved? Click Accept as Solution!

Hello, Eddie and thanks for your response, but I'm familiarized with create custom behaviours. My question is what event I can listen to trigger my behaviour when the permissions are set. I tried with OnCreateAssociationPolicyOnCreateChildAssociationPolicy OnUpdateNodePolicy and OnUpdatePropertiesPolicy, but my behaviour is not triggered by any of them. So which policy could I use?

Thanks in advance again!

You can try using PermissionServicePolicies.

https://github.com/Alfresco/alfresco-repository/blob/master/src/main/java/org/alfresco/repo/security...

  • OnGrantLocalPermission > onGrantLocalPermission
  • OnRevokeLocalPermission > onRevokeLocalPermission
  • OnInheritPermissionsEnabled > onInheritPermissionsEnabled
  • OnInheritPermissionsDisabled > onInheritPermissionsDisabled

https://github.com/Alfresco/alfresco-repository/blob/master/src/main/java/org/alfresco/repo/security...

Hyland Developer Evangelist

afaust
Legendary Innovator
Legendary Innovator

PermissionServicePolicies are NOT part of the Alfresco Public API and thus may change without warning between Alfresco releases. Also, these policies do NOT work like other policies, because their implementation has been hacked in a quick & dirty manner. You can only bind against these permissions using the node type - aspects of a node will be ignored during registered policy lookup. The OnInheritPermissionsEnabled  and OnInheritPermissionsDisabled  are the worst of all, as their lookup will only check for bindings against the system base type, and completely ignores any special type the node may have.

As it stands, these policies require more or less a global binding and custom type/aspect check when your behaviour implementation is being called to determine if your logic actually needs to run.