return pathExpression;
}
protected void populatePathParams(HttpRequest request, Matcher matcher, String path)
{
UriInfo uriInfo = (UriInfo) request.getUri();
for (Group group : groups)
{
String value = matcher.group(group.group);
uriInfo.addEncodedPathParameter(group.name, value);
int index = matcher.start(group.group);
int start = 0;
if (path.charAt(0) == '/')
start++;
int segmentIndex = 0;
if (start < path.length())
{
int count = 0;
for (int i = start; i < index && i < path.length(); i++)
{
if (path.charAt(i) == '/')
count++;
}
segmentIndex = count;
}
int numSegments = 1;
for (int i = 0; i < value.length(); i++)
{
if (value.charAt(i) == '/')
numSegments++;
}
if (segmentIndex + numSegments > request.getUri().getPathSegments().size())
{
throw new BadRequestException("Number of matched segments greater than actual", "Can not invoke requested service");
}
PathSegment[] encodedSegments = new PathSegment[numSegments];
PathSegment[] decodedSegments = new PathSegment[numSegments];
for (int i = 0; i < numSegments; i++)
{
decodedSegments[i] = request.getUri().getPathSegments().get(segmentIndex + i);
encodedSegments[i] = request.getUri().getPathSegments(false).get(segmentIndex + i);
}
uriInfo.getEncodedPathParameterPathSegments().add(group.name, encodedSegments);
uriInfo.getPathParameterPathSegments().add(group.name, decodedSegments);
}
}