}
return key;
}
protected URLHandler checkForMatches(String requestURI) {
URLHandler currentHandler = null;
try {
List<URLHandler> urlHandlers = findAllURLHandlers();
for (URLHandler urlHandler : urlHandlers) {
currentHandler = urlHandler;
String incomingUrl = currentHandler.getIncomingURL();
if (!incomingUrl.startsWith("^")) {
if (incomingUrl.startsWith("/")) {
incomingUrl = "^" + incomingUrl + "$";
} else {
incomingUrl = "^/" + incomingUrl + "$";
}
}
Pattern p = urlPatternMap.get(incomingUrl);
if (p == null) {
p = Pattern.compile(incomingUrl);
urlPatternMap.put(incomingUrl, p);
}
Matcher m = p.matcher(requestURI);
if (m.find()) {
String newUrl = m.replaceFirst(urlHandler.getNewURL());
if (newUrl.equals(urlHandler.getNewURL())) {
return urlHandler;
} else {
return new URLHandlerDTO(newUrl, urlHandler.getUrlRedirectType());
}
}
}
} catch (RuntimeException re) {
if (currentHandler != null) {
// We don't want an invalid regex to cause tons of logging
if (LOG.isWarnEnabled()) {
LOG.warn("Error parsing URL Handler (incoming =" + currentHandler.getIncomingURL() + "), outgoing = ( "
+ currentHandler.getNewURL() + "), " + requestURI);
}
}
}