Please Note: This post refers to recent updates to the Alfresco Community source – at the time of writing these features are NOT available in any current Alfresco release.We’ve added a new capability to the Spring Surf extensibility that allows modules to make dynamic changes to the configuration service. Alfresco Share uses the Surf configuration service extensively to control its behaviour (check out all the files ending with the suffix “-config.xml” in the “shareWEB-INFclassesalfresco” directory) and up until now it’s only been possible to make changes to this configuration between server restarts.To make a module provide additional (or replace existing) configuration you simply need to add the configuration within a element in the module configuration (apologies for the overuse of the word “configuration” there!)Here is an example module that replaces the Document Library configuration for Flash enablement for any site with the name “noflash” (the section in green is the important part - I'm using the 'out-of-the-box' site evaluator to only apply the module to sites with the name 'noflash' that were created using any preset).
The original configuration can be found in the file “shareWEB-INFclassesalfrescoshare-documentlibrary-config.xml”. The screenshots show the resulting upload dialog when accessed from the Document Library of two different sites, one called “flash” and the other “noflash” (after the module has been applied obviously - see earlier posts for more information on this)It’s important to note that when replacing configuration that you will need to preserve any existing configuration from the original that you don’t want to lose. For example – I’ve kept the “in-memory-limit” setting because it would otherwise have been lost as part of the replace.Equally if you don’t specify the “replace” attribute as true then you will only ADD additional configuration and it’s possible that your configuration change won’t be observed because it won’t be the first element found – i.e. if the “replace” attribute was not set in my configuration the end result would be:
<description>Applies config based on site id</description>
<config evaluator='string-compare' condition='DocumentLibrary' replace='true'>
…and when the Document Library code accessed the configuration it would detect Flash as enabled as the first “adobe-flash-enabled” element would be returned. If you’re familiar with overriding configuration in Alfresco through static files on the “web-extension” path then this shouldn’t be a surprise to you as the behaviour is identical – however, I thought it would be worth mentioning in case it takes people by surprise.