Notify user with an email when user's granted permission to see a file

cancel
Showing results for 
Search instead for 
Did you mean: 
Rildo
Member II

Notify user with an email when user's granted permission to see a file

Hello,

is there a way to notify users with an email when user's granted permission to see a file.

per.PNG

 

Thanks in advance.

1 Reply
abhinavmishra14
Moderator
Moderator

Re: Notify user with an email when user's granted permission to see a file

Nothing ootb, however you can implement a custom behavior using PermissionServicePolicies

 

org.alfresco.repo.security.permissions.PermissionServicePolicies
org.alfresco.repo.security.permissions.PermissionServicePolicies.OnGrantLocalPermission

You must be using alfresco version 5.2.g and above in order to use PermissionServicePolicies , this class was not available before alfresco 5.2.g if i remember correctly.

Example:

public class PermissionChangeBehavior implements PermissionServicePolicies.OnGrantLocalPermission, InitializingBean {

	private static Log logger = LogFactory.getLog(PermissionChangeBehavior.class);

	private PolicyComponent policyComponent;

	@Override
	public void onGrantLocalPermission(final NodeRef nodeRef, final String authority, final String permission) {
		logger.info("onGrantLocalPermission invoked for nodeRef: " + nodeRef + " | authority: " + authority
				+ " | permission: " + permission);
		// TODO:: Notify the user/group (authority) via email
	}
	public void setPolicyComponent(final PolicyComponent policyComponent) {
		this.policyComponent = policyComponent;
	}

	@Override
	public void afterPropertiesSet() throws Exception {
          policyComponent.bindClassBehaviour(PermissionServicePolicies.OnGrantLocalPermission.QNAME,
		 ContentModel.TYPE_CONTENT,
		 new JavaBehaviour(this, PermissionServicePolicies.OnGrantLocalPermission.QNAME.getLocalName(),
			NotificationFrequency.EVERY_EVENT));
}

 

~Abhinav
(ACSCE, AWS SAA-C02, GAIQ)