Custom Alfresco Model with UUID default value

223 views Asked by At

I want to add a new property to the alfresco model which will have the node-uuid as default value.

 <type name="nemo:Pdossier">
                <title>Dossier Nemo</title>
                <parent>cm:folder</parent>
                <properties>
                    <property name="nemo:etatDossier">
                        <type>d:text</type>
                    </property>
                    <!-- Nouveau UUID qui sera utilisé lors de la migration d'alfresco -->
                    <property name="client:uuidClientFolder">
                        <type>d:text</type>
                        <default>????</default>
                    </property>
                </properties>
            </type>

how can I access the value of node-uuid?

1

There are 1 answers

0
Jeff Potts On BEST ANSWER

As Gagravarr mentioned, use a behavior. The code in the behavior would look something like:

@Override
public void onUpdateNode(NodeRef nodeRef) {
    String uuid = (String) nodeService.getProperty(nodeRef, PROP_UNIQUE_ID);        
    final QName PROP_UUID_CLIENT_FOLDER = QName.createQName("http://www.your.namespace.uri/model/1.0","uuidClientFolder");
    nodeService.setProperty(nodeRef, PROP_UUID_CLIENT_FOLDER, uuid);
}

If you've never implemented a behavior before, take a look at my tutorial for an example.