diff options
author | (no author) <(no author)@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2005-01-24 11:20:53 +0000 |
---|---|---|
committer | (no author) <(no author)@d688527b-c9ab-4aba-bd8d-4036d912da1d> | 2005-01-24 11:20:53 +0000 |
commit | 035ea4f59287d8c3f3ccd6bae5e6a9306162a0df (patch) | |
tree | 24874baa6bb2ded9ff7ed98d13f34db55d2b7fcd /spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java | |
parent | 03d4edd310c7ccbe7dae4ca951e383c448c16b64 (diff) | |
download | moa-id-spss-tags/Build-SPSS-1_2_0_D04.tar.gz moa-id-spss-tags/Build-SPSS-1_2_0_D04.tar.bz2 moa-id-spss-tags/Build-SPSS-1_2_0_D04.zip |
This commit was manufactured by cvs2svn to create tagtags/Build-SPSS-1_2_0_D04
'Build-SPSS-1_2_0_D04'.
git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/tags/Build-SPSS-1_2_0_D04@254 d688527b-c9ab-4aba-bd8d-4036d912da1d
Diffstat (limited to 'spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java')
-rw-r--r-- | spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java | 119 |
1 files changed, 0 insertions, 119 deletions
diff --git a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java b/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java deleted file mode 100644 index e1b8e77e5..000000000 --- a/spss.slinterface/WEB-INF/src/at/gv/egovernment/moa/spss/slinterface/URLRewriter.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Created on 15.12.2003 - * - * (c) Stabsstelle IKT-Strategie des Bundes - */ -package at.gv.egovernment.moa.spss.slinterface; - -import java.net.MalformedURLException; -import java.net.URL; -import java.util.Properties; - -import org.apache.log4j.Logger; - -/** - * @author Gregor Karlinger (mailto:gregor.karlinger@cio.gv.at) - */ -public class URLRewriter -{ - private static Logger logger_ = Logger.getLogger(Constants.LH_LISTENERS_); - - Properties initProps_; - - /** - * Class that manges the rewriting of URLs for the result pages. Necessary as workaround for the deploy- - * ment in the Federal Chancellory. - */ - public URLRewriter(Properties initProps) - { - initProps_ = initProps; - } - - /** - * Rewrites the specified URL. - * - * @param url A URL relative to the context path of the serlet. - * - * @param sessionId The session id which will be considered in the rewritten URL. - * - * @return A URL fitting for the proxy component running at the Federal Chancellory. - */ - public String rewrite(String url, String sessionId) - { - String proxyURLStr = initProps_.getProperty(Constants.IP_REW_PROXYRUL_); - String slInterfaceURLParamName = initProps_.getProperty(Constants.IP_REW_SLI_URLPARAMNAME_); - String slInterfaceURLStr = initProps_.getProperty(Constants.IP_REW_SLIRUL_); - - if (proxyURLStr == null || - slInterfaceURLParamName == null || - slInterfaceURLStr == null || - "".equals(proxyURLStr.trim()) || - "".equals(slInterfaceURLParamName.trim()) || - "".equals(slInterfaceURLStr.trim())) - { - logger_.warn("Some params for URL rewriting are not available; rewriting disabled:" + - " proxyURL: \"" + proxyURLStr + "\"," + - " slInterfaceURLParamName: \"" + slInterfaceURLParamName + "\"," + - " slInterfaceURL: \"" + slInterfaceURLStr + "\""); - return url; - } - - URL slInterfaceURL = null; - try - { - slInterfaceURL = new URL(slInterfaceURLStr + url); - } - catch (MalformedURLException e) - { - logger_.warn("Parameter \"slInterfaceURL\" is not a valid URL: \"" + slInterfaceURLStr + "\""); - return url; - } - URL proxyURL = null; - try - { - proxyURL = new URL(proxyURLStr); - } - catch (MalformedURLException e) - { - logger_.warn("Parameter \"proxyURL\" is not a valid URL: \"" + proxyURLStr + "\""); - return url; - } - - String sessionIdParam = (sessionId != null) ? (";" + "jsessionid=" + sessionId) : ""; - String returnValue = - proxyURL.getProtocol() + - "://" + - proxyURL.getHost() + - ((proxyURL.getPort() != -1) ? (":" + proxyURL.getPort()) : "") + - proxyURL.getPath() + - ((proxyURL.getQuery() != null) ? "?" + proxyURL.getQuery() + "&" : "?") + - slInterfaceURLParamName + "=" + - slInterfaceURL.getProtocol() + - "://" + - slInterfaceURL.getHost() + - ((slInterfaceURL.getPort() != -1) ? (":" + slInterfaceURL.getPort()) : "") + - slInterfaceURL.getPath() + - sessionIdParam + - ((slInterfaceURL.getQuery() != null) ? "?" + escapeQueryPart(slInterfaceURL.getQuery()) : ""); - - logger_.debug("Rewritten URL: " + returnValue); - return returnValue; - } - - private String escapeQueryPart(String query) - { - StringBuffer querySB = new StringBuffer(); - for (int i = 0; i < query.length(); i++) - { - if (query.charAt(i) == '&') - { - querySB.append("%26"); - } - else - { - querySB.append(query.charAt(i)); - } - } - return querySB.toString(); - } -} |