Share Configuration Extensibility

cancel
Showing results for 
Search instead for 
Did you mean: 

Share Configuration Extensibility

Intermediate II
0 9 1,626
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
Active Member
Hi,

You say '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.'.
Do you know in which version of Alfresco Enterprise this feature will be available ?

Regards.
Intermediate II
@Bertrand In order for these features to work on Share it is not just a case of updating the Surf libs, there also have to be some changes to the underlying Share files to take advantage of the features (actually using the new FreeMarker directives for example) and these changes have been made on the Community source and could be merged onto the Enterprise branch. I would *like* these changes to be pulled across for a 4.0.x release, but this will need to be agreed with project management. It definitely won't make 4.0.1 so the *earliest* would be 4.0.2 - but that is by no means guaranteed. I'm sorry that I can't give you a more definitive answer at the moment.

I'll update the post as soon as this is available in a release though.
Active Member
Hi,

I try your example, on a nightly build, and it works like a charm.
Next, I've try to do the same thing with aspects, my idea is to customize visible aspects in differents sites but it doesn't seem to work.

Do you know if it's possible to do this ?

I've try this (in each site, I can only see the two aspects : generalclassifiable and taggable) :

  
     
         Hide_aspects_on_sites
         Try to hide aspects on sites
        
           
               test
               .*
           
        
        
           
             
                
                   
                   
                

                
                
             
           
        
     
  


Regards.
Intermediate II
@Bertrand It's tricky to tell what you've done as WordPress has trashed your XML... however, I think I might know what the problem is. I tried out the following sample:

<module>
   <id>Hide Aspects From Site</id>
   <description></description>
   <evaluator type='site.module.evaluator'>
      <params>
         <sites>noaspects</sites>
         <sitePresets>.*</sitePresets>
      </params>
   </evaluator>
   <configurations>
      <config evaluator='string-compare' condition='DocumentLibrary' replace='true'>
         <aspects>
            <visible></visible>
         </aspects>
      </config>
   </configurations>
</module>

...and I found that when the module was applied I would never see any aspects regardless of the site I visited (I would observe this behaviour when clicking on the 'Manage Aspects' action for a document). However, I know that the site module evaluator is actually coded so that if no site data is provided that it evaluates to true. The manage aspects action is an AJAX request and the site data is actually missing so the module is actually applied.

I tried the same module with a different evaluator that evaluated the authenticated user id and found that the behaviour worked expected. The problem here is the absence of site data for the evaluator to work with.
Active Member
Hi,

Is this feature available in Alfresco Comunity 4.0e? I'm trying your example and it isn't working for me...
What I realy whant to do is to configure the advanced search of a custom type only in one specific site, It is posible to do it like this??



 
   Site Conditional Advanced Search
   Applies config based on site id
  
   
     prueba
     .*
   
  
  
   
    
      false
      262144000
      
    
  
 



Thanks!!! Regards
Active Member


 
              
    mar:contrato
  
 

Intermediate II
No, unfortunately this capability is not in Alfresco Community 4.0e... it is in the latest Community Source code though if you wanted to take a nightly build. You could also try replacing the Spring Surf JARs from the latest Community Source in order to gain this feature though. That should hopefully work,

Regards,
Dave
Active Member
Dave,

I have been trying to find a way to add an entry into the Document Library 'Selected Items' menu.

This would be to apply a custom action to a custom type.

I have seen references to this blog post but it is still not clear to me.

I would appreciate any suggestions.



Thanks,

Bob McDowell
Intermediate II
Hi Bob,



This would be relatively tricky. The actual HTML template for that menu will be in a FreeMarker template which won't be easy to extend. Your best option here would be to use the approach described in the blog and try to programmatically create the addition HTML element required for the new item in the the 'Selected Items' menu. You'd then need to further update the Document Library to capture the click events and handle them appropriate.



Regards,

Dave