cancel
Showing results for 
Search instead for 
Did you mean: 

Why has a type extending sys:base the attribute cm:name?

gertschi
Champ in-the-making
Champ in-the-making
Hello,
I've created my own content model where I defined a few types. Each of those types extends sys:base.
Whenever I create nodes of those types with the Java API - nodeService.createNode() - Alfresco adds the attribute cm:name to it. The value is always the same as the node-uuid.

Why is Alfresco doing this? How can I prevent it from happening?
I don't need that attribute. In fact it's causing problems when I use CopyService.copy() to copy such a node. Alfresco can't insert the copied node within the same cm:folder since the name is the same. As a workaround I've created my own folder type which allows duplicates. However, that's quite ugly and now the unused cm:name of the copied nodes has values that doesn't correspond with the actual node-uuid anymore. That can be a little bit confusing.

I'd be grateful if someone could explain why this is happening and how this behaviour can be alterd.

BTW: I'm currently using Alfresco 3.4b.
2 REPLIES 2

amitabhandari1
Champ in-the-making
Champ in-the-making
Hi gertschi,

If you have to create your own content type for content then you have to extend with cm:content not sys:base.
If you are creating your own folder type for folder then you have to extend with cm:folder not sys:base.

For eg : create type in any custom model .xml
<types>
      <type name="kgk:hcpClient">
         <title>KGK HCP Credentials (HCP Client)</title>
         <parent>cm:content</parent>
         <properties>
            <property name="kgk:hcp_id">
               <title>HCP Number</title>
               <type>d:int</type>
               <mandatory>true</mandatory>
            </property>
            <property name="kgk:assignment_id">
               <title>Assignment No</title>
               <type>d:int</type>
               <mandatory>true</mandatory>
               <default>0</default>
               <index enabled="false">
               </index>
            </property>
            <property name="kgk:hcpCertificate">
               <type>d:text</type>
               <mandatory>true</mandatory>
            </property>
            <property name="kgk:dateReceived">
            <title>Received Date</title>
               <type>d:date</type>
               <index enabled="false">
               </index>
            </property>
            <property name="kgk:recruiterInitials">
               <type>d:text</type>
               <mandatory>true</mandatory>
            </property>
         </properties>
         <associations>
            <association name="kgk:hcpCertificates">
               <title>HCP Certificates</title>
               <target>
                  <class>cm:content</class>
                  <mandatory>false</mandatory>
                  <many>true</many>
               </target>
            </association>
         </associations>
      </type>
   </types>

Secondly , make entry in web-client-config-custom.xml .

<config evaluator="string-compare" condition="Content Wizards"
      replace="false">
      <content-types>
         <type name="kgk:hcpClient" />
      </content-types>
   </config>

   <config evaluator="node-type" condition="kgk:hcpClient" replace="true">
      <property-sheet>
         <show-property name="author" display-label-id="author"
                        ignore-if-missing="false" show-in-edit-mode="false"/>
         <show-property name="description" display-label="Description"
                        component-generator="DescriptionTextAreaGenerator" />
         <separator name="sep"/>
         <separator name="sep 1"
            display-label="Health Care Professionals Information"
            component-generator="HeaderSeparatorGenerator" />
         <show-property name="kgk:hcp_id" display-label="HCP ID"   />
         <show-property name="kgk:assignment_id" display-label-id = "assignment_id"/>
         <show-property name="kgk:hcpCertificate" />
         <show-property name="kgk:dateReceived"   />
         <show-property name="kgk:recruiterInitials"  display-label="Recruiter Initials"/>
         <separator name="sep 2"/>
         <show-association name="kgk:hcpCertificates" />
              </property-sheet>
   </config>

Thirdy  , Restart your server  and Go to add content wizard . You will find your custom type .

Thanks,

gertschi
Champ in-the-making
Champ in-the-making
The reason why I chose to use sys:base as parent was that I didn't need the cm:auditable aspect and the cm:name property in all my types. However, it looks like Alfresco doesn't care about my wishes and always adds cm:name which is causing problems during copying. Well, I'm now using cm:cmobject as parent for all my types. Copying works now fine as well.

Thanks for your help!