cancel
Showing results for 
Search instead for 
Did you mean: 

Help Setting Up a Custom Transform

kharris
Champ in-the-making
Champ in-the-making
I'm using the community edition of 3.2r2.  It uses Tomcat.  I have a file type that is not viewable in the share web component.  I have been studying how to handle this and it looks like the best option is to create a transform but I'm a little confused on exactly what files need to modified in order to do this.  I have a conversion command-line executable that transforms my existing file format to a pdf so I'm ok there.

I have already studied the following wiki entries and I still don't seem to have it all figured out.
http://wiki.alfresco.com/wiki/Simple_Customisations#Transformation_Mimetype
http://wiki.alfresco.com/wiki/Adding_a_Mime_Type
http://wiki.alfresco.com/wiki/Content_Transformations

I have a file just like the one shown in the wiki entry above called Content Transformations, (I'll use the same name as in the first example in that wiki entry) called dwg2pdf-transform-context.xml.  I have it modified to work with the conversion program I have mentioned above.

So my questions are as follows:
1.) My goal is to get the Share web client to transform the file into a pdf automatically so that it can be viewed in the web client document viewer.  Is this the correct way to approach this?

2.)  If the answer is yes to above, where do I put the file called dwg2pdf-transform-context.xml or is that the wrong way to do this?

3.)  After I have that file in the correct location, what other files need to be modified and in what way to get this to work?

Thank you very much in advance.
5 REPLIES 5

zaizi
Champ in-the-making
Champ in-the-making
1. The Share client requires Flash conversion to display pages.
2. You put it in tomcat/shared/extensions/. See http://wiki.alfresco.com/wiki/Repository_Configuration#Advanced_Spring_Configuration
3. You need to define a complex transformation to convert from your file format to flash via Pdf. http://wiki.alfresco.com/wiki/Content_Transformations#ComplexContentTransformer. Check your existing installation for sample configurations.

kharris
Champ in-the-making
Champ in-the-making
OK, that helps a lot as I didn't realize it had to be an swf.  However, the directions in the wiki are still a bit confusing.  I have developed several software packages, but not using this technology so please hang with me.  I have a file such as the following called dwg2pdf-transform-context.xml located in /opt/Alfresco/tomcat/shared/classes/alfresco/extension

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>
<beans>
   <bean id="transformer.worker.dwg2pdf" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker">
      <property name="mimetypeService">
         <ref bean="mimetypeService" />
      </property>
      <property name="checkCommand">
         <bean class="org.alfresco.util.exec.RuntimeExec">
            <property name="commandsAndArguments">
               <map>
                  <entry key=".*">
                     <list>
                        <value>ls</value>
                        <value>/usr/local/bin/dwg2pdf</value>
                     </list>
                  </entry>
               </map>
            </property>
         </bean>
      </property>
      <property name="transformCommand">
         <bean class="org.alfresco.util.exec.RuntimeExec">
            <property name="commandsAndArguments">
               <map>
                  <entry key=".*">
                     <list>
                        <value>/usr/local/bin/dwg2pdf</value>
                        <value>${source}</value>
                        <value>${target}</value>
                     </list>
                  </entry>
               </map>
            </property>
            <property name="errorCodes">
               <value>1,2</value>
            </property>
         </bean>
      </property>
      <property name="explicitTransformations">
         <list>
            <bean class="org.alfresco.repo.content.transform.ExplictTransformationDetails">
               <property name="sourceMimetype"><value>image/x-dwg</value></property>
               <property name="targetMimetype"><value>application/pdf</value></property>
            </bean>
         </list>
      </property>
   </bean>
   <bean id="transformer.dwg2pdf" class="org.alfresco.repo.content.transform.ProxyContentTransformer" parent="baseContentTransformer">
      <property name="worker">
         <ref bean="transformer.worker.dwg2pdf" />
      </property>
   </bean>
</beans>

The page you pointed me to show this example of a complex transform:

   <bean id="transformer.complex.OpenOffice.PdfBox"
        class="org.alfresco.repo.content.transform.ComplexContentTransformer"
        parent="baseContentTransformer" >
      <property name="transformers">
         <list>
            <ref bean="transformer.OpenOffice" />
            <ref bean="transformer.PdfBox" />
         </list>
      </property>
      <property name="intermediateMimetypes">
         <list>
            <value>application/pdf</value>
         </list>
      </property>
   </bean>

Questions:

