AnsweredAssumed Answered

Custom Action not working

Question asked by doblek on Feb 13, 2007
Latest reply on Feb 14, 2007 by doblek
Hi all,

I don't know if this is the appropiate forum, but I'll give it a shot…


I'm trying to develop a Custom Action following the steps that I've founded in the wiki:
So, taking these guidelines into account, I've created the following files:

[size=150]01_tagsModel.xml[/size] [located at 'WEB-INF/classes/alfresco/extension' folder]

<?xml version="1.0" encoding="UTF-8"?>

<!– Definition of new Model –>
<model name="tag:tagsmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!– Optional meta-data about the model –>  
   <description>Tagging Model</description>
   <author>Gavin Cornwell</author>
   <version>1.0</version>

   <!– Imports are required to allow references to definitions in other models –>  
   <imports>
      <!– Import Alfresco Dictionary Definitions –>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <!– Import Alfresco Content Domain Model Definitions –>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>

   <!– Introduction of new namespaces defined by this model –>
   <namespaces>
      <namespace uri="extension.tags" prefix="tag"/>
   </namespaces>
 
    <aspects>
     
      <!– Definition of new Taggable Aspect –>
      <aspect name="tag:taggable">
         <title>Taggable</title>
         <properties>
            <property name="tag:tags">
               <title>Tags</title>
               <type>d:text</type>
               <multiple>true</multiple>
            </property>
         </properties>
      </aspect>
     
   </aspects>
  
</model>

[size=150]01_tags-context.xml[/size] [located at 'WEB-INF/classes/alfresco/extension' folder]

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

<!– Tags bean definitions –>
<beans>
   <bean id="tags.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
      <property name="models">
         <list>
            <value>alfresco/extension/01_tagsModel.xml</value>
         </list>
      </property>
   </bean>
   
   <!– <bean id="tag" class="org.alfresco.sample.TagActionExecuter" parent="action-executer" > –>
   <bean id="tag" class="dit.alfresco.ext.action.executer.TagActionExecuter" parent="action-executer" >
      <property name="nodeService">
         <ref bean="nodeService" />
      </property>
   </bean>
   
   <bean id="tag-action-messages" class="org.alfresco.i18n.ResourceBundleBootstrapComponent">
      <property name="resourceBundles">
         <list>
            <value>dit.alfresco.ext.action.executer.01_tag-action-messages</value>
         </list>
      </property>
   </bean>

</beans>

And I have an ext-action-tag.jar file at 'WEB-INF/lib' containing:
dit»alfresco»ext»action»executer»TagActionExecuter.class
dit»alfresco»ext»action»executer»01_tag-action-messages.properties

where the java file is:

package dit.alfresco.ext.action.executer;

import org.alfresco.repo.action.executer.*;
import org.alfresco.service.cmr.repository.*;
import org.alfresco.service.cmr.action.Action;
import org.alfresco.service.cmr.action.ParameterDefinition;
import org.alfresco.service.namespace.QName;
import java.util.List;

public class TagActionExecuter extends ActionExecuterAbstractBase
{
      public static final String NAME = "tag";

      private NodeService nodeService;

      public void setNodeService(NodeService nodeService)
      {
         this.nodeService = nodeService;
      }
     
      @Override
      public void executeImpl(Action action, NodeRef actionedUponNodeRef){
         if (this.nodeService.exists(actionedUponNodeRef) == true){
            // add the aspect if it is not already present on the node
            QName tagAspect = QName.createQName("extension.tags", "taggable");
            if (this.nodeService.hasAspect(actionedUponNodeRef, tagAspect) == false){
               this.nodeService.addAspect(actionedUponNodeRef, tagAspect, null);
            }
         }
     }
     
      @Override
      protected void addParameterDefintions(List<ParameterDefinition> paramList){
         //there are no parameters
      }
}

but I'm always getting this error message when creating the bean and I don't know why:
18:37:27,778 ERROR [org.apache.catalina.core.ContainerBase.[Catalina].[localhost].[/alfresco]] Excepción enviando evento de contexto destruÃdo a instancia de escuchador de clase org.alfresco.web.app.ContextListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tag' defined in file [C:\apache-tomcat-5.5.17\webapps\alfresco\WEB-INF\classes\alfresco\extension\01_tags-context.xml]: Initialization of bean failed; nested exception is java.lang.AbstractMethodError: null
java.lang.AbstractMethodError
   at org.alfresco.repo.action.ParameterizedItemAbstractBase.getParameterDefintions(ParameterizedItemAbstractBase.java:76)
   at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.getActionDefinition(ActionExecuterAbstractBase.java:97)
   at org.alfresco.repo.action.ActionServiceImpl.registerActionExecuter(ActionServiceImpl.java:549)
   at org.alfresco.repo.action.executer.ActionExecuterAbstractBase.init(ActionExecuterAbstractBase.java:56)
   at sun.reflect.GeneratedMethodAccessor88.invoke(Unknown Source)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:585)
   at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeCustomInitMethod(AbstractAutowireCapableBeanFactory.java:1093)
[…]

Can anyone give some advice, please?
I really need your help.

Regards,
Enrique

Outcomes