cancel
Showing results for 
Search instead for 
Did you mean: 

new Aspect, mimic of auditable: init fired not other methods

jbaton
Champ in-the-making
Champ in-the-making
Hi all,

I'm facing a problem on aspect creation (1.1 OS jboss bundle … rebuilded)

I've created a new aspect, it contains a sole date.
I need it to be initialised.
I made the corresponding class on the example of the AuditableAspect class.
The aspect appears in the UI, the init method is fired but not the onCreate/onUpdate/onAdd methods.

I've binded those methods in the same way that in the 'auditable' aspect.

I believe the problem is that the methods are 'badly' registered.
Looking at AuditableAspect.init() , I can not figure out what are the parameters of policyComponent.bindClassBehaviour().

The first QName is based on "http://www.alfresco.org" which does not appear in contentModel.xml where the auditable aspect is defined.

The second parameter, seems to use the namespace uri defined in the custom model (xpath like path == model/namespaces/namespace/uri)
The third parameter is a Behaviour instance.

How should one select the value of the first QName parameter ?

Thanks for your time.


Jerome


Here is the java code (excerp)

public void init() {
// Create behaviours
onCreateObsoDate    = new JavaBehaviour(this, "onCreateObsoDate");
onAddObsoDate       = new JavaBehaviour(this, "onAddObsoDate");
onUpdateObsoDate    = new JavaBehaviour(this, "onUpdateObsoDate");
       
QName ASPECT_OBSO = QName.createQName("http://www.toto.com/ged/obso", "obsolescence");
       
policyComponent.bindClassBehaviour(QName.createQName("http://www.toto.com/ged/obso", "onCreateNode"),ASPECT_OBSO, onCreateObsoDate);
      
      policyComponent.bindClassBehaviour(QName.createQName("http://www.toto.com/ged/obso", "onAddAspect"), ASPECT_OBSO, onAddObsoDate);
       
policyComponent.bindClassBehaviour(QName.createQName("http://www.toto.com/ged/obso", "onUpdateNode"), ASPECT_OBSO, onUpdateObsoDate);


Here is the custom model


<model name="gc:obso_model" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <description>custom Model for obsolescence date (GED-2)</description>
   <author></author>
   <version>1.0</version>

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

   <namespaces>
      <!– Define a Namespace for my new definitions –>
      <namespace uri="http://www.toto.com/ged/obso" prefix="gc"/>
   </namespaces>

   <!– Type and Aspect definitions go here –>
   <types/>
   <aspects>
      <aspect name="gc:obsolescence">
         <title>Date d'obsolescence</title>
         <properties>
            <property name="gc:obso_date">
               <type>d:date</type>
            </property>
         </properties>
      </aspect>
   </aspects>
</model>
1 ACCEPTED ANSWER

rwetherall
Confirmed Champ
Confirmed Champ
Hi Ryan,

The behaviour implementations are bound to the policy using the method bindClassBehaviour.

Eg …



policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"),ASPECT_OBSO, onCreateObsoDate);       


The first parameter is the QName of the policy that you want to bind your behaviour to (or in other terms register interest in).  These policies are well defined elsewhere in the repository although we don't have a central registry of them all.  Something we should do perhaps.

The second parameter is the type restriction.  When the policy is fired the type and aspects of the node in question are looked at and if they match the type restriction we have specified then the policy behaviour will be executed otherwise it will not.  In this way we can add behaviour for specific aspects and types.  For example the auto-version behaviour is only executed for nodes that have the Versionable aspect applied.

The last parameter is the behaviour object, in this case it is a Java Behaviour pointing to a method in this class.  The behaviour can refer to any method in any class as long as it has the correct set of parameters that the policy is expecting.  There is no special prefix naming required.

Eg …



onCreateObsoDate =  new JavaBehaviour(this, "onCreateObsoDate");


In the future you will be able to specify a non Java behaviour so that behaviours can be implemented in other languages, for example Ruby.

Hope this clears things up a little,
Thanks,
Roy

View answer in original post

11 REPLIES 11

xerox
Champ in-the-making
Champ in-the-making
How can I subscribe someone (with the subscribable aspect)
I don't know how to use it?
Can someone help me?

Nick

steel
Champ in-the-making
Champ in-the-making
As I say, v1.2 will provide this support in a much simpler way!

Has the transaction policy handler been updated in the latest release?

thanks