// iterate through all path segments, simultaneously descending the resource hierarchy
// and parsing path keys where applicable;
// the goal of this loop is to locate the leaf resource, which will be set in
// currentResource, and to parse the necessary information into the context
ResourceLevel currentLevel = currentResource.getResourceLevel();
while (remainingPath.peek() != null)
{
String currentPathSegment = remainingPath.poll();
if (currentLevel.equals(ResourceLevel.ENTITY))
{
currentResource =
currentResource.getSubResource(parseSubresourceName(currentPathSegment));
currentLevel = currentResource == null ?
ResourceLevel.ANY : currentResource.getResourceLevel();