Fix/mnt 18404 image magick fails on windows (#14)

REMO-18404 Environment not being set for ImageMagick

The environment required by ImageMagick was not being set. Even though the environment shown by  log4j.logger.org.alfresco.util.exec.RuntimeExec=trace indicated that the required variables already existed in the current environment, that does not mean they are passed on to the sub process. In this case they were not being passed on and they were not being set as additional variables required by the sub process.

The bug was introduced when Alfresco PDF renderer was added (REPO-2054) to ACS 5.2.1 and ACS 5.2.g. The context file for ImageMagic (imagemagick-transform-context.xml) was used as the basis for Alfresco PDF renderer's context file. Unfortunately the names of the spring beans that provided the Windows and Unix environment variable values were not changed. As a result, ImageMagick was being provided with Alfresco PDF renderer's environment variables.

The Alfresco global property img.gslib and environment variable $GS_LIB set using it, are now redundant following the REPO-2054 work so have been removed in this commit.

When testing this issue we should test ImageMagick and Alfresco PDF renderer on both Windows and Unix (Linux). I have not dug into why ImageMagick and Alfresco PDF renderer are working on Linux. I'm guessing that the current environment is being passed on unlike Windows.
This commit is contained in:
alandavis
2017-09-11 09:09:33 +01:00
committed by GitHub
parent 58f29fb7a9
commit d1216de8d4
6 changed files with 57 additions and 47 deletions

3
.gitignore vendored
View File

@@ -32,3 +32,6 @@ target
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid* hs_err_pid*
alf_data
/src/main/resources/alfresco-global.properties
/src/main/resources/alfresco/extension/custom-log4j.properties

View File

@@ -29,7 +29,6 @@
# #
#img.coders=${img.root}/modules/coders #img.coders=${img.root}/modules/coders
#img.config=${img.root}/config #img.config=${img.root}/config
#img.gslib=${img.root}/lib
# #
# Property to control whether schema updates are performed automatically. # Property to control whether schema updates are performed automatically.
@@ -69,16 +68,16 @@
#db.url=jdbc:postgresql://localhost:5432/alfresco #db.url=jdbc:postgresql://localhost:5432/alfresco
# #
# DB2 connection # DB2 connection
# #
#db.driver=com.ibm.db2.jcc.DB2Driver #db.driver=com.ibm.db2.jcc.DB2Driver
#db.url=jdbc:db2://localhost:50000/alfresco:retrieveMessagesFromServerOnGetMessage=true; #db.url=jdbc:db2://localhost:50000/alfresco:retrieveMessagesFromServerOnGetMessage=true;
# #
# When schema is used which does not match DB2 username then currentSchema and hibernate.default_schema should be set # When schema is used which does not match DB2 username then currentSchema and hibernate.default_schema should be set
#db.url=jdbc:db2://localhost:50000/alfresco:retrieveMessagesFromServerOnGetMessage=true;currentSchema=${hibernate.default_schema}; #db.url=jdbc:db2://localhost:50000/alfresco:retrieveMessagesFromServerOnGetMessage=true;currentSchema=${hibernate.default_schema};
#hibernate.default_schema=SAMPLE_SCHEMA #hibernate.default_schema=SAMPLE_SCHEMA
# #
# Index Recovery Mode # Index Recovery Mode
#------------- #-------------
#index.recovery.mode=AUTO #index.recovery.mode=AUTO
@@ -142,11 +141,11 @@
#imap.server.port=143 #imap.server.port=143
#imap.server.host=localhost #imap.server.host=localhost
# Default value of alfresco.rmi.services.host is 0.0.0.0 which means 'listen on all adapters'. # Default value of alfresco.rmi.services.host is 0.0.0.0 which means 'listen on all adapters'.
# This allows connections to JMX both remotely and locally. # This allows connections to JMX both remotely and locally.
# #
alfresco.rmi.services.host=0.0.0.0 alfresco.rmi.services.host=0.0.0.0
# #
# #
# Assign individual ports for each service for best performance # Assign individual ports for each service for best performance

View File

@@ -20,7 +20,7 @@
</entry> </entry>
</map> </map>
</property> </property>
<property name="processProperties" ref="#{systemProperties['os.name'].contains('Windows') ? 'processPropertiesWindows' : 'processPropertiesUnix'}" /> <property name="processProperties" ref="#{systemProperties['os.name'].contains('Windows') ? 'transformer.worker.subsys.alfresco-pdf-renderer.processPropertiesWindows' : 'transformer.worker.subsys.alfresco-pdf-renderer.processPropertiesUnix'}" />
<property name="defaultProperties"> <property name="defaultProperties">
<props> <props>
<prop key="options"></prop> <prop key="options"></prop>
@@ -47,7 +47,7 @@
</property> </property>
</bean> </bean>
<bean id="processPropertiesWindows" class="org.springframework.beans.factory.config.MapFactoryBean"> <bean id="transformer.worker.subsys.alfresco-pdf-renderer.processPropertiesWindows" class="org.springframework.beans.factory.config.MapFactoryBean">
<property name="sourceMap"> <property name="sourceMap">
<map> <map>
<entry key="ALFRESCO-PDF-RENDERER_HOME"> <entry key="ALFRESCO-PDF-RENDERER_HOME">
@@ -57,7 +57,7 @@
</property> </property>
</bean> </bean>
<bean id="processPropertiesUnix" class="org.springframework.beans.factory.config.MapFactoryBean"> <bean id="transformer.worker.subsys.alfresco-pdf-renderer.processPropertiesUnix" class="org.springframework.beans.factory.config.MapFactoryBean">
<property name="sourceMap"> <property name="sourceMap">
<map> <map>
<entry key="ALFRESCO-PDF-RENDERER_HOME"> <entry key="ALFRESCO-PDF-RENDERER_HOME">

View File

@@ -22,7 +22,7 @@
</entry> </entry>
</map> </map>
</property> </property>
<property name="processProperties" ref="#{systemProperties['os.name'].contains('Windows') ? 'processPropertiesWindows' : 'processPropertiesUnix'}" /> <property name="processProperties" ref="#{systemProperties['os.name'].contains('Windows') ? 'transformer.worker.ImageMagick.processPropertiesWindows' : 'transformer.worker.ImageMagick.processPropertiesUnix'}" />
<property name="defaultProperties"> <property name="defaultProperties">
<props> <props>
<prop key="options"></prop> <prop key="options"></prop>
@@ -50,7 +50,7 @@
</property> </property>
</bean> </bean>
<bean id="processPropertiesWindows" class="org.springframework.beans.factory.config.MapFactoryBean"> <bean id="transformer.worker.ImageMagick.processPropertiesWindows" class="org.springframework.beans.factory.config.MapFactoryBean">
<property name="sourceMap"> <property name="sourceMap">
<map> <map>
<entry key="MAGICK_HOME"> <entry key="MAGICK_HOME">
@@ -62,9 +62,6 @@
<entry key="MAGICK_CONFIGURE_PATH"> <entry key="MAGICK_CONFIGURE_PATH">
<value>${img.config}</value> <value>${img.config}</value>
</entry> </entry>
<entry key="GS_LIB">
<value>${img.gslib}</value>
</entry>
<entry key="DYLD_FALLBACK_LIBRARY_PATH"> <entry key="DYLD_FALLBACK_LIBRARY_PATH">
<value>${img.dyn}</value> <value>${img.dyn}</value>
</entry> </entry>
@@ -75,7 +72,7 @@
</property> </property>
</bean> </bean>
<bean id="processPropertiesUnix" class="org.springframework.beans.factory.config.MapFactoryBean"> <bean id="transformer.worker.ImageMagick.processPropertiesUnix" class="org.springframework.beans.factory.config.MapFactoryBean">
<property name="sourceMap"> <property name="sourceMap">
<map> <map>
<entry key="MAGICK_HOME"> <entry key="MAGICK_HOME">

View File

@@ -4,4 +4,3 @@ img.dyn=${img.root}/lib
img.exe=${img.root}/bin/convert img.exe=${img.root}/bin/convert
img.coders=${img.root}/modules/coders img.coders=${img.root}/modules/coders
img.config=${img.root}/config img.config=${img.root}/config
img.gslib=

View File

@@ -1,28 +1,28 @@
/* /*
* #%L * #%L
* Alfresco Repository * Alfresco Repository
* %% * %%
* Copyright (C) 2005 - 2016 Alfresco Software Limited * Copyright (C) 2005 - 2016 Alfresco Software Limited
* %% * %%
* This file is part of the Alfresco software. * This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of * If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is * the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms: * provided under the following open source license terms:
* *
* Alfresco is free software: you can redistribute it and/or modify * Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by * it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* Alfresco is distributed in the hope that it will be useful, * Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. * along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
* #L% * #L%
*/ */
package org.alfresco.repo.content.transform.magick; package org.alfresco.repo.content.transform.magick;
import java.io.File; import java.io.File;
@@ -120,12 +120,24 @@ public class ImageMagickContentTransformerTest extends AbstractContentTransforme
} }
} }
public void testGifToPng() throws Exception
{
ImageTransformationOptions options = new ImageTransformationOptions();
transform(MimetypeMap.MIMETYPE_IMAGE_GIF, MimetypeMap.MIMETYPE_IMAGE_PNG, options);
}
public void testJpegToPng() throws Exception
{
ImageTransformationOptions options = new ImageTransformationOptions();
transform(MimetypeMap.MIMETYPE_IMAGE_JPEG, MimetypeMap.MIMETYPE_IMAGE_PNG, options);
}
public void testPageSourceOptions() throws Exception public void testPageSourceOptions() throws Exception
{ {
// Test empty source options // Test empty source options
ImageTransformationOptions options = new ImageTransformationOptions(); ImageTransformationOptions options = new ImageTransformationOptions();
this.transform(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_IMAGE_PNG, options); this.transform(MimetypeMap.MIMETYPE_PDF, MimetypeMap.MIMETYPE_IMAGE_PNG, options);
// Test first page // Test first page
options = new ImageTransformationOptions(); options = new ImageTransformationOptions();
List<TransformationSourceOptions> sourceOptionsList = new ArrayList<TransformationSourceOptions>(); List<TransformationSourceOptions> sourceOptionsList = new ArrayList<TransformationSourceOptions>();