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>
|
<list>
|
||||||
<!-- Allow authentication subsystem to see file server config at runtime -->
|
<!-- Allow authentication subsystem to see file server config at runtime -->
|
||||||
<value>org.alfresco.filesys.ExtendedServerConfigurationAccessor</value>
|
<value>org.alfresco.filesys.ExtendedServerConfigurationAccessor</value>
|
||||||
|
<!-- Allow export as MBean -->
|
||||||
|
<value>org.alfresco.filesys.FileServerConfigMBean</value>
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
@ -395,12 +397,10 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="openOfficeConnectionTester" class="org.alfresco.util.OpenOfficeConnectionTester" >
|
<!-- Third party transformer Subsystem -->
|
||||||
<property name="connection">
|
<bean id="thirdparty" class="org.alfresco.repo.management.DefaultManagedApplicationContextFactory">
|
||||||
<ref bean="openOfficeConnection" />
|
<property name="autoStart">
|
||||||
</property>
|
<value>true</value>
|
||||||
<property name="strict">
|
|
||||||
<value>false</value>
|
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
@ -129,8 +129,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="openOfficeConnection" class="net.sf.jooreports.openoffice.connection.SocketOpenOfficeConnection" />
|
|
||||||
|
|
||||||
<!-- Metadata Extraction Regisitry -->
|
<!-- Metadata Extraction Regisitry -->
|
||||||
<bean id="metadataExtracterRegistry" class="org.alfresco.repo.content.metadata.MetadataExtracterRegistry" />
|
<bean id="metadataExtracterRegistry" class="org.alfresco.repo.content.metadata.MetadataExtracterRegistry" />
|
||||||
|
|
||||||
@ -150,7 +148,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<!-- Content Metadata Extracters -->
|
<!-- Content Metadata Extractors -->
|
||||||
<bean id="extracter.PDFBox" class="org.alfresco.repo.content.metadata.PdfBoxMetadataExtracter" parent="baseMetadataExtracter" />
|
<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.Office" class="org.alfresco.repo.content.metadata.OfficeMetadataExtracter" parent="baseMetadataExtracter" />
|
||||||
<bean id="extracter.Mail" class="org.alfresco.repo.content.metadata.MailMetadataExtracter" 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.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.OpenDocument" class="org.alfresco.repo.content.metadata.OpenDocumentMetadataExtracter" parent="baseMetadataExtracter" />
|
||||||
<bean id="extracter.OpenOffice" class="org.alfresco.repo.content.metadata.OpenOfficeMetadataExtracter" parent="baseMetadataExtracter" >
|
<bean id="extracter.OpenOffice" class="org.alfresco.repo.content.metadata.OpenOfficeMetadataExtracter" parent="baseMetadataExtracter" >
|
||||||
<property name="connection">
|
<property name="worker">
|
||||||
<ref bean="openOfficeConnection" />
|
<!-- 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>
|
||||||
<property name="supportedMimetypes">
|
<property name="supportedMimetypes">
|
||||||
<list>
|
<list>
|
||||||
@ -173,7 +184,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
<!-- Content Transformation Regisitry -->
|
<!-- Content Transformation Regisitry -->
|
||||||
<bean id="contentTransformerRegistry" class="org.alfresco.repo.content.transform.ContentTransformerRegistry" />
|
<bean id="contentTransformerRegistry" class="org.alfresco.repo.content.transform.ContentTransformerRegistry" />
|
||||||
|
|
||||||
@ -326,14 +336,23 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="transformer.OpenOffice"
|
<bean id="transformer.OpenOffice" class="org.alfresco.repo.content.transform.ProxyContentTransformer"
|
||||||
class="org.alfresco.repo.content.transform.OpenOfficeContentTransformer"
|
|
||||||
parent="baseContentTransformer">
|
parent="baseContentTransformer">
|
||||||
<property name="connection">
|
<property name="worker">
|
||||||
<ref bean="openOfficeConnection" />
|
<!-- 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>
|
||||||
<property name="documentFormatsConfiguration">
|
<property name="sourceBeanName">
|
||||||
<value>classpath:alfresco/mimetype/openoffice-document-formats.xml</value>
|
<value>transformer.worker.OpenOffice</value>
|
||||||
|
</property>
|
||||||
|
<property name="interfaces">
|
||||||
|
<list>
|
||||||
|
<value>org.alfresco.repo.content.transform.ContentTransformerWorker</value>
|
||||||
|
</list>
|
||||||
|
</property>
|
||||||
|
</bean>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
@ -357,57 +376,24 @@
|
|||||||
class="org.alfresco.repo.content.transform.MailContentTransformer"
|
class="org.alfresco.repo.content.transform.MailContentTransformer"
|
||||||
parent="baseContentTransformer" />
|
parent="baseContentTransformer" />
|
||||||
|
|
||||||
<bean id="transformer.ImageMagick"
|
<!-- Import the ImageMagick transformer from the third party subsystem -->
|
||||||
class="org.alfresco.repo.content.transform.magick.ImageMagickContentTransformer"
|
<bean id="transformer.worker.ImageMagick" class="org.alfresco.repo.management.ManagedSubsystemProxyFactory">
|
||||||
parent="baseContentTransformer"
|
<property name="sourceApplicationContextFactory">
|
||||||
init-method="init">
|
<ref bean="thirdparty" />
|
||||||
<property name="executer">
|
</property>
|
||||||
<bean name="transformer.ImageMagick.Command" class="org.alfresco.util.exec.RuntimeExec">
|
<property name="sourceBeanName">
|
||||||
<property name="commandsAndArguments">
|
<value>transformer.worker.ImageMagick</value>
|
||||||
<map>
|
</property>
|
||||||
<entry key=".*">
|
<property name="interfaces">
|
||||||
<list>
|
<list>
|
||||||
<value>${img.exe}</value>
|
<value>org.alfresco.repo.content.transform.ContentTransformerWorker</value>
|
||||||
<value>${source}</value>
|
|
||||||
<value>SPLIT:${options}</value>
|
|
||||||
<value>${target}</value>
|
|
||||||
</list>
|
</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>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
<bean id="transformer.ImageMagick" class="org.alfresco.repo.content.transform.ProxyContentTransformer" parent="baseContentTransformer">
|
||||||
|
<property name="worker">
|
||||||
|
<ref bean="transformer.worker.ImageMagick" />
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
@ -299,14 +299,6 @@ authentication.rmi.service.port=50504
|
|||||||
repo.rmi.service.port=50505
|
repo.rmi.service.port=50505
|
||||||
action.rmi.service.port=50506
|
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
|
# Property to enable upgrade from 2.1-A
|
||||||
V2.1-A.fixes.to.schema=0
|
V2.1-A.fixes.to.schema=0
|
||||||
#V2.1-A.fixes.to.schema=82
|
#V2.1-A.fixes.to.schema=82
|
||||||
|
@ -175,30 +175,6 @@
|
|||||||
</property>
|
</property>
|
||||||
</bean>
|
</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">
|
<bean id="indexBackupJobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
|
||||||
<property name="jobClass">
|
<property name="jobClass">
|
||||||
<value>org.alfresco.repo.search.impl.lucene.AbstractLuceneIndexerAndSearcherFactory$LuceneIndexBackupJob</value>
|
<value>org.alfresco.repo.search.impl.lucene.AbstractLuceneIndexerAndSearcherFactory$LuceneIndexBackupJob</value>
|
||||||
|
@ -51,6 +51,23 @@
|
|||||||
</constructor-arg>
|
</constructor-arg>
|
||||||
</bean>
|
</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">
|
<bean id="cifsServerConfig" class="org.alfresco.filesys.config.CIFSConfigBean">
|
||||||
<property name="serverEnabled">
|
<property name="serverEnabled">
|
||||||
<value>${cifs.enabled}</value>
|
<value>${cifs.enabled}</value>
|
||||||
@ -188,9 +205,7 @@
|
|||||||
<!-- FTP server debug settings -->
|
<!-- FTP server debug settings -->
|
||||||
<!-- Enable 'log4j.logger.org.alfresco.fileserver=debug' in log4j.properties file -->
|
<!-- Enable 'log4j.logger.org.alfresco.fileserver=debug' in log4j.properties file -->
|
||||||
<!--
|
<!--
|
||||||
<property name="debugFlags">
|
<property name="debugFlags"> <value>File,Search,Error,Directory,Info,DataPort</value> </property>
|
||||||
<value>File,Search,Error,Directory,Info,DataPort</value>
|
|
||||||
</property>
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
</bean>
|
</bean>
|
||||||
@ -296,79 +311,31 @@
|
|||||||
</bean>
|
</bean>
|
||||||
<!-- Other desktop actions which may be enabled -->
|
<!-- Other desktop actions which may be enabled -->
|
||||||
<!--
|
<!--
|
||||||
<bean class="org.alfresco.filesys.repo.desk.EchoDesktopAction">
|
<bean class="org.alfresco.filesys.repo.desk.EchoDesktopAction"> <property name="name">
|
||||||
<property name="name">
|
<value>Echo</value> </property> <property name="filename"> <value>__AlfrescoEcho.exe</value>
|
||||||
<value>Echo</value>
|
</property> </bean> <bean class="org.alfresco.filesys.repo.desk.URLDesktopAction"> <property
|
||||||
</property>
|
name="name"> <value>URL</value> </property> <property name="filename">
|
||||||
<property name="filename">
|
<value>__AlfrescoURL.exe</value> </property> </bean> <bean
|
||||||
<value>__AlfrescoEcho.exe</value>
|
class="org.alfresco.filesys.repo.desk.CmdLineDesktopAction"> <property name="name">
|
||||||
</property>
|
<value>CmdLine</value> </property> <property name="filename"> <value>__AlfrescoCmd.exe</value>
|
||||||
</bean>
|
</property> </bean> <bean class="org.alfresco.filesys.repo.desk.JavaScriptDesktopAction">
|
||||||
<bean class="org.alfresco.filesys.repo.desk.URLDesktopAction">
|
<property name="name"> <value>JavaScript</value> </property> <property name="filename">
|
||||||
<property name="name">
|
<value>__AlfrescoScript.exe</value> </property> <property name="scriptName">
|
||||||
<value>URL</value>
|
<value>alfresco/desktop/dumpRequest.js</value> </property> <property name="attributeList">
|
||||||
</property>
|
<value>anyFiles, multiplePaths, allowNoParams</value> </property> <property name="preprocess">
|
||||||
<property name="filename">
|
<value>confirm, copyToTarget</value> </property> </bean>
|
||||||
<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>
|
</list>
|
||||||
</property>
|
</property>
|
||||||
<!-- Additional access control of the filesystem -->
|
<!-- Additional access control of the filesystem -->
|
||||||
<!-- Access type of 'none' will stop the filesystem from showing up for that user/address/protocol -->
|
<!-- Access type of 'none' will stop the filesystem from showing up for that user/address/protocol -->
|
||||||
<!--
|
<!--
|
||||||
<property name="defaultAccessLevel">
|
<property name="defaultAccessLevel"> <value>Write</value> </property> <property name="accessControl">
|
||||||
<value>Write</value>
|
<list> <bean class="org.alfresco.jlan.server.auth.acl.UserAccessControl"> <property name="name">
|
||||||
</property>
|
<value>admin</value> </property> <property name="access"> <value>Write</value> </property> </bean>
|
||||||
<property name="accessControl">
|
<bean class="org.alfresco.jlan.server.auth.acl.IpAddressAccessControl"> <property name="subNet">
|
||||||
<list>
|
<value>192.168.1.0</value> </property> <property name="netMask"> <value>255.255.255.0</value>
|
||||||
<bean class="org.alfresco.jlan.server.auth.acl.UserAccessControl">
|
</property> <property name="access"> <value>Write</value> </property> </bean> </list> </property>
|
||||||
<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>
|
</bean>
|
||||||
<!-- AVM virtualization view of all stores/versions for WCM -->
|
<!-- AVM virtualization view of all stores/versions for WCM -->
|
||||||
@ -392,67 +359,28 @@
|
|||||||
<!-- Domain mappings used for passthru authentication routing -->
|
<!-- Domain mappings used for passthru authentication routing -->
|
||||||
<!-- Used when the client does not provide a domain name in the NTLM logon -->
|
<!-- Used when the client does not provide a domain name in the NTLM logon -->
|
||||||
<!--
|
<!--
|
||||||
<property name="domainMappings">
|
<property name="domainMappings"> <list> <bean class="org.alfresco.filesys.config.DomainMappingConfigBean">
|
||||||
<list>
|
<property name="name"> <value>ALFRESCO</value> </property> <property name="subnet"> <value>192.168.1.0</value>
|
||||||
<bean class="org.alfresco.filesys.config.DomainMappingConfigBean">
|
</property> <property name="mask"> <value>192.168.1.255</value> </property> </bean> </list> </property>
|
||||||
<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 -->
|
<!-- Custom share mapper when multi-tenancy is enabled -->
|
||||||
<!--
|
<!--
|
||||||
<property name="shareMapper">
|
<property name="shareMapper"> <bean class="org.alfresco.filesys.alfresco.MultiTenantShareMapper"> <property
|
||||||
<bean class="org.alfresco.filesys.alfresco.MultiTenantShareMapper">
|
name="serverConfiguration"> <ref bean="fileServerConfiguration" /> </property> <property name="debug">
|
||||||
<property name="serverConfiguration">
|
<value>true</value> </property> </bean> </property>
|
||||||
<ref bean="fileServerConfiguration" />
|
|
||||||
</property>
|
|
||||||
<property name="debug">
|
|
||||||
<value>true</value>
|
|
||||||
</property>
|
|
||||||
</bean>
|
|
||||||
</property>
|
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<!-- Global access control list -->
|
<!-- Global access control list -->
|
||||||
<!-- Applied to all filesystems that do not have an accessControl property -->
|
<!-- 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 -->
|
<!-- Access type of 'none' will stop the filesystem from showing up for that user/address/protocol -->
|
||||||
<!--
|
<!--
|
||||||
<property name="globalDefaultAccessLevel">
|
<property name="globalDefaultAccessLevel"> <value>None</value> </property> <property
|
||||||
<value>None</value>
|
name="globalAccessControl"> <list> <bean class="org.alfresco.jlan.server.auth.acl.UserAccessControl"> <property
|
||||||
</property>
|
name="name"> <value>admin</value> </property> <property name="access"> <value>Write</value> </property> </bean>
|
||||||
<property name="globalAccessControl">
|
<bean class="org.alfresco.jlan.server.auth.acl.IpAddressAccessControl"> <property name="subNet">
|
||||||
<list>
|
<value>192.168.1.2</value> </property> <property name="netMask"> <value>255.255.255.0</value> </property>
|
||||||
<bean class="org.alfresco.jlan.server.auth.acl.UserAccessControl">
|
<property name="access"> <value>Write</value> </property> </bean> </list> </property>
|
||||||
<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>
|
</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,50 +3,28 @@
|
|||||||
|
|
||||||
<beans>
|
<beans>
|
||||||
|
|
||||||
<bean id="transformer.Pdf2swf" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformer" parent="baseContentTransformer">
|
<!-- Import the swftools transformer worker from the third party subsystem -->
|
||||||
<property name="checkCommand">
|
<bean id="transformer.worker.Pdf2swf" class="org.alfresco.repo.management.ManagedSubsystemProxyFactory">
|
||||||
<bean class="org.alfresco.util.exec.RuntimeExec">
|
<property name="sourceApplicationContextFactory">
|
||||||
<property name="commandMap">
|
<ref bean="thirdparty" />
|
||||||
<map>
|
|
||||||
<entry key=".*">
|
|
||||||
<value>${swf.exe} -V</value>
|
|
||||||
</entry>
|
|
||||||
</map>
|
|
||||||
</property>
|
</property>
|
||||||
<property name="errorCodes">
|
<property name="sourceBeanName">
|
||||||
<value>1</value>
|
<value>transformer.worker.Pdf2swf</value>
|
||||||
</property>
|
</property>
|
||||||
</bean>
|
<property name="interfaces">
|
||||||
</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>
|
<list>
|
||||||
<bean class="org.alfresco.repo.content.transform.ExplictTransformationDetails" >
|
<value>org.alfresco.repo.content.transform.ContentTransformerWorker</value>
|
||||||
<property name="sourceMimetype"><value>application/pdf</value></property>
|
|
||||||
<property name="targetMimetype"><value>application/x-shockwave-flash</value></property>
|
|
||||||
</bean>
|
|
||||||
</list>
|
</list>
|
||||||
</property>
|
</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"
|
<bean id="transformer.complex.OpenOffice.Pdf2swf"
|
||||||
class="org.alfresco.repo.content.transform.ComplexContentTransformer"
|
class="org.alfresco.repo.content.transform.ComplexContentTransformer"
|
||||||
parent="baseContentTransformer" >
|
parent="baseContentTransformer" >
|
||||||
|
@ -27,7 +27,7 @@ package org.alfresco.repo.action.executer;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.alfresco.repo.action.ParameterDefinitionImpl;
|
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.repo.content.transform.magick.ImageTransformationOptions;
|
||||||
import org.alfresco.service.cmr.action.Action;
|
import org.alfresco.service.cmr.action.Action;
|
||||||
import org.alfresco.service.cmr.action.ParameterDefinition;
|
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 NAME = "transform-image";
|
||||||
public static final String PARAM_CONVERT_COMMAND = "convert-command";
|
public static final String PARAM_CONVERT_COMMAND = "convert-command";
|
||||||
|
|
||||||
private ImageMagickContentTransformer imageMagickContentTransformer;
|
private ContentTransformer imageMagickContentTransformer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the image magick content transformer
|
* Set the image magick content transformer
|
||||||
*
|
*
|
||||||
* @param imageMagickContentTransformer the conten transformer
|
* @param imageMagickContentTransformer the conten transformer
|
||||||
*/
|
*/
|
||||||
public void setImageMagickContentTransformer(ImageMagickContentTransformer imageMagickContentTransformer)
|
public void setImageMagickContentTransformer(ContentTransformer imageMagickContentTransformer)
|
||||||
{
|
{
|
||||||
this.imageMagickContentTransformer = imageMagickContentTransformer;
|
this.imageMagickContentTransformer = imageMagickContentTransformer;
|
||||||
}
|
}
|
||||||
@ -79,17 +79,19 @@ public class ImageTransformActionExecuter extends TransformActionExecuter
|
|||||||
NodeRef sourceNodeRef, ContentReader contentReader,
|
NodeRef sourceNodeRef, ContentReader contentReader,
|
||||||
NodeRef destinationNodeRef, ContentWriter contentWriter)
|
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
|
// 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
|
// create some options for the transform
|
||||||
ImageTransformationOptions imageOptions = new ImageTransformationOptions();
|
ImageTransformationOptions imageOptions = new ImageTransformationOptions();
|
||||||
imageOptions.setCommandOptions(convertCommand);
|
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);
|
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.filestore.FileContentStore;
|
||||||
import org.alfresco.repo.content.transform.ContentTransformer;
|
import org.alfresco.repo.content.transform.ContentTransformer;
|
||||||
import org.alfresco.repo.content.transform.ContentTransformerRegistry;
|
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.ClassPolicyDelegate;
|
||||||
import org.alfresco.repo.policy.JavaBehaviour;
|
import org.alfresco.repo.policy.JavaBehaviour;
|
||||||
import org.alfresco.repo.policy.PolicyComponent;
|
import org.alfresco.repo.policy.PolicyComponent;
|
||||||
@ -97,7 +96,7 @@ public class RoutingContentService implements ContentService, ApplicationContext
|
|||||||
private ContentStore store;
|
private ContentStore store;
|
||||||
/** the store for all temporarily created content */
|
/** the store for all temporarily created content */
|
||||||
private ContentStore tempStore;
|
private ContentStore tempStore;
|
||||||
private ImageMagickContentTransformer imageMagickContentTransformer;
|
private ContentTransformer imageMagickContentTransformer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The policy component
|
* The policy component
|
||||||
@ -153,7 +152,7 @@ public class RoutingContentService implements ContentService, ApplicationContext
|
|||||||
this.avmService = service;
|
this.avmService = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setImageMagickContentTransformer(ImageMagickContentTransformer imageMagickContentTransformer)
|
public void setImageMagickContentTransformer(ContentTransformer imageMagickContentTransformer)
|
||||||
{
|
{
|
||||||
this.imageMagickContentTransformer = imageMagickContentTransformer;
|
this.imageMagickContentTransformer = imageMagickContentTransformer;
|
||||||
}
|
}
|
||||||
@ -317,7 +316,6 @@ public class RoutingContentService implements ContentService, ApplicationContext
|
|||||||
Serializable propValue = nodeService.getProperty(nodeRef, propertyQName);
|
Serializable propValue = nodeService.getProperty(nodeRef, propertyQName);
|
||||||
if (propValue instanceof Collection)
|
if (propValue instanceof Collection)
|
||||||
{
|
{
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Collection<Serializable> colPropValue = (Collection<Serializable>)propValue;
|
Collection<Serializable> colPropValue = (Collection<Serializable>)propValue;
|
||||||
if (colPropValue.size() > 0)
|
if (colPropValue.size() > 0)
|
||||||
{
|
{
|
||||||
@ -461,7 +459,6 @@ public class RoutingContentService implements ContentService, ApplicationContext
|
|||||||
* @see org.alfresco.repo.content.transform.ContentTransformer
|
* @see org.alfresco.repo.content.transform.ContentTransformer
|
||||||
* @deprecated
|
* @deprecated
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public void transform(ContentReader reader, ContentWriter writer, Map<String, Object> options)
|
public void transform(ContentReader reader, ContentWriter writer, Map<String, Object> options)
|
||||||
throws NoTransformerException, ContentIOException
|
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" */
|
* http://www.alfresco.com/legal/licensing" */
|
||||||
package org.alfresco.repo.content.metadata;
|
package org.alfresco.repo.content.metadata;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.net.ConnectException;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import net.sf.jooreports.openoffice.connection.OpenOfficeConnection;
|
|
||||||
|
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
import org.alfresco.util.PropertyCheck;
|
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:
|
* Extracts values from Star Office documents into the following:
|
||||||
@ -55,12 +41,8 @@ import com.sun.star.uno.UnoRuntime;
|
|||||||
*
|
*
|
||||||
* @author Jesper Steen Møller
|
* @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[] {
|
public static String[] SUPPORTED_MIMETYPES = new String[] {
|
||||||
MimetypeMap.MIMETYPE_STAROFFICE5_WRITER,
|
MimetypeMap.MIMETYPE_STAROFFICE5_WRITER,
|
||||||
MimetypeMap.MIMETYPE_STAROFFICE5_IMPRESS,
|
MimetypeMap.MIMETYPE_STAROFFICE5_IMPRESS,
|
||||||
@ -68,16 +50,16 @@ public class OpenOfficeMetadataExtracter extends AbstractMappingMetadataExtracte
|
|||||||
MimetypeMap.MIMETYPE_OPENOFFICE1_IMPRESS
|
MimetypeMap.MIMETYPE_OPENOFFICE1_IMPRESS
|
||||||
};
|
};
|
||||||
|
|
||||||
private OpenOfficeConnection connection;
|
private OpenOfficeMetadataWorker worker;
|
||||||
|
|
||||||
public OpenOfficeMetadataExtracter()
|
public OpenOfficeMetadataExtracter()
|
||||||
{
|
{
|
||||||
super(new HashSet<String>(Arrays.asList(SUPPORTED_MIMETYPES)));
|
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
|
@Override
|
||||||
public synchronized void init()
|
public synchronized void init()
|
||||||
{
|
{
|
||||||
PropertyCheck.mandatory("OpenOfficeMetadataExtracter", "connection", connection);
|
PropertyCheck.mandatory("OpenOfficeMetadataExtracter", "worker", worker);
|
||||||
|
|
||||||
// Base initialization
|
// Base initialization
|
||||||
super.init();
|
super.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/* (non-Javadoc)
|
||||||
* @return Returns true if a connection to the Uno server could be
|
* @see org.alfresco.repo.content.metadata.OpenOfficeMetadataWorker#isConnected()
|
||||||
* established
|
|
||||||
*/
|
*/
|
||||||
public boolean isConnected()
|
public boolean isConnected()
|
||||||
{
|
{
|
||||||
return connection.isConnected();
|
return worker.isConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,67 +95,18 @@ public class OpenOfficeMetadataExtracter extends AbstractMappingMetadataExtracte
|
|||||||
return super.isSupported(sourceMimetype);
|
return super.isSupported(sourceMimetype);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.alfresco.repo.content.metadata.OpenOfficeMetadataWorker#extractRaw(org.alfresco.service.cmr.repository.ContentReader)
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Map<String, Serializable> extractRaw(ContentReader reader) throws Throwable
|
public Map<String, Serializable> extractRaw(ContentReader reader) throws Throwable
|
||||||
{
|
{
|
||||||
Map<String, Serializable> rawProperties = newRawMap();
|
Map<String, Serializable> rawProperties = newRawMap();
|
||||||
|
Map<String, Serializable> result = this.worker.extractRaw(reader);
|
||||||
String sourceMimetype = reader.getMimetype();
|
for (Map.Entry<String, Serializable> entry : result.entrySet())
|
||||||
|
|
||||||
// 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)
|
|
||||||
{
|
{
|
||||||
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;
|
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 = new OpenOfficeMetadataExtracter();
|
||||||
extracter.setMimetypeService(mimetypeMap);
|
extracter.setMimetypeService(mimetypeMap);
|
||||||
extracter.setDictionaryService(dictionaryService);
|
extracter.setDictionaryService(dictionaryService);
|
||||||
extracter.setConnection(connection);
|
DefaultOpenOfficeMetadataWorker worker = new DefaultOpenOfficeMetadataWorker();
|
||||||
|
worker.setConnection(connection);
|
||||||
|
worker.setMimetypeService(mimetypeMap);
|
||||||
|
extracter.setWorker(worker);
|
||||||
extracter.init();
|
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;
|
package org.alfresco.repo.content.transform;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
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.ContentIOException;
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
import org.alfresco.service.cmr.repository.MimetypeService;
|
|
||||||
import org.alfresco.service.cmr.repository.TransformationOptions;
|
import org.alfresco.service.cmr.repository.TransformationOptions;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@ -48,13 +44,11 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
* @author Derek Hulley
|
* @author Derek Hulley
|
||||||
* @author Roy Wetherall
|
* @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 static final Log logger = LogFactory.getLog(AbstractContentTransformer2.class);
|
||||||
|
|
||||||
private MimetypeService mimetypeService;
|
|
||||||
private ContentTransformerRegistry registry;
|
private ContentTransformerRegistry registry;
|
||||||
private List<ExplictTransformationDetails> explicitTransformations;
|
|
||||||
private double averageTime = 0.0;
|
private double averageTime = 0.0;
|
||||||
private long count = 0L;
|
private long count = 0L;
|
||||||
|
|
||||||
@ -64,7 +58,6 @@ public abstract class AbstractContentTransformer2 implements ContentTransformer
|
|||||||
protected AbstractContentTransformer2()
|
protected AbstractContentTransformer2()
|
||||||
{
|
{
|
||||||
averageTime = 0.0;
|
averageTime = 0.0;
|
||||||
explicitTransformations = new ArrayList<ExplictTransformationDetails>(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,30 +70,6 @@ public abstract class AbstractContentTransformer2 implements ContentTransformer
|
|||||||
this.registry = 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
|
@Override
|
||||||
public String toString()
|
public String toString()
|
||||||
{
|
{
|
||||||
@ -128,24 +97,6 @@ public abstract class AbstractContentTransformer2 implements ContentTransformer
|
|||||||
registry.addTransformer(this);
|
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
|
* 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));
|
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
|
* @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;
|
import org.alfresco.util.TempFileProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.repo.content.transform.OpenOfficeContentTransformer
|
* @see org.alfresco.repo.content.transform.OpenOfficeContentTransformerWorker
|
||||||
*
|
*
|
||||||
* @author Derek Hulley
|
* @author Derek Hulley
|
||||||
*/
|
*/
|
||||||
@ -45,7 +45,8 @@ public class OpenOfficeContentTransformerTest extends AbstractContentTransformer
|
|||||||
{
|
{
|
||||||
private static String MIMETYPE_RUBBISH = "text/rubbish";
|
private static String MIMETYPE_RUBBISH = "text/rubbish";
|
||||||
|
|
||||||
private OpenOfficeContentTransformer transformer;
|
private OpenOfficeContentTransformerWorker worker;
|
||||||
|
private ContentTransformer transformer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
@ -54,11 +55,15 @@ public class OpenOfficeContentTransformerTest extends AbstractContentTransformer
|
|||||||
|
|
||||||
OpenOfficeConnection connection = (OpenOfficeConnection) ctx.getBean("openOfficeConnection");
|
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.setMimetypeService(mimetypeService);
|
||||||
transformer.setConnection(connection);
|
transformer.setWorker(worker);
|
||||||
transformer.setDocumentFormatsConfiguration("classpath:alfresco/mimetype/openoffice-document-formats.xml");
|
this.transformer = transformer;
|
||||||
transformer.register();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -77,7 +82,7 @@ public class OpenOfficeContentTransformerTest extends AbstractContentTransformer
|
|||||||
|
|
||||||
public void testReliability() throws Exception
|
public void testReliability() throws Exception
|
||||||
{
|
{
|
||||||
if (!transformer.isConnected())
|
if (!worker.isAvailable())
|
||||||
{
|
{
|
||||||
// no connection
|
// no connection
|
||||||
return;
|
return;
|
||||||
@ -99,7 +104,7 @@ public class OpenOfficeContentTransformerTest extends AbstractContentTransformer
|
|||||||
*/
|
*/
|
||||||
public void testHtmlToPdf() throws Exception
|
public void testHtmlToPdf() throws Exception
|
||||||
{
|
{
|
||||||
if (!transformer.isConnected())
|
if (!worker.isAvailable())
|
||||||
{
|
{
|
||||||
// no connection
|
// no connection
|
||||||
return;
|
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
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* 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
|
* 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
|
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
* 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:
|
* the FLOSS exception, and it is also available here:
|
||||||
* http://www.alfresco.com/legal/licensing"
|
* 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.service.cmr.repository.TransformationOptions;
|
||||||
import org.alfresco.util.PropertyCheck;
|
import org.alfresco.util.PropertyCheck;
|
||||||
import org.alfresco.util.TempFileProvider;
|
import org.alfresco.util.TempFileProvider;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
import org.springframework.core.io.DefaultResourceLoader;
|
import org.springframework.core.io.DefaultResourceLoader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Makes use of the {@link http://sourceforge.net/projects/joott/ JOOConverter} library to
|
* Makes use of the {@link http://sourceforge.net/projects/joott/JOOConverter} library to perform OpenOffice-drive
|
||||||
* perform OpenOffice-drive conversions.
|
* conversions.
|
||||||
*
|
*
|
||||||
* @author Derek Hulley
|
* @author Derek Hulley
|
||||||
*/
|
*/
|
||||||
public class OpenOfficeContentTransformer extends AbstractContentTransformer2
|
public class OpenOfficeContentTransformerWorker extends ContentTransformerHelper implements ContentTransformerWorker, InitializingBean
|
||||||
{
|
{
|
||||||
private OpenOfficeConnection connection;
|
private OpenOfficeConnection connection;
|
||||||
private AbstractOpenOfficeDocumentConverter converter;
|
private AbstractOpenOfficeDocumentConverter converter;
|
||||||
private String documentFormatsConfiguration;
|
private String documentFormatsConfiguration;
|
||||||
private DocumentFormatRegistry formatRegistry;
|
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)
|
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
|
* Explicitly set the converter to be used. The converter must use the same connection set in
|
||||||
* set in {@link #setConnection(OpenOfficeConnection)}.
|
* {@link #setConnection(OpenOfficeConnection)}.
|
||||||
* <p>
|
* <p>
|
||||||
* If not set, then the <code>OpenOfficeDocumentConverter</code> will be used.
|
* 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)
|
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.
|
* 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)
|
public void setDocumentFormatsConfiguration(String path)
|
||||||
{
|
{
|
||||||
this.documentFormatsConfiguration = path;
|
this.documentFormatsConfiguration = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isConnected()
|
public boolean isAvailable()
|
||||||
{
|
{
|
||||||
return connection.isConnected();
|
return this.connection.isConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void afterPropertiesSet() throws Exception
|
||||||
public void register()
|
|
||||||
{
|
{
|
||||||
PropertyCheck.mandatory("OpenOfficeContentTransformer", "connection", connection);
|
PropertyCheck.mandatory("OpenOfficeContentTransformerWorker", "connection", this.connection);
|
||||||
|
|
||||||
// load the document conversion configuration
|
// load the document conversion configuration
|
||||||
if (documentFormatsConfiguration != null)
|
if (this.documentFormatsConfiguration != null)
|
||||||
{
|
{
|
||||||
DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
|
DefaultResourceLoader resourceLoader = new DefaultResourceLoader();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
InputStream is = resourceLoader.getResource(documentFormatsConfiguration).getInputStream();
|
InputStream is = resourceLoader.getResource(this.documentFormatsConfiguration).getInputStream();
|
||||||
formatRegistry = new XmlDocumentFormatRegistry(is);
|
this.formatRegistry = new XmlDocumentFormatRegistry(is);
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException(
|
throw new AlfrescoRuntimeException("Unable to load document formats configuration file: "
|
||||||
"Unable to load document formats configuration file: " + documentFormatsConfiguration);
|
+ this.documentFormatsConfiguration);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
formatRegistry = new XmlDocumentFormatRegistry();
|
this.formatRegistry = new XmlDocumentFormatRegistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
// set up the converter
|
// 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,7 +137,7 @@ public class OpenOfficeContentTransformer extends AbstractContentTransformer2
|
|||||||
*/
|
*/
|
||||||
public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options)
|
public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options)
|
||||||
{
|
{
|
||||||
if (!isConnected())
|
if (!isAvailable())
|
||||||
{
|
{
|
||||||
// The connection management is must take care of this
|
// The connection management is must take care of this
|
||||||
return false;
|
return false;
|
||||||
@ -165,14 +161,14 @@ public class OpenOfficeContentTransformer extends AbstractContentTransformer2
|
|||||||
String sourceExtension = mimetypeService.getExtension(sourceMimetype);
|
String sourceExtension = mimetypeService.getExtension(sourceMimetype);
|
||||||
String targetExtension = mimetypeService.getExtension(targetMimetype);
|
String targetExtension = mimetypeService.getExtension(targetMimetype);
|
||||||
// query the registry for the source format
|
// query the registry for the source format
|
||||||
DocumentFormat sourceFormat = formatRegistry.getFormatByFileExtension(sourceExtension);
|
DocumentFormat sourceFormat = this.formatRegistry.getFormatByFileExtension(sourceExtension);
|
||||||
if (sourceFormat == null)
|
if (sourceFormat == null)
|
||||||
{
|
{
|
||||||
// no document format
|
// no document format
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// query the registry for the target format
|
// query the registry for the target format
|
||||||
DocumentFormat targetFormat = formatRegistry.getFormatByFileExtension(targetExtension);
|
DocumentFormat targetFormat = this.formatRegistry.getFormatByFileExtension(targetExtension);
|
||||||
if (targetFormat == null)
|
if (targetFormat == null)
|
||||||
{
|
{
|
||||||
// no document format
|
// no document format
|
||||||
@ -193,10 +189,7 @@ public class OpenOfficeContentTransformer extends AbstractContentTransformer2
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void transformInternal(
|
public void transform(ContentReader reader, ContentWriter writer, TransformationOptions options) throws Exception
|
||||||
ContentReader reader,
|
|
||||||
ContentWriter writer,
|
|
||||||
TransformationOptions options) throws Exception
|
|
||||||
{
|
{
|
||||||
String sourceMimetype = getMimetype(reader);
|
String sourceMimetype = getMimetype(reader);
|
||||||
String targetMimetype = getMimetype(writer);
|
String targetMimetype = getMimetype(writer);
|
||||||
@ -205,14 +198,14 @@ public class OpenOfficeContentTransformer extends AbstractContentTransformer2
|
|||||||
String sourceExtension = mimetypeService.getExtension(sourceMimetype);
|
String sourceExtension = mimetypeService.getExtension(sourceMimetype);
|
||||||
String targetExtension = mimetypeService.getExtension(targetMimetype);
|
String targetExtension = mimetypeService.getExtension(targetMimetype);
|
||||||
// query the registry for the source format
|
// query the registry for the source format
|
||||||
DocumentFormat sourceFormat = formatRegistry.getFormatByFileExtension(sourceExtension);
|
DocumentFormat sourceFormat = this.formatRegistry.getFormatByFileExtension(sourceExtension);
|
||||||
if (sourceFormat == null)
|
if (sourceFormat == null)
|
||||||
{
|
{
|
||||||
// source format is not recognised
|
// source format is not recognised
|
||||||
throw new ContentIOException("No OpenOffice document format for source extension: " + sourceExtension);
|
throw new ContentIOException("No OpenOffice document format for source extension: " + sourceExtension);
|
||||||
}
|
}
|
||||||
// query the registry for the target format
|
// query the registry for the target format
|
||||||
DocumentFormat targetFormat = formatRegistry.getFormatByFileExtension(targetExtension);
|
DocumentFormat targetFormat = this.formatRegistry.getFormatByFileExtension(targetExtension);
|
||||||
if (targetFormat == null)
|
if (targetFormat == null)
|
||||||
{
|
{
|
||||||
// target format is not recognised
|
// target format is not recognised
|
||||||
@ -223,38 +216,41 @@ public class OpenOfficeContentTransformer extends AbstractContentTransformer2
|
|||||||
// does the format support the conversion
|
// does the format support the conversion
|
||||||
if (!targetFormat.isExportableFrom(sourceFamily))
|
if (!targetFormat.isExportableFrom(sourceFamily))
|
||||||
{
|
{
|
||||||
throw new ContentIOException(
|
throw new ContentIOException("OpenOffice conversion not supported: \n" + " reader: " + reader + "\n"
|
||||||
"OpenOffice conversion not supported: \n" +
|
+ " writer: " + writer);
|
||||||
" reader: " + reader + "\n" +
|
|
||||||
" writer: " + writer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// create temporary files to convert from and to
|
// create temporary files to convert from and to
|
||||||
File tempFromFile = TempFileProvider.createTempFile(
|
File tempFromFile = TempFileProvider.createTempFile("OpenOfficeContentTransformer-source-", "."
|
||||||
"OpenOfficeContentTransformer-source-",
|
+ sourceExtension);
|
||||||
"." + sourceExtension);
|
File tempToFile = TempFileProvider
|
||||||
File tempToFile = TempFileProvider.createTempFile(
|
.createTempFile("OpenOfficeContentTransformer-target-", "." + targetExtension);
|
||||||
"OpenOfficeContentTransformer-target-",
|
|
||||||
"." + targetExtension);
|
|
||||||
// download the content from the source reader
|
// download the content from the source reader
|
||||||
reader.getContent(tempFromFile);
|
reader.getContent(tempFromFile);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
converter.convert(tempFromFile, sourceFormat, tempToFile, targetFormat);
|
this.converter.convert(tempFromFile, sourceFormat, tempToFile, targetFormat);
|
||||||
// conversion success
|
// conversion success
|
||||||
}
|
}
|
||||||
catch (OpenOfficeException e)
|
catch (OpenOfficeException e)
|
||||||
{
|
{
|
||||||
throw new ContentIOException("OpenOffice server conversion failed: \n" +
|
throw new ContentIOException("OpenOffice server conversion failed: \n" + " reader: " + reader + "\n"
|
||||||
" reader: " + reader + "\n" +
|
+ " writer: " + writer + "\n" + " from file: " + tempFromFile + "\n" + " to file: "
|
||||||
" writer: " + writer + "\n" +
|
+ tempToFile, e);
|
||||||
" from file: " + tempFromFile + "\n" +
|
|
||||||
" to file: " + tempToFile,
|
|
||||||
e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// upload the temp output to the writer given us
|
// upload the temp output to the writer given us
|
||||||
writer.putContent(tempToFile);
|
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;
|
import org.alfresco.util.exec.RuntimeExec;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see org.alfresco.repo.content.transform.RuntimeExecutableContentTransformer
|
* @see org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker
|
||||||
*
|
*
|
||||||
* @author Derek Hulley
|
* @author Derek Hulley
|
||||||
*/
|
*/
|
||||||
public class RuntimeExecutableContentTransformerTest extends BaseAlfrescoTestCase
|
public class RuntimeExecutableContentTransformerTest extends BaseAlfrescoTestCase
|
||||||
{
|
{
|
||||||
private RuntimeExecutableContentTransformer transformer;
|
private ContentTransformer transformer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setUp() throws Exception
|
protected void setUp() throws Exception
|
||||||
{
|
{
|
||||||
super.setUp();
|
super.setUp();
|
||||||
|
|
||||||
transformer = new RuntimeExecutableContentTransformer();
|
RuntimeExecutableContentTransformerWorker worker = new RuntimeExecutableContentTransformerWorker();
|
||||||
// the command to execute
|
// the command to execute
|
||||||
RuntimeExec transformCommand = new RuntimeExec();
|
RuntimeExec transformCommand = new RuntimeExec();
|
||||||
Map<String, String> commandMap = new HashMap<String, String>(5);
|
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}\"");
|
commandMap.put(".*", "cmd /c copy /Y \"${source}\" \"${target}\"");
|
||||||
transformCommand.setCommandMap(commandMap);
|
transformCommand.setCommandMap(commandMap);
|
||||||
transformCommand.setErrorCodes("1, 2");
|
transformCommand.setErrorCodes("1, 2");
|
||||||
transformer.setTransformCommand(transformCommand);
|
worker.setTransformCommand(transformCommand);
|
||||||
transformer.setMimetypeService(serviceRegistry.getMimetypeService());
|
worker.setMimetypeService(serviceRegistry.getMimetypeService());
|
||||||
// set the explicit transformations
|
// set the explicit transformations
|
||||||
List<ExplictTransformationDetails> explicitTranformations = new ArrayList<ExplictTransformationDetails>(1);
|
List<ExplictTransformationDetails> explicitTranformations = new ArrayList<ExplictTransformationDetails>(1);
|
||||||
explicitTranformations.add(
|
explicitTranformations.add(
|
||||||
new ExplictTransformationDetails(MimetypeMap.MIMETYPE_TEXT_PLAIN, MimetypeMap.MIMETYPE_XML));
|
new ExplictTransformationDetails(MimetypeMap.MIMETYPE_TEXT_PLAIN, MimetypeMap.MIMETYPE_XML));
|
||||||
transformer.setExplicitTransformations(explicitTranformations);
|
worker.setExplicitTransformations(explicitTranformations);
|
||||||
|
|
||||||
// initialise so that it doesn't score 0
|
// 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
|
public void testCopyCommand() throws Exception
|
||||||
|
@ -39,6 +39,7 @@ import org.alfresco.util.exec.RuntimeExec;
|
|||||||
import org.alfresco.util.exec.RuntimeExec.ExecutionResult;
|
import org.alfresco.util.exec.RuntimeExec.ExecutionResult;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This configurable wrapper is able to execute any command line transformation that
|
* 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
|
* @since 1.1
|
||||||
* @author Derek Hulley
|
* @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_SOURCE = "source";
|
||||||
public static final String VAR_TARGET = "target";
|
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 boolean available;
|
||||||
private RuntimeExec checkCommand;
|
private RuntimeExec checkCommand;
|
||||||
@ -81,7 +82,7 @@ public class RuntimeExecutableContentTransformer extends AbstractContentTransfor
|
|||||||
/** Stores the output from the check command */
|
/** Stores the output from the check command */
|
||||||
private String versionString;
|
private String versionString;
|
||||||
|
|
||||||
public RuntimeExecutableContentTransformer()
|
public RuntimeExecutableContentTransformerWorker()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,13 +131,13 @@ public class RuntimeExecutableContentTransformer extends AbstractContentTransfor
|
|||||||
throw new AlfrescoRuntimeException("content.runtime_exec.property_moved");
|
throw new AlfrescoRuntimeException("content.runtime_exec.property_moved");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executes the check command, if present. Any errors will result in this component
|
* 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
|
* being rendered unusable within the transformer registry, but may still be called
|
||||||
* directly.
|
* directly.
|
||||||
*/
|
*/
|
||||||
@Override
|
public void afterPropertiesSet()
|
||||||
public void register()
|
|
||||||
{
|
{
|
||||||
if (transformCommand == null)
|
if (transformCommand == null)
|
||||||
{
|
{
|
||||||
@ -162,8 +163,6 @@ public class RuntimeExecutableContentTransformer extends AbstractContentTransfor
|
|||||||
// no check - just assume it is available
|
// no check - just assume it is available
|
||||||
available = true;
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isExplicitTransformation(sourceMimetype, targetMimetype, options) == true)
|
if (isExplicitTransformation(sourceMimetype, targetMimetype, options))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -217,7 +216,7 @@ public class RuntimeExecutableContentTransformer extends AbstractContentTransfor
|
|||||||
*
|
*
|
||||||
* @see #transformInternal(File, File)
|
* @see #transformInternal(File, File)
|
||||||
*/
|
*/
|
||||||
protected final void transformInternal(
|
public final void transform(
|
||||||
ContentReader reader,
|
ContentReader reader,
|
||||||
ContentWriter writer,
|
ContentWriter writer,
|
||||||
TransformationOptions options) throws Exception
|
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
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* 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
|
* 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
|
* the GPL, you may redistribute this Program in connection with Free/Libre
|
||||||
* and Open Source Software ("FLOSS") applications as described in Alfresco's
|
* 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:
|
* the FLOSS exception, and it is also available here:
|
||||||
* http://www.alfresco.com/legal/licensing"
|
* http://www.alfresco.com/legal/licensing"
|
||||||
*/
|
*/
|
||||||
@ -30,30 +30,33 @@ import java.io.InputStream;
|
|||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
import org.alfresco.error.AlfrescoRuntimeException;
|
||||||
import org.alfresco.repo.content.MimetypeMap;
|
import org.alfresco.repo.content.MimetypeMap;
|
||||||
import org.alfresco.repo.content.filestore.FileContentWriter;
|
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.ContentIOException;
|
||||||
import org.alfresco.service.cmr.repository.ContentReader;
|
import org.alfresco.service.cmr.repository.ContentReader;
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
|
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||||
import org.alfresco.service.cmr.repository.TransformationOptions;
|
import org.alfresco.service.cmr.repository.TransformationOptions;
|
||||||
import org.alfresco.util.TempFileProvider;
|
import org.alfresco.util.TempFileProvider;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.springframework.beans.factory.InitializingBean;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Abstract helper for transformations based on <b>ImageMagick</b>
|
* Abstract helper for transformations based on <b>ImageMagick</b>
|
||||||
*
|
*
|
||||||
* @author Derek Hulley
|
* @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 */
|
/** the prefix for mimetypes supported by the transformer */
|
||||||
public static final String MIMETYPE_IMAGE_PREFIX = "image/";
|
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;
|
private boolean available;
|
||||||
|
|
||||||
public AbstractImageMagickContentTransformer()
|
public AbstractImageMagickContentTransformerWorker()
|
||||||
{
|
{
|
||||||
this.available = false;
|
this.available = false;
|
||||||
}
|
}
|
||||||
@ -82,7 +85,7 @@ public abstract class AbstractImageMagickContentTransformer extends AbstractCont
|
|||||||
* <p>
|
* <p>
|
||||||
* If initialization is successful, then autoregistration takes place.
|
* If initialization is successful, then autoregistration takes place.
|
||||||
*/
|
*/
|
||||||
public void init()
|
public void afterPropertiesSet()
|
||||||
{
|
{
|
||||||
if (getMimetypeService() == null)
|
if (getMimetypeService() == null)
|
||||||
{
|
{
|
||||||
@ -121,9 +124,6 @@ public abstract class AbstractImageMagickContentTransformer extends AbstractCont
|
|||||||
}
|
}
|
||||||
// we can be sure that it works
|
// we can be sure that it works
|
||||||
setAvailable(true);
|
setAvailable(true);
|
||||||
|
|
||||||
// register
|
|
||||||
super.register();
|
|
||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
@ -171,8 +171,8 @@ public abstract class AbstractImageMagickContentTransformer extends AbstractCont
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!AbstractImageMagickContentTransformer.isSupported(sourceMimetype) ||
|
if (!AbstractImageMagickContentTransformerWorker.isSupported(sourceMimetype) ||
|
||||||
!AbstractImageMagickContentTransformer.isSupported(targetMimetype))
|
!AbstractImageMagickContentTransformerWorker.isSupported(targetMimetype))
|
||||||
{
|
{
|
||||||
// only support IMAGE -> IMAGE (excl. RGB)
|
// only support IMAGE -> IMAGE (excl. RGB)
|
||||||
return false;
|
return false;
|
||||||
@ -186,7 +186,7 @@ public abstract class AbstractImageMagickContentTransformer extends AbstractCont
|
|||||||
/**
|
/**
|
||||||
* @see #transformInternal(File, File)
|
* @see #transformInternal(File, File)
|
||||||
*/
|
*/
|
||||||
protected final void transformInternal(
|
public final void transform(
|
||||||
ContentReader reader,
|
ContentReader reader,
|
||||||
ContentWriter writer,
|
ContentWriter writer,
|
||||||
TransformationOptions options) throws Exception
|
TransformationOptions options) throws Exception
|
||||||
@ -196,8 +196,9 @@ public abstract class AbstractImageMagickContentTransformer extends AbstractCont
|
|||||||
String targetMimetype = getMimetype(writer);
|
String targetMimetype = getMimetype(writer);
|
||||||
|
|
||||||
// get the extensions to use
|
// get the extensions to use
|
||||||
String sourceExtension = getMimetypeService().getExtension(sourceMimetype);
|
MimetypeService mimetypeService = getMimetypeService();
|
||||||
String targetExtension = getMimetypeService().getExtension(targetMimetype);
|
String sourceExtension = mimetypeService.getExtension(sourceMimetype);
|
||||||
|
String targetExtension = mimetypeService.getExtension(targetMimetype);
|
||||||
if (sourceExtension == null || targetExtension == null)
|
if (sourceExtension == null || targetExtension == null)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("Unknown extensions for mimetypes: \n" +
|
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.MimetypeMap;
|
||||||
import org.alfresco.repo.content.transform.AbstractContentTransformerTest;
|
import org.alfresco.repo.content.transform.AbstractContentTransformerTest;
|
||||||
import org.alfresco.repo.content.transform.ContentTransformer;
|
import org.alfresco.repo.content.transform.ContentTransformer;
|
||||||
|
import org.alfresco.repo.content.transform.ProxyContentTransformer;
|
||||||
import org.alfresco.service.cmr.repository.TransformationOptions;
|
import org.alfresco.service.cmr.repository.TransformationOptions;
|
||||||
import org.alfresco.util.exec.RuntimeExec;
|
import org.alfresco.util.exec.RuntimeExec;
|
||||||
|
|
||||||
@ -39,7 +40,8 @@ import org.alfresco.util.exec.RuntimeExec;
|
|||||||
*/
|
*/
|
||||||
public class ImageMagickContentTransformerTest extends AbstractContentTransformerTest
|
public class ImageMagickContentTransformerTest extends AbstractContentTransformerTest
|
||||||
{
|
{
|
||||||
private ImageMagickContentTransformer transformer;
|
private ImageMagickContentTransformerWorker worker;
|
||||||
|
private ContentTransformer transformer;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception
|
public void setUp() throws Exception
|
||||||
@ -50,10 +52,15 @@ public class ImageMagickContentTransformerTest extends AbstractContentTransforme
|
|||||||
executer.setCommand(new String[] {"imconvert.exe", "${source}", "${options}", "${target}"});
|
executer.setCommand(new String[] {"imconvert.exe", "${source}", "${options}", "${target}"});
|
||||||
executer.setDefaultProperties(Collections.singletonMap("options", ""));
|
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.setMimetypeService(mimetypeService);
|
||||||
transformer.setExecuter(executer);
|
this.transformer = transformer;
|
||||||
transformer.init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -66,7 +73,7 @@ public class ImageMagickContentTransformerTest extends AbstractContentTransforme
|
|||||||
|
|
||||||
public void testReliability() throws Exception
|
public void testReliability() throws Exception
|
||||||
{
|
{
|
||||||
if (!transformer.isAvailable())
|
if (!this.worker.isAvailable())
|
||||||
{
|
{
|
||||||
return;
|
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
|
* This program is free software; you can redistribute it and/or
|
||||||
* modify it under the terms of the GNU General Public License
|
* modify it under the terms of the GNU General Public License
|
||||||
@ -41,7 +41,7 @@ import org.apache.commons.logging.LogFactory;
|
|||||||
*
|
*
|
||||||
* @author Derek Hulley
|
* @author Derek Hulley
|
||||||
*/
|
*/
|
||||||
public class ImageMagickContentTransformer extends AbstractImageMagickContentTransformer
|
public class ImageMagickContentTransformerWorker extends AbstractImageMagickContentTransformerWorker
|
||||||
{
|
{
|
||||||
/** options variable name */
|
/** options variable name */
|
||||||
private static final String KEY_OPTIONS = "options";
|
private static final String KEY_OPTIONS = "options";
|
||||||
@ -50,7 +50,7 @@ public class ImageMagickContentTransformer extends AbstractImageMagickContentTra
|
|||||||
/** target variable name */
|
/** target variable name */
|
||||||
private static final String VAR_TARGET = "target";
|
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 */
|
/** the system command executer */
|
||||||
private RuntimeExec executer;
|
private RuntimeExec executer;
|
||||||
@ -64,7 +64,7 @@ public class ImageMagickContentTransformer extends AbstractImageMagickContentTra
|
|||||||
/**
|
/**
|
||||||
* Default constructor
|
* Default constructor
|
||||||
*/
|
*/
|
||||||
public ImageMagickContentTransformer()
|
public ImageMagickContentTransformerWorker()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -110,32 +110,29 @@ public class ImageMagickContentTransformer extends AbstractImageMagickContentTra
|
|||||||
return this.versionString;
|
return this.versionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks for the JMagick and ImageMagick dependencies, using the common
|
* Checks for the JMagick and ImageMagick dependencies, using the common
|
||||||
* {@link #transformInternal(File, File) transformation method} to check
|
* {@link #transformInternal(File, File) transformation method} to check
|
||||||
* that the sample image can be converted.
|
* that the sample image can be converted.
|
||||||
*/
|
*/
|
||||||
public void init()
|
@Override
|
||||||
|
public void afterPropertiesSet()
|
||||||
{
|
{
|
||||||
if (executer == null)
|
if (executer == null)
|
||||||
{
|
{
|
||||||
throw new AlfrescoRuntimeException("System runtime executer not set");
|
throw new AlfrescoRuntimeException("System runtime executer not set");
|
||||||
}
|
}
|
||||||
super.init();
|
super.afterPropertiesSet();
|
||||||
if (isAvailable())
|
if (isAvailable())
|
||||||
{
|
{
|
||||||
try
|
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();
|
ExecutionResult result = this.checkCommand.execute();
|
||||||
if (result.getSuccess())
|
|
||||||
{
|
|
||||||
this.versionString = result.getStdOut().trim();
|
this.versionString = result.getStdOut().trim();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
setAvailable(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
setAvailable(false);
|
setAvailable(false);
|
@ -129,16 +129,19 @@ public class DefaultManagedApplicationContextFactory extends AbstractLifecycleBe
|
|||||||
{
|
{
|
||||||
"classpath*:alfresco/subsystems/" + this.beanName + "/*-context.xml"
|
"classpath*:alfresco/subsystems/" + this.beanName + "/*-context.xml"
|
||||||
}, false, this.parent);
|
}, 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
|
// Add a property placeholder configurer, with the subsystem-scoped default properties
|
||||||
PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
|
PropertyPlaceholderConfigurer configurer = new PropertyPlaceholderConfigurer();
|
||||||
configurer.setProperties(this.properties);
|
configurer.setProperties(this.properties);
|
||||||
configurer.setIgnoreUnresolvablePlaceholders(true);
|
configurer.setIgnoreUnresolvablePlaceholders(true);
|
||||||
this.applicationContext.addBeanFactoryPostProcessor(configurer);
|
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.setClassLoader(parent.getClassLoader());
|
||||||
this.applicationContext.refresh();
|
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.
|
* Sets the source application context factory.
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user