Mercurial > dive4elements > gnv-client
changeset 624:6a3a1da5e680
Improved velocity configuration.
gnv-artifacts/trunk@696 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 22 Feb 2010 10:43:25 +0000 |
parents | 65f09139e9b3 |
children | 40ead2d2a08d |
files | gnv-artifacts/ChangeLog gnv-artifacts/doc/conf/conf.xml gnv-artifacts/doc/conf/maptemplates/horizontalcrosssection_salinity.vm gnv-artifacts/doc/conf/maptemplates/horizontalcrosssection_salinity_isolines.vm gnv-artifacts/src/main/java/de/intevation/gnv/utils/MapfileGenerator.java |
diffstat | 5 files changed, 45 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/gnv-artifacts/ChangeLog Sun Feb 21 21:05:55 2010 +0000 +++ b/gnv-artifacts/ChangeLog Mon Feb 22 10:43:25 2010 +0000 @@ -1,3 +1,14 @@ +2010-02-22 Ingo Weinzierl <ingo.weinzierl@intevation.de> + + * doc/conf/conf.xml: Added path for velocity logfile. + + * doc/conf/maptemplates/horizontalcrosssection_salinity.vm, + doc/conf/maptemplates/horizontalcrosssection_salinity_isolines.vm: Removed + absolute path in style includes. + + * src/main/java/de/intevation/gnv/utils/MapfileGenerator.java: Improved + velocity configuration regarding absolute pathes and logfile. + 2010-02-21 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/main/java/de/intevation/gnv/state/profile/horizontalcrosssection/HorizontalCrossSectionMeshOutputState.java:
--- a/gnv-artifacts/doc/conf/conf.xml Sun Feb 21 21:05:55 2010 +0000 +++ b/gnv-artifacts/doc/conf/conf.xml Mon Feb 22 10:43:25 2010 +0000 @@ -478,6 +478,10 @@ </vertical-cross-section> </gnv> + <velocity> + <logfile path="/var/log/artifacts/velocity.log" /> + </velocity> + <ehcache> <!-- In this Section the Path to Configurationfile for the EHCache, which is unsed to store the Results of the Artifacts ,
--- a/gnv-artifacts/doc/conf/maptemplates/horizontalcrosssection_salinity.vm Sun Feb 21 21:05:55 2010 +0000 +++ b/gnv-artifacts/doc/conf/maptemplates/horizontalcrosssection_salinity.vm Mon Feb 22 10:43:25 2010 +0000 @@ -3,5 +3,5 @@ TYPE $info.getType() DATA "${info.getName()}/${info.getData()}" STATUS $info.getStatus() - #include("/opt/artifacts/conf/maptemplates/salinity_polygons.class.vm") + #include("salinity_polygons.class.vm") END
--- a/gnv-artifacts/doc/conf/maptemplates/horizontalcrosssection_salinity_isolines.vm Sun Feb 21 21:05:55 2010 +0000 +++ b/gnv-artifacts/doc/conf/maptemplates/horizontalcrosssection_salinity_isolines.vm Mon Feb 22 10:43:25 2010 +0000 @@ -5,5 +5,5 @@ TYPE $info.getType() STATUS $info.getStatus() LABELITEM VALUE - #include("/opt/artifacts/conf/maptemplates/salinity_isolines.class.vm") + #include("salinity_isolines.class.vm") END
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/utils/MapfileGenerator.java Sun Feb 21 21:05:55 2010 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/MapfileGenerator.java Mon Feb 22 10:43:25 2010 +0000 @@ -53,6 +53,9 @@ public static final String SHAPEFILE_BASE_DIR = "/artifact-database/map-generator/mapfile/shapefiles/text()"; + public static final String VELOCITY_LOGFILE = + "/artifact-database/velocity/logfile/@path"; + public static final String META_FILE_NAME = "meta.xml"; public static final String XPATH_LAYER = "/art:meta/art:layer"; @@ -153,26 +156,39 @@ protected void setupVelocity(VelocityEngine engine) throws Exception { - Properties ps = new Properties(); - - ps.setProperty( + engine.setProperty( "input.encoding", "UTF-8"); - ps.setProperty( - "resource.loader", - "class"); + engine.setProperty( + VelocityEngine.RUNTIME_LOG, + getVelocityLogfile()); - ps.setProperty( - "class.resource.loader.class", - "org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"); + engine.setProperty( + "resource.loader", + "file"); - engine.init(ps); + engine.setProperty( + "file.resource.loader.path", + getTemplateBaseDir()); + + engine.init(); + } + + + protected String getVelocityLogfile() { + if (velocityLogfile == null) + velocityLogfile = Config.getStringXPath(VELOCITY_LOGFILE); + + return velocityLogfile; } protected String getTemplateBaseDir() { - return Config.getStringXPath(TEMPLATE_PATH); + if (templatePath == null) + templatePath = Config.getStringXPath(TEMPLATE_PATH); + + return templatePath; } @@ -182,12 +198,6 @@ model = model.concat(".vm"); } - File file = new File(templatePath, model); - if (!file.exists() || !file.canRead()) { - logger.warn("Can't find template file: " + file.getAbsolutePath()); - return null; - } - try { VelocityEngine engine = getVelocityEngine(); if (engine == null) { @@ -195,7 +205,7 @@ return null; } - return engine.getTemplate(file.getAbsolutePath()); + return engine.getTemplate(model); } catch (Exception e) { logger.warn(e, e);