cancel
Showing results for 
Search instead for 
Did you mean: 

Separate aspects and types for re-use

JayQueue
Champ on-the-rise
Champ on-the-rise

Hello,

Situation:
We're creating generic aspects that we want to re-use in different Types. 

So now I have the shared-model.xml

<?xml version="1.0" encoding="UTF-8"?>
<model name="doc:contentModel"
       xmlns="http://www.alfresco.org/model/dictionary/1.0">

    <description>
        Dossier document Datamodel
    </description>

    <author>Author</author>
    <version>1.0.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"/>
        <import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/>
    </imports>

    <namespaces>
        <namespace uri="http://www.site.tld/model/content/socialedienst/1.0" prefix="sd" />
        <namespace uri="http://www.site.tld/model/content/document/1.0" prefix="doc" />
        <namespace uri="http://www.site.tld/model/content/folder/klant/1.0" prefix="klant" />
        <namespace uri="http://www.site.tld/model/content/folder/medewerker/1.0" prefix="medewerker" />
    </namespaces>

    <types>
        <!-- Types
            Socialedienst document: Socialedienst-model.xml
            Socialedienst folder: socialedienstfolder-model.xml
         -->
    </types>

    <aspects>
        <aspect name="doc:dossierDocument">
            <title>Dossier document</title>
            <properties>
                <property name="doc:documentSoort">
                    <type>d:text</type>
                </property>
                <--snip-->
            </properties>
        </aspect>

        <aspect name="sd:socialeDienst">
            <title>Sociale Dienst</title>
            <properties>
                <property name="sd:contactPersoon">
                    <type>d:text</type>
                </property>
                <--snip-->
            </properties>
        </aspect>

        <aspect name="klant:Folder">
            <title>Sociale Dienst Folder</title>
            <properties>
                <property name="klant:rrnr">
                    <type>d:text</type>
                </property>
              <--snip-->
            </properties>
        </aspect>

        <aspect name="medewerker:Folder">
            <title>Medewerker Folder</title>
            <properties>
                <property name="medewerker:rrnr">
                    <type>d:text</type>
                </property>
                <--snip-->
            </properties>
        </aspect>
    </aspects>
</model>

As you can see I want to have the Types in socialedienst-model.xml and socialedienstfolder-xml

Content of socialedienst-model.xml

<?xml version="1.0" encoding="UTF-8"?>
<model name="sd:contentModel"
       xmlns="http://www.alfresco.org/model/dictionary/1.0">

<description> Sociale Dienst Contentmodel </description> <author>Author</author> <version>1.0.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"/> <import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/> <import uri="http://www.site.tld/model/content/socialedienst/1.0" prefix="sd" /> <import uri="http://www.site.tld/model/content/document/1.0" prefix="doc" /> </imports> <namespaces> <namespace uri="http://www.site.tld/model/content/socialedienst/1.0" prefix="sd" /> <namespace uri="http://www.site.tld/model/content/document/1.0" prefix="doc" /> </namespaces> <types> <type name="sd:sociaalDossier"> <title>Sociaal Dossier</title> <parent>cm:content</parent> <properties> <property name="sd:naam"> <type>d:text</type> </property> </properties> <mandatory-aspects> <aspect>sd:socialeDienst</aspect> <aspect>doc:dossierDocument</aspect> </mandatory-aspects> </type> </types> <aspects>
<!-- Aspects in shared-model.xml -->
</aspects> </model>

But this results in

Caused by: org.alfresco.service.namespace.NamespaceException: URI http://www.site.tld/model/content/socialedienst/1.0 has already been defined

Is this even possible or what is the best practice here?

TIA

Jonathan

1 REPLY 1

openpj
Elite Collaborator
Elite Collaborator

You can't define the same namespaces with related prefixes in two different models.

So you have to change the namespaces and prefixes in your second model, I mean the <namespaces> xml element.

It should be enough for making it work correctly Smiley Wink