Alfresco, how to notify when a user leaves a Site

Recently a colleague asked me if the sysadmin could be notified every time a user leaves a Site in Alfresco. The short answer is no, as Alfresco does not have this feature by default. However, by using a classical development skill named Behaviour, the feature can be ready in about half an hour.

How a member relation to a Site is stored in Alfresco repository

Alfresco is only a tree of nodes, so every piece of data can be found as a node and its relationships.

For a site member, a child association of type cm:member is created for the user belonging the site. Every role of a site (Manager, Collaborator, Contributor, Consumer) is stored as a node of type cm:authorityContainer, so the role Manager for the Site swsdp has an authority GROUP named site_swdsp_SiteManager including all the members for this role as children (admin and abeecher in the picture below).

Creating a behaviour to react when a member is removed from a role group

Alfresco provides different kind of behaviours, which allows a developer to include custom code when a condition is matched.

In our case, is required to react when an association of type cm:member is removed from an cm:authorityContainer . This can be done with a few lines of Java.

public class MemberAssociationBehaviour
    implements NodeServicePolicies.OnDeleteChildAssociationPolicy {

    // Bind your code to the behaviour
    public void init() {
            new JavaBehaviour(this, "onDeleteChildAssociation",

    public void onDeleteChildAssociation(ChildAssociationRef childAssocRef) {
        // Do some magic!

Once declared this behaviour as a Spring bean, any notification mechanism can be developed in the “do some magic” section. Since then, every time a user leaves a site our custom code will be fired.

Final words

A sample implementation for this blog post has been provided at GitHub, however it should be easy to adapt the notification part to your requirements.

No modification has been done to Alfresco product nor configuration, just only a standard extension mechanism has been used to provide this new feature.

Note also that this sample includes i18n messages to provide a consistent log trace for the sysadm.

Alfresco, how to hide categories component from Share app

Every Surf component in a Share page can be extended in order to perform customisations on it.

To identify the target component, enable SurfBug …

… and navigate to the page to identify the component by clicking on it.

Having this component details in mind, you can write a simple surf customisation at /opt/alfresco/tomcat/shared/classes/alfresco/web-extension/site-data/extensions/remove-categories-extension.xml

            <id>Remove categories from share</id>
                        <sub-component id="default">
                                <evaluation id="guaranteedToHide">

After restarting Alfresco, categories tab will disappear from Repository view page for every user. If you want to apply this configuration also for document library, just replace




at /opt/alfresco/tomcat/shared/classes/alfresco/web-extension/site-data/extensions/remove-categories-extension.xml or create a new component entry in this XML file to hide categories on both pages.

Remember to include all your customisations under /opt/alfresco/tomcat/shared directory in order to avoid maintenance and upgrading conflicts.

Alfresco, accessing folders by path via REST

From Alfresco 5.2, three different REST API are available:

Below obtaining

Repository > Sites > test > documentLibrary > TestFolder

folder metadata is described for each API.

Existent REST API



It looks like Alfresco makes everything easier with each new release!