# HG changeset patch # User Ingo Weinzierl # Date 1261050141 0 # Node ID 77cd3a2bc381329b4969ba0480170109d1795aa4 # Parent 6491000407dd7dd1a976dc89eda5f2e7ccd65283 Fixed file-leak bug and sourced xml parsing out to XMLUtils of artifactdatabase. gnv-artifacts/trunk@446 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 6491000407dd -r 77cd3a2bc381 gnv-artifacts/ChangeLog --- 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 + + * 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 * src/main/java/de/intevation/gnv/state/profile/horizontal/HorizontalProfileOutputState.java, diff -r 6491000407dd -r 77cd3a2bc381 gnv-artifacts/src/main/java/de/intevation/gnv/artifacts/context/GNVArtifactContextFactory.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 @@ -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);