From 64ef43d992ffd7cfd5f571b1922ad0d32ef668ad Mon Sep 17 00:00:00 2001 From: Thomas Lenz Date: Wed, 11 Jun 2014 13:26:08 +0200 Subject: solve problem with Velocity Engine --- .../java/at/gv/egovernment/moa/id/moduls/SSOManager.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'id/server/idserverlib/src/main') diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/SSOManager.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/SSOManager.java index a46b11c6e..cb12bc5bd 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/SSOManager.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/moduls/SSOManager.java @@ -288,21 +288,22 @@ public class SSOManager { public void printSingleLogOutInfo(VelocityContext context, HttpServletResponse httpResp) throws MOAIDException { try { Logger.trace("Initialize VelocityEngine..."); - VelocityEngine velocityEngine = VelocityProvider.getClassPathVelocityEngine(); InputStream is = null; + String pathLocation = null; try { String rootconfigdir = AuthConfigurationProvider.getInstance().getRootConfigFileDir(); - String pathLocation = rootconfigdir + HTMLTEMPLATESDIR + HTMLTEMPLATEFULL; + pathLocation = rootconfigdir + HTMLTEMPLATESDIR + HTMLTEMPLATEFULL; File file = new File(new URI(pathLocation)); is = new FileInputStream(file); evaluateSLOTemplate(context, httpResp, is); } catch (Exception e) { - Logger.warn("SLO Template is not found in configuration directory. Load template from project library ... "); + Logger.warn("SLO Template is not found in configuration directory (" + + pathLocation + "). Load template from project library ... "); try { - String pathLocation = "resources/templates/" + HTMLTEMPLATEFULL; + pathLocation = "resources/templates/" + HTMLTEMPLATEFULL; is = Thread.currentThread() .getContextClassLoader() .getResourceAsStream(pathLocation); @@ -326,7 +327,10 @@ public class SSOManager { } - private void evaluateSLOTemplate(VelocityContext context, HttpServletResponse httpResp, InputStream is) throws ConfigurationException, IOException { + private void evaluateSLOTemplate(VelocityContext context, HttpServletResponse httpResp, InputStream is) throws Exception { + + VelocityEngine engine = VelocityProvider.getClassPathVelocityEngine(); + BufferedReader reader = new BufferedReader(new InputStreamReader(is )); //set default elements to velocity context @@ -334,7 +338,7 @@ public class SSOManager { StringWriter writer = new StringWriter(); //velocityEngine.evaluate(context, writer, "SLO_Template", reader); - Velocity.evaluate(context, writer, "SLO Template", reader); + engine.evaluate(context, writer, "SLO Template", reader); httpResp.setContentType("text/html;charset=UTF-8"); -- cgit v1.2.3