cancel
Showing results for 
Search instead for 
Did you mean: 

store renditions

anweber
Champ in-the-making
Champ in-the-making
Hello,

   I try to find a way to store renditions of a file (renditions are alternate formats of the same content, for example a "doc" file has also representations in PDF, HTML, …).  I think it should be nice to store it in the same object as the main content.

   I have created a custom class.  I have defined an attribute named "renditionPdf" with the type "d:content".


      <type name="custom:ep_doc">
         <title>EP's concrete document</title>
         <parent>cm:content</parent>
         <properties>
            <property name="custom:language">
               <type>d:text</type>
            </property>
            <property name="custom:renditionPdf">
               <type>d:content</type>
               <mandatory>false</mandatory>
               <!— Index content in the background –>
               <index enabled="true">
                  <atomic>true</atomic>
                  <stored>false</stored>
                  <tokenised>true</tokenised>
               </index>
            </property>
         </properties>
    </type>

    Then by code, I have no problem to fill this attribute with some content (it creates a second internal file stored in the file system, the attribute "renditionPdf" receive a string where the localization of the internal file and the format are written).  Until this point, all is wright.

    Now, I should like to obtain the possibility to store several renditions of the same file.  My first idea was to define my custom attribute as multi-valued :


      <type name="custom:ep_doc">
         <title>EP's concrete document</title>
         <parent>cm:content</parent>
         <properties>
            <property name="custom:language">
               <type>d:text</type>
            </property>
             <property name="custom:renditions">
               <type>d:content</type>
               <mandatory>false</mandatory>
               <multiple>true</multiple>
               <!— Index content in the background –>
               <index enabled="true">
                  <atomic>true</atomic>
                  <stored>false</stored>
                  <tokenised>true</tokenised>
               </index>
            </property>
         </properties>
    </type>

    My problem is that I do not see how I can obtain the writer to fill the content in such a multivalue attribute.  In the previous version (with an mono-valued attribute), I used the following instruction :


       ContentWriter writer = contentService.getWriter(nodeRef, propRendition, true);

   But now, I should specify the indice in my custom attribute and it seems that the method "getWriter" doesn't offer this possibility.

           Thanks for your help,

                    Andre
1 REPLY 1

kevinr
Star Contributor
Star Contributor
This might be done better using an association to new node(s) to represent the renditions - rather than a multi-value property. If you use an association then cleanup of any deleted associations will happen automatically if you remove the rendition nodes. Also is it more appropriate for this style of 1-many relationship. Take a look at the <aspect name="cmSmiley Tongueartable"> in contentModel.xml as an  example of something similar.

Thanks,

Kevin