cancel
Showing results for 
Search instead for 
Did you mean: 

Trouble with custom transformation

randomman
Champ in-the-making
Champ in-the-making
I'm trying to get a custom transformer (Abiword: msword -> xhtml) working on Alfresco 2.1 on Linux. It's almost there but failing at the final hurdle resulting in no errors but with an empty file being created in Alfresco.

If I use my command line manually, i get the expected results. In reference to a previous post on here, I also tried creating a simple shell script with two inputs that runs the full command line. No joy.

If I perform the transform in the Web Client (resulting in an empty file being created) and then look at the contents of the temp directory, I see three files:

RuntimeExecutableContentTransformer_source_19263.doc
RuntimeExecutableContentTransformer_source_19263.xhtml
RuntimeExecutableContentTransformer_target_19264.xhtml

There's the doc I started with, a mystery file with the correct results in (but with the same filename as the source instead of target) and finally the empty file that goes into Alfresco.  I want the middle file to be my result file not the empty one.

Has anyone else experienced this? Is this a bug or some quirk of using Abiword? I've tried all sorts different command lines in the transformation bean config and nothing seems to work. If anyone is interested in helping,  I've included my config code below:

<?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.Abiword.XHTML" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformer" parent="baseContentTransformer">
      <property name="checkCommand">
         <bean class="org.alfresco.util.exec.RuntimeExec">
            <property name="commandMap">
                <map>
                    <entry key=".*">
                        <value>abiword –help</value>
                    </entry>
                </map>
            </property>
            <property name="errorCodes">
               <value>2</value>
            </property>
         </bean>
      </property>
      <property name="transformCommand">
         <bean class="org.alfresco.util.exec.RuntimeExec">
            <property name="commandMap">
                <map>
                    <entry key="Linux">
                        <value>abiword –to=xhtml –print=${target} ${source}</value>
                    </entry>
                </map>
            </property>
            <property name="errorCodes">
               <value>2</value>
            </property>
         </bean>
      </property>
      <property name="explicitTransformations">
         <list>
            <bean class="org.alfresco.repo.content.transform.ContentTransformerRegistry$TransformationKey" >
                <constructor-arg><value>application/msword</value></constructor-arg>
                <constructor-arg><value>application/xhtml+xml</value></constructor-arg>
            </bean>
         </list>
      </property>
   </bean>
</beans>
1 REPLY 1

randomman
Champ in-the-making
Champ in-the-making
I've got around this by replacing the command line with a shell script that performs the command and then replaces the empty file with the mystery file.

It works but smells like a bit of a hack to me so if anyone has a nicer solution, I'm all ears!  :wink:

EDIT: After further investigation into this, it would appear that the problem lay with a possible bug in Abiword where it was not printing to file as expected. i.e. it appeared to ignore the print filename and just used the original name regardless.