From 3caa1e66d35f676deadc60f1ea3cb76eba8c8bba Mon Sep 17 00:00:00 2001 From: Adrian Crum Date: Sat, 16 Feb 2013 20:43:38 +0000 Subject: [PATCH] Small improvements to ApacheFopWorker: check for file/folder existence before applying settings. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1446940 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/ofbiz/webapp/view/ApacheFopWorker.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java b/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java index b270bb17d9..5e3db8f3b1 100644 --- a/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java +++ b/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java @@ -80,10 +80,19 @@ public class ApacheFopWorker { String ofbizHome = System.getProperty("ofbiz.home"); String fopPath = UtilProperties.getPropertyValue("fop.properties", "fop.path", ofbizHome + "/framework/webapp/config"); File userConfigFile = FileUtil.getFile(fopPath + "/fop.xconf"); - fopFactory.setUserConfig(userConfigFile); - String fopFontBaseUrl = UtilProperties.getPropertyValue("fop.properties", "fop.font.base.url", "file:///" + ofbizHome + "/framework/webapp/config/"); - fopFactory.getFontManager().setFontBaseURL(fopFontBaseUrl); - Debug.logInfo("FOP-FontBaseURL: " + fopFontBaseUrl, module); + if (userConfigFile.exists()) { + fopFactory.setUserConfig(userConfigFile); + } else { + Debug.logWarning("FOP configuration file not found: " + userConfigFile, module); + } + String fopFontBaseProperty = UtilProperties.getPropertyValue("fop.properties", "fop.font.base.url", "file:///" + ofbizHome + "/framework/webapp/config/"); + File fontBaseFile = FileUtil.getFile(fopFontBaseProperty); + if (fontBaseFile.isDirectory()) { + fopFactory.getFontManager().setFontBaseURL(fontBaseFile.toURI().toURL().toString()); + } else { + Debug.logWarning("FOP font base URL not found: " + fontBaseFile, module); + } + Debug.logInfo("FOP FontBaseURL: " + fopFactory.getFontManager().getFontBaseURL(), module); } catch (Exception e) { Debug.logWarning(e, "Error reading FOP configuration", module); }