在Alfresco中运行转换脚本



为什么我的转换脚本不在第一个文件以外的任何上传文件上运行?

我在Alfresco中设置了一个转换规则,该规则会倾听到文件夹。当将新文件放入文件夹中时,规则会触发一个脚本来运行,该脚本在没有文本层的情况下使用PDF,将其分解为JPEG,将JPEG ocrs ocrs,然后将JPEG转换为PDF,然后将PDF合并,返回OCRED PDF然后,使用文本层将结果复制到另一个文件夹中,因此我们知道它已完成。

在命令行中运行脚本工作。第一次将文件放入Alfresco文件夹(上传)时,它运行脚本并复制文件。但是任何后续的时间我都将文件放入文件夹中,脚本不会运行,但是该文件仍将复制到目标文件夹中。因此,我知道该规则正在被调用,但是脚本似乎并未在以下文件上运行。我已经在脚本上记录了,所以我知道脚本甚至没有被调用。该规则正在应用于没有过滤器的文件夹中的所有新文件和修改后的文件。然后,它使用我们的自定义OCR脚本运行转换和复制命令,并且目标文件夹被定义为父文件夹。

下面是我的alfresco转换扩展:

<?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.PdfOCRTool" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker">
    <property name="mimetypeService">
      <ref bean="mimetypeService"/>
    </property>
    <property name="transformCommand">
      <bean name="transformer.pdftoocr.Command" class="org.alfresco.util.exec.RuntimeExec">
        <property name="commandMap">
     <map>
          <entry key=".*">
                <value>/opt/ocr/ocr.sh ${source} ${target}</value>
            </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>application/pdf</value>
          </property>
          <property name="targetMimetype">
            <value>application/pdf</value>
          </property>
        </bean>
      </list>
    </property>
  </bean>
  <bean id="transformer.proxy.PdfOCRTool" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
    <property name="sourceApplicationContextFactory">
      <ref bean="thirdparty"/>
    </property>
    <property name="sourceBeanName">
      <value>transformer.worker.PdfOCRTool</value>
    </property>
    <property name="interfaces">
      <list>
        <value>org.alfresco.repo.content.transform.ContentTransformerWorker</value>
      </list>
    </property>
  </bean>
  <bean id="transformer.PdfOCRTool" class="org.alfresco.repo.content.transform.ProxyContentTransformer" parent="baseContentTransformer">
    <property name="worker">
      <ref bean="transformer.proxy.PdfOCRTool"/>
    </property>
  </bean>
</beans>

转换服务旨在将项目从一个模仿类型转换为另一种。我不确定从PDF转换为第二个PDF是否有效。您将更好地实施自定义的Java存储库操作,然后使用org.alfresco.util.exec.RuntimeExec BEAN发射命令。

由于您的Spring配置已经定义了RuntimeExec BEAN,因此您可以重复使用此定义,但将其包装在您自己的自定义类中,该类扩展了org.alfresco.repo.action.executer.ActionExecuterAbstractBase。实际上,如果您查看org.alfresco.repo.action.executer.TransformActionExecuter的来源,那么这可能会给您一些有关如何实施事物的线索。

最新更新