line = linkBasePathMatcher.replaceAll("$1$2=$3" + defaultRemoteURLReplaces + "$4$3");
// if there's any https? absolute url link, try to find the proxy path mapper again...
if (lookUpAllMappings)
{
CharSequence segment = new CharArraySegment(line);
for (Matcher absURLMatcher = LINK_HTTP_ABS_URL_PATTERN.matcher(segment); absURLMatcher.find(); )
{
HttpReverseProxyPathMapper proxyMapper = null;
String absURL = absURLMatcher.group(3);
int maxMatchingPathPartCount = getMaxMatchingPathPartCount();
String [] pathParts = StringUtils.split(absURL, "/", maxMatchingPathPartCount + 2);
int pathPartCount = (pathParts != null ? pathParts.length : 0);
if (pathPartCount < 2)
{
continue;
}
String scheme = pathParts[0];
for (int i = Math.min(pathPartCount, maxMatchingPathPartCount + 1); i > 1; i--)
{
String remoteBaseURLKey = scheme + "//" + StringUtils.join(pathParts, "/", 1, i);
if (blacklist != null && blacklist.contains(remoteBaseURLKey))
{
continue;
}
proxyMapper = getHttpReverseProxyPathMapperProvider().findMapperByRemoteURL(remoteBaseURLKey + "/");
if (proxyMapper == null)
{
if (blacklist == null)
{
blacklist = new HashSet<String>();
}
blacklist.add(remoteBaseURLKey);
}
else
{
if (remoteURLMatchingPatternMap == null)
{
remoteURLMatchingPatternMap = new HashMap<HttpReverseProxyPathMapper, Pattern>();
localPathMatchingReplacesMap = new HashMap<HttpReverseProxyPathMapper, String>();
}
Pattern pattern = remoteURLMatchingPatternMap.get(proxyMapper);
if (pattern == null)
{
pattern = createRemoteURLMatchingPattern(proxyMapper);
remoteURLMatchingPatternMap.put(proxyMapper, pattern);
}
String localPathMatchingReplaces = localPathMatchingReplacesMap.get(proxyMapper);
if (localPathMatchingReplaces == null)
{
localPathMatchingReplaces = createLocalPathMatchingReplaces(proxyMapper);
localPathMatchingReplacesMap.put(proxyMapper, localPathMatchingReplaces);
}
Matcher matcher = pattern.matcher(line);
line = replaceRemoteLinkValues(matcher, "$1$2=$3" + localPathMatchingReplaces + "$6$3", line);
break;
}
}
segment = segment.subSequence(absURLMatcher.end(), segment.length());
absURLMatcher.reset(segment);
}
}
else
{