cancel
Showing results for 
Search instead for 
Did you mean: 

Merge files from web-extension

gric
Champ in-the-making
Champ in-the-making
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 Smiley Sad !

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>
1 REPLY 1

mikeh
Star Contributor
Star Contributor
Generally we recommend that modification that modify existing files should be placed in the web-extensions folder directly, i.e. not in an AMP or JAR. That way you've only got exactly ONE override.

New functionality can be added via AMP or JAR. Yes, you can override using those mechanisms, but you run into the problem you've just encountered. Whilst your bootstrap idea is a clever one, it would only work for config files, not implementation.

Thanks,
Mike