cancel
Showing results for 
Search instead for 
Did you mean: 

Add properties to the user model?

gronfelt
Champ in-the-making
Champ in-the-making
I'd like to extend the user model with a few custom properties of my own (some booleans).

I've read the Wiki page "Data Dictionary Guide", but am still pretty puzzled, since it mostly seems to be about adding new content models. Is that the proper cause of action, to create an entirely new content model and then somehow override the standard user model?

In the end of the wiki page there's a paragraph on modifying content models, but the fact that it begins with the words "Although not recommended" makes me wonder if there's a better way?
1 REPLY 1

jayjayecl
Confirmed Champ
Confirmed Champ
I proceeded as the following :
- create (in tomcat/shared/classes/alfresco/extension) a customModel.xml, declaring the properties I needed for the person model
- create (in tomcat/shared/classes/alfresco/extension/model) a customContentModel.xml, which is almost a copy of the original ContentModel.xml, except the part where I add my aspect to the mandatory ones of cmSmiley Tongueerson model :

<type name="cm:person">
         <title>Person</title>
         <parent>sys:base</parent>
         <properties>
            <!– The tokenisation set here is ignored - it is fixed for this type –>
            <!– This is so you can not break person lookup –>
            <property name="cm:userName">
               <type>d:text</type>
               <mandatory>true</mandatory>
               <constraints>
                  <constraint ref="cm:userNameConstraint" />
               </constraints>
            </property>
            <property name="cm:homeFolder">
               <type>d:noderef</type>
               <mandatory>true</mandatory>
            </property>
             <property name="cm:firstName">
               <type>d:text</type>
               <mandatory>true</mandatory>
            </property>
            <property name="cm:lastName">
               <type>d:text</type>
               <mandatory>true</mandatory>
            </property>
            <property name="cm:middleName">
               <type>d:text</type>
            </property>
            <property name="cm:email">
               <type>d:text</type>
            </property>
            <property name="cm:organizationId">
               <type>d:text</type>
            </property>
            <property name="cm:homeFolderProvider">
               <type>d:text</type>
            </property>
            <property name="cm:defaultHomeFolderPath">
               <type>d:text</type>
            </property>
            <property name="cm:presenceProvider">
               <type>d:text</type>
            </property>
            <property name="cm:presenceUsername">
               <type>d:text</type>
            </property>
            <property name="cm:organization">
               <type>d:text</type>
            </property>
            <property name="cm:jobtitle">
               <type>d:text</type>
            </property>
            <property name="cm:location">
               <type>d:text</type>
            </property>
            <property name="cm:persondescription">
               <type>d:content</type>
            </property>
            <property name="cm:telephone">
               <type>d:text</type>
            </property>
            <property name="cm:mobile">
               <type>d:text</type>
            </property>
            <property name="cm:companyaddress1">
               <type>d:text</type>
            </property>
            <property name="cm:companyaddress2">
               <type>d:text</type>
            </property>
            <property name="cm:companyaddress3">
               <type>d:text</type>
            </property>
            <property name="cm:companypostcode">
               <type>d:text</type>
            </property>
            <property name="cm:companytelephone">
               <type>d:text</type>
            </property>
            <property name="cm:companyfax">
               <type>d:text</type>
            </property>
            <property name="cm:companyemail">
               <type>d:text</type>
            </property>
            <property name="cm:skype">
               <type>d:text</type>
            </property>
            <property name="cm:instantmsg">
               <type>d:text</type>
            </property>
           
            <!– system maintained values –>
            <property name="cm:sizeCurrent">
                <type>d:long</type>
                <protected>true</protected>
            </property>
            <property name="cm:sizeQuota">
                <type>d:long</type>
                <protected>true</protected>
            </property>
         </properties>
        
         <associations>
            <association name="cm:avatar">
               <source>
                  <role>cm:avatarOf</role>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </source>
               <target>
                  <class>cm:content</class>
                  <role>cm:hasAvatar</role>
                  <mandatory>false</mandatory>
                  <many>false</many>
               </target>
            </association>
         </associations>
   
    <mandatory-aspects>
    <aspect>custom:myPersonAspect</aspect>
    </mandatory-aspects>
      </type>

- declared both of my models in my custom-model-context.xml

That way, I did not modify the file contentModel.xml in the webapp.


Of course, I had to begin with a clear alf_data (and DB too) in order to get admin user have the mandatory aspect


Hope this helps