1.)  Should the complex transform above be modified for this instance and placed in a separate file or should the original transformer above be made into a complex transform?

2.)  If the complex transform should be a second, separate file, can you give me a clue what to name it, where to put it, and hopefully show me what it should look like to match the original transform above?  In other words, what would this complex transform look like?

Again, my apologies if I am making this more difficult than it should be.  If I could find a complete example of everything that needed to be modified for this version of Alfresco, I don't think I would have these questions.  I have found examples for previous versions but things seem to have changed.  By the way, you said to check my existing installation for sample configurations but I see no examples of complex transforms such as you suggest?

So far, I have been very impressed with this product but the wiki documentation seems to point in so many directions that it is very difficult to follow.

Thank you again for your assistance.

mycroes
Champ in-the-making
Champ in-the-making
1.)  Should the complex transform above be modified for this instance and placed in a separate file or should the original transformer above be made into a complex transform?
As far as I know (I'm still somewhat new to this too, but the dwg2pdf example on the wiki is mine) the complex transformer is just to chain other transformers. So if you're able to define a transformation from your source to pdf, then you can chain that one and Alfresco's internal pdf2swf (or whatever is needed) transformer in a complex content transformer.

2.)  If the complex transform should be a second, separate file, can you give me a clue what to name it, where to put it, and hopefully show me what it should look like to match the original transform above?  In other words, what would this complex transform look like?
I assume the second seperate file should be named in the same fashion as the first transformer, for instance dwg2swf-transform-context.xml. I'm not definately sure about this one yet, but I'm trying to solve the same issue as you and I will surely report when I've solved it!

By the way, you said to check my existing installation for sample configurations but I see no examples of complex transforms such as you suggest?
Depending on the type of installation these might have been in a seperate package, look for the samples package on the downloads page.

So far, I have been very impressed with this product but the wiki documentation seems to point in so many directions that it is very difficult to follow.
I totally agree. I started by writing an installation howto on my own blog, then added my first transformer to the wiki as complete file so it's actually usable. I don't know if the wiki is intentionally dumbed down, but it really lacks a lot of information. I'm trying to add more there as I learn, I hope you'll do the same.
Regards,

Michael

mycroes
Champ in-the-making
Champ in-the-making
I got a bit further. I managed to define a ComplexContentTransformation based on the dwg2pdf transformer from the wiki and the alfresco PDF to PNG transformer (extensions/dwg2png-transform-context.xml):
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
    <bean id="transformer.complex.dwg2png" class="org.alfresco.repo.content.transform.ComplexContentTransformer" parent="baseContentTransformer">
        <property name="transformers">
            <list>
                <ref bean="transformer.dwg2pdf" />
                <bean id="transformer.dwg2png.PdfBoxPdfToImageContentTransformer" class="org.alfresco.repo.content.transform.PdfToImageContentTransformer" />
            </list>
        </property>
        <property name="intermediateMimetypes">
            <list>
                <value>application/pdf</value>
            </list>
        </property>
    </bean>
</beans>

I don't know if the bean element inside the transformers list is the right approach, but it seems to register properly. Only issue I'm having with this transformer right now is that ImageMagick 'steals' the transformation request, so my transformer never gets invoked… It does get listed for the transformation though, so maybe this is engouh information to create complex transformers for other filetypes.
Regards,

Michael

mycroes
Champ in-the-making
Champ in-the-making
I've got a working example now, however it does not involve DWG to PNG but DWG to SWF. For one this doesn't conflict with ImageMagick and it works the exact same way, so I was thinking correctly I guess… So here's my code (I'll also add it to the wiki):
(/var/lib/tomcat6/shared/classes/alfresco/extension/)dwg2swf-transform-context.xml
<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
    <bean id="transformer.complex.dwg2swf" class="org.alfresco.repo.content.transform.ComplexContentTransformer" parent="baseContentTransformer">
        <property name="transformers">
            <list>
                <ref bean="transformer.dwg2pdf" />
                <ref bean="transformer.Pdf2swf" />
            </list>
        </property>
        <property name="intermediateMimetypes">
            <list>
                <value>application/pdf</value>
            </list>
        </property>
    </bean>
</beans>

This example uses my dwg2pdf transformer to convert to PDF and then uses swf2pdf from SWFtools (use 0.9 or above) to generate a swf file that can be used for the preview in Share.
Hope this helps, if so please mark the first post solved in the title.
Regards,

Michael