changeset 369:77cd3a2bc381

Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase. gnv-artifacts/trunk@446 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 17 Dec 2009 11:42:21 +0000
parents 6491000407dd
children 061355435075
files gnv-artifacts/ChangeLog gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java
diffstat 2 files changed, 22 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog	Thu Dec 17 10:20:05 2009 +0000
+++ b/gnv-artifacts/ChangeLog	Thu Dec 17 11:42:21 2009 +0000
@@ -1,3 +1,9 @@
+009-12-17  Ingo Weinzierl <ingo.weinzierl@intevation.de>
+
+	* src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java:
+	  Fixed a file-leak bug while reading chart template. Sourced parsing of xml
+	  file out to XMLUtils of de.intevation.artifactdatabase.XMLUtils.
+
 009-12-17  Ingo Weinzierl <ingo.weinzierl@intevation.de>
 
 	* src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileOutputState.java,
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java	Thu Dec 17 10:20:05 2009 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.java	Thu Dec 17 11:42:21 2009 +0000
@@ -7,6 +7,8 @@
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
+import java.io.File;
+
 import java.util.Properties;
 
 import org.apache.log4j.Logger;
@@ -19,7 +21,8 @@
 import de.intevation.gnv.geobackend.base.query.container.QueryContainerFactory;
 import de.intevation.gnv.geobackend.base.query.container.exception.QueryContainerException;
 import de.intevation.gnv.chart.XMLChartTheme;
-import de.intevation.gnv.utils.ArtifactXMLUtilities;
+
+import de.intevation.artifactdatabase.XMLUtils;
 
 /**
  * @author Tim Englich <tim.englich@intevation.de>
@@ -85,12 +88,19 @@
             String chartConfigFile = Config.getStringXPath(
                 config, CHARTCONFIGNODEPATH
             );
-            chartConfigFile        = Config.replaceConfigDir(chartConfigFile);
+            chartConfigFile = Config.replaceConfigDir(chartConfigFile);
             log.debug("Parse xml configuration of " + chartConfigFile);
-            InputStream is         = new FileInputStream(chartConfigFile);
-            Document      template = ArtifactXMLUtilities.readDocument(is);
-            XMLChartTheme theme    = new XMLChartTheme("XMLChartTheme");
-            theme.applyXMLConfiguration(template);
+
+            Document tmpl = XMLUtils.parseDocument(new File(chartConfigFile));
+            XMLChartTheme theme = new XMLChartTheme("XMLChartTheme");
+            if (tmpl != null) {
+                theme.applyXMLConfiguration(tmpl);
+            }
+            else {
+                log.error(
+                    "Cannot load chart template from '" +
+                    chartConfigFile + "'");
+            }
 
             returnValue = new GNVArtifactContext(config);
 

http://dive4elements.wald.intevation.org