cancel
Showing results for 
Search instead for 
Did you mean: 

Defining group of actions in a module

bgl
Champ on-the-rise
Champ on-the-rise
Hi,

I would like to add new group of actions (specified in web-client-config-actions.xml) defined for the purpose of my own module.
I thought it would work like the web-client-config.xml, adding a web-client-config-actions-custom.xml would make the trick…but that is not the case.

After searching, I found in web-client-application-context.xml this:


   <bean id="webClientConfigSource" class="org.alfresco.config.source.UrlConfigSource">
      <constructor-arg>
         <list>
            <value>classpath:alfresco/web-client-config.xml</value>
            <value>classpath:alfresco/web-client-config-dialogs.xml</value>
            <value>classpath:alfresco/web-client-config-wizards.xml</value>
            <value>classpath:alfresco/web-client-config-properties.xml</value>
            <value>classpath:alfresco/web-client-config-navigation.xml</value>
            <value>classpath:alfresco/web-client-config-wcm.xml</value>
            <value>classpath:alfresco/web-client-config-actions.xml</value>
            <value>classpath:alfresco/web-client-config-forum-actions.xml</value>
            <value>classpath:alfresco/web-client-config-wcm-actions.xml</value>
            <value>classpath:alfresco/web-client-config-workflow-actions.xml</value>
            <value>classpath:alfresco/extension/web-client-config-custom.xml</value>
            <value>jar:*!/META-INF/web-client-config-custom.xml</value>
         </list>
      </constructor-arg>
   </bean>

Now I understand much better the tips&tricks about web-client-config-custom.xml in jar file. But I'm afraid I cannot declare my set of actions.

I'm trying to do the following:
  create a custom drop down menu (following the code of create space) to create some special space with special attributes that can be filled at creation time.

I have my own browse.jsp which is a copy/paste from alfresco war but I have added a menu. This menu expects a group of actions defined in my META-INF/web-client-config-actions-custom.xml but it is not loaded.

If I add in the web-client-application-context.xml the following:

<value>jar:*!/META-INF/web-client-config-actions-custom.xml</value>

where I saw the web-client-config-custom, it seems to be found.

