Create a Custom Content Model Deployed to ACS - Alfresco Content Services - 23.4 - 23.4 - Ready - Alfresco - external

Alfresco Content Services

Platform
Alfresco
Product
Alfresco Content Services
Release
23.4
License
The following steps show how to create a custom content model that can be deployed to ACS
  1. Describe the custom content model with XML.

    Let’s use the following content model, which defines the custom type acme:document:

    <?xml version="1.0" encoding="UTF-8"?>
    <model name="acme:contentModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">
       <description>Sample Document Model</description>
       <author>My Name</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"/>
           <import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/>
       </imports>
        
       <namespaces>
           <namespace uri="http://www.acme.org/model/content/1.0" prefix="acme"/>
       </namespaces>
        
       <constraints>
           <constraint name="acme:securityClassificationOptions" type="LIST">
               <parameter name="allowedValues">
                   <list>
                       <value></value>
                       <value>Public</value>
                       <value>Client Confidential</value>
                       <value>Company Confidential</value>
                       <value>Strictly Confidential</value>
                   </list>
               </parameter>
           </constraint>
       </constraints>
        
       <types>
           <type name="acme:document">
               <title>Sample Document Type</title>
               <parent>cm:content</parent>
               <properties>
                   <property name="acme:documentId">
                       <title>Document Identification Number</title>
                       <type>d:text</type>
                   </property>
               </properties>
               <mandatory-aspects>
                   <aspect>acme:securityClassified</aspect>
               </mandatory-aspects>
           </type>
       </types>
        
       <aspects>
           <aspect name="acme:securityClassified">
               <title>ACME Security Classified</title>
               <description>Content has been security classified</description>
               <properties>
                   <property name="acme:securityClassification">
                       <type>d:text</type>
                       <index enabled="true">
                           <atomic>true</atomic>
                           <stored>false</stored>
                           <tokenised>false</tokenised>
                       </index>
                       <constraints>
                           <constraint ref="acme:securityClassificationOptions"/>
                       </constraints>
                   </property>
               </properties>
           </aspect>
       </aspects>
    </model>
    

    This model also has a custom aspect acme:securityClassified, so we can see how aspects can be applied at the same time as we set a custom content type. Store the XML in a file called, for example, acme-content-model.xml.

  2. Create a file that bootstraps the content model.

    For the custom content model to be applied to the Repository we need to define a bootstrap file that points to the acme-content-model.xml file. Create a file called acme-bootstrap-context.xml with the following XML:

    <?xml version='1.0' encoding='UTF-8'?>
    <!DOCTYPE beansPUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
    <beans>
        <bean id="acme.extension.dictionaryBootstrap" 
                parent="dictionaryModelBootstrap" 
                depends-on="dictionaryBootstrap">
            <property name="models">
              <list>                
                <value>alfresco/extension/acme-content-model.xml</value>
              </list>
            </property>
        </bean>
    </beans>
    
  3. Create a directory somewhere for Repository extension files and copy the files there.

    Now, copy both the acme-content-model.xml file and the acme-bootstrap-context.xml file into this new directory. This directory could also contain the api-explorer.war if you have applied it to your ACS installation.

    There are now two different ways of deploying this content model depending on if you are using an ACS Trial or an Alfresco SDK project.

    If you are using a trial version of ACS then you follow the first approach described below. If you are using the Alfresco SDK you would want to follow the second approach. The main difference between the two is that the first one will lead to loss of the data that you are working with as the ACS trial Docker Compose file does not use volumes (i.e. it does not store data externally but instead inside the container).