mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-07 18:25:23 +00:00
3rd Party Service admin (OpenOffice, SWFTools, ImageMagick)
- All supporting classes moved out to thirdparty subsystem - Open Office service automatically started if available - All utility locations editable via JMX (and subsystem can be reinitialized with new values without rebooting tomcat) - New ContentTransformerWorker interface introduced in order to allow separation between ContentTransformer registry and third party utilities - Existing JMX query capabilities preserved git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13860 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
parent
132fdb81cb
commit
a166add97f
@ -383,6 +383,8 @@
|
||||
<list>
|
||||
<!-- Allow authentication subsystem to see file server config at runtime -->
|
||||
<value>org.alfresco.filesys.ExtendedServerConfigurationAccessor</value>
|
||||
<!-- Allow export as MBean -->
|
||||
<value>org.alfresco.filesys.FileServerConfigMBean</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
@ -395,12 +397,10 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="openOfficeConnectionTester" class="org.alfresco.util.OpenOfficeConnectionTester" >
|
||||
<property name="connection">
|
||||
<ref bean="openOfficeConnection" />
|
||||
</property>
|
||||
<property name="strict">
|
||||
<value>false</value>
|
||||
<!-- Third party transformer Subsystem -->
|
||||
<bean id="thirdparty" class="org.alfresco.repo.management.DefaultManagedApplicationContextFactory">
|
||||
<property name="autoStart">
|
||||
<value>true</value>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
@ -129,8 +129,6 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="openOfficeConnection" class="net.sf.jooreports.openoffice.connection.SocketOpenOfficeConnection" />
|
||||
|
||||
<!-- Metadata Extraction Regisitry -->
|
||||
<bean id="metadataExtracterRegistry" class="org.alfresco.repo.content.metadata.MetadataExtracterRegistry" />
|
||||
|
||||
@ -150,7 +148,7 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<!-- Content Metadata Extracters -->
|
||||
<!-- Content Metadata Extractors -->
|
||||
<bean id="extracter.PDFBox" class="org.alfresco.repo.content.metadata.PdfBoxMetadataExtracter" parent="baseMetadataExtracter" />
|
||||
<bean id="extracter.Office" class="org.alfresco.repo.content.metadata.OfficeMetadataExtracter" parent="baseMetadataExtracter" />
|
||||
<bean id="extracter.Mail" class="org.alfresco.repo.content.metadata.MailMetadataExtracter" parent="baseMetadataExtracter" />
|
||||
@ -158,8 +156,21 @@
|
||||
<bean id="extracter.MP3" class="org.alfresco.repo.content.metadata.MP3MetadataExtracter" parent="baseMetadataExtracter" />
|
||||
<bean id="extracter.OpenDocument" class="org.alfresco.repo.content.metadata.OpenDocumentMetadataExtracter" parent="baseMetadataExtracter" />
|
||||
<bean id="extracter.OpenOffice" class="org.alfresco.repo.content.metadata.OpenOfficeMetadataExtracter" parent="baseMetadataExtracter" >
|
||||
<property name="connection">
|
||||
<ref bean="openOfficeConnection" />
|
||||
<property name="worker">
|
||||
<!-- Import the OpenOffice extractor worker from the third party subsystem -->
|
||||
<bean class="org.alfresco.repo.management.ManagedSubsystemProxyFactory">
|
||||
<property name="sourceApplicationContextFactory">
|
||||
<ref bean="thirdparty" />
|
||||
</property>
|
||||
<property name="sourceBeanName">
|
||||
<value>extracter.worker.OpenOffice</value>
|
||||
</property>
|
||||
<property name="interfaces">
|
||||
<list>
|
||||
<value>org.alfresco.repo.content.metadata.OpenOfficeMetadataWorker</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="supportedMimetypes">
|
||||
<list>
|
||||
@ -172,7 +183,6 @@
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
||||
<!-- Content Transformation Regisitry -->
|
||||
<bean id="contentTransformerRegistry" class="org.alfresco.repo.content.transform.ContentTransformerRegistry" />
|
||||
@ -324,16 +334,25 @@
|
||||
<property name="fileFolderService">
|
||||
<ref bean="FileFolderService" />
|
||||
</property>
|
||||
</bean>
|
||||
</bean>
|
||||
|
||||
<bean id="transformer.OpenOffice"
|
||||
class="org.alfresco.repo.content.transform.OpenOfficeContentTransformer"
|
||||
parent="baseContentTransformer" >
|
||||
<property name="connection">
|
||||
<ref bean="openOfficeConnection" />
|
||||
</property>
|
||||
<property name="documentFormatsConfiguration">
|
||||
<value>classpath:alfresco/mimetype/openoffice-document-formats.xml</value>
|
||||
<bean id="transformer.OpenOffice" class="org.alfresco.repo.content.transform.ProxyContentTransformer"
|
||||
parent="baseContentTransformer">
|
||||
<property name="worker">
|
||||
<!-- Import the OpenOffice transformer worker from the third party subsystem -->
|
||||
<bean class="org.alfresco.repo.management.ManagedSubsystemProxyFactory">
|
||||
<property name="sourceApplicationContextFactory">
|
||||
<ref bean="thirdparty" />
|
||||
</property>
|
||||
<property name="sourceBeanName">
|
||||
<value>transformer.worker.OpenOffice</value>
|
||||
</property>
|
||||
<property name="interfaces">
|
||||
<list>
|
||||
<value>org.alfresco.repo.content.transform.ContentTransformerWorker</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
@ -349,7 +368,7 @@
|
||||
<property name="intermediateMimetypes">
|
||||
<list>
|
||||
<value>application/pdf</value>
|
||||
</list>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
@ -357,57 +376,24 @@
|
||||
class="org.alfresco.repo.content.transform.MailContentTransformer"
|
||||
parent="baseContentTransformer" />
|
||||
|
||||
<bean id="transformer.ImageMagick"
|
||||
class="org.alfresco.repo.content.transform.magick.ImageMagickContentTransformer"
|
||||
parent="baseContentTransformer"
|
||||
init-method="init">
|
||||
<property name="executer">
|
||||
<bean name="transformer.ImageMagick.Command" class="org.alfresco.util.exec.RuntimeExec">
|
||||
<property name="commandsAndArguments">
|
||||
<map>
|
||||
<entry key=".*">
|
||||
<list>
|
||||
<value>${img.exe}</value>
|
||||
<value>${source}</value>
|
||||
<value>SPLIT:${options}</value>
|
||||
<value>${target}</value>
|
||||
</list>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
<property name="processProperties">
|
||||
<map>
|
||||
<entry key="MAGICK_HOME">
|
||||
<value>${img.root}</value>
|
||||
</entry>
|
||||
<entry key="DYLD_LIBRARY_PATH">
|
||||
<value>${img.dyn}</value>
|
||||
</entry>
|
||||
<entry key="LD_LIBRARY_PATH">
|
||||
<value>${img.dyn}</value>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
<property name="defaultProperties">
|
||||
<props>
|
||||
<prop key="options"></prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
<!-- Import the ImageMagick transformer from the third party subsystem -->
|
||||
<bean id="transformer.worker.ImageMagick" class="org.alfresco.repo.management.ManagedSubsystemProxyFactory">
|
||||
<property name="sourceApplicationContextFactory">
|
||||
<ref bean="thirdparty" />
|
||||
</property>
|
||||
<property name="checkCommand">
|
||||
<bean name="transformer.ImageMagick.CheckCommand" class="org.alfresco.util.exec.RuntimeExec">
|
||||
<property name="commandsAndArguments">
|
||||
<map>
|
||||
<entry key=".*">
|
||||
<list>
|
||||
<value>${img.exe}</value>
|
||||
<value>-version</value>
|
||||
</list>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
<property name="sourceBeanName">
|
||||
<value>transformer.worker.ImageMagick</value>
|
||||
</property>
|
||||
<property name="interfaces">
|
||||
<list>
|
||||
<value>org.alfresco.repo.content.transform.ContentTransformerWorker</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="transformer.ImageMagick" class="org.alfresco.repo.content.transform.ProxyContentTransformer" parent="baseContentTransformer">
|
||||
<property name="worker">
|
||||
<ref bean="transformer.worker.ImageMagick" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
|
@ -299,14 +299,6 @@ authentication.rmi.service.port=50504
|
||||
repo.rmi.service.port=50505
|
||||
action.rmi.service.port=50506
|
||||
|
||||
# External executable locations
|
||||
ooo.exe=soffice
|
||||
ooo.user=${dir.root}/oouser
|
||||
img.root=./ImageMagick
|
||||
img.dyn=${img.root}/lib
|
||||
img.exe=${img.root}/bin/convert
|
||||
swf.exe=./bin/pdf2swf
|
||||
|
||||
# Property to enable upgrade from 2.1-A
|
||||
V2.1-A.fixes.to.schema=0
|
||||
#V2.1-A.fixes.to.schema=82
|
||||
|
@ -175,30 +175,6 @@
|
||||
</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="indexBackupJobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
|
||||
<property name="jobClass">
|
||||
<value>org.alfresco.repo.search.impl.lucene.AbstractLuceneIndexerAndSearcherFactory$LuceneIndexBackupJob</value>
|
||||
|
@ -51,6 +51,23 @@
|
||||
</constructor-arg>
|
||||
</bean>
|
||||
|
||||
<!-- JMX Monitoring -->
|
||||
|
||||
<bean id="FileServerConfig" class="org.alfresco.filesys.FileServerConfig">
|
||||
<property name="fileServerConfiguration">
|
||||
<ref bean="fileServerConfiguration" />
|
||||
</property>
|
||||
<property name="ftpServer">
|
||||
<ref bean="ftpServer" />
|
||||
</property>
|
||||
<property name="cifsServer">
|
||||
<ref bean="cifsServer" />
|
||||
</property>
|
||||
<property name="nfsServer">
|
||||
<ref bean="nfsServer" />
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="cifsServerConfig" class="org.alfresco.filesys.config.CIFSConfigBean">
|
||||
<property name="serverEnabled">
|
||||
<value>${cifs.enabled}</value>
|
||||
@ -188,9 +205,7 @@
|
||||
<!-- FTP server debug settings -->
|
||||
<!-- Enable 'log4j.logger.org.alfresco.fileserver=debug' in log4j.properties file -->
|
||||
<!--
|
||||
<property name="debugFlags">
|
||||
<value>File,Search,Error,Directory,Info,DataPort</value>
|
||||
</property>
|
||||
<property name="debugFlags"> <value>File,Search,Error,Directory,Info,DataPort</value> </property>
|
||||
-->
|
||||
|
||||
</bean>
|
||||
@ -296,79 +311,31 @@
|
||||
</bean>
|
||||
<!-- Other desktop actions which may be enabled -->
|
||||
<!--
|
||||
<bean class="org.alfresco.filesys.repo.desk.EchoDesktopAction">
|
||||
<property name="name">
|
||||
<value>Echo</value>
|
||||
</property>
|
||||
<property name="filename">
|
||||
<value>__AlfrescoEcho.exe</value>
|
||||
</property>
|
||||
</bean>
|
||||
<bean class="org.alfresco.filesys.repo.desk.URLDesktopAction">
|
||||
<property name="name">
|
||||
<value>URL</value>
|
||||
</property>
|
||||
<property name="filename">
|
||||
<value>__AlfrescoURL.exe</value>
|
||||
</property>
|
||||
</bean>
|
||||
<bean class="org.alfresco.filesys.repo.desk.CmdLineDesktopAction">
|
||||
<property name="name">
|
||||
<value>CmdLine</value>
|
||||
</property>
|
||||
<property name="filename">
|
||||
<value>__AlfrescoCmd.exe</value>
|
||||
</property>
|
||||
</bean>
|
||||
<bean class="org.alfresco.filesys.repo.desk.JavaScriptDesktopAction">
|
||||
<property name="name">
|
||||
<value>JavaScript</value>
|
||||
</property>
|
||||
<property name="filename">
|
||||
<value>__AlfrescoScript.exe</value>
|
||||
</property>
|
||||
<property name="scriptName">
|
||||
<value>alfresco/desktop/dumpRequest.js</value>
|
||||
</property>
|
||||
<property name="attributeList">
|
||||
<value>anyFiles, multiplePaths, allowNoParams</value>
|
||||
</property>
|
||||
<property name="preprocess">
|
||||
<value>confirm, copyToTarget</value>
|
||||
</property>
|
||||
</bean>
|
||||
<bean class="org.alfresco.filesys.repo.desk.EchoDesktopAction"> <property name="name">
|
||||
<value>Echo</value> </property> <property name="filename"> <value>__AlfrescoEcho.exe</value>
|
||||
</property> </bean> <bean class="org.alfresco.filesys.repo.desk.URLDesktopAction"> <property
|
||||
name="name"> <value>URL</value> </property> <property name="filename">
|
||||
<value>__AlfrescoURL.exe</value> </property> </bean> <bean
|
||||
class="org.alfresco.filesys.repo.desk.CmdLineDesktopAction"> <property name="name">
|
||||
<value>CmdLine</value> </property> <property name="filename"> <value>__AlfrescoCmd.exe</value>
|
||||
</property> </bean> <bean class="org.alfresco.filesys.repo.desk.JavaScriptDesktopAction">
|
||||
<property name="name"> <value>JavaScript</value> </property> <property name="filename">
|
||||
<value>__AlfrescoScript.exe</value> </property> <property name="scriptName">
|
||||
<value>alfresco/desktop/dumpRequest.js</value> </property> <property name="attributeList">
|
||||
<value>anyFiles, multiplePaths, allowNoParams</value> </property> <property name="preprocess">
|
||||
<value>confirm, copyToTarget</value> </property> </bean>
|
||||
-->
|
||||
</list>
|
||||
</property>
|
||||
<!-- Additional access control of the filesystem -->
|
||||
<!-- Access type of 'none' will stop the filesystem from showing up for that user/address/protocol -->
|
||||
<!--
|
||||
<property name="defaultAccessLevel">
|
||||
<value>Write</value>
|
||||
</property>
|
||||
<property name="accessControl">
|
||||
<list>
|
||||
<bean class="org.alfresco.jlan.server.auth.acl.UserAccessControl">
|
||||
<property name="name">
|
||||
<value>admin</value>
|
||||
</property>
|
||||
<property name="access">
|
||||
<value>Write</value>
|
||||
</property>
|
||||
</bean>
|
||||
<bean class="org.alfresco.jlan.server.auth.acl.IpAddressAccessControl">
|
||||
<property name="subNet">
|
||||
<value>192.168.1.0</value>
|
||||
</property>
|
||||
<property name="netMask">
|
||||
<value>255.255.255.0</value>
|
||||
</property>
|
||||
<property name="access">
|
||||
<value>Write</value>
|
||||
</property>
|
||||
</bean>
|
||||
</list>
|
||||
</property>
|
||||
<property name="defaultAccessLevel"> <value>Write</value> </property> <property name="accessControl">
|
||||
<list> <bean class="org.alfresco.jlan.server.auth.acl.UserAccessControl"> <property name="name">
|
||||
<value>admin</value> </property> <property name="access"> <value>Write</value> </property> </bean>
|
||||
<bean class="org.alfresco.jlan.server.auth.acl.IpAddressAccessControl"> <property name="subNet">
|
||||
<value>192.168.1.0</value> </property> <property name="netMask"> <value>255.255.255.0</value>
|
||||
</property> <property name="access"> <value>Write</value> </property> </bean> </list> </property>
|
||||
-->
|
||||
</bean>
|
||||
<!-- AVM virtualization view of all stores/versions for WCM -->
|
||||
@ -392,67 +359,28 @@
|
||||
<!-- Domain mappings used for passthru authentication routing -->
|
||||
<!-- Used when the client does not provide a domain name in the NTLM logon -->
|
||||
<!--
|
||||
<property name="domainMappings">
|
||||
<list>
|
||||
<bean class="org.alfresco.filesys.config.DomainMappingConfigBean">
|
||||
<property name="name">
|
||||
<value>ALFRESCO</value>
|
||||
</property>
|
||||
<property name="subnet">
|
||||
<value>192.168.1.0</value>
|
||||
</property>
|
||||
<property name="mask">
|
||||
<value>192.168.1.255</value>
|
||||
</property>
|
||||
</bean>
|
||||
</list>
|
||||
</property>
|
||||
<property name="domainMappings"> <list> <bean class="org.alfresco.filesys.config.DomainMappingConfigBean">
|
||||
<property name="name"> <value>ALFRESCO</value> </property> <property name="subnet"> <value>192.168.1.0</value>
|
||||
</property> <property name="mask"> <value>192.168.1.255</value> </property> </bean> </list> </property>
|
||||
-->
|
||||
|
||||
<!-- Custom share mapper when multi-tenancy is enabled -->
|
||||
<!--
|
||||
<property name="shareMapper">
|
||||
<bean class="org.alfresco.filesys.alfresco.MultiTenantShareMapper">
|
||||
<property name="serverConfiguration">
|
||||
<ref bean="fileServerConfiguration" />
|
||||
</property>
|
||||
<property name="debug">
|
||||
<value>true</value>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="shareMapper"> <bean class="org.alfresco.filesys.alfresco.MultiTenantShareMapper"> <property
|
||||
name="serverConfiguration"> <ref bean="fileServerConfiguration" /> </property> <property name="debug">
|
||||
<value>true</value> </property> </bean> </property>
|
||||
-->
|
||||
|
||||
<!-- Global access control list -->
|
||||
<!-- Applied to all filesystems that do not have an accessControl property -->
|
||||
<!-- Access type of 'none' will stop the filesystem from showing up for that user/address/protocol -->
|
||||
<!--
|
||||
<property name="globalDefaultAccessLevel">
|
||||
<value>None</value>
|
||||
</property>
|
||||
<property name="globalAccessControl">
|
||||
<list>
|
||||
<bean class="org.alfresco.jlan.server.auth.acl.UserAccessControl">
|
||||
<property name="name">
|
||||
<value>admin</value>
|
||||
</property>
|
||||
<property name="access">
|
||||
<value>Write</value>
|
||||
</property>
|
||||
</bean>
|
||||
<bean class="org.alfresco.jlan.server.auth.acl.IpAddressAccessControl">
|
||||
<property name="subNet">
|
||||
<value>192.168.1.2</value>
|
||||
</property>
|
||||
<property name="netMask">
|
||||
<value>255.255.255.0</value>
|
||||
</property>
|
||||
<property name="access">
|
||||
<value>Write</value>
|
||||
</property>
|
||||
</bean>
|
||||
</list>
|
||||
</property>
|
||||
<property name="globalDefaultAccessLevel"> <value>None</value> </property> <property
|
||||
name="globalAccessControl"> <list> <bean class="org.alfresco.jlan.server.auth.acl.UserAccessControl"> <property
|
||||
name="name"> <value>admin</value> </property> <property name="access"> <value>Write</value> </property> </bean>
|
||||
<bean class="org.alfresco.jlan.server.auth.acl.IpAddressAccessControl"> <property name="subNet">
|
||||
<value>192.168.1.2</value> </property> <property name="netMask"> <value>255.255.255.0</value> </property>
|
||||
<property name="access"> <value>Write</value> </property> </bean> </list> </property>
|
||||
-->
|
||||
</bean>
|
||||
|
||||
|
59
config/alfresco/subsystems/thirdparty/imagemagick-transform-context.xml
vendored
Normal file
59
config/alfresco/subsystems/thirdparty/imagemagick-transform-context.xml
vendored
Normal file
@ -0,0 +1,59 @@
|
||||
<?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.ImageMagick" class="org.alfresco.repo.content.transform.magick.ImageMagickContentTransformerWorker">
|
||||
<property name="mimetypeService">
|
||||
<ref bean="mimetypeService" />
|
||||
</property>
|
||||
<property name="executer">
|
||||
<bean name="transformer.ImageMagick.Command" class="org.alfresco.util.exec.RuntimeExec">
|
||||
<property name="commandsAndArguments">
|
||||
<map>
|
||||
<entry key=".*">
|
||||
<list>
|
||||
<value>${img.exe}</value>
|
||||
<value>${source}</value>
|
||||
<value>SPLIT:${options}</value>
|
||||
<value>${target}</value>
|
||||
</list>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
<property name="processProperties">
|
||||
<map>
|
||||
<entry key="MAGICK_HOME">
|
||||
<value>${img.root}</value>
|
||||
</entry>
|
||||
<entry key="DYLD_LIBRARY_PATH">
|
||||
<value>${img.dyn}</value>
|
||||
</entry>
|
||||
<entry key="LD_LIBRARY_PATH">
|
||||
<value>${img.dyn}</value>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
<property name="defaultProperties">
|
||||
<props>
|
||||
<prop key="options"></prop>
|
||||
</props>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="checkCommand">
|
||||
<bean name="transformer.ImageMagick.CheckCommand" class="org.alfresco.util.exec.RuntimeExec">
|
||||
<property name="commandsAndArguments">
|
||||
<map>
|
||||
<entry key=".*">
|
||||
<list>
|
||||
<value>${img.exe}</value>
|
||||
<value>-version</value>
|
||||
</list>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
4
config/alfresco/subsystems/thirdparty/imagemagick-transform.properties
vendored
Normal file
4
config/alfresco/subsystems/thirdparty/imagemagick-transform.properties
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
# External executable locations
|
||||
img.root=./ImageMagick
|
||||
img.dyn=${img.root}/lib
|
||||
img.exe=${img.root}/bin/convert
|
98
config/alfresco/subsystems/thirdparty/openoffice-transform-context.xml
vendored
Normal file
98
config/alfresco/subsystems/thirdparty/openoffice-transform-context.xml
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
<?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>
|
||||
</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>
|
||||
<value>-env:UserInstallation=file:///${ooo.user}</value>
|
||||
<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>
|
3
config/alfresco/subsystems/thirdparty/openoffice-transform.properties
vendored
Normal file
3
config/alfresco/subsystems/thirdparty/openoffice-transform.properties
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
# External executable locations
|
||||
ooo.exe=soffice
|
||||
ooo.user=${dir.root}/oouser
|
57
config/alfresco/subsystems/thirdparty/swf-transform-context.xml
vendored
Normal file
57
config/alfresco/subsystems/thirdparty/swf-transform-context.xml
vendored
Normal file
@ -0,0 +1,57 @@
|
||||
<?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.Pdf2swf" 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="commandMap">
|
||||
<map>
|
||||
<entry key=".*">
|
||||
<value>${swf.exe} -V</value>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
<property name="errorCodes">
|
||||
<value>1</value>
|
||||
</property>
|
||||
</bean>
|
||||
</property>
|
||||
<property name="transformCommand">
|
||||
<bean class="org.alfresco.util.exec.RuntimeExec">
|
||||
<property name="commandMap">
|
||||
<map>
|
||||
<entry key=".*">
|
||||
<value>${swf.exe} -T ${flashVersion} ${source} -o ${target}</value>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
<property name="defaultProperties">
|
||||
<map>
|
||||
<entry key="flashVersion" value="9" />
|
||||
</map>
|
||||
</property>
|
||||
<property name="errorCodes">
|
||||
<value>1</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/x-shockwave-flash</value>
|
||||
</property>
|
||||
</bean>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
</beans>
|
2
config/alfresco/subsystems/thirdparty/swf-transform.properties
vendored
Normal file
2
config/alfresco/subsystems/thirdparty/swf-transform.properties
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# External executable locations
|
||||
swf.exe=./bin/pdf2swf
|
@ -3,49 +3,27 @@
|
||||
|
||||
<beans>
|
||||
|
||||
<bean id="transformer.Pdf2swf" 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>${swf.exe} -V</value>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
<property name="errorCodes">
|
||||
<value>1</value>
|
||||
</property>
|
||||
</bean>
|
||||
<!-- Import the swftools transformer worker from the third party subsystem -->
|
||||
<bean id="transformer.worker.Pdf2swf" class="org.alfresco.repo.management.ManagedSubsystemProxyFactory">
|
||||
<property name="sourceApplicationContextFactory">
|
||||
<ref bean="thirdparty" />
|
||||
</property>
|
||||
<property name="transformCommand">
|
||||
<bean class="org.alfresco.util.exec.RuntimeExec">
|
||||
<property name="commandMap">
|
||||
<map>
|
||||
<entry key=".*">
|
||||
<value>${swf.exe} -T ${flashVersion} ${source} -o ${target}</value>
|
||||
</entry>
|
||||
</map>
|
||||
</property>
|
||||
<property name="defaultProperties">
|
||||
<map>
|
||||
<entry key="flashVersion" value="9" />
|
||||
</map>
|
||||
</property>
|
||||
<property name="errorCodes">
|
||||
<value>1</value>
|
||||
</property>
|
||||
</bean>
|
||||
<property name="sourceBeanName">
|
||||
<value>transformer.worker.Pdf2swf</value>
|
||||
</property>
|
||||
<property name="explicitTransformations">
|
||||
<property name="interfaces">
|
||||
<list>
|
||||
<bean class="org.alfresco.repo.content.transform.ExplictTransformationDetails" >
|
||||
<property name="sourceMimetype"><value>application/pdf</value></property>
|
||||
<property name="targetMimetype"><value>application/x-shockwave-flash</value></property>
|
||||
</bean>
|
||||
<value>org.alfresco.repo.content.transform.ContentTransformerWorker</value>
|
||||
</list>
|
||||
</property>
|
||||
</bean>
|
||||
</bean>
|
||||
|
||||
<bean id="transformer.Pdf2swf" class="org.alfresco.repo.content.transform.ProxyContentTransformer"
|
||||
parent="baseContentTransformer">
|
||||
<property name="worker">
|
||||
<ref bean="transformer.worker.Pdf2swf"/>
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<bean id="transformer.complex.OpenOffice.Pdf2swf"
|
||||
class="org.alfresco.repo.content.transform.ComplexContentTransformer"
|
||||
|
@ -27,7 +27,7 @@ package org.alfresco.repo.action.executer;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
||||
import org.alfresco.repo.content.transform.magick.ImageMagickContentTransformer;
|
||||
import org.alfresco.repo.content.transform.ContentTransformer;
|
||||
import org.alfresco.repo.content.transform.magick.ImageTransformationOptions;
|
||||
import org.alfresco.service.cmr.action.Action;
|
||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
||||
@ -50,14 +50,14 @@ public class ImageTransformActionExecuter extends TransformActionExecuter
|
||||
public static final String NAME = "transform-image";
|
||||
public static final String PARAM_CONVERT_COMMAND = "convert-command";
|
||||
|
||||
private ImageMagickContentTransformer imageMagickContentTransformer;
|
||||
private ContentTransformer imageMagickContentTransformer;
|
||||
|
||||
/**
|
||||
* Set the image magick content transformer
|
||||
*
|
||||
* @param imageMagickContentTransformer the conten transformer
|
||||
*/
|
||||
public void setImageMagickContentTransformer(ImageMagickContentTransformer imageMagickContentTransformer)
|
||||
public void setImageMagickContentTransformer(ContentTransformer imageMagickContentTransformer)
|
||||
{
|
||||
this.imageMagickContentTransformer = imageMagickContentTransformer;
|
||||
}
|
||||
@ -79,17 +79,19 @@ public class ImageTransformActionExecuter extends TransformActionExecuter
|
||||
NodeRef sourceNodeRef, ContentReader contentReader,
|
||||
NodeRef destinationNodeRef, ContentWriter contentWriter)
|
||||
{
|
||||
// check if the transformer is going to work, i.e. is available
|
||||
if (!this.imageMagickContentTransformer.isAvailable())
|
||||
{
|
||||
throw new NoTransformerException(contentReader.getMimetype(), contentWriter.getMimetype());
|
||||
}
|
||||
// Try and transform the content
|
||||
String convertCommand = (String)ruleAction.getParameterValue(PARAM_CONVERT_COMMAND);
|
||||
String convertCommand = (String) ruleAction.getParameterValue(PARAM_CONVERT_COMMAND);
|
||||
// create some options for the transform
|
||||
ImageTransformationOptions imageOptions = new ImageTransformationOptions();
|
||||
imageOptions.setCommandOptions(convertCommand);
|
||||
|
||||
|
||||
// check if the transformer is going to work, i.e. is available
|
||||
if (!this.imageMagickContentTransformer.isTransformable(contentReader.getMimetype(), contentWriter
|
||||
.getMimetype(), imageOptions))
|
||||
{
|
||||
throw new NoTransformerException(contentReader.getMimetype(), contentWriter.getMimetype());
|
||||
}
|
||||
|
||||
this.imageMagickContentTransformer.transform(contentReader, contentWriter, imageOptions);
|
||||
}
|
||||
}
|
||||
|
@ -39,7 +39,6 @@ import org.alfresco.repo.content.ContentServicePolicies.OnContentUpdatePolicy;
|
||||
import org.alfresco.repo.content.filestore.FileContentStore;
|
||||
import org.alfresco.repo.content.transform.ContentTransformer;
|
||||
import org.alfresco.repo.content.transform.ContentTransformerRegistry;
|
||||
import org.alfresco.repo.content.transform.magick.ImageMagickContentTransformer;
|
||||
import org.alfresco.repo.policy.ClassPolicyDelegate;
|
||||
import org.alfresco.repo.policy.JavaBehaviour;
|
||||
import org.alfresco.repo.policy.PolicyComponent;
|
||||
@ -97,7 +96,7 @@ public class RoutingContentService implements ContentService, ApplicationContext
|
||||
private ContentStore store;
|
||||
/** the store for all temporarily created content */
|
||||
private ContentStore tempStore;
|
||||
private ImageMagickContentTransformer imageMagickContentTransformer;
|
||||
private ContentTransformer imageMagickContentTransformer;
|
||||
|
||||
/**
|
||||
* The policy component
|
||||
@ -153,7 +152,7 @@ public class RoutingContentService implements ContentService, ApplicationContext
|
||||
this.avmService = service;
|
||||
}
|
||||
|
||||
public void setImageMagickContentTransformer(ImageMagickContentTransformer imageMagickContentTransformer)
|
||||
public void setImageMagickContentTransformer(ContentTransformer imageMagickContentTransformer)
|
||||
{
|
||||
this.imageMagickContentTransformer = imageMagickContentTransformer;
|
||||
}
|
||||
@ -317,7 +316,6 @@ public class RoutingContentService implements ContentService, ApplicationContext
|
||||
Serializable propValue = nodeService.getProperty(nodeRef, propertyQName);
|
||||
if (propValue instanceof Collection)
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
Collection<Serializable> colPropValue = (Collection<Serializable>)propValue;
|
||||
if (colPropValue.size() > 0)
|
||||
{
|
||||
@ -461,7 +459,6 @@ public class RoutingContentService implements ContentService, ApplicationContext
|
||||
* @see org.alfresco.repo.content.transform.ContentTransformer
|
||||
* @deprecated
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void transform(ContentReader reader, ContentWriter writer, Map<String, Object> options)
|
||||
throws NoTransformerException, ContentIOException
|
||||
{
|
||||
|
@ -0,0 +1,147 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have received a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.content.metadata;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.Serializable;
|
||||
import java.net.ConnectException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sf.jooreports.openoffice.connection.OpenOfficeConnection;
|
||||
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
|
||||
import com.sun.star.beans.PropertyValue;
|
||||
import com.sun.star.beans.XPropertySet;
|
||||
import com.sun.star.document.XDocumentInfoSupplier;
|
||||
import com.sun.star.frame.XComponentLoader;
|
||||
import com.sun.star.lang.XComponent;
|
||||
import com.sun.star.ucb.XFileIdentifierConverter;
|
||||
import com.sun.star.uno.UnoRuntime;
|
||||
|
||||
/**
|
||||
* The class doing the actual work of the OpenOfficeMetadataExtracter, based around an OpenOffice connection.
|
||||
*
|
||||
* @author dward
|
||||
*/
|
||||
public class DefaultOpenOfficeMetadataWorker implements OpenOfficeMetadataWorker
|
||||
{
|
||||
private static final String KEY_AUTHOR = "author";
|
||||
private static final String KEY_TITLE = "title";
|
||||
private static final String KEY_DESCRIPTION = "description";
|
||||
|
||||
private OpenOfficeConnection connection;
|
||||
private MimetypeService mimetypeService;
|
||||
|
||||
public void setConnection(OpenOfficeConnection connection)
|
||||
{
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
/*
|
||||
* @param mimetypeService the mimetype service. Set this if required.
|
||||
*/
|
||||
public void setMimetypeService(MimetypeService mimetypeService)
|
||||
{
|
||||
this.mimetypeService = mimetypeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns true if a connection to the Uno server could be established
|
||||
*/
|
||||
public boolean isConnected()
|
||||
{
|
||||
return connection.isConnected();
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @seeorg.alfresco.repo.content.metadata.OpenOfficeMetadataWorker#extractRaw(org.alfresco.service.cmr.repository.
|
||||
* ContentReader)
|
||||
*/
|
||||
public Map<String, Serializable> extractRaw(ContentReader reader) throws Throwable
|
||||
{
|
||||
Map<String, Serializable> rawProperties = new HashMap<String, Serializable>(17);
|
||||
|
||||
String sourceMimetype = reader.getMimetype();
|
||||
|
||||
// create temporary files to convert from and to
|
||||
File tempFromFile = TempFileProvider.createTempFile("OpenOfficeMetadataExtracter-", "."
|
||||
+ this.mimetypeService.getExtension(sourceMimetype));
|
||||
|
||||
// download the content from the source reader
|
||||
reader.getContent(tempFromFile);
|
||||
|
||||
String sourceUrl = toUrl(tempFromFile, connection);
|
||||
|
||||
// UNO Interprocess Bridge *should* be thread-safe, but...
|
||||
XComponentLoader desktop = connection.getDesktop();
|
||||
XComponent document = desktop.loadComponentFromURL(sourceUrl, "_blank", 0, new PropertyValue[]
|
||||
{
|
||||
property("Hidden", Boolean.TRUE)
|
||||
});
|
||||
if (document == null)
|
||||
{
|
||||
throw new FileNotFoundException("could not open source document: " + sourceUrl);
|
||||
}
|
||||
try
|
||||
{
|
||||
XDocumentInfoSupplier infoSupplier = (XDocumentInfoSupplier) UnoRuntime.queryInterface(
|
||||
XDocumentInfoSupplier.class, document);
|
||||
XPropertySet propSet = (XPropertySet) UnoRuntime.queryInterface(XPropertySet.class, infoSupplier
|
||||
.getDocumentInfo());
|
||||
|
||||
rawProperties.put(KEY_TITLE, propSet.getPropertyValue("Title").toString());
|
||||
rawProperties.put(KEY_DESCRIPTION, propSet.getPropertyValue("Subject").toString());
|
||||
rawProperties.put(KEY_AUTHOR, propSet.getPropertyValue("Author").toString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
document.dispose();
|
||||
}
|
||||
// Done
|
||||
return rawProperties;
|
||||
}
|
||||
|
||||
public String toUrl(File file, OpenOfficeConnection connection) throws ConnectException
|
||||
{
|
||||
Object fcp = connection.getFileContentProvider();
|
||||
XFileIdentifierConverter fic = (XFileIdentifierConverter) UnoRuntime.queryInterface(
|
||||
XFileIdentifierConverter.class, fcp);
|
||||
return fic.getFileURLFromSystemPath("", file.getAbsolutePath());
|
||||
}
|
||||
|
||||
private static PropertyValue property(String name, Object value)
|
||||
{
|
||||
PropertyValue property = new PropertyValue();
|
||||
property.Name = name;
|
||||
property.Value = value;
|
||||
return property;
|
||||
}
|
||||
}
|
@ -22,28 +22,14 @@
|
||||
* http://www.alfresco.com/legal/licensing" */
|
||||
package org.alfresco.repo.content.metadata;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.Serializable;
|
||||
import java.net.ConnectException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
||||
import net.sf.jooreports.openoffice.connection.OpenOfficeConnection;
|
||||
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
|
||||
import com.sun.star.beans.PropertyValue;
|
||||
import com.sun.star.beans.XPropertySet;
|
||||
import com.sun.star.document.XDocumentInfoSupplier;
|
||||
import com.sun.star.frame.XComponentLoader;
|
||||
import com.sun.star.lang.XComponent;
|
||||
import com.sun.star.ucb.XFileIdentifierConverter;
|
||||
import com.sun.star.uno.UnoRuntime;
|
||||
|
||||
/**
|
||||
* Extracts values from Star Office documents into the following:
|
||||
@ -55,12 +41,8 @@ import com.sun.star.uno.UnoRuntime;
|
||||
*
|
||||
* @author Jesper Steen Møller
|
||||
*/
|
||||
public class OpenOfficeMetadataExtracter extends AbstractMappingMetadataExtracter
|
||||
public class OpenOfficeMetadataExtracter extends AbstractMappingMetadataExtracter implements OpenOfficeMetadataWorker
|
||||
{
|
||||
private static final String KEY_AUTHOR = "author";
|
||||
private static final String KEY_TITLE = "title";
|
||||
private static final String KEY_DESCRIPTION = "description";
|
||||
|
||||
public static String[] SUPPORTED_MIMETYPES = new String[] {
|
||||
MimetypeMap.MIMETYPE_STAROFFICE5_WRITER,
|
||||
MimetypeMap.MIMETYPE_STAROFFICE5_IMPRESS,
|
||||
@ -68,16 +50,16 @@ public class OpenOfficeMetadataExtracter extends AbstractMappingMetadataExtracte
|
||||
MimetypeMap.MIMETYPE_OPENOFFICE1_IMPRESS
|
||||
};
|
||||
|
||||
private OpenOfficeConnection connection;
|
||||
private OpenOfficeMetadataWorker worker;
|
||||
|
||||
public OpenOfficeMetadataExtracter()
|
||||
{
|
||||
super(new HashSet<String>(Arrays.asList(SUPPORTED_MIMETYPES)));
|
||||
}
|
||||
|
||||
public void setConnection(OpenOfficeConnection connection)
|
||||
public void setWorker(OpenOfficeMetadataWorker worker)
|
||||
{
|
||||
this.connection = connection;
|
||||
this.worker = worker;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -86,19 +68,18 @@ public class OpenOfficeMetadataExtracter extends AbstractMappingMetadataExtracte
|
||||
@Override
|
||||
public synchronized void init()
|
||||
{
|
||||
PropertyCheck.mandatory("OpenOfficeMetadataExtracter", "connection", connection);
|
||||
PropertyCheck.mandatory("OpenOfficeMetadataExtracter", "worker", worker);
|
||||
|
||||
// Base initialization
|
||||
super.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns true if a connection to the Uno server could be
|
||||
* established
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.content.metadata.OpenOfficeMetadataWorker#isConnected()
|
||||
*/
|
||||
public boolean isConnected()
|
||||
{
|
||||
return connection.isConnected();
|
||||
return worker.isConnected();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -114,67 +95,18 @@ public class OpenOfficeMetadataExtracter extends AbstractMappingMetadataExtracte
|
||||
return super.isSupported(sourceMimetype);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.alfresco.repo.content.metadata.OpenOfficeMetadataWorker#extractRaw(org.alfresco.service.cmr.repository.ContentReader)
|
||||
*/
|
||||
@Override
|
||||
public Map<String, Serializable> extractRaw(ContentReader reader) throws Throwable
|
||||
{
|
||||
Map<String, Serializable> rawProperties = newRawMap();
|
||||
|
||||
String sourceMimetype = reader.getMimetype();
|
||||
|
||||
// create temporary files to convert from and to
|
||||
File tempFromFile = TempFileProvider.createTempFile(
|
||||
"OpenOfficeMetadataExtracter-", "."
|
||||
+ getMimetypeService().getExtension(sourceMimetype));
|
||||
// download the content from the source reader
|
||||
reader.getContent(tempFromFile);
|
||||
|
||||
String sourceUrl = toUrl(tempFromFile, connection);
|
||||
|
||||
// UNO Interprocess Bridge *should* be thread-safe, but...
|
||||
XComponentLoader desktop = connection.getDesktop();
|
||||
XComponent document = desktop.loadComponentFromURL(
|
||||
sourceUrl,
|
||||
"_blank",
|
||||
0,
|
||||
new PropertyValue[] { property("Hidden", Boolean.TRUE) });
|
||||
if (document == null)
|
||||
Map<String, Serializable> result = this.worker.extractRaw(reader);
|
||||
for (Map.Entry<String, Serializable> entry : result.entrySet())
|
||||
{
|
||||
throw new FileNotFoundException("could not open source document: " + sourceUrl);
|
||||
putRawValue(entry.getKey(), entry.getValue(), rawProperties);
|
||||
}
|
||||
try
|
||||
{
|
||||
XDocumentInfoSupplier infoSupplier = (XDocumentInfoSupplier) UnoRuntime.queryInterface(
|
||||
XDocumentInfoSupplier.class, document);
|
||||
XPropertySet propSet = (XPropertySet) UnoRuntime.queryInterface(
|
||||
XPropertySet.class,
|
||||
infoSupplier
|
||||
.getDocumentInfo());
|
||||
|
||||
putRawValue(KEY_TITLE, propSet.getPropertyValue("Title").toString(), rawProperties);
|
||||
putRawValue(KEY_DESCRIPTION, propSet.getPropertyValue("Subject").toString(), rawProperties);
|
||||
putRawValue(KEY_AUTHOR, propSet.getPropertyValue("Author").toString(), rawProperties);
|
||||
}
|
||||
finally
|
||||
{
|
||||
document.dispose();
|
||||
}
|
||||
// Done
|
||||
return rawProperties;
|
||||
}
|
||||
|
||||
public String toUrl(File file, OpenOfficeConnection connection) throws ConnectException
|
||||
{
|
||||
Object fcp = connection.getFileContentProvider();
|
||||
XFileIdentifierConverter fic = (XFileIdentifierConverter) UnoRuntime.queryInterface(
|
||||
XFileIdentifierConverter.class, fcp);
|
||||
return fic.getFileURLFromSystemPath("", file.getAbsolutePath());
|
||||
}
|
||||
|
||||
private static PropertyValue property(String name, Object value)
|
||||
{
|
||||
PropertyValue property = new PropertyValue();
|
||||
property.Name = name;
|
||||
property.Value = value;
|
||||
return property;
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,10 @@ public class OpenOfficeMetadataExtracterTest extends AbstractMetadataExtracterTe
|
||||
extracter = new OpenOfficeMetadataExtracter();
|
||||
extracter.setMimetypeService(mimetypeMap);
|
||||
extracter.setDictionaryService(dictionaryService);
|
||||
extracter.setConnection(connection);
|
||||
DefaultOpenOfficeMetadataWorker worker = new DefaultOpenOfficeMetadataWorker();
|
||||
worker.setConnection(connection);
|
||||
worker.setMimetypeService(mimetypeMap);
|
||||
extracter.setWorker(worker);
|
||||
extracter.init();
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have received a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.content.metadata;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
|
||||
/**
|
||||
* An interface that allows separation between the metadata extractor registry and the third party subsystem owning the
|
||||
* open office connection.
|
||||
*
|
||||
* @author dward
|
||||
*/
|
||||
public interface OpenOfficeMetadataWorker
|
||||
{
|
||||
/**
|
||||
* @return Returns true if a connection to the Uno server could be established
|
||||
*/
|
||||
public boolean isConnected();
|
||||
|
||||
public Map<String, Serializable> extractRaw(ContentReader reader) throws Throwable;
|
||||
}
|
@ -24,16 +24,12 @@
|
||||
*/
|
||||
package org.alfresco.repo.content.transform;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.cmr.repository.ContentAccessor;
|
||||
import org.alfresco.service.cmr.repository.ContentIOException;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.TransformationOptions;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@ -48,13 +44,11 @@ import org.apache.commons.logging.LogFactory;
|
||||
* @author Derek Hulley
|
||||
* @author Roy Wetherall
|
||||
*/
|
||||
public abstract class AbstractContentTransformer2 implements ContentTransformer
|
||||
public abstract class AbstractContentTransformer2 extends ContentTransformerHelper implements ContentTransformer
|
||||
{
|
||||
private static final Log logger = LogFactory.getLog(AbstractContentTransformer2.class);
|
||||
|
||||
private MimetypeService mimetypeService;
|
||||
private ContentTransformerRegistry registry;
|
||||
private List<ExplictTransformationDetails> explicitTransformations;
|
||||
private double averageTime = 0.0;
|
||||
private long count = 0L;
|
||||
|
||||
@ -64,7 +58,6 @@ public abstract class AbstractContentTransformer2 implements ContentTransformer
|
||||
protected AbstractContentTransformer2()
|
||||
{
|
||||
averageTime = 0.0;
|
||||
explicitTransformations = new ArrayList<ExplictTransformationDetails>(0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,31 +68,7 @@ public abstract class AbstractContentTransformer2 implements ContentTransformer
|
||||
public void setRegistry(ContentTransformerRegistry registry)
|
||||
{
|
||||
this.registry = registry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper setter of the mimetype service. This is not always required.
|
||||
*
|
||||
* @param mimetypeService
|
||||
*/
|
||||
public void setMimetypeService(MimetypeService mimetypeService)
|
||||
{
|
||||
this.mimetypeService = mimetypeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the mimetype helper
|
||||
*/
|
||||
protected MimetypeService getMimetypeService()
|
||||
{
|
||||
return mimetypeService;
|
||||
}
|
||||
|
||||
public void setExplicitTransformations(List<ExplictTransformationDetails> explicitTransformations)
|
||||
{
|
||||
this.explicitTransformations = explicitTransformations;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
@ -128,24 +97,6 @@ public abstract class AbstractContentTransformer2 implements ContentTransformer
|
||||
registry.addTransformer(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience to fetch and check the mimetype for the given content
|
||||
*
|
||||
* @param content the reader/writer for the content
|
||||
* @return Returns the mimetype for the content
|
||||
* @throws AlfrescoRuntimeException if the content doesn't have a mimetype
|
||||
*/
|
||||
protected String getMimetype(ContentAccessor content)
|
||||
{
|
||||
String mimetype = content.getMimetype();
|
||||
if (mimetype == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Mimetype is mandatory for transformation: " + content);
|
||||
}
|
||||
// done
|
||||
return mimetype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to check the transformability of a transformation
|
||||
*
|
||||
@ -270,26 +221,6 @@ public abstract class AbstractContentTransformer2 implements ContentTransformer
|
||||
this.transform(reader, writer, new TransformationOptions(options));
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation, override if need to extend logic
|
||||
*
|
||||
* @see org.alfresco.repo.content.transform.ContentTransformer#isExplicitTransformation(java.lang.String, java.lang.String, org.alfresco.service.cmr.repository.TransformationOptions)
|
||||
*/
|
||||
public boolean isExplicitTransformation(String sourceMimetype, String targetMimetype, TransformationOptions options)
|
||||
{
|
||||
boolean result = false;
|
||||
for (ExplictTransformationDetails explicitTransformation : this.explicitTransformations)
|
||||
{
|
||||
if (sourceMimetype.equals(explicitTransformation.getSourceMimetype()) == true &&
|
||||
targetMimetype.equals(explicitTransformation.getTargetMimetype()) == true)
|
||||
{
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the calculated running average of the current transformations
|
||||
*/
|
||||
|
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have received a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.content.transform;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.service.cmr.repository.ContentAccessor;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.TransformationOptions;
|
||||
|
||||
/**
|
||||
* A class providing basic functionality shared by both {@link ContentTransformer}s and {@link ContentTransformerWorker}
|
||||
* s.
|
||||
*
|
||||
* @author dward
|
||||
*/
|
||||
public class ContentTransformerHelper
|
||||
{
|
||||
|
||||
private MimetypeService mimetypeService;
|
||||
private List<ExplictTransformationDetails> explicitTransformations;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public ContentTransformerHelper()
|
||||
{
|
||||
setExplicitTransformations(Collections.<ExplictTransformationDetails> emptyList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper setter of the mimetype service. This is not always required.
|
||||
*
|
||||
* @param mimetypeService
|
||||
*/
|
||||
public void setMimetypeService(MimetypeService mimetypeService)
|
||||
{
|
||||
this.mimetypeService = mimetypeService;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the mimetype helper
|
||||
*/
|
||||
protected MimetypeService getMimetypeService()
|
||||
{
|
||||
return mimetypeService;
|
||||
}
|
||||
|
||||
public void setExplicitTransformations(List<ExplictTransformationDetails> explicitTransformations)
|
||||
{
|
||||
this.explicitTransformations = explicitTransformations;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience to fetch and check the mimetype for the given content
|
||||
*
|
||||
* @param content
|
||||
* the reader/writer for the content
|
||||
* @return Returns the mimetype for the content
|
||||
* @throws AlfrescoRuntimeException
|
||||
* if the content doesn't have a mimetype
|
||||
*/
|
||||
protected String getMimetype(ContentAccessor content)
|
||||
{
|
||||
String mimetype = content.getMimetype();
|
||||
if (mimetype == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Mimetype is mandatory for transformation: " + content);
|
||||
}
|
||||
// done
|
||||
return mimetype;
|
||||
}
|
||||
|
||||
/**
|
||||
* Default implementation, override if need to extend logic
|
||||
*
|
||||
* @see org.alfresco.repo.content.transform.ContentTransformer#isExplicitTransformation(java.lang.String,
|
||||
* java.lang.String, org.alfresco.service.cmr.repository.TransformationOptions)
|
||||
*/
|
||||
public boolean isExplicitTransformation(String sourceMimetype, String targetMimetype, TransformationOptions options)
|
||||
{
|
||||
boolean result = false;
|
||||
for (ExplictTransformationDetails explicitTransformation : this.explicitTransformations)
|
||||
{
|
||||
if (sourceMimetype.equals(explicitTransformation.getSourceMimetype()) == true
|
||||
&& targetMimetype.equals(explicitTransformation.getTargetMimetype()) == true)
|
||||
{
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have received a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.content.transform;
|
||||
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.TransformationOptions;
|
||||
|
||||
/**
|
||||
* An interface that allows separation between the content transformer registry and the various third party subsystems
|
||||
* performing the transformation.
|
||||
*
|
||||
* @author dward
|
||||
*/
|
||||
public interface ContentTransformerWorker
|
||||
{
|
||||
/**
|
||||
* Checks if this worker is available.
|
||||
*
|
||||
* @return true if it is available
|
||||
*/
|
||||
public boolean isAvailable();
|
||||
|
||||
/**
|
||||
* Gets a string returning product and version information.
|
||||
*
|
||||
* @return the version string
|
||||
*/
|
||||
public String getVersionString();
|
||||
|
||||
public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options);
|
||||
|
||||
public void transform(ContentReader reader, ContentWriter writer, TransformationOptions options) throws Exception;
|
||||
}
|
@ -37,7 +37,7 @@ import org.alfresco.service.cmr.repository.TransformationOptions;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.content.transform.OpenOfficeContentTransformer
|
||||
* @see org.alfresco.repo.content.transform.OpenOfficeContentTransformerWorker
|
||||
*
|
||||
* @author Derek Hulley
|
||||
*/
|
||||
@ -45,7 +45,8 @@ public class OpenOfficeContentTransformerTest extends AbstractContentTransformer
|
||||
{
|
||||
private static String MIMETYPE_RUBBISH = "text/rubbish";
|
||||
|
||||
private OpenOfficeContentTransformer transformer;
|
||||
private OpenOfficeContentTransformerWorker worker;
|
||||
private ContentTransformer transformer;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception
|
||||
@ -54,11 +55,15 @@ public class OpenOfficeContentTransformerTest extends AbstractContentTransformer
|
||||
|
||||
OpenOfficeConnection connection = (OpenOfficeConnection) ctx.getBean("openOfficeConnection");
|
||||
|
||||
transformer = new OpenOfficeContentTransformer();
|
||||
this.worker = new OpenOfficeContentTransformerWorker();
|
||||
worker.setMimetypeService(mimetypeService);
|
||||
worker.setConnection(connection);
|
||||
worker.setDocumentFormatsConfiguration("classpath:alfresco/mimetype/openoffice-document-formats.xml");
|
||||
worker.afterPropertiesSet();
|
||||
ProxyContentTransformer transformer = new ProxyContentTransformer();
|
||||
transformer.setMimetypeService(mimetypeService);
|
||||
transformer.setConnection(connection);
|
||||
transformer.setDocumentFormatsConfiguration("classpath:alfresco/mimetype/openoffice-document-formats.xml");
|
||||
transformer.register();
|
||||
transformer.setWorker(worker);
|
||||
this.transformer = transformer;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,7 +82,7 @@ public class OpenOfficeContentTransformerTest extends AbstractContentTransformer
|
||||
|
||||
public void testReliability() throws Exception
|
||||
{
|
||||
if (!transformer.isConnected())
|
||||
if (!worker.isAvailable())
|
||||
{
|
||||
// no connection
|
||||
return;
|
||||
@ -99,7 +104,7 @@ public class OpenOfficeContentTransformerTest extends AbstractContentTransformer
|
||||
*/
|
||||
public void testHtmlToPdf() throws Exception
|
||||
{
|
||||
if (!transformer.isConnected())
|
||||
if (!worker.isAvailable())
|
||||
{
|
||||
// no connection
|
||||
return;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -18,7 +18,7 @@
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* FLOSS exception. You should have received a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
@ -46,27 +46,25 @@ import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.TransformationOptions;
|
||||
import org.alfresco.util.PropertyCheck;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.core.io.DefaultResourceLoader;
|
||||
|
||||
/**
|
||||
* Makes use of the {@link http://sourceforge.net/projects/joott/ JOOConverter} library to
|
||||
* perform OpenOffice-drive conversions.
|
||||
* Makes use of the {@link http://sourceforge.net/projects/joott/JOOConverter} library to perform OpenOffice-drive
|
||||
* conversions.
|
||||
*
|
||||
* @author Derek Hulley
|
||||
*/
|
||||
public class OpenOfficeContentTransformer extends AbstractContentTransformer2
|
||||
public class OpenOfficeContentTransformerWorker extends ContentTransformerHelper implements ContentTransformerWorker, InitializingBean
|
||||
{
|
||||
private OpenOfficeConnection connection;
|
||||
private AbstractOpenOfficeDocumentConverter converter;
|
||||
private String documentFormatsConfiguration;
|
||||
private DocumentFormatRegistry formatRegistry;
|
||||
|
||||
public OpenOfficeContentTransformer()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param connection the connection that the converter uses
|
||||
* @param connection
|
||||
* the connection that the converter uses
|
||||
*/
|
||||
public void setConnection(OpenOfficeConnection connection)
|
||||
{
|
||||
@ -74,12 +72,13 @@ public class OpenOfficeContentTransformer extends AbstractContentTransformer2
|
||||
}
|
||||
|
||||
/**
|
||||
* Explicitly set the converter to be used. The converter must use the same connection
|
||||
* set in {@link #setConnection(OpenOfficeConnection)}.
|
||||
* Explicitly set the converter to be used. The converter must use the same connection set in
|
||||
* {@link #setConnection(OpenOfficeConnection)}.
|
||||
* <p>
|
||||
* If not set, then the <code>OpenOfficeDocumentConverter</code> will be used.
|
||||
*
|
||||
* @param converter the converter to use.
|
||||
* @param converter
|
||||
* the converter to use.
|
||||
*/
|
||||
public void setConverter(AbstractOpenOfficeDocumentConverter converter)
|
||||
{
|
||||
@ -89,51 +88,48 @@ public class OpenOfficeContentTransformer extends AbstractContentTransformer2
|
||||
/**
|
||||
* Set a non-default location from which to load the document format mappings.
|
||||
*
|
||||
* @param path a resource location supporting the <b>file:</b> or <b>classpath:</b> prefixes
|
||||
* @param path
|
||||
* a resource location supporting the <b>file:</b> or <b>classpath:</b> prefixes
|
||||
*/
|
||||
public void setDocumentFormatsConfiguration(String path)
|
||||
{
|
||||
this.documentFormatsConfiguration = path;
|
||||
}
|
||||
|
||||
public boolean isConnected()
|
||||
public boolean isAvailable()
|
||||
{
|
||||
return connection.isConnected();
|
||||
return this.connection.isConnected();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void register()
|
||||
public void afterPropertiesSet() throws Exception
|
||||
{
|
||||
PropertyCheck.mandatory("OpenOfficeContentTransformer", "connection", connection);
|
||||
|
||||
PropertyCheck.mandatory("OpenOfficeContentTransformerWorker", "connection", this.connection);
|
||||
|
||||
// load the document conversion configuration
|
||||
if (documentFormatsConfiguration != null)
|
||||
if (this.documentFormatsConfiguration != null)
|
||||
{
|
||||
DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
|
||||
try
|
||||
{
|
||||
InputStream is = resourceLoader.getResource(documentFormatsConfiguration).getInputStream();
|
||||
formatRegistry = new XmlDocumentFormatRegistry(is);
|
||||
InputStream is = resourceLoader.getResource(this.documentFormatsConfiguration).getInputStream();
|
||||
this.formatRegistry = new XmlDocumentFormatRegistry(is);
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
throw new AlfrescoRuntimeException(
|
||||
"Unable to load document formats configuration file: " + documentFormatsConfiguration);
|
||||
throw new AlfrescoRuntimeException("Unable to load document formats configuration file: "
|
||||
+ this.documentFormatsConfiguration);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
formatRegistry = new XmlDocumentFormatRegistry();
|
||||
this.formatRegistry = new XmlDocumentFormatRegistry();
|
||||
}
|
||||
|
||||
|
||||
// set up the converter
|
||||
if (converter == null)
|
||||
if (this.converter == null)
|
||||
{
|
||||
converter = new OpenOfficeDocumentConverter(connection);
|
||||
this.converter = new OpenOfficeDocumentConverter(this.connection);
|
||||
}
|
||||
|
||||
// Register
|
||||
super.register();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,12 +137,12 @@ public class OpenOfficeContentTransformer extends AbstractContentTransformer2
|
||||
*/
|
||||
public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options)
|
||||
{
|
||||
if (!isConnected())
|
||||
if (!isAvailable())
|
||||
{
|
||||
// The connection management is must take care of this
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// there are some conversions that fail, despite the converter believing them possible
|
||||
if (targetMimetype.equals(MimetypeMap.MIMETYPE_XHTML))
|
||||
{
|
||||
@ -160,19 +156,19 @@ public class OpenOfficeContentTransformer extends AbstractContentTransformer2
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
MimetypeService mimetypeService = getMimetypeService();
|
||||
String sourceExtension = mimetypeService.getExtension(sourceMimetype);
|
||||
String targetExtension = mimetypeService.getExtension(targetMimetype);
|
||||
// query the registry for the source format
|
||||
DocumentFormat sourceFormat = formatRegistry.getFormatByFileExtension(sourceExtension);
|
||||
DocumentFormat sourceFormat = this.formatRegistry.getFormatByFileExtension(sourceExtension);
|
||||
if (sourceFormat == null)
|
||||
{
|
||||
// no document format
|
||||
return false;
|
||||
}
|
||||
// query the registry for the target format
|
||||
DocumentFormat targetFormat = formatRegistry.getFormatByFileExtension(targetExtension);
|
||||
DocumentFormat targetFormat = this.formatRegistry.getFormatByFileExtension(targetExtension);
|
||||
if (targetFormat == null)
|
||||
{
|
||||
// no document format
|
||||
@ -193,10 +189,7 @@ public class OpenOfficeContentTransformer extends AbstractContentTransformer2
|
||||
}
|
||||
}
|
||||
|
||||
protected void transformInternal(
|
||||
ContentReader reader,
|
||||
ContentWriter writer,
|
||||
TransformationOptions options) throws Exception
|
||||
public void transform(ContentReader reader, ContentWriter writer, TransformationOptions options) throws Exception
|
||||
{
|
||||
String sourceMimetype = getMimetype(reader);
|
||||
String targetMimetype = getMimetype(writer);
|
||||
@ -205,14 +198,14 @@ public class OpenOfficeContentTransformer extends AbstractContentTransformer2
|
||||
String sourceExtension = mimetypeService.getExtension(sourceMimetype);
|
||||
String targetExtension = mimetypeService.getExtension(targetMimetype);
|
||||
// query the registry for the source format
|
||||
DocumentFormat sourceFormat = formatRegistry.getFormatByFileExtension(sourceExtension);
|
||||
DocumentFormat sourceFormat = this.formatRegistry.getFormatByFileExtension(sourceExtension);
|
||||
if (sourceFormat == null)
|
||||
{
|
||||
// source format is not recognised
|
||||
throw new ContentIOException("No OpenOffice document format for source extension: " + sourceExtension);
|
||||
}
|
||||
// query the registry for the target format
|
||||
DocumentFormat targetFormat = formatRegistry.getFormatByFileExtension(targetExtension);
|
||||
DocumentFormat targetFormat = this.formatRegistry.getFormatByFileExtension(targetExtension);
|
||||
if (targetFormat == null)
|
||||
{
|
||||
// target format is not recognised
|
||||
@ -223,38 +216,41 @@ public class OpenOfficeContentTransformer extends AbstractContentTransformer2
|
||||
// does the format support the conversion
|
||||
if (!targetFormat.isExportableFrom(sourceFamily))
|
||||
{
|
||||
throw new ContentIOException(
|
||||
"OpenOffice conversion not supported: \n" +
|
||||
" reader: " + reader + "\n" +
|
||||
" writer: " + writer);
|
||||
throw new ContentIOException("OpenOffice conversion not supported: \n" + " reader: " + reader + "\n"
|
||||
+ " writer: " + writer);
|
||||
}
|
||||
|
||||
// create temporary files to convert from and to
|
||||
File tempFromFile = TempFileProvider.createTempFile(
|
||||
"OpenOfficeContentTransformer-source-",
|
||||
"." + sourceExtension);
|
||||
File tempToFile = TempFileProvider.createTempFile(
|
||||
"OpenOfficeContentTransformer-target-",
|
||||
"." + targetExtension);
|
||||
File tempFromFile = TempFileProvider.createTempFile("OpenOfficeContentTransformer-source-", "."
|
||||
+ sourceExtension);
|
||||
File tempToFile = TempFileProvider
|
||||
.createTempFile("OpenOfficeContentTransformer-target-", "." + targetExtension);
|
||||
// download the content from the source reader
|
||||
reader.getContent(tempFromFile);
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
converter.convert(tempFromFile, sourceFormat, tempToFile, targetFormat);
|
||||
this.converter.convert(tempFromFile, sourceFormat, tempToFile, targetFormat);
|
||||
// conversion success
|
||||
}
|
||||
catch (OpenOfficeException e)
|
||||
{
|
||||
throw new ContentIOException("OpenOffice server conversion failed: \n" +
|
||||
" reader: " + reader + "\n" +
|
||||
" writer: " + writer + "\n" +
|
||||
" from file: " + tempFromFile + "\n" +
|
||||
" to file: " + tempToFile,
|
||||
e);
|
||||
throw new ContentIOException("OpenOffice server conversion failed: \n" + " reader: " + reader + "\n"
|
||||
+ " writer: " + writer + "\n" + " from file: " + tempFromFile + "\n" + " to file: "
|
||||
+ tempToFile, e);
|
||||
}
|
||||
|
||||
|
||||
// upload the temp output to the writer given us
|
||||
writer.putContent(tempToFile);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
* @see org.alfresco.repo.content.transform.ContentTransformerWorker#getVersionString()
|
||||
*/
|
||||
public String getVersionString()
|
||||
{
|
||||
// Actual version information owned by OpenOfficeConnectionTester
|
||||
return "";
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have received a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
package org.alfresco.repo.content.transform;
|
||||
|
||||
import net.sf.jooreports.converter.DocumentFormatRegistry;
|
||||
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.TransformationOptions;
|
||||
|
||||
/**
|
||||
* Makes use of a {@link ContentTransformerWorker} to perform conversions.
|
||||
*
|
||||
* @author dward
|
||||
*/
|
||||
public class ProxyContentTransformer extends AbstractContentTransformer2
|
||||
{
|
||||
private ContentTransformerWorker worker;
|
||||
|
||||
public ProxyContentTransformer()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param worker
|
||||
* the worker that the converter uses
|
||||
*/
|
||||
public void setWorker(ContentTransformerWorker worker)
|
||||
{
|
||||
this.worker = worker;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DocumentFormatRegistry
|
||||
*/
|
||||
public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options)
|
||||
{
|
||||
return this.worker.isTransformable(sourceMimetype, targetMimetype, options);
|
||||
}
|
||||
|
||||
protected void transformInternal(ContentReader reader, ContentWriter writer, TransformationOptions options)
|
||||
throws Exception
|
||||
{
|
||||
this.worker.transform(reader, writer, options);
|
||||
}
|
||||
}
|
@ -39,20 +39,20 @@ import org.alfresco.util.TempFileProvider;
|
||||
import org.alfresco.util.exec.RuntimeExec;
|
||||
|
||||
/**
|
||||
* @see org.alfresco.repo.content.transform.RuntimeExecutableContentTransformer
|
||||
* @see org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker
|
||||
*
|
||||
* @author Derek Hulley
|
||||
*/
|
||||
public class RuntimeExecutableContentTransformerTest extends BaseAlfrescoTestCase
|
||||
{
|
||||
private RuntimeExecutableContentTransformer transformer;
|
||||
private ContentTransformer transformer;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
transformer = new RuntimeExecutableContentTransformer();
|
||||
RuntimeExecutableContentTransformerWorker worker = new RuntimeExecutableContentTransformerWorker();
|
||||
// the command to execute
|
||||
RuntimeExec transformCommand = new RuntimeExec();
|
||||
Map<String, String> commandMap = new HashMap<String, String>(5);
|
||||
@ -61,16 +61,21 @@ public class RuntimeExecutableContentTransformerTest extends BaseAlfrescoTestCas
|
||||
commandMap.put(".*", "cmd /c copy /Y \"${source}\" \"${target}\"");
|
||||
transformCommand.setCommandMap(commandMap);
|
||||
transformCommand.setErrorCodes("1, 2");
|
||||
transformer.setTransformCommand(transformCommand);
|
||||
transformer.setMimetypeService(serviceRegistry.getMimetypeService());
|
||||
worker.setTransformCommand(transformCommand);
|
||||
worker.setMimetypeService(serviceRegistry.getMimetypeService());
|
||||
// set the explicit transformations
|
||||
List<ExplictTransformationDetails> explicitTranformations = new ArrayList<ExplictTransformationDetails>(1);
|
||||
explicitTranformations.add(
|
||||
new ExplictTransformationDetails(MimetypeMap.MIMETYPE_TEXT_PLAIN, MimetypeMap.MIMETYPE_XML));
|
||||
transformer.setExplicitTransformations(explicitTranformations);
|
||||
worker.setExplicitTransformations(explicitTranformations);
|
||||
|
||||
// initialise so that it doesn't score 0
|
||||
transformer.register();
|
||||
worker.afterPropertiesSet();
|
||||
|
||||
ProxyContentTransformer transformer = new ProxyContentTransformer();
|
||||
transformer.setMimetypeService(serviceRegistry.getMimetypeService());
|
||||
transformer.setWorker(worker);
|
||||
this.transformer = transformer;
|
||||
}
|
||||
|
||||
public void testCopyCommand() throws Exception
|
||||
|
@ -39,6 +39,7 @@ import org.alfresco.util.exec.RuntimeExec;
|
||||
import org.alfresco.util.exec.RuntimeExec.ExecutionResult;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* This configurable wrapper is able to execute any command line transformation that
|
||||
@ -67,12 +68,12 @@ import org.apache.commons.logging.LogFactory;
|
||||
* @since 1.1
|
||||
* @author Derek Hulley
|
||||
*/
|
||||
public class RuntimeExecutableContentTransformer extends AbstractContentTransformer2
|
||||
public class RuntimeExecutableContentTransformerWorker extends ContentTransformerHelper implements ContentTransformerWorker, InitializingBean
|
||||
{
|
||||
public static final String VAR_SOURCE = "source";
|
||||
public static final String VAR_TARGET = "target";
|
||||
|
||||
private static Log logger = LogFactory.getLog(RuntimeExecutableContentTransformer.class);
|
||||
private static Log logger = LogFactory.getLog(RuntimeExecutableContentTransformerWorker.class);
|
||||
|
||||
private boolean available;
|
||||
private RuntimeExec checkCommand;
|
||||
@ -81,7 +82,7 @@ public class RuntimeExecutableContentTransformer extends AbstractContentTransfor
|
||||
/** Stores the output from the check command */
|
||||
private String versionString;
|
||||
|
||||
public RuntimeExecutableContentTransformer()
|
||||
public RuntimeExecutableContentTransformerWorker()
|
||||
{
|
||||
}
|
||||
|
||||
@ -130,13 +131,13 @@ public class RuntimeExecutableContentTransformer extends AbstractContentTransfor
|
||||
throw new AlfrescoRuntimeException("content.runtime_exec.property_moved");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Executes the check command, if present. Any errors will result in this component
|
||||
* being rendered unusable within the transformer registry, but may still be called
|
||||
* directly.
|
||||
*/
|
||||
@Override
|
||||
public void register()
|
||||
public void afterPropertiesSet()
|
||||
{
|
||||
if (transformCommand == null)
|
||||
{
|
||||
@ -162,8 +163,6 @@ public class RuntimeExecutableContentTransformer extends AbstractContentTransfor
|
||||
// no check - just assume it is available
|
||||
available = true;
|
||||
}
|
||||
// call the base class to make sure that it gets registered
|
||||
super.register();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -181,7 +180,7 @@ public class RuntimeExecutableContentTransformer extends AbstractContentTransfor
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isExplicitTransformation(sourceMimetype, targetMimetype, options) == true)
|
||||
if (isExplicitTransformation(sourceMimetype, targetMimetype, options))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -217,7 +216,7 @@ public class RuntimeExecutableContentTransformer extends AbstractContentTransfor
|
||||
*
|
||||
* @see #transformInternal(File, File)
|
||||
*/
|
||||
protected final void transformInternal(
|
||||
public final void transform(
|
||||
ContentReader reader,
|
||||
ContentWriter writer,
|
||||
TransformationOptions options) throws Exception
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2007 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -18,7 +18,7 @@
|
||||
* As a special exception to the terms and conditions of version 2.0 of
|
||||
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
||||
* FLOSS exception. You should have recieved a copy of the text describing
|
||||
* FLOSS exception. You should have received a copy of the text describing
|
||||
* the FLOSS exception, and it is also available here:
|
||||
* http://www.alfresco.com/legal/licensing"
|
||||
*/
|
||||
@ -30,30 +30,33 @@ import java.io.InputStream;
|
||||
import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.content.filestore.FileContentWriter;
|
||||
import org.alfresco.repo.content.transform.AbstractContentTransformer2;
|
||||
import org.alfresco.repo.content.transform.ContentTransformerHelper;
|
||||
import org.alfresco.repo.content.transform.ContentTransformerWorker;
|
||||
import org.alfresco.service.cmr.repository.ContentIOException;
|
||||
import org.alfresco.service.cmr.repository.ContentReader;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||
import org.alfresco.service.cmr.repository.TransformationOptions;
|
||||
import org.alfresco.util.TempFileProvider;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
|
||||
/**
|
||||
* Abstract helper for transformations based on <b>ImageMagick</b>
|
||||
*
|
||||
* @author Derek Hulley
|
||||
*/
|
||||
public abstract class AbstractImageMagickContentTransformer extends AbstractContentTransformer2
|
||||
public abstract class AbstractImageMagickContentTransformerWorker extends ContentTransformerHelper implements ContentTransformerWorker, InitializingBean
|
||||
{
|
||||
/** the prefix for mimetypes supported by the transformer */
|
||||
public static final String MIMETYPE_IMAGE_PREFIX = "image/";
|
||||
|
||||
private static final Log logger = LogFactory.getLog(AbstractImageMagickContentTransformer.class);
|
||||
private static final Log logger = LogFactory.getLog(AbstractImageMagickContentTransformerWorker.class);
|
||||
|
||||
private boolean available;
|
||||
|
||||
public AbstractImageMagickContentTransformer()
|
||||
public AbstractImageMagickContentTransformerWorker()
|
||||
{
|
||||
this.available = false;
|
||||
}
|
||||
@ -82,7 +85,7 @@ public abstract class AbstractImageMagickContentTransformer extends AbstractCont
|
||||
* <p>
|
||||
* If initialization is successful, then autoregistration takes place.
|
||||
*/
|
||||
public void init()
|
||||
public void afterPropertiesSet()
|
||||
{
|
||||
if (getMimetypeService() == null)
|
||||
{
|
||||
@ -120,10 +123,7 @@ public abstract class AbstractImageMagickContentTransformer extends AbstractCont
|
||||
" to: " + outputFile);
|
||||
}
|
||||
// we can be sure that it works
|
||||
setAvailable(true);
|
||||
|
||||
// register
|
||||
super.register();
|
||||
setAvailable(true);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
@ -171,8 +171,8 @@ public abstract class AbstractImageMagickContentTransformer extends AbstractCont
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!AbstractImageMagickContentTransformer.isSupported(sourceMimetype) ||
|
||||
!AbstractImageMagickContentTransformer.isSupported(targetMimetype))
|
||||
if (!AbstractImageMagickContentTransformerWorker.isSupported(sourceMimetype) ||
|
||||
!AbstractImageMagickContentTransformerWorker.isSupported(targetMimetype))
|
||||
{
|
||||
// only support IMAGE -> IMAGE (excl. RGB)
|
||||
return false;
|
||||
@ -186,7 +186,7 @@ public abstract class AbstractImageMagickContentTransformer extends AbstractCont
|
||||
/**
|
||||
* @see #transformInternal(File, File)
|
||||
*/
|
||||
protected final void transformInternal(
|
||||
public final void transform(
|
||||
ContentReader reader,
|
||||
ContentWriter writer,
|
||||
TransformationOptions options) throws Exception
|
||||
@ -196,8 +196,9 @@ public abstract class AbstractImageMagickContentTransformer extends AbstractCont
|
||||
String targetMimetype = getMimetype(writer);
|
||||
|
||||
// get the extensions to use
|
||||
String sourceExtension = getMimetypeService().getExtension(sourceMimetype);
|
||||
String targetExtension = getMimetypeService().getExtension(targetMimetype);
|
||||
MimetypeService mimetypeService = getMimetypeService();
|
||||
String sourceExtension = mimetypeService.getExtension(sourceMimetype);
|
||||
String targetExtension = mimetypeService.getExtension(targetMimetype);
|
||||
if (sourceExtension == null || targetExtension == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("Unknown extensions for mimetypes: \n" +
|
@ -29,6 +29,7 @@ import java.util.Collections;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.repo.content.transform.AbstractContentTransformerTest;
|
||||
import org.alfresco.repo.content.transform.ContentTransformer;
|
||||
import org.alfresco.repo.content.transform.ProxyContentTransformer;
|
||||
import org.alfresco.service.cmr.repository.TransformationOptions;
|
||||
import org.alfresco.util.exec.RuntimeExec;
|
||||
|
||||
@ -39,7 +40,8 @@ import org.alfresco.util.exec.RuntimeExec;
|
||||
*/
|
||||
public class ImageMagickContentTransformerTest extends AbstractContentTransformerTest
|
||||
{
|
||||
private ImageMagickContentTransformer transformer;
|
||||
private ImageMagickContentTransformerWorker worker;
|
||||
private ContentTransformer transformer;
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception
|
||||
@ -50,10 +52,15 @@ public class ImageMagickContentTransformerTest extends AbstractContentTransforme
|
||||
executer.setCommand(new String[] {"imconvert.exe", "${source}", "${options}", "${target}"});
|
||||
executer.setDefaultProperties(Collections.singletonMap("options", ""));
|
||||
|
||||
transformer = new ImageMagickContentTransformer();
|
||||
this.worker = new ImageMagickContentTransformerWorker();
|
||||
worker.setMimetypeService(mimetypeService);
|
||||
worker.setExecuter(executer);
|
||||
worker.afterPropertiesSet();
|
||||
|
||||
ProxyContentTransformer transformer = new ProxyContentTransformer();
|
||||
transformer.setMimetypeService(mimetypeService);
|
||||
transformer.setExecuter(executer);
|
||||
transformer.init();
|
||||
this.transformer = transformer;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -66,7 +73,7 @@ public class ImageMagickContentTransformerTest extends AbstractContentTransforme
|
||||
|
||||
public void testReliability() throws Exception
|
||||
{
|
||||
if (!transformer.isAvailable())
|
||||
if (!this.worker.isAvailable())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2005-2008 Alfresco Software Limited.
|
||||
* Copyright (C) 2005-2009 Alfresco Software Limited.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
@ -41,7 +41,7 @@ import org.apache.commons.logging.LogFactory;
|
||||
*
|
||||
* @author Derek Hulley
|
||||
*/
|
||||
public class ImageMagickContentTransformer extends AbstractImageMagickContentTransformer
|
||||
public class ImageMagickContentTransformerWorker extends AbstractImageMagickContentTransformerWorker
|
||||
{
|
||||
/** options variable name */
|
||||
private static final String KEY_OPTIONS = "options";
|
||||
@ -50,7 +50,7 @@ public class ImageMagickContentTransformer extends AbstractImageMagickContentTra
|
||||
/** target variable name */
|
||||
private static final String VAR_TARGET = "target";
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ImageMagickContentTransformer.class);
|
||||
private static final Log logger = LogFactory.getLog(ImageMagickContentTransformerWorker.class);
|
||||
|
||||
/** the system command executer */
|
||||
private RuntimeExec executer;
|
||||
@ -64,7 +64,7 @@ public class ImageMagickContentTransformer extends AbstractImageMagickContentTra
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public ImageMagickContentTransformer()
|
||||
public ImageMagickContentTransformerWorker()
|
||||
{
|
||||
}
|
||||
|
||||
@ -110,31 +110,28 @@ public class ImageMagickContentTransformer extends AbstractImageMagickContentTra
|
||||
return this.versionString;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks for the JMagick and ImageMagick dependencies, using the common
|
||||
* {@link #transformInternal(File, File) transformation method} to check
|
||||
* that the sample image can be converted.
|
||||
*/
|
||||
public void init()
|
||||
@Override
|
||||
public void afterPropertiesSet()
|
||||
{
|
||||
if (executer == null)
|
||||
{
|
||||
throw new AlfrescoRuntimeException("System runtime executer not set");
|
||||
}
|
||||
super.init();
|
||||
super.afterPropertiesSet();
|
||||
if (isAvailable())
|
||||
{
|
||||
try
|
||||
{
|
||||
// On some platforms / versions, the -version command seems to return an error code whilst still
|
||||
// returning output, so let's not worry about the exit code!
|
||||
ExecutionResult result = this.checkCommand.execute();
|
||||
if (result.getSuccess())
|
||||
{
|
||||
this.versionString = result.getStdOut().trim();
|
||||
}
|
||||
else
|
||||
{
|
||||
setAvailable(false);
|
||||
}
|
||||
this.versionString = result.getStdOut().trim();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
@ -129,16 +129,19 @@ public class DefaultManagedApplicationContextFactory extends AbstractLifecycleBe
|
||||
{
|
||||
"classpath*:alfresco/subsystems/" + this.beanName + "/*-context.xml"
|
||||
}, false, this.parent);
|
||||
// Add all the post processors of the parent, e.g. to make sure system placeholders get expanded properly
|
||||
for (Object postProcessor : this.parent.getBeansOfType(BeanFactoryPostProcessor.class).values())
|
||||
{
|
||||
this.applicationContext.addBeanFactoryPostProcessor((BeanFactoryPostProcessor) postProcessor);
|
||||
}
|
||||
|
||||
// Add a property placeholder configurer, with the subsystem-scoped default properties
|
||||
PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
|
||||
configurer.setProperties(this.properties);
|
||||
configurer.setIgnoreUnresolvablePlaceholders(true);
|
||||
this.applicationContext.addBeanFactoryPostProcessor(configurer);
|
||||
|
||||
// Add all the post processors of the parent, e.g. to make sure system placeholders get expanded properly
|
||||
for (Object postProcessor : this.parent.getBeansOfType(BeanFactoryPostProcessor.class).values())
|
||||
{
|
||||
this.applicationContext.addBeanFactoryPostProcessor((BeanFactoryPostProcessor) postProcessor);
|
||||
}
|
||||
|
||||
this.applicationContext.setClassLoader(parent.getClassLoader());
|
||||
this.applicationContext.refresh();
|
||||
}
|
||||
|
@ -87,6 +87,16 @@ public class ManagedSubsystemProxyFactory extends ProxyFactoryBean
|
||||
}));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void setInterfaces(Class[] interfaces)
|
||||
{
|
||||
super.setInterfaces(interfaces);
|
||||
// Make it possible to export the object via JMX
|
||||
setTargetClass(getObjectType());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the source application context factory.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user