Search code examples
alfrescomodelsalfresco-share

Alfresco custom subtypes for cm:folder not working


I tried to to create a new folder type, that inherits everything from cm:folder, so I created an xml file for myModel.xml under tomcat/shared/classes/alfresco/extension/models, and added the following content to it:

<?xml version="1.0" encoding="UTF-8"?>
<!-- xsi:schemaLocation="http://www.alfresco.org/model/dictionary/1.0      modelSchema.xsd" -->
<model name="my:custmodel" 
   xmlns="http://www.alfresco.org/model/dictionary/1.0" 
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

<description>custom folder test</description>
<author>Max Mustermann</author>
<published>2015-11-24</published>
<version>1.0</version>
<imports>
  <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
  <import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/>
</imports>

<namespaces>
  <namespace uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
  <namespace uri="http://www.alfresco.org/model/rendition/1.0" prefix="rn"/>
  <namespace uri="http://www.alfresco.org/model/exif/1.0" prefix="exif"/>
  <namespace uri="http://www.alfresco.org/model/audio/1.0" prefix="audio"/>
  <namespace uri="http://www.alfresco.org/model/webdav/1.0" prefix="webdav"/>
  <namespace uri="http://www.example.com/model/content/1.0" prefix="my" />
</namespaces>

<types>
<type name="my:folder1">
    <title>folder1</title>
    <parent>cm:folder</parent>
    <archive>true</archive>
 </type>
 <type name="my:folder2">
    <title>folder2</title>
    <parent>cm:folder</parent>
    <archive>true</archive>
 </type>
 </types>

then I added the following line to tomcat/shared/classes/alfresco/extension/custom-model-context.xml

<value>alfresco/extension/models/myModel.xml</value>

and finally in tomcat/shared/classes/alfresco/web-extension/share-config-custom.xml:

<type name="cm:folder">
            <subtype name="my:folder1" />
            <subtype name="my:folder2" />
</type>

Now the under details->change Typ, my subtypes appear, but when I try to apply them I get "cannot change type of document ..."


Solution

  • Your model file name in context file is mentioned as

    <value>alfresco/extension/models/custModel.xml</value>
    

    in your description you are saying name as "myModel.xml" is that a typo? Otherwise your file entries looks okey. Hope you are placing those entries properly.

    This entry

    <namespace uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
    

    should be part of <imports> tag not <namespaces>

    Something like this

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