<?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="openOfficeStartupBootstrap" class="org.alfresco.util.exec.RuntimeExecBootstrapBean">
      <property name="startupCommands">
         <list>
            <ref bean="openOfficeStartupCommand" />
         </list>
      </property>
      <property name="failOnError">
         <value>false</value>
      </property>
      <property name="enabled">
         <value>${ooo.enabled}</value>
      </property>
   </bean>

   <!--  We have to convert the user directory to an Open Office compatible URI -->
   <bean id="userInstallationURI" class="org.alfresco.util.OpenOfficeURI">
      <constructor-arg>
         <value>${ooo.user}</value>
      </constructor-arg>
   </bean>

   <bean id="openOfficeStartupCommand" class="org.alfresco.util.exec.RuntimeExec">
      <property name="commandsAndArguments">
         <map>
            <entry key=".*">
               <list>
                  <value>${ooo.exe}</value>
                  <value>-accept=socket,host=localhost,port=8100;urp;StarOffice.ServiceManager</value>
                  <bean class="org.alfresco.util.StringAppendingFactoryBean">
                     <property name="items">
                        <list>
                           <value>-env:UserInstallation=</value>
                           <ref bean="userInstallationURI" />
                        </list>
                     </property>
                  </bean>
                  <value>-nologo</value>
                  <value>-headless</value>
                  <value>-nofirststartwizard</value>
                  <value>-nocrashrep</value>
                  <value>-norestore</value>
               </list>
            </entry>
         </map>
      </property>
      <property name="waitForCompletion">
         <value>false</value>
      </property>
      <property name="errorCodes">
         <value>2</value>
      </property>
   </bean>

   <bean id="openOfficeConnection" class="net.sf.jooreports.openoffice.connection.SocketOpenOfficeConnection" />

   <bean id="openOfficeConnectionTester" class="org.alfresco.util.OpenOfficeConnectionTester">
      <property name="connection">
         <ref bean="openOfficeConnection" />
      </property>
      <property name="strict">
         <value>false</value>
      </property>
   </bean>

   <bean id="openOfficeConnectionTesterJobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
      <property name="jobClass">
         <value>org.alfresco.util.OpenOfficeConnectionTester$OpenOfficeConnectionTesterJob</value>
      </property>
      <property name="jobDataAsMap">
         <map>
            <entry key="openOfficeConnectionTester">
               <ref bean="openOfficeConnectionTester" />
            </entry>
         </map>
      </property>
   </bean>

   <bean id="openOfficeConnectionTesterTrigger" class="org.alfresco.util.CronTriggerBean">
      <property name="jobDetail">
         <ref bean="openOfficeConnectionTesterJobDetail" />
      </property>
      <property name="scheduler">
         <ref bean="schedulerFactory" />
      </property>
      <property name="cronExpression">
         <value>${openOffice.test.cronExpression}</value>
      </property>
   </bean>

   <bean id="extracter.worker.OpenOffice" class="org.alfresco.repo.content.metadata.DefaultOpenOfficeMetadataWorker">
      <property name="mimetypeService">
         <ref bean="mimetypeService" />
      </property>
      <property name="connection">
         <ref bean="openOfficeConnection" />
      </property>
   </bean>

   <bean id="transformer.worker.OpenOffice" class="org.alfresco.repo.content.transform.OpenOfficeContentTransformerWorker">
      <property name="mimetypeService">
         <ref bean="mimetypeService" />
      </property>
      <property name="connection">
         <ref bean="openOfficeConnection" />
      </property>
      <property name="documentFormatsConfiguration">
         <value>classpath:alfresco/mimetype/openoffice-document-formats.xml</value>
      </property>
   </bean>

</beans>