diff options
author | tkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2013-12-10 16:21:26 +0000 |
---|---|---|
committer | tkellner <tkellner@8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4> | 2013-12-10 16:21:26 +0000 |
commit | cac60be3e0be598bf30bc39d813a19c4f213482d (patch) | |
tree | 741dccde3dbea4004841e902457ca74d085be1c0 /BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp | |
parent | 6512ba8830ed46156c9f285cee1c4f8b895c3f95 (diff) | |
download | mocca-cac60be3e0be598bf30bc39d813a19c4f213482d.tar.gz mocca-cac60be3e0be598bf30bc39d813a19c4f213482d.tar.bz2 mocca-cac60be3e0be598bf30bc39d813a19c4f213482d.zip |
Allow to override servlet init parameters with context parameters
git-svn-id: https://joinup.ec.europa.eu/svn/mocca/trunk@1247 8a26b1a7-26f0-462f-b9ef-d0e30c41f5a4
Diffstat (limited to 'BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp')
4 files changed, 21 insertions, 8 deletions
diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/MoccaParameterBean.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/MoccaParameterBean.java index 0e2e4b02..4bba6947 100644 --- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/MoccaParameterBean.java +++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/MoccaParameterBean.java @@ -36,6 +36,8 @@ import java.util.Arrays; import java.util.Locale; import java.util.regex.Pattern; +import javax.servlet.ServletConfig; +import javax.servlet.ServletContext; import javax.servlet.http.HttpServletResponse; import org.apache.commons.configuration.Configuration; @@ -47,8 +49,8 @@ import at.gv.egiz.bku.utils.StreamUtil; public class MoccaParameterBean { - private final Logger log = LoggerFactory.getLogger(MoccaParameterBean.class); - + private static final Logger log = LoggerFactory.getLogger(MoccaParameterBean.class); + public static final String PARAM_UI_PAGE_P = "appletPage"; public static final String PARAM_APPLET_WIDTH = "appletWidth"; @@ -234,4 +236,15 @@ public class MoccaParameterBean { response.addHeader("P3P", P3P_POLICY); } } + + public static String getInitParameter(String name, ServletConfig config, + ServletContext context) { + String initVal = config.getInitParameter(name); + String contextVal = context.getInitParameter(config.getServletName() + "." + name); + log.debug("Reading init param " + name + ": " + initVal + + " - context param " + (config.getServletName() + "." + name) + ": " + contextVal); + if (contextVal != null) + return contextVal; + return initVal; + } } diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java index 9c531a3c..67253f24 100644 --- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java +++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/ResultServlet.java @@ -63,12 +63,12 @@ public class ResultServlet extends HttpServlet { @Override public void init() throws ServletException { - String encoding = getServletConfig().getInitParameter("responseEncoding"); + String encoding = MoccaParameterBean.getInitParameter("responseEncoding", getServletConfig(), getServletContext()); if (encoding != null) { log.info("Init default responseEncoding to: {}.", encoding); responseEncoding = encoding; } - String url = getServletConfig().getInitParameter("expiredPageUrl"); + String url = MoccaParameterBean.getInitParameter("expiredPageUrl", getServletConfig(), getServletContext()); if (url != null) { // try { // expiredPageUrl = new URL(url).toString(); diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/UIServlet.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/UIServlet.java index 1a1c30d0..0b344f9d 100644 --- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/UIServlet.java +++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/UIServlet.java @@ -55,7 +55,7 @@ public class UIServlet extends HttpServlet { @Override public void init() throws ServletException { - String url = getServletConfig().getInitParameter("expiredPageUrl"); + String url = MoccaParameterBean.getInitParameter("expiredPageUrl", getServletConfig(), getServletContext()); if (url != null) { // try { // expiredPageUrl = new URL(url).toString(); @@ -99,7 +99,7 @@ public class UIServlet extends HttpServlet { MoccaParameterBean parameterBean = new MoccaParameterBean((HTTPBindingProcessor) bindingProcessor); req.setAttribute("moccaParam", parameterBean); - String uiPage = getServletConfig().getInitParameter("uiPage"); + String uiPage = MoccaParameterBean.getInitParameter("uiPage", getServletConfig(), getServletContext()); uiPage = parameterBean.getUIPage(uiPage); if (uiPage == null) { uiPage = "applet.jsp"; diff --git a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/WebRequestHandler.java b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/WebRequestHandler.java index 6accc5a1..2912fb02 100644 --- a/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/WebRequestHandler.java +++ b/BKUOnline/src/main/java/at/gv/egiz/bku/online/webapp/WebRequestHandler.java @@ -56,7 +56,7 @@ public class WebRequestHandler extends HttpServlet { @Override public void init() throws ServletException { - String url = getServletConfig().getInitParameter("uiRedirectUrl"); + String url = MoccaParameterBean.getInitParameter("uiRedirectUrl", getServletConfig(), getServletContext()); if (url != null) { uiRedirectUrl = url; log.info("Init uiRedirectUrl to: {}.", uiRedirectUrl); @@ -99,7 +99,7 @@ public class WebRequestHandler extends HttpServlet { } // create new binding processor - String protocol = getServletConfig().getInitParameter("protocol"); + String protocol = MoccaParameterBean.getInitParameter("protocol", getServletConfig(), getServletContext()); if (protocol == null || protocol.isEmpty()) { protocol = req.getScheme(); } |