AnsweredAssumed Answered

OnContentRead behavior

Question asked by cristianfrog on Dec 14, 2013
Latest reply on Dec 19, 2013 by cristianfrog
Three days I'm stuck on this:

I want to execute a script when users READ files on Alfresco. I read Jeff Potts guide "Implementing custom behaviors" and tried to create a behavior using OnContentRead policy.

This is what I did until now:

Modified custom-model-context.xml like this:


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

<beans>

    <!– Registration of new models –>   
    <bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/customModel.xml</value>
            </list>
        </property>
    </bean>
         
<bean id="onContentReadpolicy" class="org.alfresco.repo.policy.registration.ClassPolicyRegistration" parent="policyRegistration">
      <property name="policyName">
         <value>{http://www.alfresco.org}onContentRead</value>
      </property>
      <property name="className">
         <value>{http://www.alfresco.org/model/content/1.0}content</value>
      </property>
      <property name="behaviour">
         <bean class="org.alfresco.repo.jscript.ScriptBehaviour" parent="scriptBehaviour">
            <property name="location">
               <bean class="org.alfresco.repo.jscript.ClasspathScriptLocation">
                  <constructor-arg>
                     <value>alfresco/extension/scripts/myscript.js</value>
                  </constructor-arg>
               </bean>
            </property>
         </bean>
      </property>
</bean>

</beans>


And added a simple myscript.js in alfresco/extension/scripts.

When I restart Alfresco it doesn't work, it seems to crash at all…
I'm pretty sure I'm doing something wrong, I looked at alfresco.log but can't understand what's the problem…

Hope in some help!

P.S. I'm using Alfresco Community version 4.2.e on Windows 7 machine

Outcomes