xmlalfrescoalfresco-sharealfresco-webscriptsalfresco-enterprise

Custom Alfresco Model with UUID default value


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?


Solution

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