public ResourceInvoker matchPattern(HttpRequest
request, String
path, int start)
{
UriInfoImpl uriInfo = (UriInfoImpl) request.getUri();
Matcher matcher = pattern.matcher(path);
matcher.region(start, path.length());
if (matcher.matches())
{
// we consumed entire path string
ResourceInvoker invoker = match(request.getHttpMethod(), request);
if (invoker == null)
throw new NotFoundException("Could not find resource for relative : " + path + " of full path: " + request.getUri().getRequestUri());
uriInfo.pushMatchedURI(path, Encode.decode(path));
populatePathParams(request, matcher, path);
return invoker;
}
if (locator == null)
{
throw new NotFoundException("Could not find resource for relative : " + path + " of full path: " + request.getUri().getRequestUri());
}
if (matcher.find(start) && matcher.start() == start)
{
// a non-matched locator path must have a '/' immediately after. A locator cannot match a partial segment
String group0 = matcher.group(0);
int charAt = start + group0.length();
char c = path.charAt(charAt);
if (c == '/')
{
String matched = path.substring(0, start + matcher.group(0).length());
uriInfo.pushMatchedURI(matched, Encode.decode(matched));
populatePathParams(request, matcher, path);
return locator;
}
}
throw new NotFoundException("Could not find resource for relative : " + path + " of full path: " + request.getUri().getRequestUri());