Modulizing me! Time to take a deep breath!

Do you remember on Alfresco Labs?

Yes the time was great for renewing Alfresco´s kind of how we want to work with our informations and with our self. Some things we´d expected of that new approach wasn´t that good after some development with that. But most of the essence of that way brought us to new ways on bringing Open Source to companies … and new thoughts.

As with the most new inventions it is esential to get the next glues on how the product can be enhanced and spreaded accross the globe. This means, spreading innovations in an effective way.

Ask yourself:

How do you think how innovative is your mind to bring a very nice product from your it-company to a potential customer?

How do you adpot business to technique and go straight ahead for the next gread successor of your current product-suite built with Alfresco Share?

Can you create in a businesss-oriented way, such as creating a workflow and ONLY a workflow without building cross-cutting-concersn beaneath, ahead or between your existing Alfresco-Share code?

Do you remember old Alfresco Explorers way which we relyed on it in the past?

I guess you probably get a clue which point i want to turn out.

To get the point, we want summarize the current way on how Share can be extended in a component-like-approach.

We can …

1) … extend Share´s configuration on how nodes can be displayed and performed by actions (search, etc.) AND you can have more than one configuration file as you can see here:

<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN'
'http://www.springframework.org/dtd/spring-beans.dtd'><beans><!-- Load the datalist form config -->

<bean id="customer.module.model.clientConfig" class="org.springframework.extensions.config.ConfigBootstrap" init-method="register">
   <property name="configService" ref="web.config" />
   <property name="configs">
     <list>
       <value>classpath:alfresco/web-extension/customer-module-model-config.xml</value>
     </list>
   </property>

</bean>

</beans>

Just add you custom alfresco-config file at alfresco/web-extension/.

2) Your presets.xml can be applied like your webscripts through an extension-folder. This approach is well suited for all of your projects BUT without the way we want to talk here AND in the future - the component way. So this is a very disadvantage - we need a better way to add custom code to our project - we need something like connectores / adapters alfresco does not provide. So how can we made presets.xml more component-like? Well Alfresco Share IS ABLE to handle multiple presets.xml, for sure. But for unexpectly reasons we can not use that feature right now in a convinient way. So i want to present you a hack-way to get this component-way to the finish-lane:

<bean id="customer.module.core.initializeBean" class="com.westernacher.wps.alfresco.customer.module.core.PresetManagerBean"></bean>

Now add the following java-code:

package com.westernacher.wps.alfresco.customer.module.core;

import java.lang.reflect.Field;
import java.util.List;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.extensions.surf.PresetsManager;

public class PresetManagerBean implements InitializingBean, ApplicationContextAware{

private ApplicationContext applicationContext;

@Override

   public void afterPropertiesSet() throws Exception {

      PresetsManager pmb = (PresetsManager)applicationContext.getBean("webframework.presets.manager");

      Field filesField = pmb.getClass().getDeclaredField("files");

      try {

            filesField.setAccessible(true);
            List<String> files = (List<String>)filesField.get(pmb);

            files.add("presets-customer-module-core.xml");

      }
      catch(Exception e){
         throw new RuntimeException(e);
      }
      finally {
         filesField.setAccessible(false);
     }

}

@Override

      public void setApplicationContext(ApplicationContext applicationContext)
            throws BeansException {

            this.applicationContext = applicationContext;

      }

}

We just adding our own presets.xml file (”presets-customer-module-core.xml”) through java-reflection. Just place your presets.xml file at alfresco/web-extension and you are on the right way.

3) Adding documentlibrary-actions was made until 3.2R in a realy hardly way - through fancy HTML-anchor semantic. As from Alfresco 3.3 we have an XML-orientied way using the Webscripts-Configuration-Files features (webscriptname.mimetype.config.xml). But like ive already told you, you can have only ONE configuration file. Currently there exists no valid solution for that but i gave you another way to solve that. The stupid think on that is, we realy have to edit one alfresco-webscript file to perform our component-approach. So we gonna start with following file /org/alfresco/components/documentlibrary/include/documentlist.lib.js. Please find the function getActionSets and go to the line where alfresco wants to return the actionSets. Place following code above of that code:

var documentActions = siteDetailsUtils.getDocumentActions();
for(var idx = 0; idx < documentActions.length; idx++){

      var documentAction = documentActions[idx];
      var myConfig = new XML(documentAction);

      for each (var xmlActionSet in myConfig..actionSet)
            {

                  actionSet = [];

                  actionSetId = xmlActionSet.@id.toString();

                  prefActionSet = prefActions[actionSetId] || {};

                  defaultOrder = 100;

                  //actionSetId can be document, empty ...
                  logger.getSystem().out("----------------" + actionSetId);
                  for each (var xmlAction in xmlActionSet..action)
                        {

                              defaultOrder++;
                              actionId = xmlAction.@id.toString();

                              actionSet.push(

                                    {

                            order: prefActionSet[actionId] || defaultOrder,
                            id: actionId,
                            type: xmlAction.@type.toString(),
                            permission: xmlAction.@permission.toString(),
                            href: xmlAction.@href.toString(),
                            label: xmlAction.@label.toString()

                        });

                  logger.getSystem().out("----------------" + actionId);

            }

      var actions = actionSet.sort(sortByOrder);

      for(var k = 0; k < actions.length; k++){

            actionSets[actionSetId].push(actions[k]);

      }}

}

Next, add the sitedetailsutils through xml so we make available this java-functionality through javascript:

   <bean id="customer.module.core.siteDetailsUtils" class="com.westernacher.wps.alfresco.customer.module.core.SiteDetailsUtils" />   

<bean id="webscripts.container" parent="webscripts.abstractcontainer" class="org.springframework.extensions.webscripts.LocalWebScriptRuntimeContainer">
      <property name="name"><value>Spring Surf Container</value></property>
      <property name="registry" ref="webscripts.registry" />
      <property name="searchPath" ref="webframework.webscripts.searchpath" />
      <property name="templateProcessorRegistry" ref="webframework.webscripts.registry.templateprocessor" />
      <property name="scriptProcessorRegistry" ref="webframework.webscripts.registry.scriptprocessor" />
      <property name="configService" ref="web.config" />
      <property name="scriptObjects">

         <map merge="true">
            <entry key="remote" value-ref="webframework.webscripts.scriptremote" />
 	    <entry key="siteDetailsUtils" value-ref="customer.module.core.siteDetailsUtils" />
         </map>

      </property>

      <property name="processorModelHelper" ref="processor.model.helper"></property>

   </bean>

Now add your custom document-actions through the same xml-file:

<documentList>
   <actionSets>
      <actionSet id="empty"></actionSet>

      <actionSet id="document">

         <action type="action-link" id="onActionDetails" permission="edit" label="actions.document.edit-metadata" />
         <action type="action-link" id="onActionCopyMetadata" permission="edit" label="actions.document.manage-copymetadata" />
	     <action type="action-link" id="onActionApplyMetadata" permission="edit" label="actions.document.manage-applymetadata" />

      </actionSet>

   </actionSets>
</documentList>

This was just a view notes on it - if i have time i want to continue that in next time.

Comments

Leave a Reply




Security Code: