AnsweredAssumed Answered

How can add mandatory aspect on cm:content type on runtime

Question asked by 4535992 on Jan 22, 2019
Latest reply on Jan 23, 2019 by openpj

Hi i need to add "mandatory aspect" on the default alfresco type "cm:content" on runtime without touching the xml model configurations.

 

So the solution i'm using now is the classic create a custom type with parent "cm:content" like in the following code:

 

    <types>
        <type name="up:UploadFile">
            <title>Uploader Plus File</title>
            <parent>cm:content</parent>
            <properties>
                 <property name="up:classifiCationAspect2">
                  <title>Classification Aspect 2</title>
                  <type>d:text</type>
                  <multiple>true</multiple>
                  <index enabled="true">
                    <atomic>true</atomic>
                    <stored>false</stored>
                    <tokenised>false</tokenised>
                  </index>
                  <constraints>
                    <constraint ref="up:classificationAspectListConstraint" />
                  </constraints>
                </property>
            </properties>
            <associations>
                <association name="up:files">
                    <title>Related Documents</title>
                    <source>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </source>
                    <target>
                        <class>cm:content</class>
                        <mandatory>false</mandatory>
                        <many>true</many>
                    </target>
                </association>
            </associations>
            <mandatory-aspects>
                <aspect>up:UploadFolder</aspect>
            </mandatory-aspects>     
        </type>
    </types>

 

But i need to the same thing with java code, by adding the mandatory aspect to the "cm:content" on runtime. There is some alfresco service to do that?

 

I can accept even a java code to modify custom model on runtime .

 

Greetings.

Outcomes