• Skip to primary navigation
  • Skip to main content
  • Skip to footer
ecm experts in australia

Seed Information Management

Enterprise Content Management Consultants ECM Experts

  • Services
    • Content Management
    • Collaboration
    • Business Process Management
    • Migration Services
    • Integration Services
    • Support & Maintenance
    • Pricing
  • Technology
    • Alfresco Digital Business Platform
    • Alfresco Application Development Framework
    • Cloud (PaaS)
    • Activiti
    • Flowable
    • Hyland RPA
  • Alfresco Addons
  • Case Studies
    • Industries
  • Blog
  • Contact Us
    • About

Alfresco Email Notifications

June 11, 2013 By Seed IM

Alfresco Email Notifications – The User Subscribe Model

Overview

Recently we upgraded one of our customers to Alfresco 4.  This meant that the Email Notification feature was available.  While everyone agreed that this was a great addition to Share, our customer did not want to role this out as it would have meant that all of their Alfresco users would suddenly get email notifications of Alfresco changes regardless if they wanted to be informed or not.  So in effect, the release of 4.0 subscribes every user to get email notifications.  This is the antithesis of normal subscription services whereby users themselves need to agree to receive notifications.  We therefore have rolled out the following solution to unsubscribe users by default.

  • Disable Global Notification Feed:  On upgrade of Alfresco we turned off the Notification service from Share Admin Console (Admin Console ->Activities Feed ->Feed Notifier Enabled)
  • Set Notification feed value for all users:  We then created a js script to update all users so that their Email Notification Feed was unchecked (accessed by Share User Account->My Profile->Notifications).  This was done by setting cm:emailFeedDisabled to true (its false by default).
  • User Behaviour:  We ensured that all new users (person nodes) created had their cm:emailFeedDisabled set to true by using a behaviour class attached to the node create policy for the type cm:person.    Note:  Initially we tried to do this using a rule against the users home folder but this did not work for users created with ldap.
  • Enable Global Notification Feed:   Using Share admin console we turned on notification feed and configured it to run once a week.

Alfresco users can now determine if they want to subscribe to email notifications.  We expect that many users will subscribe but we have avoided sending out emails to those users who may feel it is uncalled for spam.   Hopefully alfresco at some stage will allow customers to determine whether notifications will be enabled at the user level by a configuration in alfresco-global.properties but until then hopefully this blog will help you if faced with the same problem.

Implementation Details:

Email Notification Script

  • Copy the following lines to a file with the .js extension (E.g emailFeednotification.js)

var nodes = search.luceneSearch(“+TYPE:\”{http://www.alfresco.org/model/content/1.0}person\””);

for each(var node in nodes) {

                node.properties[“cm:emailFeedDisabled”]=true;

                node.save();

                logger.log(node.properties[“cm:userName”] + ” : ” +     node.properties[“cm:emailFeedDisabled”]);

}

  • Login Alfresco Explorer, navigate to Company Home -> Data Dictionary -> Scripts and upload the js script.
  • From Company Home directory, go to ‘More Actions’ and click on ‘View Details’.
  • Then click on ‘Run Actions’ from the right hand side menu, select ‘Execute Script’ from the ‘Select Action’ drop down menu and choose emailFeednotification.js from the ‘Set Values and Add’ drop down.
  • Finally hit Finish.

Person Behaviour Details

The PersonBehaviour Java Class was packaged into a jar file and deployed in $ALFRESCO_HOME/tomcat/webapps/alfresco/WEB-INF/classes/lib directory

PersonBehaviour Java Class

package au.edu.seedim.behaviour;

import org.alfresco.model.ContentModel;

import org.alfresco.repo.node.NodeServicePolicies;

import org.alfresco.repo.node.NodeServicePolicies.OnCreateNodePolicy;

import org.alfresco.repo.policy.Behaviour;

import org.alfresco.repo.policy.JavaBehaviour;

import org.alfresco.repo.policy.PolicyComponent;

import org.alfresco.service.cmr.repository.ChildAssociationRef;

import org.alfresco.service.cmr.repository.NodeRef;

import org.alfresco.service.cmr.repository.NodeService;

import org.apache.log4j.Logger;

public class PersonBehaviour implements NodeServicePolicies.OnCreateNodePolicy{

    // Dependencies injected by Spring

    private NodeService nodeService;

    private PolicyComponent policyComponent;

    // Behaviours

    private Behaviour onCreatePerson;

    private Logger logger = Logger.getLogger(PersonBehaviour.class);

    public void init() {

       logger.info(“Initializing RACP Person behaviors”);

        // Create behaviours

        this.onCreatePerson = new JavaBehaviour(this, “onCreateNode”);

       // NotificationFrequency.TRANSACTION_COMMIT

        // bind to policy

        this.policyComponent.bindClassBehaviour(

                OnCreateNodePolicy.QNAME,

                ContentModel.TYPE_PERSON,

                this.onCreatePerson);

        logger.info(“Exiting PersonBehaviour Init”);

    }

    @Override

    public void onCreateNode(ChildAssociationRef childAssocRef)

    {

                logger.info(“Enter onCreatePerson”);

                NodeRef personRef = childAssocRef.getChildRef();

       this.nodeService.setProperty(personRef, ContentModel.PROP_EMAIL_FEED_DISABLED, true);

        logger.info(“Exit onCreatePerson”);

    }

    public NodeService getNodeService() {

        return nodeService;

    }

    public void setNodeService(NodeService nodeService) {

        this.nodeService = nodeService;

    }

    public PolicyComponent getPolicyComponent() {

        return policyComponent;

    }

    public void setPolicyComponent(PolicyComponent policyComponent) {

        this.policyComponent = policyComponent;

    }

}

Context File

The context file for the above java class is shown below and has to be placed in $ALFRESCO_HOME/tomcat/webapps/alfresco/WEB-INF/classes/alfresco/extension directory.

<?xml version=’1.0′ encoding=’UTF-8′?>

<!DOCTYPE beans PUBLIC ‘-//SPRING//DTD BEAN//EN’ ‘http://www.springframework.org/dtd/spring-beans.dtd’>

<beans>   

 <bean id=”seedimPersonBehavior” class=”au.edu.seedim.behaviour.PersonBehaviour” init-method=”init”>

                                <property name=”nodeService”>

                                                <ref bean=”nodeService” />

                                </property>

                                <property name=”policyComponent”>

                                                <ref bean=”policyComponent” />

                                </property>

                </bean>             

</beans>

Footer


Seed IM is a leading ECM consulting company providing powerful solutions to businesses and organisations of all sizes

Contact Us

  • Seed Information Management Pty Ltd
    90 Maribyrnong Street
    Footscray VIC 3011
  • 03 9021 0837
  • info@seedim.com.au

Articles

Semantic Content Management for Alfresco
Using Multiple Taxonomies To Browse Your Content
Records Management Using Alfresco One

Copyright © 2025 Seed Information Management Pty Ltd · Contact Us · Privacy Policy · Our Digital Media Agency is Marmoset Digital