AnsweredAssumed Answered

Merge files from web-extension

Question asked by gric on Jan 5, 2011
Latest reply on Jan 5, 2011 by mikeh
Hi,
  I've just fell over a tricky architecture problem, and I'm not sure of the best way to solve it.
How can I deal with two modules, both deploying a same file (let's say "toolbar.get.config.xml" for instance) in a web-extension context ?

By 'module', I mean something large : whether it's
  > an AMP : the last deployed module will win, other duplicated files from web-extension context will be overriden
  > a JAR : I don't know which strategy is chosen, but only one module will work.

Just to make myself clear, here's an example :
My first module would customize 'toolbar.get.config.xml' this way :
<toolbar>
   <createContent>
      <content mimetype="text/plain" icon="plain-text" label="menu.create-content.text" />
      <content mimetype="text/html" icon="html" label="menu.create-content.html" />
      <content mimetype="text/xml" icon="xml" label="menu.create-content.xml" />
      <content mimetype="xml/custom1" icon="xml" label="menu.create-content.custom1" formid="custom1-common-form"/>
   </createContent>

And my second module would customize it like this :
<toolbar>
   <createContent>
      <content mimetype="text/plain" icon="plain-text" label="menu.create-content.text" />
      <content mimetype="text/html" icon="html" label="menu.create-content.html" />
      <content mimetype="text/xml" icon="xml" label="menu.create-content.xml" />
      <content mimetype="xml/custom2" icon="xml" label="menu.create-content.custom2" formid="custom2-common-form"/>
   </createContent>

Those two modules are incompatibles, just because of their integration :( !

On one hand, I understand this problem is 'difficult' : how could the system determine the way to merge those two files ?
But on the other, it means one module can walk over another, and make it unusable, unless I make those dependent each-other :
<toolbar>
   <createContent>
      <content mimetype="text/plain" icon="plain-text" label="menu.create-content.text" />
      <content mimetype="text/html" icon="html" label="menu.create-content.html" />
      <content mimetype="text/xml" icon="xml" label="menu.create-content.xml" />
      <content mimetype="xml/custom1" icon="xml" label="menu.create-content.custom1" formid="custom1-common-form"/>
      <content mimetype="xml/custom2" icon="xml" label="menu.create-content.custom2" formid="custom2-common-form"/>
   </createContent>
(thus, those two modules will have to be installed together to work)

So, my question is : is there a way I could define 'partially' those files ?
Maybe something like the following in a boostrap… ?
<web-extension>
   <site-webscript>
      <org>
         <alfresco>
            <components>
               <documentlibrary>
                  <toolbar.get.config.xml>
                     <addChildTo xpath="/toolbar/createContent">
                        <content mimetype="xml/custom1" icon="xml" label="menu.create-content.custom1" formid="custom1-common-form"/>
                     </addChildTo>
                     <removeNode xpath="/toolbar/createContent/content[@mimetype="text/html"]"/>
                     <modifyNode>… etc.
                  </toolbar.get.config.xml>
               </documentlibrary>
            </components>
         </alfresco>
      </org>
   </site-webscript>

Outcomes