Is this an issue or a design choice ? if the last option, how can I do ? If it is the first option, do I have to raise an issue ? (I've checked quickly jira searching for web-client-application-context.xml but did not find any…may be my criteria was incorrect…)

Thx for reading this loooong post and proposing something  :wink:
10 REPLIES 10

gavinc
Champ in-the-making
Champ in-the-making
OK, you shouldn't need the JAR approach for your case, I'll explain in a minute what it's useful for.

For your scenario a single file called web-client-config-custom.xml should be sufficient. This needs to be placed in the alfresco/extension package. The easiest place to put it is in the Tomcat shared folder i.e. /opt/alfresco/tomcat/shared/classes/alfresco/extension

This file is already included in the list of files read in as you can see from what you found in web-client-application-context.xml so you don't need to change any other files.

A reason this might not get read is if you have multiple web-client-config-custom.xml files on your classpath i.e. there is one from another AMP installed. You can see what file is getting read in by turning on debugging for the config. Add the following line to log4j.properties:

log4j.logger.org.alfresco.config=debug

Have a look for the web-client-config-custom.xml file and where its loaded from, this may give you some clues.

As for the JAR file approach, this is only required if you hit the multiple custom config file problem just explained.

Hope this helps.

bgl
Champ on-the-rise
Champ on-the-rise
Thanks for your answer Gavin.

I had read about web-client-config-custom.xml so I was aware about this.

My goal was rather to keep this "clean" structure for web-client configuration files: Alfresco supplies one file for action, one for dialog, and so on. So the goal was to reproduce this structure with the -custom suffix as for web-client-config.xml and web-client-config-custom.xml

From what I see, it is not possible without patching the file web-client-application-context.xml
Do you confirm ?

My requirement/use case was not very well explained. Sorry about that. Is it clearer ? If not I can try to explain it in another way.

thanks again for your sharp answer, as usual !

Cheers

Boris

gavinc
Champ in-the-making
Champ in-the-making
Ahh, I see what you mean now.

Yes, you can do this without patching, what you need to do is override the spring bean definition for 'webClientConfigSource' in web-client-application-context.xml.

Using the standard override mechanism for spring config files (see http://wiki.alfresco.com/wiki/Repository_Configuration) you can replace the list of files with your own, so in your own context file i.e. my-custom-context.xml you could have the following:

<beans>
   <bean id="webClientConfigSource" class="org.alfresco.config.source.UrlConfigSource">
     <constructor-arg>
       <list>
          <value>classpath:alfresco/web-client-config.xml</value>
          <value>classpath:alfresco/web-client-config-dialogs.xml</value>
          <value>classpath:alfresco/web-client-config-wizards.xml</value>
          <value>classpath:alfresco/web-client-config-properties.xml</value>
          <value>classpath:alfresco/web-client-config-navigation.xml</value>
          <value>classpath:alfresco/web-client-config-wcm.xml</value>
          <value>classpath:alfresco/web-client-config-actions.xml</value>
          <value>classpath:alfresco/web-client-config-forum-actions.xml</value>
          <value>classpath:alfresco/web-client-config-wcm-actions.xml</value>
          <value>classpath:alfresco/web-client-config-workflow-actions.xml</value>
          <value>classpath:alfresco/extension/web-client-config-custom.xml</value>
          <value>jar:*!/META-INF/web-client-config-custom.xml</value>
          <value>classpath:alfresco/extension/web-client-config-actions-custom.xml</value>
          <value>classpath:alfresco/extension/web-client-config-properties-custom.xml</value>
          etc….
      </list>
    </constructor-arg>
  </bean>
</beans>

bgl
Champ on-the-rise
Champ on-the-rise
Hi Gavin,

I have tried this but I get into a problem.

I have a module that contains files in the META-INF of the jar.

I have added the following to the module-context.xml in the alfresco/config/extension folder:


  <bean id="webClientConfigSource"
        class="org.alfresco.config.source.UrlConfigSource">
    <constructor-arg>
      <list>
        <value>classpath:alfresco/web-client-config.xml</value>
        <value>classpath:alfresco/web-client-config-dialogs.xml</value>
        <value>classpath:alfresco/web-client-config-wizards.xml</value>
        <value>classpath:alfresco/web-client-config-properties.xml</value>
        <value>classpath:alfresco/web-client-config-navigation.xml</value>
        <value>classpath:alfresco/web-client-config-wcm.xml</value>
        <value>classpath:alfresco/web-client-config-actions.xml</value>
        <value>classpath:alfresco/web-client-config-forum-actions.xml</value>
        <value>classpath:alfresco/web-client-config-wcm-actions.xml</value>
        <value>classpath:alfresco/web-client-config-workflow-actions.xml</value>
        <value>classpath:alfresco/extension/web-client-config-custom.xml</value>
        <value>jar:*!/META-INF/web-client-config-custom.xml</value>
        <value>jar:*!/META-INF/web-client-config-actions-custom.xml</value>
        <value>jar:*!/META-INF/web-client-config-dialog-custom.xml</value>
      </list>
    </constructor-arg>
  </bean>

Unfortunately, my directives seem to be ignored. The trace of the config (at debug level in log4j.properties) never talk about this web-client-config-actions-custom.xml file but still mention the web-client-config-custom.xml.

Do I have to mention them elsewhere than in my module context ?

Any idea ?

Thanks in advance.

gavinc
Champ in-the-making
Champ in-the-making
Yes, you have put your module-context.xml file in the wrong location. Have a look at the wiki page for details: http://wiki.alfresco.com/wiki/Developing_an_Alfresco_Module

It needs to go in a package of the form: alfresco.module.<moduleId>

bgl
Champ on-the-rise
Champ on-the-rise
Hi Gavin,

sorry for the late reply.
Thanks to your solution, I see the file web-client-config-actions-custom.xml loaded now !! Great ! But (yes sorry there is a "but") my action is still not found. It used to work when I was patching the alfresco file.
What I understand is the following: my bean is overriden by the alfresco one (webClientConfigSource). If I rename my bean module-webClientConfigSource, I have the following trace in the log:


10:19:19,915 INFO  [config.source.UrlConfigSource] Found META-INF/web-client-config-custom.xml in file:/home/lenzinge/apache-tomcat-5.5.23/webapps/alfresco/WEB-INF/lib/alfrescoConfig.jar
10:19:19,935 INFO  [config.source.UrlConfigSource] Found META-INF/web-client-config-custom.xml in file:/home/lenzinge/apache-tomcat-5.5.23/webapps/alfresco/WEB-INF/lib/voyages.jar
10:19:19,953 INFO  [config.source.UrlConfigSource] Found META-INF/web-client-config-actions-custom.xml in file:/home/lenzinge/apache-tomcat-5.5.23/webapps/alfresco/WEB-INF/lib/voyages.jar
10:19:19,969 INFO  [config.source.UrlConfigSource] Found META-INF/web-client-config-dialog-custom.xml in file:/home/lenzinge/apache-tomcat-5.5.23/webapps/alfresco/WEB-INF/lib/voyages.jar
10:19:19,991 INFO  [config.source.UrlConfigSource] Found META-INF/web-client-config-custom.xml in file:/home/lenzinge/apache-tomcat-5.5.23/webapps/alfresco/WEB-INF/lib/alfrescoConfig.jar
10:19:20,000 INFO  [config.source.UrlConfigSource] Found META-INF/web-client-config-custom.xml in file:/home/lenzinge/apache-tomcat-5.5.23/webapps/alfresco/WEB-INF/lib/voyages.jar

which shows that the files about actions and dialogs are found. Note the 2 times web-client-config-custom.xml loaded from the same jar which tends to indicates 2 instanciations…

My problem is now: how to use the new bean ? I've checked where the webClientConfigSource bean is used. It is used by bean webClientConfigService. So I would need to create this bean in my xml file. I've tried but it is the same which is in fact very logical. Alfresco beans are instanciated at last. I thought to force instanciation using a depends-on attribute and then create my own webClientConfigService. But it is becoming very tricky and not sure it is very very good for maintenance (anyway does not work…tried it just to be sure Smiley Happy )

So, I don't really see a solution for splitting web-client-config-custom.xml into multiple files. Adding the actions tag in web-client-config-custom.xml makes the thing of course but this is not a "clean" solution in my mind (I would prefer one file per topic as alfresco team does).

Am I missing something ?

gavinc
Champ in-the-making
Champ in-the-making
You don't need to change the bean name, in fact, you should keep it the same i.e. 'webClientConfigSource'. If you rename this bean or the 'webClientConfigService' bean you are going to have to change core Alfresco code as it is looking up a bean called "webClientConfigService".

Maybe you can post the application-context.xml file you are now using?

bgl
Champ on-the-rise
Champ on-the-rise
I agree with the name: I have to change the core which is the last thing I want to do.

Here is my module-context.xml file:


<beans>
   <bean id="webClientConfigSource"  
              class="org.alfresco.config.source.UrlConfigSource">
     <constructor-arg>
       <list>
          <value>classpath:alfresco/web-client-config.xml</value>
          <value>classpath:alfresco/web-client-config-dialogs.xml</value>
          <value>classpath:alfresco/web-client-config-wizards.xml</value>
          <value>classpath:alfresco/web-client-config-properties.xml</value>
          <value>classpath:alfresco/web-client-config-navigation.xml</value>
          <value>classpath:alfresco/web-client-config-wcm.xml</value>
          <value>classpath:alfresco/web-client-config-actions.xml</value>
          <value>classpath:alfresco/web-client-config-forum-actions.xml</value>
          <value>classpath:alfresco/web-client-config-wcm-actions.xml</value>
          <value>classpath:alfresco/web-client-config-workflow-actions.xml</value>
          <value>classpath:alfresco/extension/web-client-config-custom.xml</value>
          <value>jar:*!/META-INF/web-client-config-custom.xml</value>
          <value>jar:*!/META-INF/web-client-config-actions-custom.xml</value>
          <value>jar:*!/META-INF/web-client-config-dialogs-custom.xml</value>
      </list>
    </constructor-arg>
  </bean>
</beans>

I thought this would have overriden the definition of the bean. But when Alfresco starts, it does not say "Found web-client-config-actions-custom.xml in jar"…but I know there is one. If I patch the application-context of Alfresco "manually", it finds the file.
If I have a different name for the bean, it says it finds the file.

I probably do something wrong but I cannot find what  :?

Do you need more files ?

gavinc
Champ in-the-making
Champ in-the-making
OK, I think I've got to the bottom of the problem, it's an ordering issue.

The module-context.xml file is getting loaded before the web-client-application-context.xml file (this can be seen in web.xml) so basically our "webClientConfigSource" bean definition is getting loaded AFTER the AMP definition and thus overriding it, hence you are not seeing it get loaded!

There are a couple of options, you can obviously put all your config in the one web-client-config-custom.xml or you can use an AMP mechanism I had forgotten about Smiley Surprisedops:

There is a way to define a list of your own web client config files as part of the AMP definition. If you look at the module-context.xml file for the blog integration module ( found in root/modules/blog-integration/config/alfresco/module/org.alfresco.module.blogintegration) you' ll find the following section:

<bean id="org_alfresco_module_blogIntegration_ConfigBootstrap" class="org.alfresco.web.config.WebClientConfigBootstrap" init-method="init">
    <property name="configs">
      <list>
         <value>classpath:alfresco/module/org.alfresco.module.blogIntegration/ui/web-client-custom.xml</value>
      </list>
    </property>
</bean>


You can place your config in this block, this will then append these files to the standard set of web client config files when the AMP gets loaded. The bean name does not matter so your config could look like the following:


<bean id="Your_Module_ConfigBootstrap" class="org.alfresco.web.config.WebClientConfigBootstrap" init-method="init">
    <property name="configs">
      <list>
         <value>jar:*!/META-INF/web-client-config-custom.xml</value>
         <value>jar:*!/META-INF/web-client-config-actions-custom.xml</value>
         <value>jar:*!/META-INF/web-client-config-dialogs-custom.xml</value>
      </list>
    </property>
</bean>

Try this and let us know how it goes.