cancel
Showing results for 
Search instead for 
Did you mean: 

how to add multiple content types

plakshmi
Champ in-the-making
Champ in-the-making
Hi
I am new to Alfresco. I am working on a requirement wherein a separate content type(with corresponding fields) has to attached while adding different types of documents.
I created a custom content type (say Category 1) by modifying customModel.xml, web-client-config-custom.xml and defining my model in custom-model-context.xml.
My new content type (Category 1) is getting listed in the Content Tpye drop-down menu and I could succesfully attach values to the document as defined in Category 1.

Now that I want to add another content type (say Category 2 with a differnt set of fields) to the Content Type menu, I am unable to succeed.
This is what I did:
1. created a new file custom1Model.xml and defined my new model "res.customModel" with types , imports, namespaces etc similar to customModel.xml.
2. modified web-client-config-custom.xml to display and invoke my new model when selected.
3. In custom-model-context.xml made changes as below:
<bean id="extension.dictionaryBootstrap" parent="dictionaryModelBootstrap" depends-on="dictionaryBootstrap">
        <property name="models">
            <list>
                <value>alfresco/extension/customModel.xml</value>
               <value>alfresco/extension/custom1Model.xml</value>

           </list>
        </property>
    </bean>


I am getting the following errors:
15:05:47,968 ERROR [org.springframework.web.context.ContextLoader] Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'extension.dictionaryBootstrap' defined in file [C:\Alfresco\tomcat\shared\classes\alfresco\extension\custom-model-context.xml]: Invocation of init method failed; nested exception is org.alfresco.service.cmr.dictionary.DictionaryException: 11110001 Could not import bootstrap model alfresco/extension/custom1Model.xml
Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 11110001 Could not import bootstrap model alfresco/extension/custom1Model.xml
.
.
.
.Caused by: org.alfresco.service.cmr.dictionary.DictionaryException: 11110000 Failed to compile model res.customModel
   at org.alfresco.repo.dictionary.CompiledModel.<init>(CompiledModel.java:112)
   at org.alfresco.repo.dictionary.M2Model.compile(M2Model.java:134)
   at org.alfresco.repo.dictionary.DictionaryDAOImpl.putModel(DictionaryDAOImpl.java:274)
   at org.alfresco.repo.dictionary.DictionaryBootstrap.onDictionaryInit(DictionaryBootstrap.java:147)
   … 43 more
Caused by: org.alfresco.service.namespace.NamespaceException: Namespace prefix  is not mapped to a namespace URI
   at org.alfresco.service.namespace.QName.createQName(QName.java:105)
   at org.alfresco.service.namespace.QName.createQName(QName.java:127)
   at org.alfresco.repo.dictionary.M2ModelDefinition.<init>(M2ModelDefinition.java:47)
   at org.alfresco.repo.dictionary.CompiledModel.constructDefinitions(CompiledModel.java:137)
   at org.alfresco.repo.dictionary.CompiledModel.<init>(CompiledModel.java:94)
   … 46 more


I want to know if my approach is correct and what could be the problem.

Thanks
Ponnulakshmi.
7 REPLIES 7

kbonnet
Champ in-the-making
Champ in-the-making
Your custom1model.xml is not valid. Thats what the error says. If you post your models here people can have a look. But first, open the file in internet explorer or whatever to validate the XML. If the XML is valid the model can still be invalid.

plakshmi
Champ in-the-making
Champ in-the-making
Hi
  This my Custom1 model.xml :
<?xml version="1.0" encoding="UTF-8"?>

<!– Second model –>

<model name="res.customModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <description>Resume DB</description>
   <author></author>
   <version>1.0</version>

<imports>
   <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
   <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
</imports>

<namespaces>
   <namespace uri="res.model" prefix="res"/>
</namespaces>

<types>
   <type name="res:resume_db">
      <title>Resume ID</title>
      <parent>cm:content</parent>

   <properties>
      <property name="res:resume_id">
      <title>Resume ID</title>
      <type>d:int</type>
      </property>

      <property name="res:jd_id">
      <title>Reference JD ID</title>
      <type>d:int</type>
      </property>
   
      <property name="res:resume_date">
      <title>Resume Submitted on:</title>
      <type>d:date</type>
      </property>
   </properties>
   </type>
</types>

</model>

Thanks
Ponnulakshmi

kbonnet
Champ in-the-making
Champ in-the-making
On first sight, i dont see anything wrong. But i suspect you used the same namespace and name in your both models? They have to be unique.

Koen

plakshmi
Champ in-the-making
Champ in-the-making
hi
Thanks for your suggestion. I tried making few changes in my custom1Model.xml, but getting the same errors.  I am attaching the 2 files, customModel.xml, custom1Model.xml. Can u tell me if there is anything wrong.

customModel.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!– Custom Model –>
<model name="custom:customModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
   <description>Job Description Model</description>
   <author></author>
   <version>1.0</version>

   <imports>
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>

   <namespaces>
      <namespace uri="custom.model" prefix="custom"/>
   </namespaces>
<types>
   <type name="custom:jobdescription">
      <title>Job description content type</title>
      <parent>cm:content</parent>
    <properties>
      <property name="custom:jd_id">
      <title>Job description No</title>
      <type>d:int</type>
      </property>
      <property name="custom:dept">
      <title>Department</title>
      <type>d:text</type>
      </property>
      <property name="custom:initiator_name">
      <title>JD Initiator name</title>
      <type>d:text</type>
      </property>
   </properties>
</type>
</types>
</model>
                                          

& here is my custom1Model.xml:

<?xml version="1.0" encoding="UTF-8"?>
<!– Second model –>

<model name="res.resModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
<description>Resume DB</description>
<author></author>
<version>1.0</version>

<imports>
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
</imports>

<namespaces>
<namespace uri="res.model" prefix="res"/>
</namespaces>

<types>
<type name="res:resume_db">
<title>Resume ID</title>
<parent>cm:content</parent>

<properties>
<property name="res:resume_id">
<title>Resume ID</title>
<type>d:int</type>
</property>

<property name="res:jd_id">
<title>Reference JD ID</title>
<type>d:int</type>
</property>

<property name="res:resume_date">
<title>Resume Submitted on:</title>
<type>d:date</type>
</property>
</properties>
</type>
</types>

</model>

thanks in advance
Ponnulakshmi.

kbonnet
Champ in-the-making
Champ in-the-making
Maybe you can develop your model with increments. First activate one model. If it fails, strip the properties from it. If it still fails you have a limited piece of model to check. It it succeeds to load add the properties after another. When one model loads, do the same for the other. I still cant see anything wrong.

It complains about the namespace. I have seen examples where the namespace is like yours, but usually the name space is a fully qualified domain name and some specifics behind. We use for example:

<namespace uri="http://www.contezza.org/alfresco/model/resume/1.0" prefix="res"/>

And when you develop your model, use the possibility of dynamic models. That way you can add your models in the models space in data dictionary and activate them. That way you dont need to restart alffresco all the time.

Good luck again.

Koen

plakshmi
Champ in-the-making
Champ in-the-making
Hi Koen
Thanks for ur input. I shall work on it and let u know on Monday.

-Ponnulakshmi.

plakshmi
Champ in-the-making
Champ in-the-making
Hi Koen
My model is finally working. There was just a small mistake in my model name definition.
I had mentioned my model name as model name="res.resModel"  instead of model name="res:resModel" .
I took so much time for me to debug. Smiley Happy . Thanks for ur valuable input.

-Ponnulakshmi.