cancel
Showing results for 
Search instead for 
Did you mean: 

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

Rildo
Champ in-the-making
Champ in-the-making

Hello,

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

image

Thanks in advance.

1 REPLY 1

abhinavmishra14
World-Class Innovator
World-Class Innovator

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, Azure Admin)