private String rewriteValue(UrlRewriter rewriter, String value, String rule) {
   try {
     Template input = Parser.parse(value);
     Template output = rewriter.rewrite(this, input, UrlRewriter.Direction.IN, rule);
     value = output.toString();
   } catch (URISyntaxException e) {
     LOG.failedToParseValueForUrlRewrite(value);
   }
   return value;
 }
 private UrlRewriteFilterContentDescriptor getRewriteFilterConfig(
     String filterName, MimeType mimeType) {
   UrlRewriteFilterContentDescriptor filterContentConfig = null;
   UrlRewriteRulesDescriptor rewriteConfig = rewriter.getConfig();
   if (rewriteConfig != null) {
     UrlRewriteFilterDescriptor filterConfig = rewriteConfig.getFilter(filterName);
     if (filterConfig != null) {
       filterContentConfig = filterConfig.getContent(mimeType);
     }
   }
   return filterContentConfig;
 }
 // Note: Source url was added to the request attributes by the GatewayFilter doFilter method.
 private Template getTargetUrl() {
   boolean rewriteRequestUrl = true;
   Template targetUrl;
   if (rewriteRequestUrl) {
     targetUrl = (Template) getAttribute(AbstractGatewayFilter.TARGET_REQUEST_URL_ATTRIBUTE_NAME);
     if (targetUrl == null) {
       Template sourceUrl = getSourceUrl();
       targetUrl = rewriter.rewrite(this, sourceUrl, UrlRewriter.Direction.IN, urlRuleName);
       setAttribute(AbstractGatewayFilter.TARGET_REQUEST_URL_ATTRIBUTE_NAME, targetUrl);
     }
   } else {
     targetUrl = (Template) getAttribute(AbstractGatewayFilter.SOURCE_REQUEST_URL_ATTRIBUTE_NAME);
   }
   return targetUrl;
 }