Auto-Filing Content in Alfresco

After working with Alfresco for a while, we’ve noticed a number of design patters and functionality that are common amongst many clients across various industries.  Alfresco module packages (AMPs), make it easy to package up components and reuse them in different Alfresco implementations.  This article will focus on one reusable module that automatically files content into a folder structure in an Alfresco repository based on metadata.

Introduction

At TSG, more times than not, we recommend that clients throw out the folder paradigm in favor of utilizing metadata and search to classify documents in their ECM systems.  See our previous post “Working with Folders in Documentum User Interfaces – D2, Webtop, HPI, and xCP” for a more in-depth discussion on using folders to classify documents.  For “do all” applications like Alfresco Explorer and Alfresco Share, creating and managing content in a folder structure is a key component of the application.  This makes sense because in order to satisfy the widest range of users, it’s good to use a paradigm that users are already familiar with.  Most users are already accustomed to filing documents on their PCs into folders using Windows Explorer or Mac OS Finder, so it’s understandable that many ECM user interfaces take a similar approach.

Alternative user interfaces, like TSG’s High Performance Interface (HPI), can operate without any folder structure at all.  Part of what makes HPI “High Performance” is that users don’t have to know where to put content when they’re uploading it.  That being said, because Alfresco and other ECM applications are built with a folder paradigm already in place, all content must be in a folder behind the scenes.  For performance and maintainability reasons, it’s often important that folderless user interfaces file content into a folder structure in the back-end repository.

To make this simple in Alfresco, we’ve developed a configurable AMP module to automatically file content into a folder structure based on metadata that is applied to content at creation time.  Here’s how it works:

Configuration

In order to avoid code changes for each implementation, the auto-filing module is configurable.  System administrators can simply initiate a web service call from a browser in order to set up the auto filing configuration for their Alfresco repository.  Behind the scenes, configurations are stored as contentless objects in the repository and can be modified/deleted at any time.  Auto-filing configurations include the following parameters:

  • Root Path – path to the root Alfresco folder where auto-filed content will be stored
  • Types – list of Alfresco content types that the auto-file configuration applies to
  • Properties List – list of metadata properties that determines the folder path that content will be auto-filed into. For example, if you wanted to file documents by 2 metadata fields, “Project Name” and “Document Type,” you’d configure auto-filing for these two properties, and then new content would be filed into the folder, “/{Root Path}/{Project Name}/{Document Type}”.
  • Auto Create Folders – indicates whether folders should be automatically created if they don’t already exist in the repository
  • Auto Create Folder Type – if folders are to be automatically created, this property is used to configure the content type that new folders will be created as
  • Auto Rename Duplicates – this flag tells the system whether or not to automatically rename a document if a document with the same name already exists in the target folder during auto-filing

Aspects and Behaviors

Once the auto-file configurations are in place, Alfresco behaviors do the rest of the work.  Behaviors allow custom functionality to be to be injected into the repository when certain events occur, such as new content being created, or properties changing on existing content.  The auto-filing AMP uses behaviors to watch for new content and properties being updated so that content can be automatically filed into the correct folder structure based on the configuration.

The final piece of the puzzle is knowing when to trigger the behaviors.  We utilize an Alfresco aspect for this.  Any content that should be auto-filed receives an “Autofile” aspect.  The nice thing about using aspects is that they can be automatically applied to content by making them mandatory aspects in the content model, or by setting up folder rules in the repository.

Summary

Because most ECM repositories are closely coupled with a folder paradigm, folder structure is an important component of the overall content architecture, even in systems that utilize interfaces that hide folders from the end user.  Organizing content into a folder structure based on metadata is a common requirement in many systems that can be easily met using the Alfresco auto-filing AMP described in this post.

Please add comments and feedback below.