/*
* FIXME Refactor this horrible method.
*/
if (!rewriteOccurred(req))
{
RewriteEngine rewriteEngine = new RewriteEngine();
URL url = PrettyContext.getCurrentInstance(req).getRequestURL();
try
{
String queryString = req.getQueryString();
if ((queryString != null) && !"".equals(queryString))
{
queryString = "?" + queryString;
}
else if (queryString == null)
{
queryString = "";
}
// TODO test this now that query string is included in rewrites
String originalUrl = url.toURL() + queryString;
String newUrl = originalUrl;
for (RewriteRule rule : getConfig().getGlobalRewriteRules())
{
if (rule.matches(newUrl))
{
newUrl = rewriteEngine.processInbound(req, resp, rule, newUrl);
if (!Redirect.CHAIN.equals(rule.getRedirect()))
{
/*
* An HTTP redirect has been triggered; issue one if we have a URL or if the current URL has been