Share Configuration Extensibility

cancel
Showing results for 
Search instead for 
Did you mean: 

Share Configuration Extensibility

ddraper
Intermediate II
0 9 7,508
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).

<extension>

   <modules>

      <module>

         <id>Site_Conditional_Flash</id>

         <description>Applies config based on site id</description>

         <evaluator type='site.module.evaluator'>

            <params>

               <sites>noflash</sites>

               <sitePresets>.*</sitePresets>

            </params>

         </evaluator>

         <configurations>

            <config evaluator='string-compare' condition='DocumentLibrary' replace='true'>

               <file-upload>

                  <adobe-flash-enabled>false</adobe-flash-enabled>

                  <in-memory-limit>262144000</in-memory-limit>

               </file-upload>

            </config>

         </configurations>


      </module>

   </modules>

</extension>


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)



Screenshot of Share showing the Flash uploader



Screenshot of Share showing the HTML5 uploader



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:

<adobe-flash-enabled>true</adobe-flash-enabled>

<in-memory-limit>262144000</in-memory-limit>

<adobe-flash-enabled>false</adobe-flash-enabled>

<in-memory-limit>262144000</in-memory-limit>



…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.
9 Comments